Showing posts with label APC. Show all posts
Showing posts with label APC. Show all posts

Wednesday, March 14, 2012

Supercharge WordPress, Part 1

SkyHi @ Wednesday, March 14, 2012


Here are a few example configuration settings for servers of different memory sizes running both MySQL and a web server on the same machine. These are not perfect, but they are good starting points.
For servers with 512MB RAM:
thread_cache_size=50
key_buffer=40M
table_cache=384
sort_buffer_size=768K
read_buffer_size=512K
read_rnd_buffer_size=512K
query_cache_limit=2M
query_cache_size=16M
query_cache_type=1
thread_concurrency=2*CPU
skip-innodb
For servers with 1GB RAM:
thread_cache_size=80
key_buffer=150M
table_cache=512
sort_buffer_size=1M
read_buffer_size=1M
read_rnd_buffer_size=768K
query_cache_limit=4M
query_cache_size=32M
query_cache_type=1
thread_concurrency=2*CPU
skip-innodb
For servers with 2GB RAM:
thread_cache_size=80
key_buffer=350M
table_cache=1024
sort_buffer_size=2M
read_buffer_size=2M
read_rnd_buffer_size=768K
query_cache_limit=4M
query_cache_size=64M
query_cache_type=1
thread_concurrency=2*CPU
skip-innodb
Once WordPress has been up and running for some time you can tweak your settings by running MySQLTuner, a Perl script that analyzes your MySQL performance and, based on the statistics it gathers, gives recommendations about which variables you should adjust to increase performance. With MySQLTuner, you can tune your my.cnf file to tease out the last bit of performance from your MySQL server and make it work more efficiently.

REFERENCES
http://linuxaria.com/?p=3293?lang=en 
http://linuxaria.com/article/supercharge-wordpress-part-2?lang=en 

http://linuxaria.com/article/supercharge-wordpress-part-3?lang=en

Monday, June 14, 2010

Stack installation on CentOS 5

SkyHi @ Monday, June 14, 2010
All commands are run as root.

Text editor (mostly for my use):

yum install nano

EPEL and Remi repositories

  • Install the repositories
    rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-2.noarch.rpm
    rpm -Uvh http://rpms.famillecollet.com/el5.x86_64/remi-release-5-4.el5.remi.noarch.rpm
    
  • Edit /etc/yum.repos.d/remi.repo.
    • Under [TECH:remi], set enabled=1.

PHP and MySQL(i) client

  • Configure base packages
    yum install php-pear php-mysql php-mbstring
    /etc/init.d/httpd restart
    
  • Test
    • Configure phpinfo() page
      echo " /var/www/html/index.php
      chmod 644 /var/www/html/index.php
      
    • Load page in browser

APC

yum install php-pecl-apc
/etc/init.d/httpd restart
  • Test: Load page in browser and look for "apc.stat"

Memcached

yum install zlib-devel memcached php-pecl-memcache
/etc/init.d/memcached start
Test:  telnet localhost 11211
/etc/init.d/httpd restart
  • Test: Load page in browser and look for "memcache.default_port"

Apache

  • Change "AllowOverride None" to "AllowOverride All" for :
    /etc/httpd/conf/httpd.conf (excerpt)
    "/var/www/html">
    
    [...]
    
    AllowOverride All
    
    [...]
    
    
    

MySQL server

  • Install MySQL
    yum install mysql-server
    
  • Set better defaults in /etc/my.cnf under [TECH:mysqld]:
    default_storage_engine = InnoDB
    default_character_set = utf8
    collation_server = utf8_general_ci
    character_set_server = utf8
    
  • Start MySQL and set the root password:
    /etc/init.d/mysqld start
    /usr/bin/mysqladmin -u root password 'new-password'
    /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
    

Synchronize system clock

yum install ntp
chkconfig ntpd on
ntpdate pool.ntp.org
/etc/init.d/ntpd start

phpMyAdmin

  • Install phpMyAdmin
    yum install phpmyadmin
    
  • Edit /etc/httpd/conf.d/phpMyAdmin.conf to allow access from non-localhost clients.
  • Edit /etc/phpMyAdmin/config.inc.php to add additional servers and use the "mysqli" driver for connections.
  • Restart Apache:
    /etc/init.d/httpd restart
    
  • Visit http://server.example.com/phpmyadmin
  • Log in using "root" and the root password set from the MySQL server installation.

Nagios (only for monitoring server)

  • Install Nagios
    yum install nagios nagios-plugins-disk nagios-plugins-dns nagios-plugins-http nagios-plugins-load \
    nagios-plugins-mysql nagios-plugins-ping nagios-plugins-ssh nagios-plugins-users nagios-plugins-procs \
    nagios-plugins-nrpe nagios-plugins-swap
    htpasswd -c /etc/nagios/passwd nagios
    chgrp apache /etc/nagios/passwd
    chmod 640 /etc/nagios/passwd
    
  • Edit /etc/httpd/conf.d/nagios.conf.
    • Change allow from 127.0.0.1 to allow from all.
  • Edit /etc/nagios/nagios.cfg.
    • Uncomment cfg_dir=/etc/nagios/servers.
  • mkdir /etc/nagios/servers && chgrp nagios /etc/nagios/servers && chmod g+s /etc/nagios/servers.
  • Edit /etc/nagios/localhost.cfg to change nagios-admin to nagios.
  • Add the following text to /etc/nagios/commands.cfg to support querying NRPE on remote hosts:
    define command{
    command_name    check_nrpe
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
    }
    
  • Verify configurations:
    nagios -v /etc/nagios/nagios.cfg
    
  • Add server configurations to /etc/nagios/servers.
  • Restart Apache and Nagios:
    /etc/init.d/httpd restart
    /etc/init.d/nagios restart
    


Nagios clients

  • Install NRPE plugin:
    yum install nrpe nagios-plugins-disk nagios-plugins-load nagios-plugins-ping \
    nagios-plugins-ssh nagios-plugins-users nagios-plugins-procs nagios-plugins-swap
    
  • Edit /etc/nagios/nrpe.cfg.
    • Add the Nagios server to allowed_hosts.
    • Add necessary commands to the command definitions section.
  • Start the service:
    /etc/init.d/nrpe start
    
  • Make the service start by default:
    chkconfig nrpe on
    
  • Verify access to NRPE from the Nagios server:
    /usr/lib64/nagios/plugins/check_nrpe -H [nrpe-remote-host]
    
  • Verify access to commands from the Nagios server:
    /usr/lib64/nagios/plugins/check_nrpe -H [nrpe-remote-host] -c [command]
    


Nagios Apache clients

  • Install relevant plugin(s):
    yum install nagios-plugins-http
    
  • Add a check_http command to /etc/nagios/nrpe.cfg:
    command[check_http]=/usr/lib64/nagios/plugins/check_http -w 5 -c 20 -I 127.0.0.1
    


Nagios MySQL clients

  • Install relevant plugin(s):
    yum install nagios-plugins-mysql
    
  • Log into MySQL and add an unprivileged nrpe user:
    CREATE USER 'nrpe'@'localhost' IDENTIFIED BY 'nrpe';
    GRANT REPLICATION CLIENT ON *.* TO 'nrpe'@'localhost';
    
  • Add a check_mysql command to /etc/nagios/nrpe.cfg for a non-slave server:
    command[check_mysql]=/usr/lib64/nagios/plugins/check_mysql -u nrpe -p nrpe
    
  • Add a check_mysql command to /etc/nagios/nrpe.cfg for a slave server:
    command[check_mysql]=/usr/lib64/nagios/plugins/check_mysql -u nrpe -p nrpe -S -w 2 -c 10
    


Cacti (only for monitoring server)

  • Install the main package
    yum install php-snmp net-snmp net-snmp-utils cacti
    
  • Edit /etc/cacti/db.php:
    $database_type = 'mysql';
    $database_default = 'cacti';
    $database_hostname = 'localhost';
    $database_username = 'cacti';
    $database_password = 'password-here';
    $database_port = '3306';
    
  • Install the database:
    mysql -p cacti < /usr/share/doc/cacti-0.8.7b/cacti.sql mysql_convert_table_format --password="mysql-root-password" --type="InnoDB" cacti 
  • Edit /etc/httpd/conf.d/cacti.conf to allow access from non-localhost.
  • Restart Apache:
    /etc/init.d/httpd restart
    
  • Enable cron operation by adding the line */5 * * * * /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1 to cacti's crontab:
    export EDITOR=nano
    crontab -u cacti -e
    
  • Grant Apache access to the RRD files:
    chgrp -R apache /var/lib/cacti/rra
    chmode -R g+s /var/lib/cacti/rra
    
  • Go to http://server.example.com/cacti and log in as admin/admin.


Cacti clients

  • Install the SNMP daemon:
    yum install net-snmp net-snmp-libs net-snmp-utils
    
  • If the /etc/snmp/snmpd.conf is the default, move it:
    mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.original
    # snmpconf -i -g basic_setup
    
  • Configure the SNMP daemon by putting the following in /etc/snmp/snmpd.conf:
    rocommunity public cacti-server-ip
    rocommunity public 127.0.0.1
    dontPrintUnits true
    includeAllDisks
    
  • Enable the SNMP daemon:
    /etc/init.d/snmpd start
    chkconfig snmpd on
    
  • Add the device to the Cacti server
    • Console > Management > Devices > Add
      • Description: enter-name
      • Hostname: ip-address
      • Host Template: Generic SNMP-enabled Host
      • SNMP Version: Version 1
    • Console > Management > Graph Trees > Default Tree > Add
      • Tree Item Type: Host
      • Host: select-host


Cacti Apache clients

  • Add the following to /etc/snmp/snmpd.conf:
    proc httpd
    


Cacti MySQL clients

To be written.


Load testing with curl-loader

  • Download, build, and install:
    yum install gcc openssl-devel
    wget http://downloads.sourceforge.net/curl-loader/curl-loader-0.46.tar.gz
    tar xzf curl-loader-0.46.tar.gz
    rm curl-loader-0.46.tar.gz
    cd curl-loader-0.46
    make
    make install
    
  • Run:
    curl-loader -f configfile
    

PHP PECL xdebug

  • Install xdebug and restart Apache
    pear install pecl/xdebug
    /etc/init.d/httpd restart
    
  • To profile code
    • Add the following to /etc/php.d/xdebug.conf:
      zend_extension=/usr/lib64/php/modules/xdebug.so
      xdebug.profiler_enable_trigger = 1
      
    • Restart Apache:
      /etc/init.d/httpd restart
      
    • And then load the page you want to profile with "?XDEBUG_PROFILE=1" at the end of the URL.

To do

  • Set up multiple memcached instances (instead of the default single instance)
  • Tune APC
REFERENCES https://wiki.fourkitchens.com/display/PF/Stack+installation+on+CentOS+5