centos7 编译安装zabbix4.0
环境介绍系统:Centos7.4运行环境:LAMP(yum 安装)zabbix版本:zabbix-4.0.3.tar.gz开始安装环境准备# 永久关闭selinux[root@localhost ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config临时关闭[root@loc...
·
环境介绍
系统:Centos7.4
运行环境:LAMP(yum 安装)
zabbix版本:zabbix-4.0.3.tar.gz
开始安装
环境准备
# 永久关闭selinux
[root@localhost ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
临时关闭
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
# 关闭firewalld
[root@localhost ~]# systemctl stop firewalld;systemctl disable firewalld
安装依赖包
#安装Apache
[root@localhost ~]# yum -y install httpd
#安装php及扩展
[root@localhost ~]# yum -y install php php-bcmath php-mbstring php-mysql php-gd php-ldap php-xml
#安装依赖库
[root@localhost ~]# yum install unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel gcc
#安装mariadb
[root@localhost ~]# yum -y install mariadb mariadb-server
修改Apache,PHP配置文件
vim /etc/php.ini
date.timezone = Asia/Shanghai
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
always_populate_raw_post_data = -1
vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DocumentRoot "/var/www/html/zabbix"
# 创建对应文件夹
mkdir -p /var/www/html/zabbix
启动服务
[root@localhost ~]# systemctl start httpd;systemctl start mariadb
[root@localhost ~]# systemctl enable httpd;systemctl enable mariadb
编写测试页测试
vim /var/www/html/zabbix/index.php
<?php
phpinfo();
?>
出现如下界面表示成功
初始化Mariadb
# 初始化root 密码 其他默认按回车即可
[root@localhost ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
配置Mariadb
[root@localhost ~]# mysql -uroot -pxxxxx //输入自己的密码
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin; //创建zabbix库
MariaDB [(none)]> GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY '123456'; //建立zabbix用户并授予zabbix库所有权限
MariaDB [(none)]> flush privileges; //刷新权限
解压zabbix
#解压
[root@localhost ~]# tar zxf zabbix-4.0.3.tar.gz
[root@localhost ~]# cd zabbix-4.0.3
导入数据
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> source /root/zabbix-4.0.3/database/mysql/schema.sql
MariaDB [zabbix]> source /root/zabbix-4.0.3/database/mysql/images.sql
MariaDB [zabbix]> source /root/zabbix-4.0.3/database/mysql/data.sql //注意要按照顺序导入
Web前端代码复制
[root@localhost zabbix-4.0.3]# pwd
/root/zabbix-4.0.3
[root@localhost zabbix-4.0.3]# cp -a frontends/php/* /var/www/html/zabbix/
[root@localhost zabbix-4.0.3]# chmod -R 755 /var/www/html/zabbix/ //赋予执行权限
# 修改web家目录所有者为apache
[root@localhost zabbix-4.0.3]# chown -R apache:apache /var/www/html/zabbix/
编译安装zabbix
#创建zabbix用户,组
[root@localhost zabbix-4.0.3]# groupadd zabbix
[root@localhost zabbix-4.0.3]# useradd -g zabbix -m -s /sbin/nologin zabbix
[root@localhost zabbix-4.0.3]# ./configure --prefix=/usr/local/zabbix --sysconfdir=/usr/local/zabbix/etc/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2 --with-mysqli
# 出现如下信息表示编译成功
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
[root@localhost zabbix-4.0.3]# make && make install
修改zabbix配置文件
# 修改zabbix目录所有者为zabbix
[root@localhost zabbix-4.0.3]# chown -R zabbix:zabbix /usr/local/zabbix/
#配置启动脚本
[root@localhost zabbix-4.0.3]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
[root@localhost zabbix-4.0.3]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
[root@localhost zabbix-4.0.3]# sed -i "s/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix\//g" /etc/init.d/zabbix_server
[root@localhost zabbix-4.0.3]# sed -i "s/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix\//g" /etc/init.d/zabbix_agentd
# 修改server配置文件
[root@localhost zabbix-4.0.3]# vim /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DebugLevel=3
DBName=zabbix
DBUser=zabbix
DBPassword=wlwx2019
DBPort=3306
StartPollers=10
StartTrappers=80
StartPingers=20
StartDiscoverers=15
StartTimers=5
HousekeepingFrequency=1
MaxHousekeeperDelete=500
CacheSize=128M
CacheUpdateFrequency=75
StartDBSyncers=10
HistoryCacheSize=32M
HistoryIndexCacheSize=16M
ValueCacheSize=32M
Timeout=30
UnreachablePeriod=120
LogSlowQueries=3000
[root@localhost zabbix-4.0.3]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=192.168.111.112
ServerActive=192.168.111.112
Hostname=Zabbix_server
启动zabbix服务
[root@localhost zabbix-4.0.3]# /etc/init.d/zabbix_server start;/etc/init.d/zabbix_agentd start
#启动过程中可查看日志是否成功
[root@localhost zabbix-4.0.3]# tail -f /tmp/zabbix_server.log
35177:20190626:014139.823 server #24 started [trapper #2]
35178:20190626:014139.824 server #25 started [trapper #3]
35190:20190626:014139.834 server #32 started [preprocessing worker #2]
35191:20190626:014139.846 server #33 started [preprocessing worker #3]
35189:20190626:014139.846 server #31 started [preprocessing worker #1]
访问zabbix界面配置
浏览器输入IP回车
出现如下界面后点击下一步
确认所有php需求都通过点击下一步
填写正确数据库信息后下一步
填写正确zabbix server 信息后下一步
确认无误后下一步
登录
默认账号:Admin
默认密码:zabbix
到此zabbix4.0部署完成如对其他监控配置等有兴趣的朋友可以参阅我前面写的两篇文档。
更多推荐
已为社区贡献1条内容
所有评论(0)