阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

123次阅读
没有评论

共计 11574 个字符,预计需要花费 29 分钟才能阅读完成。

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

一、安装环境

1.1、环境准备

系统版本 Zabbix 版本 Mariadb 版本
CentOS Linux release 7.2.1511 (Core) zabbix-3.0.4 mariadb-5.5.50-1.el7_2.x86_64

1.2、安装基础环境

1
2
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum install mysql-devel gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xml -y

二、服务端安装

2.1 安装配置数据库

1
yum -y install mariadb-server

2.2 设置开机自启动

1
systemctl enable mariadb

2.3 启动数据库

1
systemctl start mariadb

2.4 初始化数据库

1
mysql_secure_installation

详细输出解析:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
[root@zabbix-server src]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
 
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
 
Enter current password for root (enter for none):
OK, successfully used password, moving on...
 
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
 
Set root password? [Y/n] Y
New password:                              # 设置数据库 root 密码
Re-enter new password:                    # 再次输入
Password updated successfully!
Reloading privilege tables..
... Success!
 
 
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
 
Remove anonymous users? [Y/n] Y    # 删除匿名用户
... Success!
 
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
 
Disallow root login remotely? [Y/n] Y  # 禁止 root 远程登陆数据库
... Success!
 
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n] Y  # 删除 test 测试库
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables now? [Y/n] Y    # 刷新数据库表
... Success!
 
Cleaning up...
 
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
 
Thanks for using MariaDB!

2.5 创建 zabbix 数据库、用户并设置密码

1
2
mysql -uroot -p123456 -e "create database zabbix default character set utf8 collate utf8_bin;" 
mysql -uroot -p123456 -e "grant all on zabbix.* to'zabbix'@'%'identified by'123456';"

2.6 登陆测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@zabbix-server src]# mysql -uzabbix -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 5.5.50-MariaDB MariaDB Server
 
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix |
+--------------------+
2 rows in set (0.00 sec)
 
MariaDB [(none)]> use zabbix
Database changed
MariaDB [zabbix]> show tables;
Empty set (0.01 sec)
 
MariaDB [zabbix]> Bye

三、安装 zabbix 服务端

3.1 yum 安装 zabbix 服务

1
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get

3.2 导入数据表结构

1
2
cd /usr/share/doc/zabbix-server-mysql-3.0.4/
zcat create.sql.gz | mysql -uzabbix -p123456 zabbix

3.3 备份并修改 zabbix 配置文件

配置数据库:

1
2
3
4
5
6
cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf_$(date +%F)
[root@zabbix-server ~]# diff /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf_2016-08-23
115c115
< DBPassword=123456
---
> # DBPassword=

定义时区:

1
2
3
4
5
6
cp /etc/httpd/conf.d/zabbix.conf /etc/httpd/conf.d/zabbix.conf_$(date +%F)
[root@zabbix-server ~]# diff /etc/httpd/conf.d/zabbix.conf /etc/httpd/conf.d/zabbix.conf_2016-08-23
19c19
<      php_value date.timezone Asia/Chongqing
---
>        # php_value date.timezone Europe/Riga

3.4 设置开机自启动,启动 zabbix 服务器端

1
2
systemctl enalble zabbix-server
systemctl restart zabbix-server

3.5 设置开机自启动,启动 apache

1
2
systemctl enable httpd
systemctl start httpd

一些 Zabbix 相关教程集合

Ubuntu 14.04 下 Zabbix2.4.5 源码编译安装  http://www.linuxidc.com/Linux/2015-05/117657.htm

安装部署分布式监控系统 Zabbix 2.06 http://www.linuxidc.com/Linux/2013-07/86942.htm

《安装部署分布式监控系统 Zabbix 2.06》http://www.linuxidc.com/Linux/2013-07/86942.htm

CentOS 7.0 x64 下 Zabbix 3.0 安装笔记  http://www.linuxidc.com/Linux/2016-11/137044.htm

Zabbix 分布式监控系统实践 http://www.linuxidc.com/Linux/2013-06/85758.htm

CentOS 6.3 下 Zabbix 监控 apache server-status http://www.linuxidc.com/Linux/2013-05/84740.htm

CentOS 6.3 下 Zabbix 监控 MySQL 数据库参数 http://www.linuxidc.com/Linux/2013-05/84800.htm

64 位 CentOS 6.2 下安装 Zabbix 2.0.6   http://www.linuxidc.com/Linux/2014-11/109541.htm

四、web 界面安装 zabbix

4.1 访问地址 http://192.168.0.125/zabbix/setup.php 配置 zabbix

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 注:下图中的所有配置必须都为 ok 才可以。

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 注:下图配置 zabbix 的一些数据库相关信息,按照自己的填写即可。

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

注:Name 为别名设置,可填写

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 CentOS 7.2 安装部署 Zabbix 3.0.4 详解

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

注:zabbix 默认登录用户名为 Admin(A 为大写,),密码为 zabbix。

 CentOS 7.2 安装部署 Zabbix 3.0.4 详解

注:下图进入登录界面

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

4.2 设置字体显示为中文

注:3.0.4 默认的中文显示配置文件里面是开启的,无需重新设置,只需要如下图选择即可

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

五、总结

到这里,Zabbix 服务器端的配置部署完毕,下篇文章部署 Zabbix 客户端的配置及其一些常用应用的监控。在配置过程中遇到的问题解决方法见 http://www.linuxidc.com/Linux/2016-11/137671p2.htm

一、查看客户端环境

1
2
3
4
[root@mysql-server ~]# cat /etc/RedHat-release
CentOS Linux release 7.2.1511 (Core)
[root@mysql-server ~]# uname -r
3.10.0-327.28.2.el7.x86_64

二、部署 zabbix-agent

2.1 安装 zabbix-agent

1
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-agent-3.0.4-1.el7.x86_64.rpm

2.2 备份并更改 zabbix-agent 配置文件

cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_$(date +%F)
sed -i 's/Server=127.0.0.1/Server=192.168.0.125/g' /etc/zabbix/zabbix_agentd.conf 
sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.0.125/g' /etc/zabbix/zabbix_agentd.conf

2.3 加入开机自启动并启动 zabbix 客户端

1
2
systemctl enable zabbix-agent
systemctl start zabbix-agent

三、添加客户机的监控

3.1 界面操作:配置 – 主机 — 创建主机

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 3.2 填写客户机信息

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 3.3 选择模板

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 3.4 添加主机,查看添加的情况

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

注:看到 ZBX 变成绿色字体后说明成功添加,这个时候查看图形信息即可。

3.5 查看模板自带的监控信息项

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 四、总结

我们可以看到 3.0.4 模板自带的监控项有:

  • CPU 概况
  • 网卡流量
  • 内存情况(物理和虚拟)
  • 负载信息
  • 磁盘使用情况

但是这些信息是不完善的,接下来需要添加 tcp 连接信息、磁盘 io 等 zabbix 默认没有的监控信息。

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

一、安装环境

1.1、环境准备

系统版本 Zabbix 版本 Mariadb 版本
CentOS Linux release 7.2.1511 (Core) zabbix-3.0.4 mariadb-5.5.50-1.el7_2.x86_64

1.2、安装基础环境

1
2
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum install mysql-devel gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xml -y

二、服务端安装

2.1 安装配置数据库

1
yum -y install mariadb-server

2.2 设置开机自启动

1
systemctl enable mariadb

2.3 启动数据库

1
systemctl start mariadb

2.4 初始化数据库

1
mysql_secure_installation

详细输出解析:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
[root@zabbix-server src]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
 
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
 
Enter current password for root (enter for none):
OK, successfully used password, moving on...
 
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
 
Set root password? [Y/n] Y
New password:                              # 设置数据库 root 密码
Re-enter new password:                    # 再次输入
Password updated successfully!
Reloading privilege tables..
... Success!
 
 
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
 
Remove anonymous users? [Y/n] Y    # 删除匿名用户
... Success!
 
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
 
Disallow root login remotely? [Y/n] Y  # 禁止 root 远程登陆数据库
... Success!
 
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n] Y  # 删除 test 测试库
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables now? [Y/n] Y    # 刷新数据库表
... Success!
 
Cleaning up...
 
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
 
Thanks for using MariaDB!

2.5 创建 zabbix 数据库、用户并设置密码

1
2
mysql -uroot -p123456 -e "create database zabbix default character set utf8 collate utf8_bin;" 
mysql -uroot -p123456 -e "grant all on zabbix.* to'zabbix'@'%'identified by'123456';"

2.6 登陆测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@zabbix-server src]# mysql -uzabbix -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 5.5.50-MariaDB MariaDB Server
 
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix |
+--------------------+
2 rows in set (0.00 sec)
 
MariaDB [(none)]> use zabbix
Database changed
MariaDB [zabbix]> show tables;
Empty set (0.01 sec)
 
MariaDB [zabbix]> Bye

三、安装 zabbix 服务端

3.1 yum 安装 zabbix 服务

1
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get

3.2 导入数据表结构

1
2
cd /usr/share/doc/zabbix-server-mysql-3.0.4/
zcat create.sql.gz | mysql -uzabbix -p123456 zabbix

3.3 备份并修改 zabbix 配置文件

配置数据库:

1
2
3
4
5
6
cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf_$(date +%F)
[root@zabbix-server ~]# diff /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf_2016-08-23
115c115
< DBPassword=123456
---
> # DBPassword=

定义时区:

1
2
3
4
5
6
cp /etc/httpd/conf.d/zabbix.conf /etc/httpd/conf.d/zabbix.conf_$(date +%F)
[root@zabbix-server ~]# diff /etc/httpd/conf.d/zabbix.conf /etc/httpd/conf.d/zabbix.conf_2016-08-23
19c19
<      php_value date.timezone Asia/Chongqing
---
>        # php_value date.timezone Europe/Riga

3.4 设置开机自启动,启动 zabbix 服务器端

1
2
systemctl enalble zabbix-server
systemctl restart zabbix-server

3.5 设置开机自启动,启动 apache

1
2
systemctl enable httpd
systemctl start httpd

一些 Zabbix 相关教程集合

Ubuntu 14.04 下 Zabbix2.4.5 源码编译安装  http://www.linuxidc.com/Linux/2015-05/117657.htm

安装部署分布式监控系统 Zabbix 2.06 http://www.linuxidc.com/Linux/2013-07/86942.htm

《安装部署分布式监控系统 Zabbix 2.06》http://www.linuxidc.com/Linux/2013-07/86942.htm

CentOS 7.0 x64 下 Zabbix 3.0 安装笔记  http://www.linuxidc.com/Linux/2016-11/137044.htm

Zabbix 分布式监控系统实践 http://www.linuxidc.com/Linux/2013-06/85758.htm

CentOS 6.3 下 Zabbix 监控 apache server-status http://www.linuxidc.com/Linux/2013-05/84740.htm

CentOS 6.3 下 Zabbix 监控 MySQL 数据库参数 http://www.linuxidc.com/Linux/2013-05/84800.htm

64 位 CentOS 6.2 下安装 Zabbix 2.0.6   http://www.linuxidc.com/Linux/2014-11/109541.htm

四、web 界面安装 zabbix

4.1 访问地址 http://192.168.0.125/zabbix/setup.php 配置 zabbix

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 注:下图中的所有配置必须都为 ok 才可以。

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 注:下图配置 zabbix 的一些数据库相关信息,按照自己的填写即可。

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

注:Name 为别名设置,可填写

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 CentOS 7.2 安装部署 Zabbix 3.0.4 详解

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

注:zabbix 默认登录用户名为 Admin(A 为大写,),密码为 zabbix。

 CentOS 7.2 安装部署 Zabbix 3.0.4 详解

注:下图进入登录界面

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

4.2 设置字体显示为中文

注:3.0.4 默认的中文显示配置文件里面是开启的,无需重新设置,只需要如下图选择即可

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

五、总结

到这里,Zabbix 服务器端的配置部署完毕,下篇文章部署 Zabbix 客户端的配置及其一些常用应用的监控。在配置过程中遇到的问题解决方法见 http://www.linuxidc.com/Linux/2016-11/137671p2.htm

一、客户端操作

1.1 书写配置脚本

1
2
3
4
5
[root@mysql-server zabbix]# cd /etc/zabbix/
[root@mysql-server zabbix]# cat /etc/zabbix/tcp.sh
#!/bin/bash
NUM=$(/usr/sbin/ss -s| grep -oP "(?<=$1)\d+")
echo ${NUM:-555}

1.2 备份并更改客户端配置文件

1
2
3
4
5
6
[root@mysql-server zabbix]# cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_$(date +%F)
[root@mysql-server zabbix]# diff /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_2016-08-23
< UnsafeUserParameters=1
< UserParameter=tcp[*],sh /etc/zabbix/tcp.sh $1
< ---
> # UserParameter=

1.3 重启 zabbix-agent 服务

1
systemctl restart zabbix-agent

二、配置 zabbix 模板

2.1 添加应用集

操作:配置 — 模板,选择 Template-OS-Linux 里面的应用集

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

2.2 创建应用集

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

2.3 创建监控项

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

2.4 添加监控图形

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

 2.5 查看刷新查看之前添加的客户点监控图形信息

CentOS 7.2 安装部署 Zabbix 3.0.4 详解

 

 2.6 配置触发器

根据自己的需求配置即可。

三、总结

待完善。。。

ZABBIX 的详细介绍:请点这里
ZABBIX 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-11/137671.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计11574字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中