Stack installation on CentOS 5
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]
, setenabled=1
.
- Under
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 "<?php phpinfo();" > /var/www/html/index.php chmod 644 /var/www/html/index.php
- Load page in browser
- Configure phpinfo() page
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-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
toallow from all
.
- Change
- Edit
/etc/nagios/nagios.cfg
.- Uncomment
cfg_dir=/etc/nagios/servers
.
- Uncomment
mkdir /etc/nagios/servers && chgrp nagios /etc/nagios/servers && chmod g+s /etc/nagios/servers
.- Edit
/etc/nagios/localhost.cfg
to changenagios-admin
tonagios
. - 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.
- Add the Nagios server to
- 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
tocacti
'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
- Console > Management > Devices > Add
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.
- Add the following to
To do
- Set up multiple memcached instances (instead of the default single instance)
- Tune APC