Set up CentOS 6.7 to act like a Zabbix Server 2.4

Install CentOS-6.7-x86_64-minimal.iso

Update system
yum update -y
Install Apache:
yum install httpd httpd-devel -y
Install MySQL server
yum install mysql mysql-server -y
Install PHP
yum install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml -y
Start Apache
service httpd start
Set Apache to run at startup
chkconfig httpd on
Start MySQL server
service mysqld start
Set MySQL server to run at system startup
chkconfig mysqld on
Set MySQL root password to LCq9LCFCNMZEqatm
/usr/bin/mysqladmin -u root password 'LCq9LCFCNMZEqatm'
Install Zabbix repository
rpm -Uvh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
Turn off GPG check in yum. This will let to install packages more automatically
sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.conf
Install all necessary zabbix packages. Do not skip any of them
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y
Uncoment your time location at Apache configuration
sed -i "s/# php_value date.timezone/php_value date.timezone/" /etc/httpd/conf.d/zabbix.conf
Restart Apache
service httpd restart
Use root account togerher with password LCq9LCFCNMZEqatm to create database zabbix
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'CREATE DATABASE zabbix CHARACTER SET UTF8'
Create new user zabbix with password drFJ7xx5MNTbqJ39 and allow it to access database zabbix from localhost location
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'GRANT ALL PRIVILEGES on zabbix.* to "zabbix"@"localhost" IDENTIFIED BY "drFJ7xx5MNTbqJ39"'
Apply permissions
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'FLUSH PRIVILEGES'
Move to directory where basic zabbix mysql structure located
cd /usr/share/doc/zabbix-server-mysql-*/create
Create necessary tables and objects into database using MySQL user zabbix with password drFJ7xx5MNTbqJ39
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < schema.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < images.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < data.sql
Set password drFJ7xx5MNTbqJ39 into zabbix server configuration file
sed -i "s/^.*DBPassword=.*$/DBPassword=drFJ7xx5MNTbqJ39/" /etc/zabbix/zabbix_server.conf
List zabbix server configuration without comments
grep -v "^#\|^$" /etc/zabbix/zabbix_server.conf
Start zabbix server
service zabbix-server start
Allow to access web interface (port 80) from everywhere and zabbix ports (10050, 10051)
iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 10050 -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 10051 -j ACCEPT
Save IP tables configuration
service iptables save
Restart firewall service
service iptables restart
Fix:

Zabbix server is not running: the information displayed may not be current.

setsebool -P httpd_can_network_connect=true
Set zabbix server to start at system bootup
chkconfig zabbix-server on
Check service sitiation about all services related to zabbix server
chkconfig --list | grep "zabbix\|mysqld\|httpd"
Set zabbix agent to boot at system startup
chkconfig zabbix-agent on
Look at zabbix agent configuration file
grep -v "^#\|^$" /etc/zabbix/zabbix_agentd.conf
Now you can go at you server IP adress and continue to set up zabbix server:
http://ip.address.goes.here/zabbix
If you want to do all steps in one click then create new file:
vi install-zabbix-server.sh
Paste this content:
yum update -y
yum install httpd httpd-devel -y
yum install mysql mysql-server -y
yum install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml -y
service httpd start
chkconfig httpd on
service mysqld start
chkconfig mysqld on
/usr/bin/mysqladmin -u root password 'LCq9LCFCNMZEqatm'
rpm -Uvh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.conf
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y
sed -i "s/# php_value date.timezone/php_value date.timezone/" /etc/httpd/conf.d/zabbix.conf
service httpd restart
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'CREATE DATABASE zabbix CHARACTER SET UTF8'
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'GRANT ALL PRIVILEGES on zabbix.* to "zabbix"@"localhost" IDENTIFIED BY "drFJ7xx5MNTbqJ39"'
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'FLUSH PRIVILEGES'
cd /usr/share/doc/zabbix-server-mysql-*/create
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < schema.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < images.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < data.sql
sed -i "s/^.*DBPassword=.*$/DBPassword=drFJ7xx5MNTbqJ39/" /etc/zabbix/zabbix_server.conf
grep -v "^#\|^$" /etc/zabbix/zabbix_server.conf
service zabbix-server start
iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 10050 -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 10051 -j ACCEPT
service iptables save
service iptables restart
setsebool -P httpd_can_network_connect=true
chkconfig zabbix-server on
chkconfig --list | grep "zabbix\|mysqld\|httpd"
chkconfig zabbix-agent on
grep -v "^#\|^$" /etc/zabbix/zabbix_agentd.conf
No need to change any of lines for success story, BUT please replace MySQL root password LCq9LCFCNMZEqatm and please replace MySQL zabbix password drFJ7xx5MNTbqJ39 with something else!

Set file executable:
chmod +x install-zabbix-server.sh
Launch installation process:
./install-zabbix-server.sh

No comments: