(1)mysql的下载
登录https://downloads.mysql.com/archives/community/选择最新的稳定版本,进行下载。
(2)cmake的下载
登录https://cmake.org/download/下载最新的版本。
(3)Boost的下载
登录https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz下载。php
(1)Yum安装依赖包
这里使用yum安装gcc,c++的编译环境。#yum -y install gcc gcc-c++ ncurses ncurses-devel *curl* *libxml2*
(2)安装cmakehtml
#tar -xvf cmake-3.10.1.tar.gz #cd cmake-3.10.1/ #./bootstrap --prefix=/home/cmake #make && make install
(3)准备boost# tar -xvf boost_1_59_0.tar.gz -C /usr/local/
(4)建立用户和日志文件目录node
# groupadd mysql # useradd -s /sbin/nologin -g mysql mysql # mkdir /var/log/mysql # chown -R mysql.mysql /var/log/mysql/
(5)安装mysqlmysql
# tar -xvf mysql-5.7.18.tar.gz # cd mysql-5.7.18/ #/home/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/node/mysql -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost_1_59_0 #make && make install
(1)拷贝启动脚本nginx
# cp /node/installfile/mysql/mysql-5.7.18/support-files/mysql.server /etc/init.d/mysqld # chmod +x /etc/init.d/mysqld
(2)将mysql数据库的动态连接库共享至系统连接库,以便被其余服务调用# ln -sv /node/mysql/lib/libmysqlclient.so.20 /usr/lib/
(3)设置库文件及环境变量c++
# echo "/node/mysql/lib" >> /etc/ld.so.conf # ldconfig # echo "export PATH=$PATH:$HOME/bin:/node/mysql/bin/" >> /etc/profile # source /etc/profile
(4)设置开机自启web
# chkconfig --add mysqld # chkconfig mysqld on # chkconfig --list mysqld
(5)配置文件
mysql的配置文件是/etc/my.cf,mysql对于zabbix的使用性能来讲,是重要的影响因素,须要作一些优化,这部份内容在后面作一些总结。sql
# mysqld --initialize-insecure --user=mysql --basedir=/node/mysql --datadir=/node/mysql/data
数据库
# chown -R mysql.mysql /node/mysql/ # /etc/init.d/mysqld restart # netstat -anptu |grep "mysql" tcp6 0 0 :::3306 :::* LISTEN 3922/mysqld
(1)Pcre
下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/# tar -xvf pcre-8.41.tar.gz
(2)Openssl
下载地址:https://www.openssl.org/source/# tar -xvf openssl-1.1.0g.tar.gz
(3)Zlib
下载地址:http://www.zlib.net/# tar -xvf zlib-1.2.11.tar.gz
bootstrap
# groupadd nginx # useradd -s /sbin/nologin -g nginx nginx
# tar -xvf nginx-1.12.2.tar.gz # cd nginx-1.12.2/ # ./configure --prefix=/node/nginx-1.12.2 --user=nginx --with-pcre=../pcre-8.41/ --with-zlib=../zlib-1.2.11/ --with-openssl=../openssl-1.1.0g/ --with-http_stub_status_module --with-http_ssl_module #make && make install
# echo 'export PATH=$PATH:/node/nginx-1.12.2/sbin/' >> /etc/profile # source /etc/profile
# nginx` #nginx -s stop #关闭nginx
#vim /etc/init.d/nginxd #!/bin/bash #chkconfig: - 80 90 pid=/node/nginx-1.12.2/logs/nginx.pid mstart(){ if [ -e $pid ];then echo -e "\033[32mnginx已启动\033[0m" else nginx &>/etc/null [ $? -eq 0 ]&&echo -e "\033[32mnginx启动成功\033[0m"||echo -e "\033[31mnginx启动失败\033[0m" fi } mstop(){ if [ -e $pid ];then nginx -s stop &>/etc/null [ $? -eq 0 ]&&echo -e "\033[32mnginx关闭成功\033[0m"||echo -e "\033[31mnginx关闭失败\033[0m" else echo -e "\033[32mnginx已关闭\033[0m" fi } mstatus(){ if [ -e $pid ];then echo -e "\033[32mnginx已启动\033[0m" else echo -e "\033[32mnginx已关闭\033[0m" fi } mrestart(){ if [ -f $pid ];then kill `cat $pid` [ $? -eq 0 ]&&echo -e "\033[32mnginx已关闭\033[0m"||echo "nginx失败" else echo -e "\033[32mnginx已关闭\033[0m" fi echo -e "nginx重启中" sleep 2 if [ -f $pid ];then echo -e "\033[32mnginx已启动\033[0m" else nginx &> /dev/null [ $? -eq 0 ]&&echo -e "\033[32mnginx已启动\033[0m"||echo "nginx启动失 败" fi } case $1 in start) mstart ;; stop) mstop ;; status) mstatus ;; restart) mrestart ;; reload) nginx -s reload ;; *) echo "Usage: $0 [start|stop|restart|status|reload]" esac
# yum install libXpm-devel
(1)安装mhash
# tar -xvf mhash-0.9.9.9.tar.gz # cd mhash-0.9.9.9/ # ./configure #make && make install
(2)安装libiconv
# tar -xvf libiconv-1.15.tar.gz # cd libiconv-1.15/ # ./configure #make && make install
(3)安装libmcrypt
# tar -xvf libmcrypt-2.5.8.tar.gz # cd libmcrypt-2.5.8/ # ./configure #make && make install
(4)安装libxml2
#tar -xvf libxml2-2.7.8.tar.gx #cd libxml2-2.7.8/ #./configure #make && make install
(5)创建软链接
# ln -sv /usr/local/lib/libmcrypt* /usr/lib/ # ln -sv /usr/local/lib/libmhash* /usr/lib/ # ln -sv /usr/local/lib/libiconv* /usr/lib/
(1)安装zlib
# tar -xvf zlib-1.2.11.tar.gz # cd zlib-1.2.11/ # ./configure --prefix=/usr/local/zlib --shared --enable-shared #make && make install
(2)安装libpng
# tar -xvf libpng-1.6.34.tar.gz # cd libpng-1.6.34/ # ./configure --prefix=/usr/local/libpng #make && make install
(3)安装freetype
# tar -xvf freetype-2.3.11.tar.gz # cd freetype-2.3.11/ # ./configure --prefix=/usr/local/freetype #make && make install
(4)安装jpeg
# tar -xvf jpegsrc.v9b.tar.gz # cd jpeg-9b/ # ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static #make && make install
(5)安装libwebp
# tar -xvf libwebp-0.6.1.tar.gz # cd libwebp-0.6.1/ # ./configure --prefix=/usr/local/libwebp --enable-libwebpmux --enable-libwebpdemux --enable-libwebpdecoder --enable-libwebpextras --enable-swap-16bit-csp --disable-static #make && make install
(6)安装gd
# tar -xvf libgd-2.2.5.tar.gz # cd libgd-2.2.5/ # ./configure --prefix=/usr/local/libgd --with-zlib=/usr/local/zlib/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/ --with-jpeg=/usr/local/jpeg/ #make && make install
#tar -xvf php-7.2.0.tar.gz #cd php-7.2.0/ #./configure --prefix=/node/php7 --with-mysql=/node/mysql --enable-fpm --enable-mbstring --with-mcrypt --with-mhash --with-curl --with-config-file-path=/node/php7/etc --with-mysqli=/node/mysql/bin/mysql_config --enable-gd-native-ttf --enable-sockets --enable-bcmath --with-zlib-dir=/usr/local/zlib/ --with-jpeg-dir=/usr/local/jpeg/ --with-freetype-dir=/usr/local/freetype/ --with-png-dir=/usr/local/libpng/ --with-webp-dir=/usr/local/libwebp/ --with-xpm-dir=/usr/ --with-iconv=/usr/ --with-gd #make #make install
(1)拷贝并修改php-fpm配置文件
# cd /node/php7/etc/ # cp php-fpm.conf.default php-fpm.conf
#vim php-fpm.conf [global] pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = error daemonize = yes
# cd php-fpm.d/ # cp www.conf.default www.conf #vim www.conf user = www group = www pm = dynamic pm.max_children = 32 pm.start_servers = 15 pm.min_spare_servers = 5 pm.max_spare_servers = 32
(2)拷贝php-fpm启动文件
# cp /node/installfile/php/php-7.2.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # chmod +x /etc/init.d/php-fpm # groupadd www # useradd -s /sbin/nologin -g www www
(3)设置开机启动
# chkconfig --add php-fpm # chkconfig php-fpm on
(4)启动php-fpm
# /etc/init.d/php-fpm start Starting php-fpm done # ps aux |grep php
# vim /node/nginx-1.12.2/conf/nginx.conf location / { root html; index index.php index.html index.htm; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
# nginx -s reload //从新加载nginx
# cp /node/installfile/php/php-7.2.0/php.ini-development /node/php7/etc/php.ini
# vim /node/php7/etc/php.ini date.timezone = Asia/Shanghai max_execution_time = 300 max_input_time = 300 post_max_size = 64M memory_limit = 128M mbstring.func_overload = 0
# yum -y install OpenIPMI OpenIPMI-devel ipmitool freeipmi net-snmp* libcurl* libevent*
# tar -xvf zabbix-3.4.3.tar.gz # cd zabbix-3.4.3/ # ./configure --prefix=/node/zabbix-3.4.3 --enable-server --enable-agent --with-mysql=/node/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi #make && make install
# mysql -uroot -p mysql> set password for 'root'@'localhost'=password('123456'); mysql> create database zabbix character set utf8; mysql> grant all on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
# cd /node/installfile/zabbix/zabbix-3.4.3/database/mysql/ # mysql -uzabbix -pzabbix zabbix < schema.sql # mysql -uzabbix -pzabbix zabbix < images.sql # mysql -uzabbix -pzabbix zabbix < data.sql
(1)建立用户
# groupadd zabbix # useradd -s /sbin/nologin -g zabbix zabbix
(2)建立日志文件目录
# mkdir /var/log/zabbix # chown -R zabbix.zabbix /var/log/zabbix/
(3)建立软连接
# ln -sv /node/zabbix-3.4.3/etc /etc/zabbix # ln -sv /node/zabbix-3.4.3/bin/* /usr/bin/ # ln -sv /node/zabbix-3.4.3/sbin/* /usr/sbin/
(4)拷贝启动脚本# cp /node/installfile/zabbix/zabbix-3.4.3/misc/init.d/fedora/core/zabbix_* /etc/init.d/
修改启动脚本中的安装路径
# vim /etc/zabbix/zabbix_server.conf BASEDIR=/node/zabbix-3.4.3
(5)添加端口信息
# vim /etc/services zabbix-agent 10050/tcp #zabbix agent zabbix-agent 10050/udp #zabbix agent zabbix-server 10051/tcp #zabbix server zabbix-server 10051/udp #zabbix server
(6)修改zabbix-server配置文件
# vim /etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log DBName=zabbix DBUser=zabbix DBPassword=zabbix
(7)拷贝web页面
# cp -r /node/installfile/zabbix/zabbix-3.4.3/frontends/php /node/nginx-1.12.2/html/zabbix # chown -R nginx.nginx /node/nginx-1.12.2/
# chkconfig --add zabbix_server # chkconfig zabbix_server on # /etc/init.d/zabbix_server start
http://ip/zabbix
可能会显示php少模块,再编译安装进去便可#yum -y install autoconf m4
(1)安装ldap# yum -y install openldap
#yum install openldap-devel
# cp /usr/lib64/libldap* /usr/lib/ # cd /node/installfile/php/php-7.2.0/ext/ldap/ # /node/php7/bin/phpize # ./configure --with-ldap --with-php-config=/node/php7/bin/php-config #make && make install
(2)安装gettext
#cd /node/installfile/php/php-7.2.0/ext/gettext # /node/php7/bin/phpize # ./configure --with-php-config=/node/php7/bin/php-config #make && make install
(3)在php.ini配置文件中增长模块
# vim /node/php7/etc/php.ini extension=gettext.so extension=ldap.so
(4)重启php-fpm# /etc/init.d/php-fpm restart
经过web页面进行配置后,进入登录页面:http://ip/zabbix/index.php
用户名:admin
密码:zabbix