Zabbix / 监控平台

Zabbix 4.4安装部署

浅时光 · 2月17日 · 2020年 10922次已读

一、环境准备

环境描述

  • PHP:72
  • Nginx 1.16
  • MySQL 8.0
  • Zabbix 4.4

1.1:设置阿里镜像源

[[email protected]zabbix-server ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

[[email protected]zabbix-server ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[[email protected] ~]# yum install epel-release

1.2:关闭SELINUX

[[email protected] ~]# sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 
[[email protected] ~]# setenforce 0
[[email protected] ~]# getenforce 
Permissive

1.3:安装常用软件

[[email protected] ~]# yum -y install bash-completion
[[email protected] ~]# yum -y install bash-completion-extras
[[email protected] ~]# yum -y install vim net-tools wget gcc gcc-devel lrzsz ntp make patch openssl openssl-devel libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed libtool zlib zlib-devel pcre pcre-devel

1.4:同步互联网时间

[[email protected] ~]# cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

[[email protected] ~]# ntpdate time1.aliyun.com
[[email protected] ~]# echo "*/5 * * * *  ntpdate time1.aliyun.com &> /dev/null && hwclock -w" >> /var/spool/cron/root

[[email protected] ~]# systemctl  restart crond

1.5:放通zabbix监听端口

#放开端口
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=10050/tcp
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=10051/tcp

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp

#使其规则生效
[[email protected] ~]# firewall-cmd --reload
 
#查看端口是否放开
[[email protected] ~]# firewall-cmd --list-port
10050/tcp 10051/tcp 80/tcp

二、部署Nginx

2.1:安装

文章来源(Source):https://www.dqzboy.com
  • 使用RPM包进行安装
[[email protected] ~]# mkdir /soft
[[email protected] ~]# cd /soft/
[[email protected] soft]# wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.16.1-1.el7.ngx.x86_64.rpm

[[email protected] soft]# rpm -ivh nginx-1.16.1-1.el7.ngx.x86_64.rpm

[[email protected] ~]# nginx -v
nginx version: nginx/1.16.1

2.2:启动

[[email protected] ~]# systemctl start nginx
[[email protected] ~]# systemctl enable nginx
[[email protected] ~]# systemctl status nginx

2.3:访问

Zabbix 4.4安装部署-浅时光博客

三、部署MySQL

  • 安装新版MySQL8.0版本
文章来源(Source):https://www.dqzboy.com

3.1:下载YUM源

[[email protected] ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

3.2:安装YUM源

[[email protected] ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm

3.3:安装 MySQL 服务端

# 查看 mysql server
[[email protected] ~]# yum repolist enabled | grep "mysql.*-community.*"
[[email protected] ~]# yum repolist all | grep mysql

# 安装
[[email protected] ~]# yum install mysql-community-server

3.4:启动 mysql文章来源(Source):https://www.dqzboy.com 服务

[[email protected] ~]# systemctl start mysqld.service
[[email protected] ~]# systemctl enable mysqld.service
[[email protected] ~]# systemctl status mysqld.service

3.5:数据库密码配置

3.5.1:查看登陆密码

[[email protected] ~]# cat /var/log/mysqld.log | grep 'password'

3.5.2:登陆

[[email protected] ~]# mysql -uroot -p
  • 到这里 MySQL 就完全安装完成了

3.5.3:重置密码

# 密码验证策略低要求
mysql> set global validate_password.policy=0; (0或LOW代表低级)

# 密码至少要包含的小写字母个数和大写字母个数
mysql> set global validate_password.mixed_case_count=0;

# 密码至少要包含的数字个数。
mysql> set global validate_password.number_count=0; 

# 密码至少要包含的特殊字符数
mysql> set global validate_password.special_char_count=0; 

# 密码长度
mysql> set global validate_password.length=4;  #8.0最小长度为4

# 再次设置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'dqz123';

3.6:创建用户和数据库

# 创建数据库
[[email protected] ~]# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;

# 创建zabbix账号;MySQL8.0的账号身份验证和MySQL5.7不同
mysql> create user [email protected] identified with mysql_native_password by 'dqz123';

# 授权
mysql> grant all privileges on zabbix.* to [email protected];

四、部署PHP

4.1:安装

[[email protected] ~]# yum install epel-release
[[email protected] ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

[[email protected] ~]# yum install php72w-fpm php72w-opcache

4.2:配置

[[email protected] ~]# vim /etc/php.ini
368 max_execution_time = 300	//默认30,Zabbix要求为300
378 max_input_time = 300		//默认60
385 max_input_vars = 10000	//去除注释,默认1000改为10000
389 memory_limit = 128M		//内存限制
656 post_max_size = 16M		//默认8M改为16M
877 date.timezone = Asia/Shanghai   //去除注释,默认空,更为为上海时区

# 修改用户
[[email protected] ~]# vim /etc/php-fpm.d/www.conf
8 user = nginx
10 group = nginx

[[email protected] ~]# chown -R nginx. /var/lib/php

4.3:启动

[[email protected] ~]# systemctl start php-fpm
[[email protected] ~]# systemctl enable php-fpm

五、安装Za文章来源(Source):https://www.dqzboy.combbix-server

5.1:添加Zabbix镜像源

[[email protected] ~]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
[[email protected] ~]# yum clean all
  • 注:安装时有可能被墙导致安装失败,可替换官方源地址,将官方地址改为清华源的地址
[[email protected] ~]# vim /etc/yum.repos.d/zabbix.repo
# 末行模式输入以下进行替换
:%s#http://repo.zabbix.com/zabbix/4.4/rhel/7/#https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/7/#g

5.2:文章来源(Source):https://www.dqzboy.com安装zabbi文章来源(Source):https://www.dqzboy.comx-server

#安装服务端,前端,和agent
[[email protected] ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-nginx-conf

5.3:配置zabbix数据库

#导入数据
[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:	//zabbix用户密码

#编辑配置文件
[[email protected] ~]# vim  /etc/zabbix/zabbix_server.conf
91 DBHost=localhost    //去除注释
100 DBName=zabbix		//数据库名称
116 DBUser=zabbix		//用户
124 DBPassword=123456	//去除注释,输入数据库用户zabbix的密码

# 以下解决报警:Zabbix discoverer processes more than 75% busy问题
189 StartPollers=12  //去除注释,增加初始化进程,默认5
244 StartDiscoverers=5  //去除注释,增加discovery进程数量,默认1

5.4:启动Zabbix Server

文章来源(Source):https://www.dqzboy.com
[[email protected] ~]# systemctl  start zabbix-server.service
[[email protected] ~]# systemctl  enable zabbix-server.service
[[email protected] ~]# systemctl  status zabbix-server.service

5.5:检查日志是否有报错

[[email protected] ~]# more /var/log/zabbix/zabbix_server.log

5.6:配置zabbix-web文章来源(Source):https://www.dqzboy.com

  • 将nginx默认调用的外部配置文件重命名,这样就直接调用zabbix的配置文件了
[[email protected] ~]# cd /etc/nginx/conf.d/
[[email protected] conf.d]# mv default.conf{,_bak}
  • zabbix.conf配置文件内容如下
server {
#        listen          80;
#        server_name     example.com;

        root    /usr/share/zabbix;

        index   index.php;

        location = /favicon.ico {
                log_not_found   off;
        }

        location / {
                try_files       $uri $uri/ =404;
        }

        location /assets {
                access_log      off;
                expires         10d;
        }

        location ~ /\.ht {
                deny            all;
        }

        location ~ /(api\/|conf[^\.]|include|locale) {
                deny            all;
                return          404;
        }

        location ~ [^/]\.php(/|$) {
                fastcgi_pass    unix:/run/php-fpm/zabbix.sock;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_index   index.php;

                fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix;
                fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
                fastcgi_param   PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;

                include fastcgi_params;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;

                fastcgi_intercept_errors        on;
                fastcgi_ignore_client_abort     off;
                fastcgi_connect_timeout         60;
                fastcgi_send_timeout            180;
                fastcgi_read_timeout            180;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 256k;
                fastcgi_busy_buffers_size       256k;
                fastcgi_temp_file_write_size    256k;
        }
}

5.7:重新启动服务

[[email protected] ~]# systemctl restart zabbix-server zabbix-agent nginx php-fpm
[[email protected] ~]# systemctl enable zabbix-server zabbix-agent nginx php-fpm

5.8:访问页面

Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客

六、zabbix页面配置

6.1:前端设置

Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客
  • 文章来源(Source):https://www.dqzboy.com认登入用户密码:Admin/zabbix
Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客

6.2:设置中文显示文章来源(Source):https://www.dqzboy.com

Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客
Zabbix 4.4安装部署-浅时光博客
0 条回应
    本站已安全运行: | 耗时 0.407 秒 | 查询 109 次 | 内存 20.01 MB