Stack installation on CentOS 5
All commands are run as root.
- 1 Text editor (mostly for my use):
- 2 EPEL and Remi repositories
- 3 PHP and MySQL(i) client
- 4 APC
- 5 Memcached
- 6 Apache
- 7 MySQL server
- 8 Synchronize system clock
- 9 phpMyAdmin
- 10 Nagios (only for monitoring server)
- 10.1 Nagios clients
- 10.2 Nagios Apache clients
- 10.3 Nagios MySQL clients
- 11 Cacti (only for monitoring server)
- 11.1 Cacti clients
- 11.2 Cacti Apache clients
- 11.3 Cacti MySQL clients
- 12 Load testing with curl-loader
- 13 PHP PECL xdebug
- 14 To do
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.rpmEdit
/etc/yum.repos.d/remi.repo.Under
[TECH:remi], setenabled=1.
PHP and MySQL(i) client
Configure base packages
yum install php-pear php-mysql php-mbstring /etc/init.d/httpd restartTest
Configure phpinfo() page
echo "<?php phpinfo();" > /var/www/html/index.php chmod 644 /var/www/html/index.phpLoad 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
<Directory "/var/www/html">:/etc/httpd/conf/httpd.conf (excerpt)
<Directory "/var/www/html"> [...] AllowOverride All [...] </Directory>
MySQL server
Install MySQL
yum install mysql-serverSet better defaults in
/etc/my.cnfunder[TECH:mysqld]:default_storage_engine = InnoDB default_character_set = utf8 collation_server = utf8_general_ci character_set_server = utf8Start 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 phpmyadminEdit
/etc/httpd/conf.d/phpMyAdmin.confto allow access from non-localhost clients.Edit
/etc/phpMyAdmin/config.inc.phpto add additional servers and use the "mysqli" driver for connections.Restart Apache:
/etc/init.d/httpd restartLog 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/passwdEdit
/etc/httpd/conf.d/nagios.conf.Change
allow from 127.0.0.1toallow 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.cfgto changenagios-admintonagios.Add the following text to
/etc/nagios/commands.cfgto 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.cfgAdd 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-swapEdit
/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 startMake the service start by default:
chkconfig nrpe onVerify 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-httpAdd a
check_httpcommand 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-mysqlLog 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_mysqlcommand to/etc/nagios/nrpe.cfgfor a non-slave server:command[check_mysql]=/usr/lib64/nagios/plugins/check_mysql -u nrpe -p nrpeAdd a
check_mysqlcommand to/etc/nagios/nrpe.cfgfor 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 cactiEdit
/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" cactiEdit
/etc/httpd/conf.d/cacti.confto allow access from non-localhost.Restart Apache:
/etc/init.d/httpd restartEnable cron operation by adding the line
*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1tocacti's crontab:export EDITOR=nano crontab -u cacti -eGrant Apache access to the RRD files:
chgrp -R apache /var/lib/cacti/rra chmode -R g+s /var/lib/cacti/rraGo 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-utilsIf the
/etc/snmp/snmpd.confis the default, move it:mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.original # snmpconf -i -g basic_setupConfigure 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 includeAllDisksEnable the SNMP daemon:
/etc/init.d/snmpd start chkconfig snmpd onAdd 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 installRun:
curl-loader -f configfile
PHP PECL xdebug
Install xdebug and restart Apache
pear install pecl/xdebug /etc/init.d/httpd restartTo profile code
Add the following to
/etc/php.d/xdebug.conf:zend_extension=/usr/lib64/php/modules/xdebug.so xdebug.profiler_enable_trigger = 1Restart Apache:
/etc/init.d/httpd restartAnd 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