```一、系统环境
日志输出
1.1 zabbix版本
3.0 LTS 稳定版
rpm -i http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
4.0 LTS 正式版
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
pre-4.0版
rpm -i http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
查看系统版本
cat /etc/redhat-release
关闭防火墙及selinux
systemctl stop firewalld
查看防火墙状态并关闭开机自启
systemctl status firewalld
systemctl disable firewalld
查看开机是否启动防火墙服务
systemctl is-enabled firewalld
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
此项生效需重启机器
vi /etc/selinux/config
二、数据库安装及配置
1.配置yum源
# 先安装wget
yum install wget -y
2.下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
3.安装数据库
yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
4.检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server -y
启动MySQL服务
systemctl start mysqld
查看MySQL的启动状态
systemctl status mysqld
5.设置开机启动
systemctl enable mysqld
systemctl daemon-reload
三.zabbix server端的配置
1.安装MySQL数据库与知识库
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
2.安装Zabbix服务器、前端、代理
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
3.编辑 /etc/httpd/conf.d/zabbix
vi /etc/httpd/conf.d/zabbix.conf
注释去掉时间改为上海
Asia/Shanghai
4.重启httpd
systemctl restart httpd
5.修改数据库修改root默认密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。
查看默认密码
grep 'temporary password' /var/log/mysqld.log
其中 jIDqgfoE-2KZ 就是我的默认密码
登陆数据库
mysql -uroot -p
修改默认密码
mysql> SET PASSWORD = PASSWORD('Lenovo@123');
Lenvoo@123是你的新密码
****************************************************************************************************************************
如何解决ERROR 1819 (HY000): Your password does not satisfy the current policy requirements呢? 这里直接提供解决方案文末有详细的说明
必须修改两个全局参数:
首先,修改validate_password_policy参数的值
set global validate_password_policy=0;
再修改密码的长度
set global validate_password_length=1;
再次执行修改密码就可以了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lenovo@123';
***********允许root远程登陆**********
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Lenovo@123' WITH GRANT OPTION;
6.创建MySQL 数据库和用户
mysql –uroot –p
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
切换到zabbix数据库
use zabbix
7.导入模板数据
source /usr/share/doc/zabbix-server-mysql-3.4.7/create/schema.sql
source /usr/share/doc/zabbix-server-mysql-3.4.7/create/images.sql
source /usr/share/doc/zabbix-server-mysql-3.4.7/create/data.sql
或者
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
gzip -d create.sql.gz
8.配置Zabbix server
编辑文件/etc/zabbix/zabbix_server.conf
vi /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
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
CacheSize=1024M
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
可选不配置
9.配置zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
#配置zabbix server 的ip
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.0.166
ListenPort=10050
ServerActive=192.168.0.166
Hostname=192.168.0.166
Include=/etc/zabbix/zabbix_agentd.d/
10.改PHP 设置
修改php.ini为zabbix 建议的设置
编辑文件 php.ini
vi /etc/php.ini
#设置为以下参数
max_execution_time = 600
max_input_time = 600
memory_limit = 256
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Shanghai
11.修改Firewall 和SELinux 设置
a. 开放zabbix端口10050 and 10051. (防火墙关闭可忽略)
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
b. 重启firewall
c. 如果使用 SELinux, 运行以下命令使 Apache 可以和 Zabbix通信
setsebool -P httpd_can_connect_zabbix=1
d.启动zabbix-server 和zabbix-agent。重启httpd,,并设置zabbix-server和zabbix-agent开机自动启动
systemctl start zabbix-server
systemctl enable zabbix-server
systemctl start zabbix-agent
systemctl enable zabbix-agent
systemctl restart httpd
systemctl enable httpd
systemctl restart mysqld
systemctl enable mysqld
四.zabbix web首次登陆
输入
http://zabbi地址/zabbix
http://192.168.0.166/zabbix
密码是之前设置的zabbix
名字随意 可不写
默认的用户是admin
转载于:https://blog.51cto.com/11485155/2377066