env --> CentOS Linux release 7.9.2009 (Core) mininal install
1 Install Zabbix repository
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
2 Install Zabbix server and agent
yum -y install zabbix-server-mysql zabbix-agent
3 Install Zabbix frontend (5.0版本要求高版本的php)
3.1 enable zabbix-frontend repository
yum install centos-release-scl -y
sed -i 11cenabled=1 /etc/yum.repos.d/zabbix.repo
3.2 Install Zabbix frontend packages
yum -y install zabbix-web-mysql-scl zabbix-nginx-conf-scl
4 初始化数据库
docker run -d --name=mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /data/mysql:/var/lib/mysql --restart=always mysql:5.7.34
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@‘192.168.1.%’ identified by ‘123456’;
grant all privileges on zabbix.* to zabbix@‘192.168.1.%’;
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -h192.168.1.113 -p zabbix
5 为Zabbix server配置数据库
sed -i.bak /#\ DBPassword=/aDBPassword=123456 /etc/zabbix/zabbix_server.conf
cat > /etc/zabbix/zabbix_server.conf << eof
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=192.168.1.113
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
eof
6 为Zabbix前端配置PHP
sed -i.bak /;date.timezone\ =/adate.timezone=Asia/Shanghai /etc/opt/rh/rh-php72/php.ini
6.1配置nginx server
sed -n 1,3p /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name 192.168.1.113;
6.2 配置php用户与时区
sed -i.bak /listen.acl_users/c’listen.acl_users = apache,nginx’ /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
echo ‘php_value[date.timezone] = Asia/Shanghai’ >> /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
cat /etc/zabbix/web/zabbix.conf.php
7 启动Zabbix server和agent进程
systemctl enable --now zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
8 连接Zabbix前端 Admin@zabbix
http://192.168.1.113
zabbix-server相关优化
- 字体汉化
对于以上环境和场景的安装,zabbix的汉化仍然会有乱码现象,重新载入自定义字体
#1. 上传字体
Windows控制面板 – 字体 – simkai.ttf字体 – 上simkai.ttf传字体到 /usr/share/fonts/dejavu/目录中
cat /var/lib/alternatives/zabbix-web-font
#2. 重新连接字体
ln -sf /usr/share/fonts/dejavu/simkai.ttf /etc/alternatives/zabbix-web-font
#3. 验证
image
安装zabbix agent
使用二进制包安装
下载与解压包
wget https://www.zabbix.com/cn/download_agents?version=5.0+LTS&release=5.0.12&os=Linux&os_version=3.0&hardware=amd64&encryption=No+encryption&packaging=Archive&show_legacy=0 -P /tmp
mkdir /usr/local/zabbix-agent
tar -xf zabbix_agent-5.0.12-linux-3.0-amd64-static.tar.gz -C /usr/local/zabbix-agent
useradd zabbix -s /sbin/nologin
配置
cat > /usr/local/zabbix-agent/conf/zabbix_agentd.conf << eof
Passive checks related #被动检查相关配置
Server=192.168.1.113 #指向当前zabbix server
Option: ListenPort
#ListenPort=10050 #监听端口
Option: StartAgents
StartAgents=3 #被动状态时默认启动的实例数(进程数),为0不监听任何端口
Option: Hostname
Hostname=192.168.1.103 #区分大小写且在zabbix server唯一的值
LogFile=/tmp/zabbix_agentd.log
PidFile=/tmp/zabbix_agentd.pid
eof
启动
echo ‘/usr/local/zabbix-agent/sbin/zabbix_agentd -c /usr/local/zabbix-agent/conf/zabbix_agentd.conf’ >> /etc/rc.local
. /etc/rc.local
server添加主机
配置 – 主机 – 添加主机 – 模板关联
使用包安装
https://repo.zabbix.com/zabbix/
yum -y install https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-agent-5.0.12-1.el7.x86_64.rpm
cat > /etc/zabbix/zabbix_agentd.conf << eof
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.1.113
ServerActive=192.168.1.113
Hostname=192.168.1.107
Include=/etc/zabbix/zabbix_agentd.d/*.conf
eof
systemctl enable --now zabbix-agent
USB Microphone https://www.soft-voice.com/
Wooden Speakers https://www.zeshuiplatform.com/
亚马逊测评 www.yisuping.cn
深圳网站建设www.sz886.com