centos7.3上用源代码安装zabbix3.2.7

安装zabbix之前请自行先搭建好LAMP环境!

1、下载源码安装包并解压

  1.1 下载

[root@nmserver-7 ~]# mkdir zabbix
[root@nmserver-7 ~]# cd zabbix/
[root@nmserver-7 zabbix]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz
--2017-07-22 22:27:27--  https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz
正在解析主机 nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)... 211.79.60.17, 2001:e10:ffff:1f02::17
正在连接 nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)|211.79.60.17|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:16016367 (15M) [application/x-gzip]
正在保存至: “zabbix-3.2.7.tar.gz”

100%[===================================================================================================================>] 16,016,367   195KB/s 用时 82s    

2017-07-22 22:28:51 (190 KB/s) - 已保存 “zabbix-3.2.7.tar.gz” [16016367/16016367])

  1.2 解压

[root@nmserver-7 zabbix]# ls
zabbix-3.2.7.tar.gz
[root@nmserver-7 zabbix]# tar -zxvf zabbix-3.2.7.tar.gz 

2、创建zabbix数据库

  zabbix server 、zabbix proxy及zabbix前端运行需要数据库支持,因此要提前创建好数据库和各种表格;

     参考官方文档: https://www.zabbix.com/documentation/3.2/manual/appendix/install/db_scripts

  2.1 创建zabbix数据库

[root@nmserver-7 zabbix-3.2.7]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.52-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)]> create database zabbix character set utf8 collate utf8_bin;    
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';   
Query OK, 0 rows affected (0.03 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| zabbix             |
+--------------------+
4 rows in set (0.03 sec)

MariaDB [(none)]> 

   

  2.2 系统创建zabbix用户

#groupadd zabbix -g 501   #创建用户组,并且设置UID501  
#useradd -g zabbix -u 501 -m zabbix

  注意一定要创建不然后面的zabbix服务会启动不了,出现以下问题

  问题一:

[root@nmserver-7 zabbix-3.2.7]# /usr/local/zabbix/sbin/zabbix_agentd 
zabbix_agentd [1380]: user zabbix does not exist
zabbix_agentd [1380]: cannot run as root!

   问题二:

[root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd (via systemctl):                    [  确定  ]
[root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_agentd status
● zabbix_agentd.service - SYSV: Starts and stops Zabbix Agent using chkconfig
   Loaded: loaded (/etc/rc.d/init.d/zabbix_agentd; bad; vendor preset: disabled)
   Active: active (exited) since 日 2017-07-23 05:22:02 CST; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1351 ExecStart=/etc/rc.d/init.d/zabbix_agentd start (code=exited, status=0/SUCCESS)

7月 23 05:22:02 nmserver-7.test.com systemd[1]: Starting SYSV: Starts and stops Zabbix Agent using chkconfig...
7月 23 05:22:02 nmserver-7.test.com zabbix_agentd[1351]: Starting zabbix_agentd:  zabbix_agentd [1358]: user zabbix does not exist
7月 23 05:22:02 nmserver-7.test.com zabbix_agentd[1351]: zabbix_agentd [1358]: cannot run as root!
7月 23 05:22:02 nmserver-7.test.com zabbix_agentd[1351]: [失败]
7月 23 05:22:02 nmserver-7.test.com systemd[1]: Started SYSV: Starts and stops Zabbix Agent using chkconfig.

  2.3 创建数据库表格

  进入解压源码后的  /zabbix-3.2.7/database/mysql 目录;

[root@nmserver-7 zabbix]# ls
zabbix-3.2.7  zabbix-3.2.7.tar.gz
[root@nmserver-7 zabbix]# pwd
/root/zabbix
[root@nmserver-7 zabbix]# cd zabbix-3.2.7/database/mysql/
[root@nmserver-7 mysql]# pwd
/root/zabbix/zabbix-3.2.7/database/mysql
[root@nmserver-7 mysql]# ls
data.sql  images.sql  schema.sql
[root@nmserver-7 mysql]# 

  2.4 将源码包中的角本导入zabbix数据库

[root@nmserver-7 mysql]# pwd
/root/zabbix/zabbix-3.2.7/database/mysql
[root@nmserver-7 mysql]# mysql -uzabbix -pzabbix  zabbix < schema.sql 
[root@nmserver-7 mysql]# mysql -uzabbix -pzabbix  zabbix < images.sql 
[root@nmserver-7 mysql]# mysql -uzabbix -pzabbix  zabbix < data.sql 
[root@nmserver-7 mysql]# mysql -uzabbix -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 5.5.52-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)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
....................
....................
....................
| | users_groups | | usrgrp | | valuemaps | +----------------------------+ 127 rows in set (0.00 sec) MariaDB [zabbix]>

  可见数据库及表格已经成功创建完成;

3、编译安装

 3.1  编译

 ./configure  --help 可以查询编译时可选参数;

[root@nmserver-7 zabbix]# cd zabbix-3.2.7
[root@nmserver-7 zabbix-3.2.7]# ./configure --help
`configure' configures Zabbix 3.2.7 to adapt to many kinds of systems.
.................
.................

  我这里只安装zabbix server  和zabbix agentd 服务器,参考官方的编译参数 代码如下:

[root@nmserver-7 mysql]# cd /root/zabbix/zabbix-3.2.7
[root@nmserver-7 zabbix-3.2.7]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml --prefix=/usr/local/zabbix

    安装路径根据需要修改--prefix参数

       第一次编译时时出现问题“configure: error: LIBXML2 library not found” 如下

  解决方法:

[root@nmserver-7 zabbix-3.2.7]# yum install libxml2-devel
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 libxml2-devel.i686.0.2.9.1-6.el7_2.3 将被 安装
--> 正在处理依赖关系 xz-devel,它被软件包 libxml2-devel-2.9.1-6.el7_2.3.i686 需要
--> 正在检查事务
---> 软件包 xz-devel.i686.0.5.2.2-1.el7 将被 安装
--> 解决依赖关系完成
...   ...
...   ...

  再次编译出现以下问题:

checking for pkg-config... /bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for xml2-config... /bin/xml2-config
checking for xmlReadMemory in -lxml2... yes
checking for net-snmp-config... no
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

  解决方法如下:

[root@nmserver-7 zabbix-3.2.7]# yum install net-snmp-devel

  安装完毕后进行第三次编译,编译成功!

[root@nmserver-7 zabbix-3.2.7]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --prefix=/usr/local/zabbix
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
configure: Configuring Zabbix 3.2.7
checking whether make sets $(MAKE)... (cached) yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
......
......
......

Configuration: Detected OS: linux
-gnu Install path: /usr/local/zabbix Compilation arch: linux Compiler: gcc Compiler flags: -g -O2 Library-specific flags: database: -I/usr/include/mysql libXML2: -I/usr/include/libxml2 Net-SNMP: -I/usr/local/include -I/usr/lib/perl5/CORE -I. -I/usr/include Enable server: yes Server details: With database: MySQL WEB Monitoring: cURL Native Jabber: no SNMP: yes IPMI: no SSH: no TLS: no ODBC: no Linker flags: -L/usr/lib/mysql -L/usr/lib -rdynamic Libraries: -lmysqlclient -lxml2 -lnetsnmp -lcurl -lm -ldl -lresolv Enable proxy: no Enable agent: yes Agent details: TLS: no Linker flags: -rdynamic Libraries: -lcurl -lm -ldl -lresolv Enable Java gateway: no LDAP support: no IPv6 support: yes *********************************************************** * Now run 'make install' * * * * Thank you for using Zabbix! * * <http://www.zabbix.com> * *********************************************************** [root@nmserver-7 zabbix-3.2.7]#

  3.2 安装zabbix

[root@nmserver-7 zabbix-3.2.7]# make install

  3.3 验证安装成功

[root@nmserver-7 conf]# /usr/local/zabbix/sbin/zabbix_server -V
zabbix_server (Zabbix) 3.2.7
Revision 70298 18 July 2017, compilation time: Jul 23 2017 04:01:34

Copyright (C) 2017 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
[root@nmserver-7 conf]# /usr/local/zabbix/sbin/zabbix_agentd -V
zabbix_agentd (daemon) (Zabbix) 3.2.7
Revision 70298 18 July 2017, compilation time: Jul 23 2017 04:01:34

Copyright (C) 2017 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
[root@nmserver-7 conf]# 

3、启用服务

  3.1修改服务器和客户端配置文件

  zabbix_server配置文件修改,主要设置好连接数据的数据库名称、登陆账号还有密码!

[root@nmserver-7 init.d]# vi /usr/local/zabbix/etc/zabbix_server.conf

.....
75 # Mandatory: no
     76 # Default:
     77 # DBHost=localhost
     78 
     79 ### Option: DBName
      ......85 # DBName=
     86 
     87 DBName=zabbix
     88 
     ......100 # Default:
    101 # DBUser=
    102 
    103 DBUser=zabbix
    104 
    ......109 # Mandatory: no
    110 # Default:
    111 # DBPassword=
    112   DBPassword=zabbix

 

  zabbix_agentd配置文件修改;主要配置好zabbix server的IP地址;

[root@nmserver-7 init.d]# vi /usr/local/zabbix/etc/zabbix_agentd.conf
    ......
    89 # Server=
     90
     91 Server=127.0.0.1
     92
     93 ### Option: ListenPort
     94 #       Agent will listen on this port for connections from the server.

    ......
   ServerActive=127.0.0.1
    ......
Hostname=127.0.0.1

    ......

  将配置文件中的ServerServerActive、Hostname参数设置成zabbix服务器的IP地址即可,我这次安装的zabbix_agentd和zabbix_server在同一服务器上,所在IP地址为本机IP地址;

  3.2 修改firewall设置

   开放zabbix端口10050和10051

[root@nmserver-7 init.d]# firewall-cmd --permanent --add-port=10051/tcp
success
[root@nmserver-7 init.d]# firewall-cmd --permanent --add-port=10050/tcp
success
[root@nmserver-7 init.d]# systemctl restart firewalld
[root@nmserver-7 init.d]# 

   3.3 设置开机启动

   3.3.1 将源码包中提供的init.d启动脚本拷贝到系统中

[root@nmserver-7 zabbix-3.2.7]# ls
aclocal.m4  compile        config.sub    depcomp     m4           misc     src
AUTHORS     conf           configure     frontends   Makefile     missing  upgrades
bin         config.guess   configure.ac  include     Makefile.am  NEWS
build       config.log     COPYING       INSTALL     Makefile.in  README
ChangeLog   config.status  database      install-sh  man          sass

[root@nmserver-7 zabbix-3.2.7]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/ -v "misc/init.d/fedora/core/zabbix_agentd" -> "/etc/init.d/zabbix_agentd" "misc/init.d/fedora/core/zabbix_server" -> "/etc/init.d/zabbix_server" [root@nmserver-7 zabbix-3.2.7]#

  3.3.2 编辑启动脚本以适应自己的安装环境

  修改服务器端启动文件

  #vi /etc/init.d/zabbix_server

  将BASEDIR=/usr/local/替换为BASEDIR=/usr/local/zabbix(以之前编译的位置为准)

  修改客户器端启动文件:

  #vi /etc/init.d/zabbix_agentd

  将BASEDIR=/usr/local/替换为BASEDIR=/usr/local/zabbix(以之前编译的位置为准)

  3.4 服务启动与配置验证

方法一:

[root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_server start
Starting zabbix_server (via systemctl):                    [  确定  ]
[root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd (via systemctl):                    [  确定  ]
[root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_server status
● zabbix_server.service - SYSV: Starts and stops Zabbix Server using chkconfig
   Loaded: loaded (/etc/rc.d/init.d/zabbix_server; bad; vendor preset: disabled)
   Active: active (running) since 日 2017-07-23 05:36:18 CST; 18s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1769 ExecStart=/etc/rc.d/init.d/zabbix_server start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/zabbix_server.service
           ├─1779 /usr/local/zabbix/sbin/zabbix_server
           ├─1784 /usr/local/zabbix/sbin/zabbix_server: configuration syncer [waiting 60 sec f...
           ├─1785 /usr/local/zabbix/sbin/zabbix_server: db watchdog [synced alerts config in 0...
           ├─1786 /usr/local/zabbix/sbin/zabbix_server: poller #1 [got 0 values in 0.000011 se...
           ├─1787 /usr/local/zabbix/sbin/zabbix_server: poller #2 [got 0 values in 0.000011 se...
           ├─1788 /usr/local/zabbix/sbin/zabbix_server: poller #3 [got 0 values in 0.000011 se...
           ├─1789 /usr/local/zabbix/sbin/zabbix_server: poller #4 [got 0 values in 0.000011 se...
           ├─1790 /usr/local/zabbix/sbin/zabbix_server: poller #5 [got 0 values in 0.000014 se...
           ├─1791 /usr/local/zabbix/sbin/zabbix_server: unreachable poller #1 [got 0 values in...
           ├─1792 /usr/local/zabbix/sbin/zabbix_server: trapper #1 [processed data in 0.000000...
           ├─1793 /usr/local/zabbix/sbin/zabbix_server: trapper #2 [processed data in 0.000000...
           ├─1794 /usr/local/zabbix/sbin/zabbix_server: trapper #3 [processed data in 0.000000...
           ├─1795 /usr/local/zabbix/sbin/zabbix_server: trapper #4 [processed data in 0.000000...
           ├─1796 /usr/local/zabbix/sbin/zabbix_server: trapper #5 [processed data in 0.001351...
           ├─1797 /usr/local/zabbix/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.0000...
           ├─1798 /usr/local/zabbix/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fai...
           ├─1799 /usr/local/zabbix/sbin/zabbix_server: housekeeper [startup idle for 30 minut...
           ├─1800 /usr/local/zabbix/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 even...
           ├─1801 /usr/local/zabbix/sbin/zabbix_server: http poller #1 [got 0 values in 0.0013...
           ├─1802 /usr/local/zabbix/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0....
           ├─1803 /usr/local/zabbix/sbin/zabbix_server: history syncer #1 [synced 0 items in 0...
           ├─1804 /usr/local/zabbix/sbin/zabbix_server: history syncer #2 [synced 0 items in 0...
           ├─1805 /usr/local/zabbix/sbin/zabbix_server: history syncer #3 [synced 0 items in 0...
           ├─1806 /usr/local/zabbix/sbin/zabbix_server: history syncer #4 [synced 0 items in 0...
           ├─1807 /usr/local/zabbix/sbin/zabbix_server: escalator #1 [processed 0 escalations ...
           ├─1808 /usr/local/zabbix/sbin/zabbix_server: proxy poller #1 [exchanged data with 0...
           ├─1809 /usr/local/zabbix/sbin/zabbix_server: self-monitoring [processed data in 0.0...
           └─1815 /usr/local/zabbix/sbin/zabbix_server: task manager [processed 0 task(s) in 0...

7月 23 05:36:18 nmserver-7.test.com systemd[1]: Starting SYSV: Starts and stops Zabbix Serv.....
7月 23 05:36:18 nmserver-7.test.com zabbix_server[1769]: Starting zabbix_server:  [  确定  ]
7月 23 05:36:18 nmserver-7.test.com systemd[1]: Started SYSV: Starts and stops Zabbix Serve...g.
Hint: Some lines were ellipsized, use -l to show in full.
[root@nmserver-7 zabbix-3.2.7]# /etc/init.d/zabbix_agentd status
● zabbix_agentd.service - SYSV: Starts and stops Zabbix Agent using chkconfig
   Loaded: loaded (/etc/rc.d/init.d/zabbix_agentd; bad; vendor preset: disabled)
   Active: active (running) since 日 2017-07-23 05:36:26 CST; 19s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1849 ExecStart=/etc/rc.d/init.d/zabbix_agentd start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/zabbix_agentd.service
           ├─1859 /usr/local/zabbix/sbin/zabbix_agentd
           ├─1860 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
           ├─1861 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection]
           ├─1862 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection]
           ├─1863 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection]
           └─1864 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

7月 23 05:36:26 nmserver-7.test.com systemd[1]: Starting SYSV: Starts and stops Zabbix Agen.....
7月 23 05:36:26 nmserver-7.test.com zabbix_agentd[1849]: Starting zabbix_agentd:  [  确定  ]
7月 23 05:36:26 nmserver-7.test.com systemd[1]: Started SYSV: Starts and stops Zabbix Agent...g.
Hint: Some lines were ellipsized, use -l to show in full.
[root@nmserver-7 zabbix-3.2.7]# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      1084/sshd           
tcp        0      0 0.0.0.0:zabbix-agent    0.0.0.0:*               LISTEN      1859/zabbix_agentd  
tcp        0      0 0.0.0.0:zabbix-trapper  0.0.0.0:*               LISTEN      1779/zabbix_server  
tcp        0      0 0.0.0.0:mysql           0.0.0.0:*               LISTEN      9760/mysqld         
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1084/sshd           
tcp6       0      0 [::]:zabbix-agent       [::]:*                  LISTEN      1859/zabbix_agentd  
tcp6       0      0 [::]:zabbix-trapper     [::]:*                  LISTEN      1779/zabbix_server  
tcp6       0      0 [::]:http               [::]:*                  LISTEN      10072/httpd         
udp        0      0 localhost:323           0.0.0.0:*                           592/chronyd         
udp6       0      0 localhost:323           [::]:*                              592/chronyd         
[root@nmserver-7 zabbix-3.2.7]# 

方法二:

[root@nmserver-7 zabbix-3.2.7]# /usr/local/zabbix/sbin/zabbix_server 
[root@nmserver-7 zabbix-3.2.7]# /usr/local/zabbix/sbin/zabbix_agentd 
[root@nmserver-7 zabbix-3.2.7]# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      1084/sshd           
tcp        0      0 0.0.0.0:zabbix-agent    0.0.0.0:*               LISTEN      2031/zabbix_agentd  
tcp        0      0 0.0.0.0:zabbix-trapper  0.0.0.0:*               LISTEN      1974/zabbix_server  
tcp        0      0 0.0.0.0:mysql           0.0.0.0:*               LISTEN      9760/mysqld         
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1084/sshd           
tcp6       0      0 [::]:zabbix-agent       [::]:*                  LISTEN      2031/zabbix_agentd  
tcp6       0      0 [::]:zabbix-trapper     [::]:*                  LISTEN      1974/zabbix_server  
tcp6       0      0 [::]:http               [::]:*                  LISTEN      10072/httpd         
udp        0      0 localhost:323           0.0.0.0:*                           592/chronyd         
udp6       0      0 localhost:323           [::]:*                              592/chronyd         
[root@nmserver-7 zabbix-3.2.7]# 

  3.5 设置zabbix server 和zabbix agentd开机自动启动

[root@nmserver-7 zabbix-3.2.7]# chkconfig --add zabbix_server
[root@nmserver-7 zabbix-3.2.7]# chkconfig --add zabbix_agentd
[root@nmserver-7 zabbix-3.2.7]# chkconfig --level 35  zabbix_server on
[root@nmserver-7 zabbix-3.2.7]# chkconfig --level 35  zabbix_agentd  on
[root@nmserver-7 zabbix-3.2.7]# chkconfig --list

注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 
      如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
      欲查看对特定 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

netconsole         0:关    1:关    2:关    3:关    4:关    5:关    6:关
network            0:关    1:关    2:开    3:开    4:开    5:开    6:关
zabbix_agentd      0:关    1:关    2:关    3:开    4:关    5:开    6:关
zabbix_server      0:关    1:关    2:关    3:开    4:关    5:开    6:关
[root@nmserver-7 zabbix-3.2.7]# 

4、 前端Web配置

  4.1 查询apache配置文件确认DocumentRoot位置

[root@nmserver-7 ~]# vi /etc/httpd/conf/httpd.conf 

    116 # DocumentRoot: The directory out of which you will serve your
    117 # documents. By default, all requests are taken from this directory, but
    118 # symbolic links and aliases may be used to point to other locations.
    119 #
    120 DocumentRoot "/var/www/html"
    121 
    122 #
    123 # Relax access to content within /var/www.
    124 #

  4.2 拷贝源码包中的前端PHP代码到apache根目录

[root@nmserver-7 zabbix-3.2.7]# mkdir /var/www/html/zabbix/
[root@nmserver-7 zabbix-3.2.7]# pwd /root/zabbix/zabbix-3.2.7 [root@nmserver-7 zabbix-3.2.7]# cp -a ./frontends/php/ /var/www/html/zabbix

  4.3 更改zabbix网页文件权限

[root@nmserver-7 zabbix-3.2.7]# chown -R zabbix.zabbix  /var/www/html/zabbix/

  4.4 重启apache Web服务器

[root@nmserver-7 zabbix-3.2.7]# systemctl restart httpd

5、浏览器登陆进行zabbix安装初始化

  5.1 浏览器输入http://192.168.8.9/zabbix/

   注意有时此页面会显示403错误 无权限访问;这时需要reboot服务器再进行登陆;

  5.2 下一步检测安装前的一些配置是否满足

我这里有4个错误报警,这里出现的问题须要解决完后才能进行一下步操作;对缺少模块的须要重新编译相应模块并加载,

大部分参数只须要修改PHP配置文件即可满足条件,针对上面4个错误提示来修改PHP配置文件:

[root@nmserver-7 zabbix-3.2.7]# vi /etc/php.ini

#在php配置文件的672行将8M改为16M
 672 post_max_size = 8M-->16M

#在384行将30改为300
384 max_execution_time = 30-->300
#在394行将max_inpu_time原来60改为300
394 max_input_time = 60-->300
#在配置文件878行添加亚洲时区
878 ;date.timezone =
878  date.timezone = Asia/Shanghai 

:wq

将4个参数修改完成后保存退出

  重启apache服务

[root@nmserver-7 zabbix-3.2.7]# systemctl restart httpd

  再重新浏览器登陆http://192.168.8.9/zabbix/setup.php

  这次安装条件全部满足没有报警提示

  

好了,可以进行下一步操作了!

  5.3 配置数据库连接

 

注意:database port是   0表示是默认3306端口

数据库名称、账号名字、密码 根据之前创建数据库时的设置来添加,我这里只用添加“Password"项为”zabbix"即可,然后可以下一步了!

       5.4 关于zabbix 服务器的配置

  主要有三个参数:host 、port  、name

  前二个参数默认即可,Name为zabbix服务器的名字这里可以根据自己情况而设置,我这里设置成NMServer-7,设置好下一步!

    5.5 安装摘要,对前面设置参数汇总

     没问题就下一步~~~

   5.6 安装

  这时突然出现以下问题:

  

  根据提示找出产生这个问题的主要原因是从源码拷贝PHP配置文件后,有关zabbix的配置文件需要修改;

  源配置文件内容如下: 可以看到名字没有修改,配置也不对

[root@nmserver-7 zabbix-3.2.7]# cd /var/www/html/zabbix/conf/
[root@nmserver-7 conf]# ls
maintenance.inc.php  zabbix.conf.php.example
[root@nmserver-7 conf]# ll
总用量 8
-rw-r--r--. 1 zabbix zabbix 1036 7月  18 18:41 maintenance.inc.php
-rw-r--r--. 1 zabbix zabbix  411 7月  18 18:41 zabbix.conf.php.example
[root@nmserver-7 conf]# cd /var/www/html/zabbix/conf/
[root@nmserver-7 conf]# ls
maintenance.inc.php  zabbix.conf.php.example
[root@nmserver-7 conf]# cat zabbix.conf.php.example 
<?php
// Zabbix GUI configuration file.
global $DB;

$DB['TYPE']                = 'MYSQL';
$DB['SERVER']            = 'localhost';
$DB['PORT']                = '0';
$DB['DATABASE']            = 'zabbix';
$DB['USER']                = 'zabbix';
$DB['PASSWORD']            = '';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA']            = '';

$ZBX_SERVER                = 'localhost';
$ZBX_SERVER_PORT        = '10051';
$ZBX_SERVER_NAME        = '';

$IMAGE_FORMAT_DEFAULT    = IMAGE_FORMAT_PNG;
[root@nmserver-7 conf]# 

修改配置文件名称,编辑配置文件参数,按照之前设置的添加好,配置如下:

[root@nmserver-7 conf]# cp zabbix.conf.php.example zabbix.conf.php
[root@nmserver-7 conf]# ls
maintenance.inc.php  zabbix.conf.php  zabbix.conf.php.example
[root@nmserver-7 conf]# vi zabbix.conf.php

<?php
// Zabbix GUI configuration file.
global $DB;

$DB['TYPE']                             = 'MYSQL';
$DB['SERVER']                   = 'localhost';
$DB['PORT']                             = '0';
$DB['DATABASE']                 = 'zabbix';
$DB['USER']                             = 'zabbix';
$DB['PASSWORD']                 = 'zabbix';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA']                   = '';

$ZBX_SERVER                             = 'localhost';
$ZBX_SERVER_PORT                = '10051';
$ZBX_SERVER_NAME                = 'NMServer-7';

:wq

6、登陆zabbix

  6.1 登陆

  前端安装好以下直接跳出以下界面,点“Login"

 

进入登陆界面:

 注意默认账号是“Admin" ,密码是:”zabbix" ,Admin的A是大写切记!

  6.2 检查状态改为中文

  状态正常

 

  修改语言:administration->users->language->Chinese(zh_CN)->update

  

  按F5刷新浏览器,可见中文界面

7、zabbix安装结束

  安装只是做为zabbix的入门,接下来要学习各种监控才是重点。

  加油!

 

posted @ 2017-07-26 10:35  JUSTZHI  阅读(7289)  评论(1编辑  收藏  举报