First, prepare two versions of the virtual machine and install the system centos7.x
Second, the configuration zabbix_server
1、http install:
# Install the software support library
yum install apr-devel apr-util-devel gcc c ncurses-devel cmake libaio bison gcc-c++ git pcre* lrzsz bzip2 vim -y
# Upload unzip and install httpd-2.4.29
rz tar -xjf httpd-2.4.29.tar.bz2 cd httpd-2.4.29 ./configure --prefix=/usr/local/apache/ --enable-so && make && make install
# Modify the configuration http.conf
sed -i '/:80/aServerName localhost:80' /usr/local/apache/conf/httpd.conf echo “ServerName localhost:80” >>/usr/local/apache/conf/httpd.conf
# View selinux state is disabled, turn off the firewall
setenforce 0 systemctl stop firewalld iptables -F
# Restart apache service
/usr/local/apache/bin/apachectl restart
# View port status, confirm apache service is turned on
netstat -antp
#############################################################
2、mysql install:
# Upload unzip and install mysql-5.5.20
rz tar -xzf mysql-5.5.20.tar.gz cd mysql-5.5.20 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_DATADIR=/data/mysql \ -DSYSCONFDIR=/etc \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306 \ -DWITH_XTRADB_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_EXTRA_CHARSETS=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DWITH_BIG_TABLES=1 \ -DWITH_DEBUG=0 && make && make install
# Copy files from the installation directory to the startup directory
cd /usr/local/mysql55/ \cp -f support-files/my-large.cnf /etc/my.cnf \cp -f support-files/mysql.server /etc/init.d/mysqld
# Add the boot mysql
chkconfig --add mysqld chkconfig --level 35 mysqld on
# Create a folder and give the relevant authority
mkdir -p /data/mysql useradd mysql chown -R mysql /data/mysql/ ln -s /usr/local/mysql55/bin/* /usr/bin/
# Create mysql_install_db
/usr/local/mysql55/scripts/mysql_install_db --user=mysql -- datadir=/data/mysql --basedir=/usr/local/mysql55/
# Restart mysql service
service mysqld restart
#############################################################
3、php install
# Unzip and upload php-5.6.8 installed
tar -xjf php-5.6.8.tar.bz2 cd php-5.6.8 ./configure --prefix=/usr/local/php5 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs
Error: Missing libxml2
yum install libxml2 libxml2-devel -y make && make install
# Modify the apache configuration page and the associated php
vim /usr/local/apache/conf/httpd.conf
# Find php support module, modify the default home support php, php types of applications to add support
:?php5
LoadModule php5_module modules/libphp5.so
:?index.html
index.html-index.php
:?AddType application
AddType application/x-httpd-php .php
Esc:wq!
# Modify Home
cd /usr/local/apache/htdocs mv index.html index.php vim index.php :%d <?php phpinfo(); ?>
# Restart apache service
/usr/local/apache/bin/apachectl restart
# View port status
netstat -natp
#############################################################
4、zabbix install
# Configure database zabbix
# Upload and extract zabbix-3.2.6
cd /usr/src rz tar -xzf zabbix-3.2.6.tar.gz cd zabbix-3.2.6 mysql create database zabbix charset=utf8; grant all on zabbix.* to zabbix@localhost identified by '123456'; flush privileges; quit
# Zabbix test database connectivity
mysql -uzabbix -p123456 -hlocalhost
show databases;
quit
# Import data into the database zabbix
mysql -uzabbix -p123456 zabbix <database/mysql/schema.sql mysql -uzabbix -p123456 zabbix <database/mysql/images.sql mysql -uzabbix -p123456 zabbix <database/mysql/data.sql
# Compile and install zabbix
./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl
Error: Missing net-snmp
yum install net-snmp net-snmp-devel -y
Error: Missing curl
yum install curl curl-devel -y make && make install
# Create a user zabbix
useradd -s /sbin/nologin zabbix
# Zabbix modify service configuration
cd /usr/local/zabbix/etc/ grep -vE "^$|^#" zabbix_server.conf LogFile=/tmp/zabbix_server.log DBName=zabbix DBUser=zabbix DBHost=localhost DBPassword=123456 Timeout=4 LogSlowQueries=3000
# Modify the content above
vim zabbix_server.conf
# Configure zabbix service as a system service
cd /usr/src/zabbix-3.2.6 cp misc/init.d/tru64/zabbix_server /etc/init.d/zabbix_server
# File permissions given zabbix Service
chmod +x /etc/init.d/zabbix_server
# Copy the file to the Home zabbix apache publishing directory
cd /usr/src/zabbix-3.2.6/frontends/php/ cp -a ./* /usr/local/apache/htdocs/
# Restart apache service
/usr/local/apache/bin/apachectl restart
Php configuration file support:
# Upload unzip and install freetype-2.6.2
rz cd /usr/src tar -xjf freetype-2.6.2.tar.bz2 cd freetype-2.6.2 ./configure –prefix=/usr/local/freetype && make && make install
# Upload unzip and install libpng-1.6.35
rz cd /usr/src tar -xzf libpng-1.6.35.tar.gz cd libpng-1.6.35/ ./configure –prefix=/usr/local/libpng/ && make && make install
# Upload unzip and install jpegsrc.v9c
rz cd /usr/src tar -xzf jpegsrc.v9c.tar.gz cd jpeg-9c/ ./configure –prefix=/usr/local/jpeg && make && make install
# Upload unzip and install zlib-1.2.11
rz cd /usr/src tar -xzf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure –prefix=/usr/local/zlib && make && make install
# Recompile php
cd /usr/src/php-5.6.8/ ./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs --enable-cli --enable-bcmath --enable-mbstring --enable-sockets --with-freetype-dir=/usr/local/freetype/ --with-png-dir=/usr/local/libpng/ --with-jped-dir=/usr/local/jpeg/ --with-zlib-dir=/usr/local/zlib/ --with-zlib --with-gettext make && make install
# Error: jpeg-gd installation fails
# Recompile php again
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs --enable-cli --enable-bcmath --enable-mbstring --enable-sockets --with-freetype-dir=/usr/local/freetype/ --with-png-dir=/usr/local/libpng/ --with-jped-dir=/usr/local/jpeg/ --with-zlib-dir=/usr/local/zlib/ --with-zlib --with-gettext --with-gd
# - with-gd This parameter need to be recompiled once
# Error: php (php.ini) configuration file does not meet the requirements of zabbix
# Create a test page info.php view php.ini file path
cd /usr/local/apache/htdocs/ vim info.php <?php phpinfo(); ?> cd /usr/src/php-5.6.8/
# Can not find such a file, copy the php.ini file from the source directory to the installation directory
cp php.ini-production /usr/local/php5/etc/ cd /usr/local/php5/etc/
# Modify php.ini configuration file
sed -i '/post_max_size/s/8/16/g;/max_execution_time/s/30/300/g;/max_input_time/s/60/300/g;s/\;date.timezone.*/date.timezone \= PRC/g;s/\;always_populate_raw_post_data/always_populate_raw_post_data/g' php.ini
# Restart apache service
!/usr/local/apa
# Error: still can not find the php.ini file path
yum install strace* -y strace /usr/local/php5/bin/php -i 2>1.log
# Modify the php.ini configuration file and authorization
vim 1.log :?php.ini (/usr/local/php5/lib/php.ini) &&(/usr/local/php5/etc/php.ini) chmod 777 php.ini (mv php.ini ../lib/) strace /usr/local/php5/bin/php
# Modify zabbix.conf.php
vim /usr/local/apache/htdocs/conf/zabbix.conf.php <?php // Zabbix GUI configuration file. global $DB; $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = 'localhost'; $DB['PORT'] = '0'; $DB['DATABASE'] = 'zabbix'; $DB['USER'] = 'zabbix'; $DB['PASSWORD'] = '123456'; // Schema name. Used for IBM DB2 and PostgreSQL. $DB['SCHEMA'] = ''; $ZBX_SERVER = 'localhost'; $ZBX_SERVER_PORT = '10051'; $ZBX_SERVER_NAME = '京峰教育'; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
Log in using IP #
http://x.x.x.x
user:admin
password:zabbix
#############################################################
5, Page Setup
# Zabbix_server modify configuration files
vim /etc/init.d/zabbix_server
DAEMON=/usr/local/zabbix/sbin/zabbix_server
# Restart zabbix Service
/etc/init.d/zabbix_server restart
# View port status
netstat -antp Port:10051
# Error: Unable to connect zabbix Service
# View zabbix service log
tail -fn 10 /tmp/zabbix_server.log find / -name “mysql.sock” mkdir -p /var/lib/mysql ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock ll /var/lib/mysql/
#############################################################
6, zabbix client configuration script
Auto_install_zabbix_agentd #!/bin/bash #auto install zabbix agentd #by virgil 2019 ############################################################# ZABBIX_SOFT="zabbix-3.2.6.tar.gz" INSTALL_DIR="/usr/local/zabbix/" SERVER_IP="x.x.x.x" IP=`ifconfig |grep inet |sed -n '1p' |awk '{print$2}'` AGENT_INSTALL(){ yum install curl curl-devel net-snmp net-snmp-devel perl-DBI gcc-c++ -y groupadd zabbix;useradd -g zabbix zabbix;usermod -s /sbin/nologin zabbix tar -xzf $ZABBIX_SOFT; cd `echo $ZABBIX_SOFT |sed 's/.tar.*//g'` ./configure --prefix=/usr/local/zabbix --enable-agent && make install if [ $? -eq 0 ];then ln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/ fi cd -;cd zabbix-3.2.6 cp misc/init.d/tru64/zabbix_agentd /etc/init.d/zabbix_agentd;chmod o+x /etc/init.d/zabbix_agentd #config zabbix agentd cat > $INSTALL_DIR/etc/zabbix_agentd.conf<<EOF LogFile=/tmp/zabbix_agentd.log Server=$SERVER_IP ServerActive=$SERVER_IP Hostname=$IP EOF #start zabbix agented /etc/init.d/zabbix_agentd restart systemctl stop firewalld.service setenforce 0 } AGENT_INSTALL