由于Server端是Server+Agent+Web在同一台服务器,所以可以同步部署
- 添加Zabbix源
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum clean all
yum install munin --nogpgcheck
- 安装Server和Agent
yum install zabbix-server-mysql zabbix-agent
- 安装依赖包epel
yum install epel-release
- 安装web
yum install zabbix-web-mysql zabbix-nginx-conf
- 创建数据库和用户
mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> flush privileges;
mysql> exit;
- 初始化数据库
把server上的/usr/share/doc/zabbix-server-mysql-4.4.8/create.sql.gz导入到mysql数据库,在有mysql客户端的服务器上执行如下命令
zcat ./create.sql.gz | mysql -uzabbix -p zabbix -h192.168.100.102
- 修改Server的配置
vi /etc/zabbix/zabbix_server.conf
LogFileSize=512 # 默认是0表示不限制日志大小
DBName=zabbix # 数据库名称
DBHost=192.168.100.102
DBUser=zabbix
DBPassword=password
DBPort=3306
- 修改Agent配置
Hostname=DOMAIN_MAIN_192.168.100.101_AGENT
- 修改web配置
vi /etc/nginx/conf.d/zabbix.conf
listen 80;
server_name 192.168.100.101;
- 修改web端数据库配置
vi /etc/zabbix/web/zabbix.conf.php
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = '192.168.100.102';
$DB['PORT'] = '3306';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'zabbix';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'Zabbix_Server';
- 修改web端的时区
vi /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
- 关闭Selinux
vi /etc/selinux/config
SELINUX=enforcing改为SELINUX=disabled
重启后生效。
- 启动服务
systemctl restart zabbix-server zabbix-agent nginx php-fpm
- 设置为开启自动启动
systemctl enable zabbix-server zabbix-agent nginx php-fpm
- 前端访问
不出意外的话,可以通过地址打开如下地址
http://192.168.100.101
默认会带有一个host:DOMAIN_MAIN_192.168.100.101_AGENT