centos7源码方式安装zabbix-4.0
1.关闭防火墙
systemctl stop firewalld.service #临时关闭firewall
systemctl disable firewalld.service #禁止firewall开机启动
2.替换yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum clean all
3.安装依赖
yum -y install httpd
yum -y install php php-bcmath php-mbstring php-mysql php-gd php-ldap php-xml
yum install unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel gcc
yum -y install mariadb mariadb-server
4.配置php和mysql
- 配置时区
vim /etc/php.ini
date.timezone = Asia/Shanghai
- 修改ServerName 为服务器IP
vim /etc/httpd/conf/httpd.conf
- 启动
systemctl start httpd
systemctl start mariadb
# 设置开机启动
systemctl enable httpd
systemctl enable mariadb
- 创建测试页面
vim /var/www/html/index.php
<?php
phpinfo()
?>
浏览器输入:ip地址
- 初始化数据库密码
mysql_secure_installation
mysql -uroot -p
CREATE DATABASE zabbix character set utf8 collate utf8_bin;
GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'root123';
flush privileges;
quit
5.安装zabbix-server和agent
- 下载zabbix-4.0.3(可上传到/opt目录)
cd /opt
# 也可上传到/opt目录
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz
tar zxf zabbix-4.0.3.tar.gz
cd zabbix-4.0.3
- 配置web端
mkdir -p /var/www/html/zabbix
cp -a frontends/php/* /var/www/html/zabbix/
chmod -R 755 /var/www/html/zabbix/
chown -R apache:apache /var/www/html/zabbix/
- 导入数据库
mysql -uroot -p
# 执行导入
use zabbix;
source /opt/zabbix-4.0.3/database/mysql/schema.sql
source /opt/zabbix-4.0.3/database/mysql/images.sql
source /opt/zabbix-4.0.3/database/mysql/data.sql
- 创建用户和组
group add zabbix
groupadd zabbix
useradd -g zabbix -m -s /sbin/nologin zabbix
- 编译&安装
./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
make && make install
chmod -R 755 /var/www/html/zabbix/
chown -R zabbix:zabbix /usr/local/zabbix/
cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
sed -i "s/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix\//g" /etc/init.d/zabbix_server
sed -i "s/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix\//g" /etc/init.d/zabbix_agentd
- 修改配置
vim /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DebugLevel=3
DBName=zabbix
DBUser=zabbix
DBPassword=XXXX
DBPort=3306
vim /usr/local/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=vm176
- 启动
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
- 停止
/etc/init.d/zabbix_server stop
/etc/init.d/zabbix_agentd stop
- 查看日志
tail -f /tmp/zabbix_server.log
tail -f /tmp/zabbix_agentd.log
6.配置web页面
浏览器输入:ip/zabbix
- 登录
默认账号:Admin
默认密码:zabbix
-
设置中文语言
Administrator-Users-点击用户Admin-语言中设置