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.rpmyum 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 foundNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou 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 MariaDBroot user without the proper authorisation.Set root password? [Y/n] YNew password: #设置数据库root密码Re-enter new password: #再次输入Password updated successfully!Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] Y #删除匿名用户... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures 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 canaccess. This is also intended only for testing, and should be removedbefore 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 farwill 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 MariaDBinstallation 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 -p123456Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 16Server version: 5.5.50-MariaDB MariaDB ServerType '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 zabbixDatabase changedMariaDB [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-serversystemctl restart zabbix-server |
3.5 设置开机自启动,启动apache
|
1
2
|
systemctl enable httpdsystemctl 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

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

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

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



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

注:下图进入登录界面

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

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