Ebook123

导航

ZABBIX5.0 安装部署

服务器版本CentOS Linux release 7.6.1810 (Core)

1.安装Zabbix仓库

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

yum clean all

yum install zabbix-server-mysql zabbix-agent  安装Zabbix服务器和代理

yum install centos-release-scl  安装Zabbix前端

编辑文件/etc/yum.repos.d/zabbix.repo并启用zabbix-frontend存储库

[zabbix-frontend]
...
enabled=1
...

yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl  安装Zabbix前端软件包

2.数据库安装: mysql5.7.28

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar

卸载服务器上自带的mabiradb 相关依赖包,否则安装mysql会失败

rpm -e mariadb-libs --nodeps \
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm \
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm \
rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm \
rpm -ivh mysql-community-embedded-5.7.28-1.el7.x86_64.rpm \
rpm -ivh mysql-community-embedded-compat-5.7.28-1.el7.x86_64.rpm \
rpm -ivh mysql-community-devel-5.7.28-1.el7.x86_64.rpm \
rpm -ivh mysql-community-embedded-devel-5.7.28-1.el7.x86_64.rpm \
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm \
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm

systemctl start mysqld

重启完成后从日志中过滤初始化mysql 密码
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p'hYLMf5?d8J3)'

修改初始化密码
set password=password('root@Yumc1');

设置数据库字符集
create database zabbix character set utf8 collate utf8_bin;

授权zabbix用户从localhost访问,并赋予对数据库完全的控制权限

grant all privileges on zabbix.* to zabbix@localhost identified by 'Yum@123!!';

刷新授权
FLUSH PRIVILEGES;

初始化并导入数据

zcat /usr/share/doc/zabbix-server-mysql-5.0.9/create.sql.gz |mysql -uzabbix -p zabbix

3.zabbix web 数据库 php nginx 配置修改

zabbix_server 配置文件修改位置

vim /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=192.168.0.123 数据库IP
DBName=zabbix  数据库名
DBUser=zabbix    数据库用户
DBPassword=Yum@123!! 数据库密码
DBPort=3306 数据库端口
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

nginx 配置文件

vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf

server_name     zabbix.example.com 192.168.0.123;

php 配置文件

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

listen.acl_users = apache,nginx

php_value[date.timezone] = Asia/Shanghai

systemctl start zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

web上出现乱码,在zabbix-server服务器上安装如下文件符集
yum install wqy-microhei-fonts

然后替换linux上默认的字符集
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
重启zabbix-server,查看乱码是否解决


将zabbix-agent 设置为开启自动启。
systemctl enable zabbix-agent.service
修改服务文件中的配置
vi /usr/lib/systemd/system/zabbix-agent.service
修改 group 和 user 为 root
重启加载所有unit单元
systemctl daemon-reload
重启zabbix服务
systemctl restart zabbix-agent.service

=====================================

如下配置是将zabbix 的web 服务http服务改为nginx服务的配置

zabbix web httpd 修改为nginx

server {
listen 80;
server_name 192.168.0.123;
root /usr/share/zabbix;
access_log /opt/log/nginx/zabbix.log;
error_log /opt/log/nginx/zabbix.error.log;
location /zabbix {
alias /usr/share/zabbix;
index index.html index.htm index.php;
}

location ~ ^/zabbix/.+\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}

posted on 2021-03-27 11:40  Ebook123  阅读(136)  评论(0编辑  收藏  举报