zabbix server7+nginx+postgresql

1.配置

(1)全局配置

  • 永久关闭防火墙:systemctl stop firewalld && systemctl disable firewalld
  • 关闭selinux: sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config
  • 查看防火墙状态:systemctl status firewalld
  • 查看selinux状态:getenforce

(2)zabbix-server的配置

  • zabbix-server依据官网安装
  • zabbix-agent 的安装也是如此,也很简单,本教程不赘述
    在这里插入图片描述
  • 操作系统:红帽8.6
  • zabbix版本:7.0
  • 数据库:pgsql
  • web server:nginx

2.zabbix-server安装

(1)安装 Zabbix 存储库

rpm -Uvh https://repo.zabbix.com/zabbix/6.5/rhel/8/x86_64/zabbix-release-6.5-1.el8.noarch.rpm

dnf clean all

(2)切换 PHP 的 DNF 模块版本

dnf module switch-to php:7.4

(3)安装 Zabbix 服务器、前端、代理

dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

(4)安装并且配置pgsql

a安装PostgreSQL的Repository

dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

b禁用内置的PostgreSQL模块

  • 需要注释掉优先级,否则会报错:不支持“failovermethod”选项
# 编辑文件:
vim /etc/yum.repos.d/pgdg-redhat-all.repo

# 注释掉failovermethod=priority这一行。
# vim打开文件后按esc进入命令模式,输入":"后,键入下面的命令全部注释掉(看下图)
%s#failovermethod=priority#\#failovermethod=priority

在这里插入图片描述

  • 禁用内置的PostgreSQL模块
dnf -qy module disable postgresql

c安装PostgreSQL Server

sudo dnf install -y postgresql15-server

d可选择初始化数据库并启用自动启动

sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15
  • 查看pgsql是否启动
systemctl status postgresql-15

e创建初始数据库

  • 创建一个PostgreSQL用户:zabbix
sudo -u postgres createuser --pwprompt zabbix
会让键入密码,我填入的是zabbix
  • 创建并指定拥有zabbix数据库的数据库用户为zabbix
sudo -u postgres createdb -O zabbix zabbix
  • 在 Zabbix 服务器主机上导入初始架构和数据。系统将提示您输入新创建的密码
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix

f Zabbix服务器配置数据库

  • 编辑/etc/zabbix/zabbix_server.conf
vim /etc/zabbix/zabbix_server.conf
将DBPassword改为你刚才设置的密码

g 为 Zabbix 前端配置 PHP

  • 编辑文件 /etc/nginx/conf.d/zabbix.conf 取消注释并设置“listen”和“server_name”指令
vim /etc/nginx/conf.d/zabbix.conf 

将下面两行取消注释
# listen 8080;  
# server_name example.com;

(5)启动Zabbix服务器和代理进程

  • 启动 Zabbix 服务器和代理进程,并使其在系统启动时启动
systemctl restart zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent nginx php-fpm

(6)网页端配置

a输入http://your_ip:8080/setup.php

  • 默认语言选择Chinese,然后点击下一步
    在这里插入图片描述
  • 检查必要条件–我这儿都是ok,如果不应该是对应的哪儿没装全
    在这里插入图片描述

b配置数据库连接

  • 需要输入创建用户时输入的密码(也是改zabbix_server.conf时的密码)
    在这里插入图片描述

c设置时区

  • 选Asia/shanghai(温馨提示:从最末尾列表往上找)
    在这里插入图片描述

  • 后面就一直点就行

d登录zabbix 页面

  • zabbix的默认登录账号密码是:Admin/zabbix
    ![[image-20231226164124427.png]]
![[image-20231226164212844.png]]
  • 25
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编译安装 ZabbixPostgreSQLNginx 可以分为以下几个步骤: 1. 安装基础依赖 ```shell yum install -y gcc make wget net-snmp-devel libcurl-devel libxml2-devel libevent-devel openssl-devel libpng-devel libjpeg-devel libuuid-devel ``` 2. 安装 PostgreSQL ```shell wget https://ftp.postgresql.org/pub/source/v13.4/postgresql-13.4.tar.gz tar -zxvf postgresql-13.4.tar.gz cd postgresql-13.4 ./configure --prefix=/usr/local/pgsql --without-readline make && make install ``` 3. 初始化 PostgreSQL ```shell cd /usr/local/pgsql/bin ./initdb -D /usr/local/pgsql/data ``` 4. 启动 PostgreSQL ```shell cd /usr/local/pgsql/bin ./pg_ctl -D /usr/local/pgsql/data -l logfile start ``` 5. 创建 Zabbix 数据库及用户 ```shell cd /usr/local/pgsql/bin ./createdb -U postgres zabbix ./createuser -U postgres -P zabbix ``` 6. 安装 Zabbix ```shell wget https://cdn.zabbix.com/zabbix/sources/stable/5.4/zabbix-5.4.4.tar.gz tar -zxvf zabbix-5.4.4.tar.gz cd zabbix-5.4.4 ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-postgresql --with-net-snmp --with-libcurl --with-libxml2 --with-openssl --with-libpng --with-jpeg --with-uuid make && make install ``` 7. 导入 Zabbix 数据库 ```shell cd /usr/local/zabbix/share/zabbix/database/postgresql psql -U zabbix -d zabbix -f schema.sql psql -U zabbix -d zabbix -f images.sql psql -U zabbix -d zabbix -f data.sql ``` 8. 配置 Zabbix ```shell cp /usr/local/zabbix/etc/zabbix_server.conf.example /usr/local/zabbix/etc/zabbix_server.conf vi /usr/local/zabbix/etc/zabbix_server.conf ``` 修改以下内容: ```ini DBName=zabbix DBUser=zabbix DBPassword=<zabbix用户密码> DBHost=localhost ``` 9. 启动 Zabbix Server 和 Agent ```shell /usr/local/zabbix/sbin/zabbix_server /usr/local/zabbix/sbin/zabbix_agentd ``` 10. 安装 Nginx ```shell wget https://nginx.org/download/nginx-1.20.1.tar.gz tar -zxvf nginx-1.20.1.tar.gz cd nginx-1.20.1 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre make && make install ``` 11. 配置 Nginx ```shell cp /usr/local/zabbix/frontends/php/*.php /usr/local/nginx/html/ vi /usr/local/nginx/conf/nginx.conf ``` 添加以下内容: ```ini server { listen 80; server_name localhost; location / { root /usr/local/nginx/html; index index.php index.html index.htm; } location ~ \.php$ { root /usr/local/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ``` 12. 启动 Nginx ```shell /usr/local/nginx/sbin/nginx ``` 至此,ZabbixPostgreSQLNginx编译安装配置已完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值