您好,登錄后才能下訂單哦!
Zabbix3.0界面煥然一新,一改10多年的老面孔,alpha4的更新具體記錄下:http://www.zabbix.com/rn3.0.0alpha4.php
What's New in 3.0.0alpha4
Zabbix 3.0安裝過程與2.x的變化類似,但又少許需要注意的坑(以下標紅的),否則會坑的不行。。。
基礎環境:
CentOS 6.6 X64
Nginx:1.9.7
Mysql:5.5.32
PHP:5.5.30( zabbix_3.0 要求php版本至少在5.4以上 )
一、Nginx安裝:
1.rpm -qa pcre pcre-devel 2.yum install pcre pcre-devel openssl openssl-devel -y 3.mkdir -p /usr/local/nginx-1.9.7 4.useradd nginx -s /sbin/nologin -M 5../configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.9.7 --with-http_stub_status_module --with-http_ssl_module make && make install ln -s /usr/local/nginx-1.9.7 /usr/local/nginx 6.ls -l /usr/local/ 7./usr/local/nginx/sbin/nginx 8.ps -ef|grep nginx 9.ss -lntup|grep nginx [root@zabbix_3.0 conf]# egrep -v "#|^$" nginx.conf.default > nginx.conf [root@zabbix_3.0 conf]# vim /usr/local/nginx/conf/nginx.conf worker_processes 1; error_log /usr/local/nginx/logs/error.log; --新增一行 events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; --新增一行 server { listen 80; server_name localhost; access_log /usr/local/nginx/logs/access.log; --新增一行 root /usr/local/nginx/html; --更改為/usr/local/nginx/html,原來的值為html; index index.php index.html index.htm; --加一個index.php error_page 500 502 503 504 /50x.html; location = /50x.html { --刪除這行 root html; --刪除這行 } --刪除這行 --下面這部分新增加的內容 location ~ \.(php|php5)?$ { #root /usr/local/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; include fastcgi_params; } } } 10.為nginx提供 init腳本,新建文件/etc/rc.d/init.d/nginx,把以下內容復制到剛建的nginx文件下: #!/bin/sh #nx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /usr/local/nginx/conf/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /usr/local/nginx/logs/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /usr/local/nginx ] && . /usr/local/nginx lockfile=/var/lock/subsys/nginx make_dirs() { # make required directories user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` options=`$nginx -V 2>&1 | grep 'configure arguments:'` for opt in $options; do if [ `echo $opt | grep '.*-temp-path'` ]; then value=`echo $opt | cut -d "=" -f 2` if [ ! -d "$value" ]; then # echo "creating" $value mkdir -p $value && chown -R $user $value fi fi done } start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 make_dirs echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop sleep 1 start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac 11.添加啟動項并做成服務: [root@localhost nginx-1.9.7]chmod +x /etc/rc.d/init.d/nginx [root@localhost nginx-1.9.7]chkconfig --add nginx [root@localhost nginx-1.9.7]chkconfig nginx on [root@localhost php]# ps -A|grep nginx 62878 ? 00:00:00 nginx 62879 ? 00:00:00 nginx
二、MySql安裝:二進制軟件包(170多M)
# yum install tree nmap lrzsz dos2unix -y # mkdir -p /usr/local/mysql-5.5.32 [root@zabbix_3.0]# tar -zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz [root@zabbix_3.0]# mv mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql-5.5.32 [root@zabbix_3.0]# ln -s /usr/local/mysql-5.5.32/ /usr/local/mysql [root@zabbix_3.0]# useradd mysql -s /sbin/nologin -M [root@zabbix_3.0]# chown -R mysql.mysql /usr/local/mysql [root@zabbix_3.0]# cd /usr/local/mysql [root@zabbix_3.0 mysql] -- 創建系統表 # ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql cp support-files/mysql.server /etc/init.d/mysqld --這步不用做sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld cp support-files/my-small.cnf /etc/my.cnf cp:是否覆蓋"/etc/my.cnf"? y echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile # source /etc/profile [root@zabbix_3.0]# echo $PATH /usr/local/mysql/bin:/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [root@zabbix_3.0 application]# cp -a /application/mysql/bin/* /usr/local/sbin [root@zabbix_3.0 application]#service mysqld start [root@zabbix_3.0 application]#chkconfig mysqld on [root@zabbix_3.0 application]#mysqladmin -uroot password 123456
三、PHP安裝:
1.yum -y install zlib-devel libxml2-devel libjpeg-devel libiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel 2.wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar zxf libiconv-1.14.tar.gz mkdir -p /usr/local/libiconv cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make && make install cd ../ 3.yum -y install libmcrypt-devel mhash mcrypt --這3個rpm包必須安裝,CentOS6.6系統的標準YUM源里沒有, 需要從EPEL源上找到下載安裝 ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/ php 5.5.30:( --with-mysqli=mysqlnd和--with-gettext一定要加上,否則前者不裝時安裝 zabbix時database type沒有選項 默認出來的數據庫是SqLite 3,且不能切換 ,后者不裝時,會報PHP gettext warning) mkdir -p /usr/local/php-5.5.30 tar -zxvf php-5.5.30.tar.gz cd php-5.5.30 ./configure \ --prefix=/usr/local/php-5.5.30 \ --with-mysql=/usr/local/mysql/ \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-iconv-dir=/usr/local/libiconv \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir=/usr \ --with-gettext \ --enable-xml \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --enable-mbregex \ --enable-fpm \ --enable-mbstring \ --with-mcrypt \ --with-gd \ --enable-gd-native-ttf \ --with-openssl \ --with-mhash \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --enable-short-tags \ --enable-static \ --with-xsl \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-ftp \ --enable-opcache=no回車 +-----------------------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +-----------------------------------------------------------------------------------+ Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/fpm/php-fpm.conf config.status: creating sapi/fpm/init.d.php-fpm config.status: creating sapi/fpm/php-fpm.service config.status: creating sapi/fpm/php-fpm.8 config.status: creating sapi/fpm/status.html config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands #make && make install Generating phar.php Generating phar.phar PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled. directorytreeiterator.inc directorygraphiterator.inc invertedregexiterator.inc clicommand.inc pharcommand.inc phar.inc Build complete. Don't forget to run 'make test'. Installing PHP CLI binary: /usr/local/php-5.5.30/bin/ Installing PHP CLI man page: /usr/local/php-5.5.30/php/man/man1/ Installing PHP FPM binary: /usr/local/php-5.5.30/sbin/ Installing PHP FPM config: /usr/local/php-5.5.30/etc/ Installing PHP FPM man page: /usr/local/php-5.5.30/php/man/man8/ Installing PHP FPM status page: /usr/local/php-5.5.30/php/php/fpm/ Installing PHP CGI binary: /usr/local/php-5.5.30/bin/ Installing PHP CGI man page: /usr/local/php-5.5.30/php/man/man1/ Installing build environment: /usr/local/php-5.5.30/lib/php/build/ Installing header files: /usr/local/php-5.5.30/include/php/ Installing helper programs: /usr/local/php-5.5.30/bin/ program: phpize program: php-config Installing man pages: /usr/local/php-5.5.30/php/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/php-5.5.30/lib/php/ [PEAR] Archive_Tar - installed: 1.3.12 [PEAR] Console_Getopt - installed: 1.3.1 [PEAR] Structures_Graph- installed: 1.0.4 [PEAR] XML_Util - installed: 1.2.3 [PEAR] PEAR - installed: 1.9.5 Wrote PEAR system config file at: /usr/local/php-5.5.30/etc/pear.conf You may want to add: /usr/local/php-5.5.30/lib/php to your php.ini include_path /root/software/php-5.5.30/build/shtool install -c ext/phar/phar.phar /usr/local/php-5.5.30/bin ln -s -f phar.phar /usr/local/php-5.5.30/bin/phar Installing PDO headers: /usr/local/php-5.5.30/include/php/ext/pdo/ [root@zabbix_3.0 php-5.5.30]# make test --此步可不做,是進行測試 [root@zabbix_3.0 php-5.5.30]# ln -s /usr/local/php-5.5.30/ /usr/local/php 生成配置php配置文件 [root@zabbix_3.0 php-5.5.30]# pwd /root/software/php-5.5.30 [root@zabbix_3.0 php-5.5.30]# cp php.ini-production /usr/local/php/lib/php.ini [root@zabbix_3.0 php-5.5.30]# cd /usr/local/php/etc/ [root@zabbix_3.0 etc]# pwd /usr/local/php/etc [root@zabbix_3.0 etc]# cp php-fpm.conf.default php-fpm.conf php啟動測試 [root@zabbix_3.0 etc]# /usr/local/php/sbin/php-fpm 驗證是否成功啟動 [root@zabbix_3.0 etc]# netstat -lntup|grep php-fpm
驗證LNMP安裝是否成功。
四、Zabbix安裝:
[root@zabbix_3.0 ~]# tar -zxvf zabbix-3.0.0.tar.gz [root@zabbix_3.0 ~]# groupadd zabbix [root@zabbix_3.0 ~]# useradd -g zabbix zabbix [root@zabbix_3.0 ~]# ln -s /usr/local/libiconv/lib/libiconv.so.2 /usr/lib/libiconv.so.2 #添加軟連接 [root@zabbix_3.0 ~]# /sbin/ldconfig #使配置立即生效 [root@zabbix_3.0 ~]# mkdir -p /usr/local/zabbix [root@zabbix_3.0 ~]# cd software/zabbix-3.0.0 [root@oldboy zabbix-3.0.0]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 參數說明 ―prefix=/usr/local/zabbix 為指定安裝目錄為/usr/local/zabbix ―enable-server 為安裝zabbix服務端程序 ―enable-agent 為安裝agent程序 ―with-mysql 為使用mysql數據庫 ―enable-ipv6 為啟用ipv6支持 ―with-net-snmp 為啟用snmp支持 ―with-libcurl 為啟用curl ―with-libxml2 編譯xml模塊,主要用于監控vm虛擬機 報錯 checking for net-snmp-config... no configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config [root@zabbix zabbix-3.0.0]# rpm -qa | grep net-snmp-devel --發現沒有該軟件包,進行YUM安裝 [root@zabbix zabbix-3.0.0]# yum install net-snmp-devel 已加載插件:fastestmirror, refresh-packagekit, security 設置安裝進程 Loading mirror speeds from cached hostfile 解決依賴關系 --> 執行事務檢查 ---> Package net-snmp-devel.x86_64 1:5.5-49.el6_5.3 will be 安裝 --> 處理依賴關系 tcp_wrappers-devel,它被軟件包 1:net-snmp-devel-5.5-49.el6_5.3.x86_64 需要 --> 處理依賴關系 rpm-devel,它被軟件包 1:net-snmp-devel-5.5-49.el6_5.3.x86_64 需要 --> 處理依賴關系 lm_sensors-devel,它被軟件包 1:net-snmp-devel-5.5-49.el6_5.3.x86_64 需要 --> 處理依賴關系 elfutils-devel,它被軟件包 1:net-snmp-devel-5.5-49.el6_5.3.x86_64 需要 --> 執行事務檢查 ---> Package elfutils-devel.x86_64 0:0.158-3.2.el6 will be 安裝 ---> Package lm_sensors-devel.x86_64 0:3.1.1-17.el6 will be 安裝 ---> Package rpm-devel.x86_64 0:4.8.0-37.el6 will be 安裝 --> 處理依賴關系 popt-devel(x86-64),它被軟件包 rpm-devel-4.8.0-37.el6.x86_64 需要 --> 處理依賴關系 file-devel(x86-64),它被軟件包 rpm-devel-4.8.0-37.el6.x86_64 需要 ---> Package tcp_wrappers-devel.x86_64 0:7.6-57.el6 will be 安裝 --> 執行事務檢查 ---> Package file-devel.x86_64 0:5.04-21.el6 will be 安裝 ---> Package popt-devel.x86_64 0:1.13-7.el6 will be 安裝 --> 完成依賴關系計算 依賴關系解決 ============================================================================================= 軟件包 架構 版本 倉庫 大小 ============================================================================================= 正在安裝: net-snmp-devel x86_64 1:5.5-49.el6_5.3 c6-media 304 k 為依賴而安裝: elfutils-devel x86_64 0.158-3.2.el6 c6-media 74 k file-devel x86_64 5.04-21.el6 c6-media 26 k lm_sensors-devel x86_64 3.1.1-17.el6 c6-media 22 k popt-devel x86_64 1.13-7.el6 c6-media 21 k rpm-devel x86_64 4.8.0-37.el6 c6-media 93 k tcp_wrappers-devel x86_64 7.6-57.el6 c6-media 15 k 事務概要 ============================================================================================= Install 7 Package(s) 總下載量:555 k Installed size: 1.3 M 確定嗎?[y/N]輸入y回車 --再次執行configure,編譯通過 [root@oldboy zabbix-3.0.0]# make && make install [root@zabbix_3.0 ~]# chown -R zabbix:zabbix /usr/local/zabbix/ [root@zabbix_3.0 ~]# mkdir -p /var/log/zabbix-server [root@zabbix_3.0 ~]# mkdir -p /var/log/zabbix-agentd [root@zabbix_3.0 ~]# chown -R zabbix:zabbix /var/log/zabbix-server/ [root@zabbix_3.0 ~]# chown -R zabbix:zabbix /var/log/zabbix-agentd/ [root@oldboy zabbix-3.0.0]# mysql -uroot -p<password> mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; mysql> flush privileges; mysql> quit;
按照SQL語句順序導入SQL:
shell> mysql -uzabbix -p<password> zabbix < database/mysql/schema.sql # stop here if you are creating database for Zabbix proxy shell> mysql -uzabbix -p<password> zabbix < database/mysql/p_w_picpaths.sql shell> mysql -uzabbix -p<password> zabbix < database/mysql/data.sql
1.修改zabbix.conf:
[root@oldboy zabbix-3.0.0]# vim /usr/local/zabbix/etc/zabbix_server.conf 增加: DBName=zabbix #數據庫名稱 DBUser=zabbix #數據庫用戶名 DBPassword=zabbix #數據庫密碼 ListenIP=localhost #數據庫ip地址 (--根據實際情況更改) AlertScriptsPath=****/zabbix/alertscripts #zabbix運行腳本存放目錄 LogFile=/var/log/zabbix-server/zabbix_server.log --更改Logfile的值為/var/log/zabbix-server/zabbix_server.log,原來的默認值為/tmp/zabbix_server.log [root@oldboy zabbix-3.0.0]# vim /usr/local/zabbix/etc/zabbix_agentd.conf LogFile=/var/log/zabbix-agentd/zabbix_agentd.log --更改Logfile的值為/var/log/zabbix-agentd/zabbix_agentd.log,原來的默認值為/tmp/zabbix_agentd.log Hostname=test202
2.zabbix 3.0啟動方式:
[root@oldboy zabbix-3.0.0]# cp /root/software /zabbix-3.0.0/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server #服務端 [root@oldboy zabbix-3.0.0]# cp /root/software/zabbix-3.0.0/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd #客戶端 [root@oldboy zabbix-3.0.0]# vi /etc/rc.d/init.d/zabbix_server # Zabbix-Directory BASEDIR=/usr/local/zabbix --更改BASEDIR的值為/usr/local/zabbix,原來的值為/usr/local,如果安裝時不指定--prefix,就默認安裝在/usr/local,因為我安裝zabbix在/usr/local/zabbix 同理,也把zabbix_agentd的BASEDIR的值改為/usr/local/zabbix shell> zabbix_server zabbix_server [15644]: cannot open "/var/log/zabbix-server/zabbix_server.log": [13] Permission denied 報錯是權限的問題,將var/log/zabbix-server的目錄及其下所有文件都設為zabbix用戶和zabbix所屬組即可
3.將/usr/local/zabbix/sbin目錄、/usr/local/nginx/sbin目錄、/usr/local/php/sbin目錄也寫入/etc/profile的環境變量PATH當中
# vi /etc/profile export PATH=/usr/local/zabbix/sbin:/usr/local/nginx/sbin:/usr/local/php/sbin:/usr/local/mysql/bin:$PATH' # source /etc/profile
4.然后啟動php
[root@oldboy zabbix-3.0.0]# /usr/local/php/sbin/php-fpm
5.配置web環境:
[root@oldboy zabbix-3.0.0]# cd /root/software/zabbix-3.0.0/frontends [root@oldboy zabbix-3.0.0]# cp -rf php /usr/local/nginx/html/zabbix
6.在瀏覽器里輸入http://10.101.0.15/zabbix 回車
7.修改php.ini:(php5.5默認值較小)
vim /usr/local/php/lib/php.ini 主要為下面幾個參數 --在vi里查找出上面的參數,再修改其值 PHP option post_max_size 16M --更改值為16M,原來的值為8M PHP option max_execution_time 300 --更改值為300,原來的值為60 PHP option max_input_time 300 --更改值為300,原來的值為30 PHP time zone Asia/Shanghai --添加值為Asia/Shanghai,原來的值為空,并把前面的;去掉,使其生效 :x
8.這里修不修改端口都可,如果編譯php時你沒有帶上 --with-mysqli=mysqlnd 你會悲劇的發現這里默認出現的是SQLite3,且無法更換。。。
9.需要給此目錄下/usr/local/nginx/html/zabbix/conf的zabbix.conf.php w+x權限,否則install之前會報錯需要下載conf,且賦權。
10.安裝至此完畢。界面如下(是比以前好看了。。)
如果您覺得此篇文章對您有幫助,歡迎關注微信公眾號:guestart的DBA學習筆記,您的支持是對我最大的鼓勵!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。