Zabbix 5.0基于Nginx安装方法

Zabbix 5.0基于Nginx安装方法

文章目录

  • Zabbix 5.0基于Nginx安装方法
    • 1.前期准备
    • 2.安装部署服务端zabbix-server
    • 3.安装数据库
    • 4.配置zabbix-server
    • 5在浏览器访问ip
    • 6.转化为中文
    • 7.zabbix-agent2

1.前期准备

1.系统:用centos7系统
[root@zabbix-server ~] cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)
web应运:Nginx
PHP:7.2版本
mariadb

2.关机防火墙、selinux
[root@zabbix-server ~]# setenforce 0
setenforce: SELinux is disabled
[root@zabbix-server ~]# vim /etc/selinux/config
SELINUX=disabled
[root@zabbix-server ~]# systemctl stop firewalld
[root@zabbix-server ~]# systemctl disable firewalld

2.安装部署服务端zabbix-server

官方yum源地址:https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/

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

2.查看yum源
[root@zabbix-server ~]# yum repolist

3.查看zabbix都有哪些版本
[root@zabbix-server ~]# yum list zabbix*

4.安装服务端和客户端zabbix-server-mysql  zabbix-agent
[root@zabbix-server ~]# yum install zabbix-server-mysql zabbix-agent -y

5.安装scl依赖
[root@zabbix-server ~]# yum install centos-release-scl -y

6.修改zabbix源,安装其他组件
[root@zabbix-server ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
将0修改为1
enabled=1

7.安装前端组件
[root@zabbix-server ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y

 

3.安装数据库

1.安装mariadb数据库
[root@zabbix-server ~]# yum install mariadb-server -y

2.启动数据库
[root@zabbix-server ~]# systemctl start mariadb
[root@zabbix-server ~]# systemctl enable mariadb

3.进入数据库,创建数据库,授权用户,数据库默认没有密码
[root@zabbix-server ~]# mysql
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [zabbix]> exit

4.查看zabbix-server都安装了什么
[root@zabbix-server ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-5.0.19
/usr/share/doc/zabbix-server-mysql-5.0.19/AUTHORS
/usr/share/doc/zabbix-server-mysql-5.0.19/COPYING
/usr/share/doc/zabbix-server-mysql-5.0.19/ChangeLog
/usr/share/doc/zabbix-server-mysql-5.0.19/NEWS
/usr/share/doc/zabbix-server-mysql-5.0.19/README
/usr/share/doc/zabbix-server-mysql-5.0.19/create.sql.gz  #数据库的数据
/usr/share/doc/zabbix-server-mysql-5.0.19/double.sql
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix

[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.19/create.sql.gz >zabbix.sql
#修改一下数据库文件,最前面加一行
vim zabbix.sql
USE zabbix;
#导入数据库
[root@zabbix-server ~]# mysql < zabbix.sql
#进入数据库查看表
mysql
use zabbix;
show tables;  #总共有166张表

 

4.配置zabbix-server

1.配置服务端zabbix-server
[root@zabbix-server ~]# egrep '^#|^$' -v /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
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix   #修改数据库密码为zabbix
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

2.配置php
#修改php的时区,修改第6行和最后一行
[root@zabbix-server ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
listen.acl_users = apache,nginx
php_value[date.timezone] = Asia/Shanghai

#配置nginx
[root@zabbix-server ~]# vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
       listen          80;
       server_name     localhost; #此处有域名就写域名
 
#为了避免冲突,注释掉下面配置
[root@zabbix-server ~]# vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf
#    server {
#        listen       80 default_server;
#        listen       [::]:80 default_server;
#        server_name  _;
#        root         /opt/rh/rh-nginx116/root/usr/share/nginx/html;
#
#        # Load configuration files for the default server block.
#        include      /etc/opt/rh/rh-nginx116/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#        location = /40x.html {
#        }
#
#        error_page 500 502 503 504  /50x.html;
#        location = /50x.html {
#        }
#
#        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#        #
#        #location ~ \.php$ {
#        #    proxy_pass   http://127.0.0.1;
#        #}
#
#        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#        #
#        #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;
#        #}

#启动服务
[root@zabbix-server ~]# systemctl start zabbix-server.service rh-php72-php-fpm.service rh-nginx116-nginx.service

#查看启动端口
PHP:9000
mariadb:3306
nginx:80
zabbix-server:10051
[root@zabbix-server ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1322/master         
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      5006/zabbix_server  
tcp        0      0 0.0.0.0:10181           0.0.0.0:*               LISTEN      1204/sshd           
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      4522/php-fpm: maste 
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      4952/mysqld         
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      910/rpcbind         
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4549/nginx: master  
tcp6       0      0 ::1:25                  :::*                    LISTEN      1322/master         
tcp6       0      0 :::10051                :::*                    LISTEN      5006/zabbix_server  
tcp6       0      0 :::10181                :::*                    LISTEN      1204/sshd           
tcp6       0      0 :::111                  :::*                    LISTEN      910/rpcbind

5在浏览器访问ip

Zabbix 5.0基于Nginx安装方法_第1张图片

Zabbix 5.0基于Nginx安装方法_第2张图片

Zabbix 5.0基于Nginx安装方法_第3张图片
Zabbix 5.0基于Nginx安装方法_第4张图片
Zabbix 5.0基于Nginx安装方法_第5张图片

Zabbix 5.0基于Nginx安装方法_第6张图片

Zabbix 5.0基于Nginx安装方法_第7张图片

6.转化为中文

Zabbix 5.0基于Nginx安装方法_第8张图片

7.zabbix-agent2

Zabbix-agent2 作为一款新的agent,未来可能会替代远有的agent

特性:

  • 降低了TCP连接的数量
  • Zabbix-agent2用go语言开发,集成了zabbix-agent原有的所有功能,并且易于通过插件扩展第三方功能

安装zabbix-agent2

#配置yum源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

#安装zabbix-agent2
[root@zabbix-agent ~]# yum install zabbix-agent2 -y

#查看一下zabbix-agent2安装文件位置
[root@zabbix-agent ~]# rpm -ql zabbix-agent2
/etc/logrotate.d/zabbix-agent2
/etc/zabbix/zabbix_agent2.conf
/etc/zabbix/zabbix_agent2.d
/usr/lib/systemd/system/zabbix-agent2.service
/usr/lib/tmpfiles.d/zabbix_agent2.conf
/usr/sbin/zabbix_agent2
/usr/share/doc/zabbix-agent2-5.0.19
/usr/share/doc/zabbix-agent2-5.0.19/AUTHORS
/usr/share/doc/zabbix-agent2-5.0.19/COPYING
/usr/share/doc/zabbix-agent2-5.0.19/ChangeLog
/usr/share/doc/zabbix-agent2-5.0.19/NEWS
/usr/share/doc/zabbix-agent2-5.0.19/README
/usr/share/man/man8/zabbix_agent2.8.gz
/var/log/zabbix
/var/run/zabbix

#配置zabbix-agent2
[root@zabbix-agent ~]# egrep '^#|^$' -v /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=192.168.10.68   #修改这个为zabbix-server的ip
ServerActive=192.168.10.67
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock

#启动zabbix-agent
[root@zabbix-agent ~]# systemctl start zabbix-agent
[root@zabbix-agent ~]# systemctl start zabbix-agent
#UserParametr
用户自定义key,格式:UserParameter=[key名称],<shell命令取值>
例如:UserParameter=system.test,who|wc -l

你可能感兴趣的:(Zabbix,nginx,运维,linux)