CentOS7 Zabbix5.0 分布安装

CentOS7 Zabbix5.0 分布安装

Acha
2021-10-07 / 0 评论 / 208 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年10月07日,已超过1172天没有更新,若内容或图片失效,请留言反馈。

zabbix5.0 分布安装

环境规划
主机名 IP 环境
zabbix-server 10.35.172.76 zabbix-server、zabbix-agent
zabbix-web 10.35.172.77 nginx、php7.2
zabbix-db 10.35.172.78 mysql5.7
zabbix-db
# 安装 MySQL5.7 Yum 源
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 检查 Yum 源
ls /etc/yum.repos.d/
yum repolist enabled | grep mysql
# 安装 & 启动 MySQL
yum install mysql-community-server -y
systemctl start mysqld && systemctl enable mysqld
# 修改root密码, 创建zabbix数据库及用户并授权,刷新权限
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -pds,GLkvre7fG
mysql> ALTER USER root@localhost IDENTIFIED BY 'P@ssw0rd';
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user 'zabbix'@'%' identified by 'P@ssw0rd';
mysql> grant all privileges on zabbix.* to 'zabbix'@'%';
mysql> flush privileges;
# 导入数据(create.sql.gz由zabbix-server主机拷贝)
zcat create.sql.gz | mysql -uzabbix -pP@ssw0rd zabbix
zabbix-web
# 安装 PHP7 Yum 源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# 安装 php7.2 及相关插件
yum install php72w-fpm  php72w-gd.x86_64 php72w-bcmath.x86_64 php72w-xml.x86_64 php72w-mbstring.x86_64 php72w-ldap.x86_64 php72w-mysqlnd.x86_64  -y
# 检查 php版本
php-fpm -v
# 安装 Nginx
yum install nginx -y
# 生成 Nginx 模板文件
grep -Ev "#|^$" /etc/nginx/nginx.conf.default > /etc/nginx/nginx.conf
# cp php 相关片段
vim /etc/nginx/nginx.conf.default 
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}
# 修改配置文件
vim /etc/nginx/nginx.conf
    # 修改 root 目录 index
    # 删除 error 模块
    # 添加 php相关片段
# 创建 Nginx 网页目录
mkdir /html
# 检查 Nginx 语法
nginx -t
# 启动 Nginx & php
systemctl start nginx && systemctl enable nginx
systemctl start php-fpm && systemctl enable php-fpm
# 下载 Zabbix 软件包
wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.16.tar.gz
# 解压 & cp 前端文件 到 网页目录
tar xf zabbix-5.0.16.tar.gz 
cp -a /root/zabbix-5.0.16/ui/* /html
# 目录授权
chown -R nginx:nginx /html
# 创建 session 目录,并授权
mkdir /var/lib/php/session
chown -R nginx:nginx /var/lib/php/session
# 修改 php.ini 配置文件
vim /etc/php.ini 
    # max_execution_time = 300
    # max_input_time = 300
    # post_max_size = 16M
    # date.timezone = Asia/Shanghai
# 重启生效配置文件
systemctl restart php-fpm
# 上传字体文件,并替换
cd /html/assets/fonts
mv simhei.ttf DejaVuSans.ttf 
zabbix-server
# 安装 Zabbix Yum源
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# 替换 Yum仓库
sed -i 's#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo
# 安装 zabbix-server
yum install zabbix-server-mysql -y
# 将 create.sql.gz 拷贝至 zabbix-db
scp  /usr/share/doc/zabbix-server-mysql-5.0.16/create.sql.gz 10.35.172.78:/root
# 配置 zabbix-server 中的 DB
vim /etc/zabbix/zabbix_server.conf
    # DBHost=localhost
    # DBName=zabbix
    # DBUser=zabbix
    # DBPassword=123456
# 启动 Zabbix-server
systemctl start zabbix-server && systemctl enable zabbix-server 
# 安装 net-tools,检查 服务端口
yum install -y net-tools
netstat -lntp
# 安装 & 启动 zabbix-agent
yum install -y zabbix-agent
systemctl start zabbix-agent && systemctl enable zabbix-agent
访问 10.35.172.77 配置使用 zabix
0

评论

博主关闭了当前页面的评论