zabbix4.0安装和配置
以下为master端安装,开始
内核
$ cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
$ uname -r
3.10.0-693.el7.x86_64
IP划分
master 192.168.1.122
client 192.168.1.123
关闭iptables和selinux
iptables -F
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
vim /etc/selinux/config
SELINUX=disabled
安装和配置Zabbix服务器
获取zabbix源
# https://www.zabbix.com/download?zabbix=4.0&os_distribution=centos&os_version=7&db=MySQL
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
安装和配置数据库(centos7带的是mariadb)
yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
mysqladmin -uroot password '123456'
vim /etc/my.cnf
[mysqld]
character-set-server = utf8
init-connect = 'SET NAMES utf8'
collation-server = utf8_general_ci
systemctl restart mariadb
mysql -uroot -p123456 #此时就能登录进去mysql中
create database zabbix character set utf8;
grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by '123456';
grant all privileges on zabbix.* to 'zabbix'@'%' identified by '123456';
exit #退出数据库
安装Zabbix服务器,前端和代理
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
初始架构和导入数据(系统会提示输入上面定义的登录mysql的密码)
zcat /usr/share/doc/zabbix-server-mysql-4.0.1/create.sql.gz |mysql -uroot -p zabbix #这个zabbix指数据库名
提示信息:Enter password:
为Zabbix服务器配置数据库
vim /etc/zabbix/zabbix_server.conf
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 #登录数据库的zabbix用户的密码
启动zabbix
service zabbix-server start
service zabbix-agent start
systemctl enable zabbix-server
systemctl enable zabbix-agent
chkconfig --level 2345 zabbix-server on
chkconfig --level 2345 zabbix-agent on
Zabbix前端配置
vim /etc/httpd/conf.d/zabbix.conf
........... 略去部分 .............
<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/Shanghai #该行取消注释并修改为亚洲时区
</IfModule>
</Directory>
........... 略去部分 .............
########################################################################
重启前的坑:
注:由于我的机器上有nginx、mysql等,装时遇到的问题都会在这里列出
页面输入IP+prot/zabbix时不能访问,在/var/og/httpd/error_log得到的信息是
PHP Warning: require_once(/etc/zabbix/web/maintenance.inc.php): failed to open stream: Permission denied in /usr/share/zabbix/include/classes/core/ZBase.php on line 276
明显这是权限方面的问题,解决方法如下:
chown -R apache.apache /etc/zabbix/web/
#有时 /etc/zabbix/web/ 目录下的所有文件会为root,之所以这样说是我第一次在虚机上装的时候不用管权限这一步,在服务器上装的时候就出现权限方面的问题
然后再往下按照本文命令执行.....
########################################################################
启动httpd
service httpd start
访问zabbix
http://192.168.1.122/zabbix/setup.php
Next step-->检查给选项是否正确,如都没问题点Next step-->Password输入zabbix登录mysql时的密码-->Next step-->Next step-->Finish
初始账号和密码:Admin/zabbix
以上为master端安装,完毕
====================================================================================
以下为client端安装,开始
关闭iptables和selinux
iptables -F
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
vim /etc/selinux/config
SELINUX=disabled
安装agent
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
yum -y install zabbix-agent zabbix-sender zabbix-get
vim /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.122 #服务端的IP
ServerActive=192.168.1.122 #服务端的IP
Hostname=Zabbix server #该名称为在服务端添加主机时的名字,需要注意
启动agent端的服务
systemctl restart zabbix-agent.service
以上为client端安装,完毕
====================================================================================
WEB端添加主机
欢迎加入QQ群一起讨论Linux、开源等技术