您好,登錄后才能下訂單哦!
CVM 搭建 ZABBIX 監(jiān)控系統(tǒng)
實驗內(nèi)容
ZABBIX 是一個基于 WEB 界面的提供分布式系統(tǒng)監(jiān)視以及網(wǎng)絡(luò)監(jiān)視功能的企業(yè)級的開源解決方案。 ZABBIX 能監(jiān)視各種網(wǎng)絡(luò)參數(shù),保證服務(wù)器系統(tǒng)的安全運營;并提供靈活的通知機制以讓系統(tǒng)管理員快速定位/解決存在的各種問題。本教程為在 CVM 搭建 ZABBIX 監(jiān)控系統(tǒng)。
基礎(chǔ)環(huán)境配置
安裝 PHP 環(huán)境
移除目前系統(tǒng)安裝的 PHP 組件
基礎(chǔ)環(huán)境配置
安裝 PHP 環(huán)境
移除目前系統(tǒng)安裝的 PHP 組件
[root@VM_208_217_centos ~]# cat /etc/redhat-release
CentOS release 6.8 (Final)
[root@VM_208_217_centos ~]#
[root@VM_208_217_centos ~]# yum remove php -y
Loaded plugins: fastestmirror, security
Setting up Remove Process
No Match for argument: php
epel | 5.3 kB 00:00
epel/primary_db | 6.1 MB 00:01
extras | 3.4 kB 00:00
extras/primary_db | 29 kB 00:00
os | 3.7 kB 00:00
os/primary_db | 4.7 MB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 6.6 MB 00:00
Package(s) php* available, but not installed.
No Packages marked for removal
安裝 PHP 的 YUM 源
root@VM_208_217_centos ~]# rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
Retrieving http://mirror.webtatic.com/yum/el6/latest.rpm
warning: /var/tmp/rpm-tmp.HbepNu: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY
Preparing... ########################################### [100%]
1:webtatic-release ########################################### [100%]
檢查 YUM 源是否已經(jīng)存在
[root@VM_208_217_centos ~]# ll /etc/yum.repos.d/webtatic.repo
-rw-r--r-- 1 root root 865 Nov 13 2016 /etc/yum.repos.d/webtatic.repo
[root@VM_208_217_centos ~]#
安裝 PHP 環(huán)境
[root@VM_208_217_centos ~]# yum list|grep php71w|awk '{printf ("%s ",$1)}'
mod_php71w.x86_64 php71w-bcmath.x86_64 php71w-cli.x86_64 php71w-common.x86_64 php71w-dba.x86_64 php71w-devel.x86_64 php71w-embedded.x86_64 php71w-enchant.x86_64 php71w-fpm.x86_64 php71w-gd.x86_64 php71w-imap.x86_64 php71w-interbase.x86_64 php71w-intl.x86_64 php71w-ldap.x86_64 php71w-mbstring.x86_64 php71w-mcrypt.x86_64 php71w-mysqlnd.x86_64 php71w-odbc.x86_64 php71w-opcache.x86_64 php71w-pdo.x86_64 php71w-pdo_dblib.x86_64 php71w-pear.noarch php71w-pecl-apcu.x86_64 php71w-pecl-apcu-devel.x86_64 php71w-pecl-geoip.x86_64 php71w-pecl-igbinary.x86_64 php71w-pecl-igbinary-devel.x86_64 php71w-pecl-imagick.x86_64 php71w-pecl-imagick-devel.x86_64 php71w-pecl-memcached.x86_64 php71w-pecl-mongodb.x86_64 php71w-pecl-redis.x86_64 php71w-pecl-xdebug.x86_64 php71w-pgsql.x86_64 php71w-phpdbg.x86_64 php71w-process.x86_64 php71w-pspell.x86_64 php71w-recode.x86_64 php71w-snmp.x86_64 php71w-soap.x86_64 php71w-tidy.x86_64 php71w-xml.x86_64 php71w-xmlrpc.x86_64 php71w-mysql.x86_64 [root@VM_208_217_centos ~]#
[root@VM_208_217_centos ~]# yum -y install yum list|grep php71w|awk '{printf ("%s ",$1)}'
--skip-broken
Package php71w-xmlrpc-7.1.33-1.w6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package php71w-mysql.x86_64 0:7.1.33-1.w6 will be installed
--> Processing Conflict: php71w-mysql-7.1.33-1.w6.x86_64 conflicts php71w-mysqlnd
Packages skipped because of dependency problems:
php71w-mysql-7.1.33-1.w6.x86_64 from webtatic
[root@VM_208_217_centos ~]#
修改 PHP 參數(shù)以安裝 ZABBIX 的安裝需求
[root@VM_208_217_centos ~]# sed -i "s#;date.timezone =#date.timezone = Asia/Shanghai#g" /etc/php.ini
[root@VM_208_217_centos ~]# cat /etc/php.ini | grep -i timezone
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai
[root@VM_208_217_centos ~]# sed -i "s#grep max_execution_time /etc/php.ini
#max_execution_time = 300#g" /etc/php.ini
[root@VM_208_217_centos ~]# grep max_execution_time /etc/php.ini
max_execution_time = 300
[root@VM_208_217_centos ~]#
sed -i "s/;date.timezone =/date.timezone = Asia/Shanghai/g" /etc/php.ini
sed -i "s#grep max_execution_time /etc/php.ini
#max_execution_time = 300#g" /etc/php.ini
sed -i "s#grep post_max_size /etc/php.ini
#post_max_size = 32M#g" /etc/php.ini
sed -i "s#grep max_input_time = /etc/php.ini
#max_input_time = 300#g" /etc/php.ini
sed -i "s#grep memory_limit /etc/php.ini
#memory_limit = 128M#g" /etc/php.ini
啟動 PHP-FPM 服務(wù)
[root@VM_208_217_centos ~]#service php-fpm start
檢查程序是否正常啟動
[root@VM_208_217_centos ~]# service php-fpm start
Starting php-fpm: No log handling enabled - turning on stderr logging
Created directory: /var/lib/net-snmp/mib_indexes
[ OK ]
將其加入開機自啟動
[root@VM_208_217_centos ~]# netstat -lntup|grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3152/php-fpm
[root@VM_208_217_centos ~]#
YUM 安裝相關(guān)依賴組件
安裝 WEB 及數(shù)據(jù)庫服務(wù)
[root@VM_208_217_centos ~]#yum install -y ntpdate mailx dos2unix vim zcat wget net-snmp-utils gcc gcc-c++ autoconf httpd libxml* mysql mysql-server httpd-manual mod_ssl mod_perl mod_auth_mysql mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel java-devel fping
Updated:
mailx.x86_64 0:12.4-10.el6_10 ntpdate.x86_64 0:4.2.6p5-15.el6.centos vim-enhanced.x86_64 2:7.4.629-5.el6_10.2 wget.x86_64 0:1.12-10.el6
Dependency Updated:
curl.x86_64 0:7.19.7-53.el6_9 db4.x86_64 0:4.7.25-22.el6 db4-utils.x86_64 0:4.7.25-22.el6 e2fsprogs.x86_64 0:1.41.12-24.el6
e2fsprogs-libs.x86_64 0:1.41.12-24.el6 glib2.i686 0:2.28.8-10.el6 glib2.x86_64 0:2.28.8-10.el6 krb5-libs.x86_64 0:1.10.3-65.el6
libcom_err.x86_64 0:1.41.12-24.el6 libcurl.x86_64 0:7.19.7-53.el6_9 libgcc.i686 0:4.4.7-23.el6 libgcc.x86_64 0:4.4.7-23.el6
libss.x86_64 0:1.41.12-24.el6 libstdc++.i686 0:4.4.7-23.el6 libstdc++.x86_64 0:4.4.7-23.el6 mysql-libs.x86_64 0:5.1.73-8.el6_8
nspr.x86_64 0:4.21.0-1.el6_10 nss.x86_64 0:3.44.0-7.el6_10 nss-softokn.x86_64 0:3.44.0-5.el6_10 nss-softokn-freebl.i686 0:3.44.0-5.el6_10
nss-softokn-freebl.x86_64 0:3.44.0-5.el6_10 nss-sysinit.x86_64 0:3.44.0-7.el6_10 nss-tools.x86_64 0:3.44.0-7.el6_10 nss-util.x86_64 0:3.44.0-1.el6_10
ntp.x86_64 0:4.2.6p5-15.el6.centos openssl.x86_64 0:1.0.1e-58.el6_10 perl.x86_64 4:5.10.1-144.el6 perl-Module-Pluggable.x86_64 1:3.90-144.el6
perl-Pod-Escapes.x86_64 1:1.04-144.el6 perl-Pod-Simple.x86_64 1:3.13-144.el6 perl-libs.x86_64 4:5.10.1-144.el6 perl-version.x86_64 3:0.77-144.el6
rpm.x86_64 0:4.8.0-59.el6 rpm-libs.x86_64 0:4.8.0-59.el6 rpm-python.x86_64 0:4.8.0-59.el6 vim-common.x86_64 2:7.4.629-5.el6_10.2
Complete!
[root@VM_208_217_centos ~]#
啟動 MYSQL 服務(wù)
[root@VM_208_217_centos ~]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h VM_208_217_centos password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
[root@VM_208_217_centos ~]# chkconfig mysqld on
[root@VM_208_217_centos ~]# mysql -uroot -e "create database zabbix character set utf8;"
[root@VM_208_217_centos ~]# mysql -uroot -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
[root@VM_208_217_centos ~]# mysql -uroot -e "flush privileges;"
[root@VM_208_217_centos ~]#
[root@VM_208_217_centos ~]# groupadd zabbix -g 201
[root@VM_208_217_centos ~]# useradd -g zabbix -u 201 -m -s /sbin/nologin zabbix
[root@VM_208_217_centos ~]#
ZABBIX 相關(guān)組件安裝部署
安裝 ZABBIX 源
[root@VM_208_217_centos ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm
warning: /var/tmp/rpm-tmp.O9iKTG: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ########################################### [100%]
1:zabbix-release ########################################### [100%]
[root@VM_208_217_centos ~]# ll /etc/yum.repos.d/zabbix.repo
-rw-r--r-- 1 root root 636 Sep 14 2016 /etc/yum.repos.d/zabbix.repo
[root@VM_208_217_centos ~]#
創(chuàng)建下載目錄下載相關(guān)軟件包
[root@VM_208_217_centos ~]# mkdir /software && cd /software
[root@VM_208_217_centos software]# wget -c --timeout=10 http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-server-mysql-3.2.7-1.el6.x86_64.rpm
--2019-11-13 17:33:51-- http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-server-mysql-3.2.7-1.el6.x86_64.rpm
Resolving repo.zabbix.com... 162.243.159.138, 2604:a880:1:20::b82:1001
Connecting to repo.zabbix.com|162.243.159.138|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1848284 (1.8M) [application/x-redhat-package-manager]
Saving to: “zabbix-server-mysql-3.2.7-1.el6.x86_64.rpm”
100%[============================================================================================================================>] 1,848,284 100K/s in 25s
2019-11-13 17:34:17 (73.4 KB/s) - “zabbix-server-mysql-3.2.7-1.el6.x86_64.rpm” saved [1848284/1848284]
[root@VM_208_217_centos software]# wget -c --timeout=10 http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-web-3.2.7-1.el6.noarch.rpm
--2019-11-13 17:34:17-- http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-web-3.2.7-1.el6.noarch.rpm
Resolving repo.zabbix.com... 162.243.159.138, 2604:a880:1:20::b82:1001
Connecting to repo.zabbix.com|162.243.159.138|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5496112 (5.2M) [application/x-redhat-package-manager]
Saving to: “zabbix-web-3.2.7-1.el6.noarch.rpm”
0% [ ] 32,211 10.8K/s in 2.9s
2019-11-13 17:34:23 (10.8 KB/s) - Connection closed at byte 32211. Retrying.
--2019-11-13 17:34:24-- (try: 2) http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-web-3.2.7-1.el6.noarch.rpm
Connecting to repo.zabbix.com|162.243.159.138|:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 5496112 (5.2M), 5463901 (5.2M) remaining [application/x-redhat-package-manager]
Saving to: “zabbix-web-3.2.7-1.el6.noarch.rpm”
100%[============================================================================================================================>] 5,496,112 1.18M/s in 9.1s
2019-11-13 17:34:33 (589 KB/s) - “zabbix-web-3.2.7-1.el6.noarch.rpm” saved [5496112/5496112]
[root@VM_208_217_centos software]# wget -c --timeout=10 http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-web-mysql-3.2.7-1.el6.noarch.rpm
--2019-11-13 17:34:33-- http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/zabbix-web-mysql-3.2.7-1.el6.noarch.rpm
Resolving repo.zabbix.com... 162.243.159.138, 2604:a880:1:20::b82:1001
Connecting to repo.zabbix.com|162.243.159.138|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5900 (5.8K) [application/x-redhat-package-manager]
Saving to: “zabbix-web-mysql-3.2.7-1.el6.noarch.rpm”
100%[============================================================================================================================>] 5,900 --.-K/s in 0s
2019-11-13 17:34:34 (386 MB/s) - “zabbix-web-mysql-3.2.7-1.el6.noarch.rpm” saved [5900/5900]
[root@VM_208_217_centos software]# wget -c --timeout=10 http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-agent-3.2.7-1.el6.x86_64.rpm
--2019-11-13 17:34:42-- http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-agent-3.2.7-1.el6.x86_64.rpm
Resolving repo.zabbix.com... 162.243.159.138, 2604:a880:1:20::b82:1001
Connecting to repo.zabbix.com|162.243.159.138|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 348200 (340K) [application/x-redhat-package-manager]
Saving to: “zabbix-agent-3.2.7-1.el6.x86_64.rpm”
100%[============================================================================================================================>] 348,200 29.5K/s in 13s
2019-11-13 17:34:55 (26.4 KB/s) - “zabbix-agent-3.2.7-1.el6.x86_64.rpm” saved [348200/348200]
[root@VM_208_217_centos software]#
安裝 ZABBIX 相關(guān)組件
[root@VM_208_217_centos software]# yum localinstall -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-web*
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : fontpackages-filesystem-1.41-1.1.el6.noarch 1/7
Installing : dejavu-fonts-common-2.33-1.el6.noarch 2/7
Installing : dejavu-sans-fonts-2.33-1.el6.noarch 3/7
Installing : zabbix-web-mysql-3.2.7-1.el6.noarch 4/7
Installing : zabbix-web-3.2.7-1.el6.noarch 5/7
Installing : iksemel-1.4-2.el6.x86_64 6/7
Installing : zabbix-server-mysql-3.2.7-1.el6.x86_64 7/7
Verifying : zabbix-server-mysql-3.2.7-1.el6.x86_64 1/7
Verifying : iksemel-1.4-2.el6.x86_64 2/7
Verifying : dejavu-sans-fonts-2.33-1.el6.noarch 3/7
Verifying : fontpackages-filesystem-1.41-1.1.el6.noarch 4/7
Verifying : dejavu-fonts-common-2.33-1.el6.noarch 5/7
Verifying : zabbix-web-mysql-3.2.7-1.el6.noarch 6/7
Verifying : zabbix-web-3.2.7-1.el6.noarch 7/7
Installed:
zabbix-server-mysql.x86_64 0:3.2.7-1.el6 zabbix-web.noarch 0:3.2.7-1.el6 zabbix-web-mysql.noarch 0:3.2.7-1.el6
Dependency Installed:
dejavu-fonts-common.noarch 0:2.33-1.el6 dejavu-sans-fonts.noarch 0:2.33-1.el6 fontpackages-filesystem.noarch 0:1.41-1.1.el6 iksemel.x86_64 0:1.4-2.el6
Complete!
導(dǎo)入數(shù)據(jù)庫
[root@VM_208_217_centos software]# cd /usr/share/doc/zabbix-server-mysql-3.2.7
[root@VM_208_217_centos zabbix-server-mysql-3.2.7]# zcat create.sql.gz | mysql -uroot zabbix
[root@VM_208_217_centos zabbix-server-mysql-3.2.7]#
[root@VM_208_217_centos zabbix-server-mysql-3.2.7]# mysqladmin -uroot password "mysqladmin"
[root@VM_208_217_centos zabbix-server-mysql-3.2.7]#
拷貝網(wǎng)頁文件
[root@VM_208_217_centos zabbix-server-mysql-3.2.7]# cd /usr/share/
[root@VM_208_217_centos share]# cp -r ./zabbix/ /var/www/html/zabbix
[root@VM_208_217_centos share]#
修改配置文件
[root@VM_208_217_centos share]# echo "DBPassword=zabbix" >> /etc/zabbix/zabbix_server.conf
[root@VM_208_217_centos share]#
啟動相關(guān)服務(wù)
[root@VM_208_217_centos share]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@VM_208_217_centos share]# service zabbix-server start
Starting Zabbix server: [ OK ]
[root@VM_208_217_centos share]# service zabbix-agent start
zabbix-agent: unrecognized service
[root@VM_208_217_centos share]# chkconfig httpd on
[root@VM_208_217_centos share]# chkconfig mysqld on
[root@VM_208_217_centos share]# chkconfig php-fpm on
[root@VM_208_217_centos share]# chkconfig zabbix-server on
[root@VM_208_217_centos share]# chkconfig zabbix-agent on
error reading information on service zabbix-agent: No such file or directory
[root@VM_208_217_centos share]#
[root@VM_208_217_centos share]# cd /software/
[root@VM_208_217_centos software]# ll
total 7548
-rw-r--r-- 1 root root 348200 Jul 20 2017 zabbix-agent-3.2.7-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 1848284 Jul 20 2017 zabbix-server-mysql-3.2.7-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 5496112 Jul 20 2017 zabbix-web-3.2.7-1.el6.noarch.rpm
-rw-r--r-- 1 root root 5900 Jul 20 2017 zabbix-web-mysql-3.2.7-1.el6.noarch.rpm
[root@VM_208_217_centos software]# yum install zabbix-agent-3.2.7-1.el6.x86_64.rpm -y
Loaded plugins: fastestmirror, security
Setting up Install Process
Examining zabbix-agent-3.2.7-1.el6.x86_64.rpm: zabbix-agent-3.2.7-1.el6.x86_64
Marking zabbix-agent-3.2.7-1.el6.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
Dependencies Resolved
======================================================================================================================================================================
Package Arch Version Repository Size======================================================================================================================================================================
Installing:
zabbix-agent x86_64 3.2.7-1.el6 /zabbix-agent-3.2.7-1.el6.x86_64 1.3 M
Transaction Summary======================================================================================================================================================================
Install 1 Package(s)
Total size: 1.3 M
Installed size: 1.3 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : zabbix-agent-3.2.7-1.el6.x86_64 1/1
Verifying : zabbix-agent-3.2.7-1.el6.x86_64 1/1
Installed:
zabbix-agent.x86_64 0:3.2.7-1.el6
Complete!
[root@VM_208_217_centos software]#
[root@VM_208_217_centos software]# service zabbix-agent start
Starting Zabbix agent: [ OK ]
[root@VM_208_217_centos software]# chkconfig zabbix-agent on
[root@VM_208_217_centos software]#
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。