Centos7安装zabbix

  1. 云栖社区>
  2. 博客>
  3. 正文

Centos7安装zabbix

余二五 2017-11-18 20:50:00 浏览769
展开阅读全文

实验环境:

1
2
3
阿里云
[zabbix@miyan ~]$ cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

不得不说,官方文档确实强大

1.官方文档地址:

1
https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages

2.导入源:

1
[zabbix@miyan ~]$ sudo rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

3.安装zabbix包

1
[zabbix@miyan ~]$ sudo yum install zabbix-server-mysql zabbix-web-mysql

清楚的看一下要安装那些包

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
Package                                Arch                      Version                                   Repository                  Size
=============================================================================================================================================
Installing:
 zabbix-server-mysql                    x86_64                    3.0.1-1.el7                               zabbix                     1.7 M
 zabbix-web-mysql                       noarch                    3.0.1-1.el7                               zabbix                     3.5 k
Installing for dependencies:
 OpenIPMI-libs                          x86_64                    2.0.19-11.el7                             base                       501 k
 OpenIPMI-modalias                      x86_64                    2.0.19-11.el7                             base                        15 k
 dejavu-fonts-common                    noarch                    2.33-6.el7                                base                        64 k
 dejavu-sans-fonts                      noarch                    2.33-6.el7                                base                       1.4 M
 fping                                  x86_64                    3.10-4.el7                                epel                        46 k
 httpd                                  x86_64                    2.4.6-40.el7.centos                       base                       2.7 M
 httpd-tools                            x86_64                    2.4.6-40.el7.centos                       base                        82 k
 iksemel                                x86_64                    1.4-6.el7                                 epel                        50 k
 libtool-ltdl                           x86_64                    2.4.2-21.el7_2                            updates                     49 k
 libzip                                 x86_64                    0.10.1-8.el7                              base                        48 k
 mailcap                                noarch                    2.1.41-2.el7                              base                        31 k
 net-snmp-libs                          x86_64                    1:5.7.2-24.el7                            base                       747 k
 php                                    x86_64                    5.4.16-36.el7_1                           base                       1.4 M
 php-bcmath                             x86_64                    5.4.16-36.el7_1                           base                        56 k
 php-cli                                x86_64                    5.4.16-36.el7_1                           base                       2.7 M
 php-common                             x86_64                    5.4.16-36.el7_1                           base                       563 k
 php-gd                                 x86_64                    5.4.16-36.el7_1                           base                       126 k
 php-ldap                               x86_64                    5.4.16-36.el7_1                           base                        51 k
 php-mbstring                           x86_64                    5.4.16-36.el7_1                           base                       503 k
 php-mysql                              x86_64                    5.4.16-36.el7_1                           base                        99 k
 php-pdo                                x86_64                    5.4.16-36.el7_1                           base                        97 k
 php-xml                                x86_64                    5.4.16-36.el7_1                           base                       124 k
 t1lib                                  x86_64                    5.1.2-14.el7                              base                       166 k
 unixODBC                               x86_64                    2.3.1-11.el7                              base                       413 k
 zabbix-web                             noarch                    3.0.1-1.el7                               zabbix                     3.3 M
 
Transaction Summary
=============================================================================================================================================
Install  2 Packages (+25 Dependent packages)
 
Total download size: 17 M

4.我们给本机也安装上客户端

[zabbix@miyan ~]$ sudo yum install zabbix-agent

5.初始化数据库

CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了。用mariadb也行。我还是选择了mysql

(1)安装mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[zabbix@miyan ~]$ rpm -ivh mysql-community-release-el7-5.noarch.rpm
#安装带有当前可用的mysql5系列社区版资源的rpm包
[zabbix@miyan ~]$ yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                 21
mysql-tools-community/x86_64      MySQL Tools Community                      33
mysql56-community/x86_64          MySQL 5.6 Community Server                214
#查看当前可用的Mysql安装源
[zabbix@miyan ~]$ sudo yum install mysql-community-server
[zabbix@miyan ~]$ sudo systemctl enable mysqld  #设置开机启动
[zabbix@miyan ~]$ systemctl start mysqld            #启动服务
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===

进入mysql报错:

1
2
3
[zabbix@miyan ~]$ mysql -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决办法:

1
[zabbix@miyan ~]$ sudo mysql_secure_installation

按照提示一步步来。不解释。

再次进入mysql:

1
2
3
4
5
6
7
8
9
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
 
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'
    -> ;
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit
Bye

(2)进入到这个目录

1
2
3
4
[zabbix@miyan zabbix-server-mysql-3.0.1]$ pwd
/usr/share/doc/zabbix-server-mysql-3.0.1
[zabbix@miyan zabbix-server-mysql-3.0.1]$ ls
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README

运行命令

1
[zabbix@miyan zabbix-server-mysql-3.0.1]$ # zcat create.sql.gz | mysql -uroot -p zabbix

注意加红色部分,易错。

6.启动zabbix server服务

修改配置文件:

1
[zabbix@miyan ~]$ vim /etc/zabbix/zabbix_server.conf
1
2
3
4
5
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
实际上我的配置文件修改的是DBHost和DBPassword去掉前面的#号。

启动zabbix服务,设置开机自启动

1
[zabbix@miyan ~]$ sudo systemctl start zabbix-server
1
2
[zabbix@miyan ~]$ sudo systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.

7.编辑zabbix前端的PHP配合配置

1
[zabbix@miyan ~]$ sudo vim /etc/httpd/conf.d/zabbix.conf
1
2
3
4
5
6
7
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai

实际上我就是修改了时区

启动apache服务,设置开机自启动

1
2
3
[zabbix@miyan ~]$ sudo systemctl start httpd
[zabbix@miyan ~]$ sudo systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

8.登陆zabbix

1
http://IP/zabbix/

显示的界面

638371-20160326112614058-2091742723.png点击next会出现检查状态:

638371-20160326112733620-818687474.png点击next配置mysql:

638371-20160326112905261-1672822274.png

点击下一步。此步出现错误,发现无法连接数据库,最后发现zabbix这个数据库中,没有任何数据,检查时加红色的那部分出问题。

next到最后

638371-20160326211833354-1411735640.png638371-20160326211852401-1216681979.png638371-20160326211905558-907988677.png默认用户名/密码:Admin/zabbix


638371-20160326211916667-1291248322.png

进入主页面:下面进行,将语言改为中文。

1
[zabbix@miyan zabbix-server-mysql-3.0.1]$ sudo vim /usr/share/zabbix/include/locales.inc.php

找到第55行,将false改为true

638371-20160326212921448-1833360430.png

点击zabbix右上角小人,进行修改:

638371-20160326213104667-215461677.png

还是遇到了中文乱码问题,直接google。

638371-20160326215112964-1418774720.png

参考这位大神的。

1
http://www.cnblogs.com/enjoycode/p/zabbix_3_installation_on_centos_7.html

Win+R打开运行,输入fonts,回车进入Windows字体目录,找到微软雅黑-常规字体,复制出来将文件名修改为msyh.ttf,然后上传到/usr/share/zabbix/fonts

89852-20160309014932007-1825688762.png

上传成功后,编辑

1
sudo vim /usr/share/zabbix/include/defines.inc.php

将'graphfont' 修改为msyh。

wKioL1gigc2wLgwoAABJNF5w5ko101.png










本文转自 xinsir999 51CTO博客,原文链接:http://blog.51cto.com/xinsir/1870922,如需转载请自行联系原作者

网友评论

登录后评论
0/500
评论
余二五
+ 关注