一、zabbix安装

1.系统环境

[root@zabbix ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
#关闭selinux和防火墙

2.安装数据库

[root@zabbix ~]# yum install mariadb-server mariadb -y
[root@zabbix ~]# systemctl enable mariadb
[root@zabbix ~]# systemctl start mariadb

3.zabbix安装

[root@zabbix ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
[root@zabbix ~]# yum install zabbix-server-mysql zabbix-web-mysql

4.创建数据库

[root@zabbix ~]# systemctl start mariadb
[root@zabbix ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, 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 '123456';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

5.导入数据

[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.12/create.sql.gz | mysql -uzabbix -p123456 zabbix

6.配置zabbix连接数据库的用户和密码

[root@zabbix ~]# cat /etc/zabbix/zabbix_server.conf | grep -v '^#' | grep -v '^$'
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts

7.配置zabbix前端的PHP配置

[root@zabbix ~]# cat /etc/httpd/conf.d/zabbix.conf
Alias /zabbix /usr/share/zabbix


    Options FollowSymLinks
    AllowOverride None
    Require all granted

    
        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 max_input_vars 10000
        php_value always_populate_raw_post_data -1
        php_value date.timezone Asia/Shanghai
    



    Require all denied



    Require all denied



    Require all denied



    Require all denied

8.启动zabbix和httpd
9.初始化zabbix

Zabbix前端可以在浏览器中通过 http://zabbix-hostname/zabbix 进行访问。默认的用户名/密码为 Admin/zabbix

10.安装客户端

[root@zabbix ~]# yum -y install zabbix-agent

11.配置客户端并设置开机启动


sed -i 's/Server=127.0.0.1/Server=10.0.10.20/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=10.0.10.20/g' /etc/zabbix/zabbix_agentd.conf
sed -i "s/Hostname=Zabbix server/Hostname=$HOSTNAME/g" /etc/zabbix/zabbix_agentd.conf

[root@zabbix ~]# cat /etc/zabbix/zabbix_agentd.conf | grep -n '^'[a-Z]
13:PidFile=/var/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
97:Server=10.0.10.20
138:ServerActive=10.0.10.20
149:Hostname=zabbix
267:Include=/etc/zabbix/zabbix_agentd.d/*.conf