5月 292019
 

安装Zabbix YUM仓库源

[root@iZj6cd9flzbx5kd084fw97Z ~]# yum -y install https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
[root@iZj6cd9flzbx5kd084fw97Z ~]# yum makecache

安装Mariadb 5.5.60(MySQL)数据库服务

[root@iZj6cd9flzbx5kd084fw97Z ~]# yum -y install mariadb-server mariadb

启动数据库服务并设置数据库服务随系统启动

[root@iZj6cd9flzbx5kd084fw97Z ~]# systemctl start mariadb
[root@iZj6cd9flzbx5kd084fw97Z ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@iZj6cd9flzbx5kd084fw97Z ~]#

创建数据库并赋权

[root@iZj6cd9flzbx5kd084fw97Z ~]# 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.60-MariaDB MariaDB Server

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

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@iZj6cd9flzbx5kd084fw97Z ~]#

安装zabbix服务端,代理端,Web端

[root@iZj6cd9flzbx5kd084fw97Z ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

修改目录写入权限(For Apache)

[root@iZj6cd9flzbx5kd084fw97Z ~]# ll /usr/share/zabbix/ |grep assets
drwxr-xr-x 5 root root 4096 May 30 11:31 assets
[root@iZj6cd9flzbx5kd084fw97Z ~]# ll /usr/share/zabbix/assets/ 
total 12
drwxr-xr-x 2 root root 4096 May 28 17:27 fonts
drwxr-xr-x 2 root root 4096 May 30 11:31 img
drwxr-xr-x 2 root root 4096 May 30 11:31 styles
[root@iZj6cd9flzbx5kd084fw97Z ~]# 
[root@iZj6cd9flzbx5kd084fw97Z ~]# chmod -R o+w /usr/share/zabbix/assets/

导入数据库脚本

[root@iZj6cd9flzbx5kd084fw97Z ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: 
[root@iZj6cd9flzbx5kd084fw97Z ~]#

修改服务端配置文件的数据库连接密码配置

[root@iZj6cd9flzbx5kd084fw97Z ~]# vi /etc/zabbix/zabbix_server.conf
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=

DBPassword=password

修改php配置参数的时区设置为本地时区

[root@iZj6cd9flzbx5kd084fw97Z ~]# vi /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Hong_Kong

启动zabbix服务端,代理端和httpd服务并注册为随系统启动

[root@iZj6cd9flzbx5kd084fw97Z ~]# systemctl start zabbix-server zabbix-agent httpd 
[root@iZj6cd9flzbx5kd084fw97Z ~]# systemctl enable zabbix-server zabbix-agent httpd 
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@iZj6cd9flzbx5kd084fw97Z ~]#

查看监听截图

使用浏览器访问zabbix安装向导

zabbix的依赖检测

配置数据连接信息

配置服务器端的主机通信地址及端口信息

确认安装清单

完成安装向导

使用默认服务默认用户名密码(Admin/zabbix)

Zabbix Web控制台首页

Yum二进制包zabbix关于php参数的配置方法参考

[root@iZj6cd9flzbx5kd084fw97Z ~]# cat /etc/httpd/conf.d/zabbix.conf 
#
# Zabbix monitoring system php web frontend
#

Alias /zabbix /usr/share/zabbix

<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted

<IfModule mod_php5.c>
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/Hong_Kong
</IfModule>
</Directory>

<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>

<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>

<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>

<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
[root@iZj6cd9flzbx5kd084fw97Z ~]#