1.关闭防火墙并关闭开机启动:
systemctl stop firewalld.service
systemctl disable firewalld.service
2.关闭SELinux安全机制(为避免出现不必要麻烦):
1.临时关闭:
setenforce 0 ##(设置SELinux 成为permissive模式)
##(setenforce 1 设置SELinux 成为enforcing模式)
2.永久关闭(修改配置文件需要重启机器):
修改/etc/selinux/config
文件将SELINUX=enforcing改为SELINUX=disabled
重启机器即可
3.搭建zabbix所需要的lamp环境。
首先将YUM源更新到最新,我这边更换到阿里云:
1.备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.下载新的CentOS-Base.repo 到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3.运行yum makecache生成缓存
在开始安装之前,还需要说明下centos7自带的mysql是mariadb,我们可以通过如下命令查看:
yum search mysql|tac
LAMP环境的安装:
yum -y install mariadb mariadb-server php php-mysql httpd
4.配置数据库
将mariadb加入开机启动,并启动。
systemctl enable mariadb
systemctl start mariadb
初始化mysql数据库,并配置root用户密码。
mysql_secure_installation
数据库初始化
mysql初始化完毕后,创建zabbix数据库及其用户,使用如下命令:
mysql -uroot -proot -e "create database zabbix default character set utf8 collate utf8_bin;"
mysql -uroot -proot -e "grant all on zabbix.* to 'zabbix'@'%' identified by 'zabbix';"
现在来测试刚刚创建的zabbix用户,是否可以连接mysql数据库,如下:
mysql -uzabbix -pzabbix
show databases;
5.将apache加入开机启动,并启动,以及开放80端口:
systemctl enable httpd
systemctl start httpd
6.安装zabbix server
导入YUM源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
安装zabbix:
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
安装完成后导入zabbix数据结构:
cd /usr/share/doc/zabbix-server-mysql-3.2.2
zcat create.sql.gz | mysql -uroot -proot zabbix
数据库导入完成以后,修改zabbix server配置文件:
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
然后修改PHP的zabbix配置文件:
修改时区参数即可
vi /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 always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</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>
将zabbix server加入开机启动,并启动:
systemctl enable zabbix-server
systemctl start zabbix-server
7.重启apache:
systemctl restart httpd
8.打开浏览器访问zabbix,地址:
访问地址如果需要修改的话,可以在zabbix.conf文件中修改 Alias 参数:
vi /etc/httpd/conf.d/zabbix.conf
出现以上页面即可正常登陆,默认超级管理员登陆账户:Admin 密码:zabbix
9.客户端zabbix-agent安装(centos7):
导入YUM源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
YUM安装zabbix-agent
yum -y install zabbix-agent
修改zabbix-agent配置文件;
zabbix agent的配置很简单,只需要修改zabbix agent配置文件中的Server、ServerActive和Hostname这三项即可。
其中Server、ServerActive是zabbix server服务器的IP地址,Hostname是被监控端的IP地址,如下:
[root@zabbix163 ~]# cat /etc/zabbix/zabbix_agentd.conf |grep -v '^#'|grep -v '^$'
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.1.162
ServerActive=192.168.1.162
Hostname=192.168.1.163
Include=/etc/zabbix/zabbix_agentd.d/*.conf
将zabbix-agent设置开机启动,并启动。
systemctl enable zabbix-agent
systemctl start zabbix-agent
在zabbix web中添加主机,注意主机名称要和配置文件中的hostname一样。
如图即为正常。
参考地址:
http://blog.csdn.net/reblue520/article/details/52136850
https://www.zabbix.com/documentation/3.2/manual/installation