在centos6.8搭建zabbix3.2
admin
2023-02-27 22:22:19
0

CVM 搭建 ZABBIX 监控系统

实验内容
ZABBIX 是一个基于 WEB 界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。 ZABBIX 能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。本教程为在 CVM 搭建 ZABBIX 监控系统。

基础环境配置
安装 PHP 环境
移除目前系统安装的 PHP 组件
基础环境配置
安装 PHP 环境
移除目前系统安装的 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 源是否已经存在

[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 环境
[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 参数以安装 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 服务
[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 安装相关依赖组件
安装 WEB 及数据库服务

[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 服务
[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 相关组件安装部署
安装 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 ~]#

创建下载目录下载相关软件包

[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 相关组件

[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!

导入数据库
[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]#

拷贝网页文件

[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]#

启动相关服务
[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

  • webtatic: us-east.repo.webtatic.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package zabbix-agent.x86_64 0:3.2.7-1.el6 will be installed
    --> Finished Dependency Resolution

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]#

相关内容

热门资讯

水龙头出水小怎么解决 水龙头出水小可能是由多种原因引起的,以下是一些常见的解决方法:1. 清洁水龙头:水龙头使用时间长了,...
小神童洗衣机启动后不出水直接洗 有可能是洗衣机的进水阀被烧坏了,需要换一个新的进水阀安装上即可。另外不建议自己擅自拆卸洗衣机内部进行...
祝贺景德镇! 海报制作:苗夏阳正在韩国釜山举行的联合国教科文组织第48届世界遗产大会25日通过决议将“景德镇手工瓷...
中央空调不制冷怎么办-中央空调... 中央空调,是电器股份有限公司主要产品之一,但是由于中央空调使用环境和使用方式的不同,在使用过程中就会...
空调不出水不制冷怎么回事 内罩长期不清洗,当然房间密封性差的话也会导致这种现象;其次就是外机问题,如果外机积满灰尘,会成空调制...
空调不出水,不制冷 原因有多种,可能是电源插头没有接牢、制冷剂不足、空调短时间休息间隙、空调滤网积灰等等。很多情况可以自...
中方反击了,欧盟回应 据凤凰卫视报道,中国商务部7月24日宣布对包括德国军工巨头莱茵金属公司在内的14家欧洲企业实施出口管...
这个“中国首次”,很有看点 刚刚,韩国釜山,第48届世界遗产大会传来好消息:“景德镇手工瓷业遗存”成功列入《世界遗产名录》!这是...
85岁剑桥教授,为何成了中国年... ·2026年6月,艾伦·麦克法兰在英国剑桥大学国王学院。(Muye.G/摄)(本文图片均由剑桥康河出...
西安造12英寸硅片月产销突破1... 12英寸电子级硅片是当前全球半导体产业链的紧缺关键材料。近日,记者从位于西安高新区的西安奕斯伟材料科...