注意关闭防火墙和selinux
操作系统为rock9
安装数据库
# dnf install http://apt.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# dnf install postgresql14-server -y
# /usr/pgsql-14/bin/postgresql-14-setup initdb
修改配置
vi /var/lib/pgsql/14/data/postgresql.conf
max_connections = 500
listen_addresses = '*'
log_timezone = 'Asia/Shanghai'
timezone = 'Asia/Shanghai'
lc_messages = 'C.UTF-8' # locale for system error message
lc_monetary = 'C.UTF-8' # locale for monetary formatting
lc_numeric = 'C.UTF-8' # locale for number formatting
lc_time = 'C.UTF-8'
如果是远程访问需要添加白名单
vi /var/lib/pgsql/14/data/pg_hba.conf
host all all IP地址 scram-sha-256
启动服务
# systemctl enable postgresql-14
# systemctl start postgresql-14
创建用户和数据库
# sudo -u postgres createuser --pwprompt zabbix
# sudo -u postgres createdb -O zabbix zabbix
# zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
安装timescaledb插件
repo配置
# tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/$(rpm -E %{rhel})/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL
安装插件(太高版本不兼容)
# dnf install timescaledb_14-2.10.0
修改配置
vi /var/lib/pgsql/14/data/postgresql.conf
shared_preload_libraries = 'timescaledb'
重启数据库
systemctl restart postgresql-14
开启插件导入数据
# echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix
# cat /usr/share/zabbix-sql-scripts/postgresql/timescaledb.sql | sudo -u zabbix psql zabbix
安装zabbix
安装server和agent
# rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/9/x86_64/zabbix-release-6.2-3.el9.noarch.rpm
# dnf install zabbix-web zabbix-web-deps zabbix-web-pgsql zabbix-nginx-conf zabbix-server-pgsql zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2 -y
zabbix配置
# vi /etc/zabbix/zabbix_server.conf
DBPassword=zabbix@123
nginx配置
# vi /etc/nginx/conf.d/zabbix.conf
listen 80;
server_name example.com;
启动服务
# systemctl enable zabbix-server zabbix-agent2 nginx php-fpm
# systemctl start zabbix-server zabbix-agent2 nginx php-fpm
配置前端
访问http://ip
登录
默认账号 Admin/zabbix
中文设置
dnf install -y langpacks-zh_CN.noarch glibc-common
systemctl restart zabbix-server.service