一、安装Zabbix3.0
- Zabbix程序包安装,以及MySQL、Zabbix-agent
[root@zabbix-server ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
[root@zabbix-server ~]# yum makecache
[root@zabbix-server ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server
- 在MySQL上安装Zabbix数据库和用户,请参看下列指导步骤。MySQL数据库创建脚本,3.0。
[root@zabbix-server ~]# systemctl start mariadb
[root@zabbix-server ~]# systemctl enable mariadb
//简单配置MariaDB数据库
[root@zabbix-server ~]# mysql_secure_installation
...
Set root password? [Y/n] y
New password:
Re-enter new password:
Sorry, passwords do not match.
New password:
Re-enter new password:
Password updated successfully!
--这里我只配置了root密码123456,之后一路回车
[root@zabbix-server ~]# mysql -uroot -p123456
//设置数据库字符集
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
//创建远程用户zabbix密码zabbix
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
- 然后导入初始架构(Schema)和数据。
cd /usr/share/doc/zabbix-server-mysql-3.0.28/
zcat create.sql.gz |mysql -uroot -p123456 zabbix
- 编辑Zabbix_server.conf数据库配置
vi /etc/zabbix/zabbix_server.conf
[root@zabbix-server ~]# grep '^[a-Z]' /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBHost=localhost # 增加了DBHost和DBPassword
DBPassword=zabbix
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
- 启动
Zabbix Server
进程,编辑Zabbix
前端的PHP
配置,一些PHP设置已经完成了配置,但是时区没配。
- 依据所在时区,你可以取消 “date.timezone” 设置的注释,并正确配置它。在配置文件更改后,需要重启Apache Web服务器。
[root@mysql-slave ~]# vim /etc/httpd/conf.d/zabbix.conf
<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/shanghai #配置时区
</IfModule>
# 重启Apache Web服务器与Zabbix服务器。
[root@mysql-slave ~]# systemctl start zabbix-server.service
[root@mysql-slave ~]# systemctl start httpd
-
输入连接到数据库详细信息。Zabbix数据库必须已经创建好
-
连接Zabbix服务细节,如果没有改变可选择默认
-
完成安装,会在/etc/zabbix/web/zabbix.conf.php生成配置文件
-
登陆默认的用户名/密码为Admin/zabbix
-
安装完成
二、Agent客户端安装配置
Zabbix可以用Agent/Server的架构,客户端的采集方式分为Agent、SNMP等,通常情况都是使用Agent方式对服务器进行监控,也可使用其他监控方式如(SNMP、JMX、IPMI)
1. 使用yum安装zabbix-agent.
agent版本可以低于Server版
[root@ntp-server ~]$ rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
[root@ntp-server ~]$ yum makcache
[root@ntp-server ~]$ yum install -y zabbix-agent
2. zabbix-Agent配置
主动模式和被动模式
ServerActive主动模式:Agent主动x向Server端发送数据(当有很多服务器时推荐主动动模式,一般一千台以上)
Server被动模式:Server端主动向Agent采集数据。被动模式 zabbix-server的IP(Agent可以有多个IP 用于向多个Master发送数据)(一千台机器以内机器推荐使用)
[root@ntp-server ~]$ vim /etc/zabbix/zabbix_agentd.conf
...
Server=192.168.1.17 # 默认是127.0.0.1,修改为zabbix服务器ip
Hostname=ntp-server # 默认是Zabbix server,修改为本机名
//查看修改后信息
[root@ntp-server ~]$ grep ^[a-Z] /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.1.17
ServerActive=127.0.0.1
Hostname=ntp-server
Include=/etc/zabbix/zabbix_agentd.d/
[root@ntp-server ~]$