Compile and install zabbix3.2 and compile zabbix3.2
1.1 prepare the environment
System Environment preparation:
Redhat 6.6 64-bit
Mysql-5.6.34
Php-5.6.28
Zabbix-3.2.1
Disable iptables and SELINUX before configuration to avoid errors during installation.
# service iptables stop
# setenforce 0
# vi /etc/sysconfig/selinuxSELINUX=disabled
Environment requirements of zabbix3.2.0:
MySQL 5.1 or later is preferably 5.6 or later.
PHP 5.4 or later
1.2 LAMP installation 1.2.1 yum installation httpd
Install Apahce, PHP, MySQL, and php to connect to the mysql library components.
#yum -y install httpd httpd-devel
1.2.2 compile and install mysql5.6 install the tools and libraries required for compiling source code
yum install \make \gcc \gcc-c++ \ncurses-devel \cmake
New mysql user group:
Groupadd mysql
New mysql users:
Useradd-g mysql-s/sbin/nologin
Chmod 755/home/mysql/
Directory required for creating MySQL
Create a mysql installation directory:
Mkdir-p/usr/local/mysql
Create a mysql database data file directory:
Mkdir-p/data/mysqldb
Compile and install:
cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/data/mysqldb/ \-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_ARCHIVE_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DENABLED_LOCAL_INFILE=1 \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=all \-DWITH_SSL=system \-DMYSQL_TCP_PORT=3306 \--enable-proxy \-DWITH_SSL=bundled
Note: delete the cmakecache.txt file after you refresh the configuration.
rm -f CMakeCache.txt
make
make install
Modify the mysql installation directory
Chown-R mysql: mysql/usr/local/mysql
Modify the mysql database file directory
Chown-R mysql: mysql/data/mysqldb
Initialize Configuration
Enter the installation path
# cd /usr/local/mysql
Go to the installation path, execute the initialization configuration script, and create the database and table that comes with the system.
# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysqldb --user=mysql
Note: when starting the MySQL service, I will search for my. cnf in a certain order and find it in the/etc directory first. If no value is found, I will search for "$ basedir/my. cnf"
Note: If the/etc directory contains a my. cnf, You need to rename this file to another name, such as:/etc/my. cnf. bak. Otherwise, the file will interfere with the correct configuration of MySQL installed by source code, resulting in startup failure.
After updating the system using "yum update", you need to check whether there will be an extra my. cnf in The/etc directory. If there are more, rename it to something else. Otherwise, MySQL will use this configuration file to start, which may cause problems such as failure to start normally.
Copy the mysql service startup configuration file
# mv /etc/my.cnf /etc/my.cnf.bak# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
Start MySQL
Add a service, copy the service script to the init. d directory, and set startup
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
Set startup
chkconfig mysqld on
service mysqld start
Configure the user
After MySQL is started successfully, the root user has no password by default. We need to set the root password.
Before setting, we need to set the PATH first, or we cannot directly call mysql
Modify the/etc/profile file and add
PATH=/usr/local/mysql/bin:$PATHexport PATH
Make the configuration take effect immediately
source /etc/profile
Modify the root password of the database:
mysql -uroot mysql> SET PASSWORD = PASSWORD('123abc');
Or
# Mysqladmin-uroot-p password 123 abcEnter password: Press ENTER Warning: Using a password on the command line interface can be insecure. to set remote access for the root user, run mysql> grant all privileges on *. * TO 'root' @ '172. 16.% 'identified BY 'Password' with grant option; when the red password is used for remote access, the root user password may be different from the local password.
Configure Firewall
Port 3306 of the firewall is disabled by default. To access the firewall remotely, you must enable this port.
Open the/etc/sysconfig/iptables file and add:
-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT
Save and close the file. Run the following command in the terminal to refresh the Firewall Configuration:
service iptables restart
OK. All configurations are complete. You can access your MySQL instance ~
1.2.3 compile and install PHP5.6
Add dependent applications
yum install -y gcc \gcc-c++ \autoconf \libjpeg \libjpeg-devel \libpng \libpng-devel \freetype \freetype-devel \libpng \libpng-devel \libxml2 \libxml2-devel \zlib \zlib-devel \glibc \glibc-devel \glib2 \glib2-devel \bzip2 \bzip2-devel \ncurses \curl \openssl-devel \db4-devel \libXpm-devel \libX11-devel \gmp-devel \readline-devel \libxslt-devel \expat-devel \xmlrpc-c \libcurl \libcurl-devel
Install the encrypted extension library. Install Libmcrypt first.
1 tar zxvf libmcrypt-2.5.8.tar.gz 2 3 cd libmcrypt-2.5.84 5 ./configure6 7 make8 9 make install
Compile and install
./configure \--prefix=/usr/local/php \--with-config-file-path=/etc \--with-apxs2=/usr/sbin/apxs \--with-mysql=/usr/local/mysql \--with-mysqli=/usr/local/mysql/bin/mysql_config \--enable-inline-optimization \--enable-fpm \--enable-soap \--with-libxml-dir \--with-xmlrpc \--with-openssl \--with-mcrypt \--with-mhash \--with-pcre-regex \--with-sqlite3 \--with-zlib \--enable-bcmath \--with-iconv \--with-bz2 \--enable-calendar \--with-curl \--with-cdb \--enable-dom \--enable-exif \--enable-fileinfo \--enable-filter \--with-pcre-dir \--enable-ftp \--with-gd \--with-openssl-dir \--with-jpeg-dir \--with-png-dir \--with-zlib-dir \--with-freetype-dir \--enable-gd-native-ttf \--with-gettext \--with-gmp \--with-mhash \--enable-json \--enable-mbstring \--disable-mbregex \--disable-mbregex-backtrack \--with-libmbfl \--with-onig \--enable-pdo \--with-pdo-mysql \--with-zlib-dir \--with-pdo-sqlite \--with-readline \--enable-session \--enable-shmop \--enable-simplexml \--enable-sockets \--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-wddx \--with-libxml-dir \--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear
WhereWith-apxs2Is used to generate Apache PHP module libphp5.so, you do not need to remove.
Make
Make install
Php configuration
Php. ini is the core configuration file for php running.
The php-fpm.conf is the configuration file for the php-fpm process service
1 # cd php-5.6.282 3 # cp php.ini-production /etc/php.ini4 5 # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf6 7 # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm8 9 # chmod +x /etc/init.d/php-fpm
Fpm test php configuration
# /usr/local/php/sbin/php-fpm -t[23-May-2016 20:03:52] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful
Add to server to manage startup:
# chkconfig --add php-fpm# chkconfig php-fpm on# service php-fpm startStarting php-fpm donenetstat –anpttcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 705/php-fpm
Modify the default PHP Port:
vi /usr/local/php/etc/php-fpm.conflisten = 127.0.0.1:8000
1.3 configure apache to access PHP
Configure httpd. conf to make apache support PHP
# Vi/usr/local/apache/conf/httpd. find AddType application/x-gzip in conf. gz. add AddType application/x-httpd-php below tgz (369. phpAddType application/x-httpd-php-source. phpsDirectoryIndex index. php index.html // adjust the homepage file setting LoadModule php5_module/usr/lib64/httpd/modules/libphp5.so. This module will be added to the automatically generated compilation.
Test page:
vi /var/www/html/test.php <?phpphpinfo();?>
2.1 Download zabbix source code package
Official Website: http://www.zabbix.com/download.php
Download zabbix-3.2.1.tar.gz
Components required for zabbix installation (server, agent)
yum -y install curl libcurl-devel net-snmp net-snmp-devel perl-DBI libdbi-dbd-mysql mysql-devel gcc gcc++ make libxml2 libxml2-devel
Server: (172.28.3.103) server
Create zabbix user group and user:
# groupadd zabbix# useradd -g zabbix -s /sbin/nologin zabbix# tar xzvf zabbix-3.2.1.tar.gz
Compile and install:
# cd zabbix-3.2.1# ./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-agent --enable-ipv6make && make install
Create databases and authorize users
Note: The import sequence of data files cannot be changed. You can also use the mysql command on the command line to import data files.
[root@test ~]# service mysqld startmysql> create database zabbix character set utf8;mysql> grant all on zabbix.* to zabbix@'localhost' identified by '123456';mysql> flush privileges;
Import Database SQL script:
# cd zabbix-3.2.1
In the decompressed zabbix directory, import the three SQL files in the database/mysql directory to the zabbix database. (The zabbix user is used to import files. This user exists in the Database by default)
# mysql -uzabbix -p123456 zabbix < database/mysql/schema.sql# mysql -uzabbix -p123456 zabbix < database/mysql/images.sql# mysql -uzabbix -p123456 zabbix < database/mysql/data.sql
Or
# mysql -uzabbix -p123456 zabbix < database/mysql/schema.sql# mysql -uzabbix -p123456 zabbix < database/mysql/images.sql# mysql -uzabbix -p123456 zabbix < database/mysql/data.sql
Modify the configuration file and start
mkdir -p /var/www/zabbixcp -R frontends/php /var/www/zabbixchmod 777 /var/www/zabbix/php/conf
Modify the name for filtering out comments
cat /usr/local/zabbix-server/etc/zabbix_server.conf |grep -v "^#" |grep -v "^$" > /usr/local/zabbix-server/etc/zabbix_server.conf.back
You only need to pay attention to DBHost, DBName, DBUser, and DBPassword. These parameters are used to configure zabbix server to connect to the mysql database.
vim /usr/local/zabbix-server/etc/zabbix_server.confLogFile=/var/log/zabbix/zabbix_server.logDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=123456
Create a log file storage location:
Mkdir/var/log/zabbix
Chown-R zabbix: zabbix/var/log/zabbix
Start zabbix:
/Usr/local/zabbix-server/sbin/zabbix_server
Use server to manage and start the zabbix service:
# Cd zabbix-3.2.1 # cp misc/init. d/fedora/core/zabbix_server/etc/init. d/# chkconfig -- add zabbix_server # chkconfig zabbix_server on to create a soft link: ln-s/usr/local/zabbix/sbin/zabbix_server/usr/local/sbin/start the service: service zabbix_server start
Agent: (172.28.3.100) Client
Create zabbix user group and user:
# groupadd zabbix# useradd -g zabbix -s /sbin/nologin zabbix
Compile and install:
# cd zabbix-3.2.1# ./configure --prefix=/usr/local/zabbix-agent --enable-agentmake && make install # cd /usr/local/zabbix-agent# vi etc/zabbix_agentd.confLogFile=/var/log/zabbix/zabbix_agentd.logServer=172.28.3.103ServerActive=172.28.3.103Hostname=172.28.3.100
Use server to manage and start the zabbix service:
# Cd zabbix-3.2.1 # cp misc/init. d/fedora/core/zabbix_agentd/etc/init. d/# chkconfig -- add zabbix_agentd # chkconfig zabbix_agentd on: # ln-s/usr/local/zabbix/sbin/zabbix_agentd/usr/local/sbin/start the service: service zabbix_agentd start
Note: To install client parameters on the server side, refer to: http://meiling.blog.51cto.com/6220221/1339389
2.3 configure the zabbix web page
vim /etc/httpd/conf.d/zabbix.conf## Zabbix monitoring system php web frontend# #Alias /zabbix/usr/share/zabbixAlias /zabbix /var/www/zabbix/php <Directory "/var/www/zabbix/php"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all #Require all granted <IfModule mod_php5.c> php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value always_populate_raw_post_data -1 # php_value date.timezone Europe/Riga php_value date.timezone Asia/Chongqing </IfModule></Directory>
Php_value date. timezone Asia/Chongqing mainly defines the php time zone.
Restart apache and zabbix as follows:
Services httpd restart
Services zabbix_server restart
Then visit the address http: // 172.28.3.103/zabbix/setup. php and install it as follows:
Log on to zabbix. The default username and password of zabbix are Admin and zabbix.
If an error is reported when creating the zabbix. conf. php file, you can manually download the file and create the zabbix. conf. php file in the corresponding directory to copy the content:
vi /var/www/zabbix/php/conf/zabbix.conf.php<?php// Zabbix GUI configuration file.global $DB; $DB['TYPE'] = 'MYSQL';$DB['SERVER'] = '172.28.3.103';$DB['PORT'] = '3306';$DB['DATABASE'] = 'zabbix';$DB['USER'] = 'zabbix';$DB['PASSWORD'] = 'zabbix'; // Schema name. Used for IBM DB2 and PostgreSQL.$DB['SCHEMA'] = ''; $ZBX_SERVER = '172.28.3.103';$ZBX_SERVER_PORT = '10051';$ZBX_SERVER_NAME = ''; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;