centos7安裝zabbix5.0, 搭建在postgresql & nginx


1. 配置zabbix & postgresql清華鏡像源

https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/ 目錄中找到release的那個rpm包

zabbix-release-5.0-1.el7.noarch.rpm

安裝:

sudo rpm -Uvh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

打開/etc/yum.repo.d/zabbix.repo

將http://repo.zabbix.com/替換成https://mirrors.tuna.tsinghua.edu.cn/zabbix/,   vim中輸入:

%s@http://repo.zabbix.com/@https://mirrors.tuna.tsinghua.edu.cn/zabbix/@g

將[zabbix-frontend]中enable改為1

enabled=1

復制一份zabbix的鏡像源, 將鏈接改為postgresql的地址, 如下:

[postgresql]
name=Postgresql Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/12/redhat/rhel-7-x86_64/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

2. 安裝postgresql

yum install postgresql12-server -y

/usr/pgsql-12/bin/postgresql-12-setup initdb

編輯/var/lib/pgsql/12/data/pg_hba.conf 文件增加一行host all all 0.0.0.0:0 md5 , 並將METHOD改為md5

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             0.0.0.0:0               md5
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

 啟動數據庫

systemctl start postgresql-12
systemctl enable postgresql-12

然后測試可以登錄postgresql: 

[root@zabbix home]# su postgres
bash-4.2$ psql
psql (12.3)
輸入 "help" 來獲取幫助信息.

postgres=#

2. 按照zabbix官方文檔安裝zabbix

官方地址: https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&db=postgresql&ws=nginx

yum install zabbix-server-pgsql zabbix-agent -y
yum install centos-release-scl -y
yum install zabbix-web-pgsql-scl zabbix-nginx-conf-scl -y

 初始化db: 

# 為數據庫創建zabbix用戶並指定初始密碼
sudo -u postgres createuser --pwprompt zabbix
# 注意下面這步與官方文檔不一樣, 需要指定編碼為utf-8
sudo -u postgres createdb -O zabbix zabbix --template=template1 --encoding='UTF-8'
# 如果是docker安裝, 似乎yum安裝的沒有這個文件, 需要用rpm包重新安裝一次zabbix-server
zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix

編輯/etc/zabbix/zabbix_server.conf , 填入上一步為zabbix初始化的密碼

BPassword=123

編輯/etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf ,  配置nignx監聽端口及服務名

        listen          80;
        server_name     192.168.204.131;

編輯/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf , 添加nginx, 配置時區

listen.acl_users = apache,nginx
...
php_value[date.timezone] = Asia/Shanghai

關閉selinux和防火牆

setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
systemctl stop firewalld systemctl disable firewalld

啟動zabbix

systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

打開瀏覽器輸入 http://本機地址, 進行頁面安裝

 

 

 填入

 

這個Name后面也可以在配置文件/etc/zabbix/web/zabbix.conf.php 中修改

 

 

一直下一步完成, 登錄默認賬戶: Admin/zabbix

 

 

4. 如果是docker環境, 可能需要安裝中文字體, 如果是其他跳過此步

yum install kde-l10n-Chinese
yum reinstall glibc-common
echo  LANG=zh_CN.UTF-8 > /etc/locale.conf

echo  export LANG=zh_CN.UTF-8 >> /etc/profile
echo  export LC_ALL=en_US.UTF-8  >> /etc/profile
echo  export LC_CTYPE=en_US.UTF-8  >> /etc/profile
.  /etc/profile

# 重啟zabbix-server
systemctl restart zabbix-server

 4. 修改中文支持: 

 

 

 將windows中的中文字體放進zabbix

找到本地C:\Windows\Fonts\simkai.ttf(楷體)上傳到服務器zabbix網站目錄/usr/share/zabbix/assets/fonts/目錄下

查看graphfont.ttf指向的是/etc/alternatives/zabbix-web-font這個軟鏈接, 

[root@zabbix fonts]# ll graphfont.ttf
lrwxrwxrwx. 1 root root 33 8月 13 23:20 graphfont.ttf -> /etc/alternatives/zabbix-web-font
[root@zabbix fonts]# ll /etc/alternatives/zabbix-web-font
lrwxrwxrwx. 1 root root 38 8月 13 23:20 /etc/alternatives/zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf

將/etc/alternatives/zabbix-web-font 指向 /usr/share/zabbix/assets/fonts/simkai.ttf

[root@zabbix fonts]# rm -f /etc/alternatives/zabbix-web-font
[root@zabbix fonts]# ln -s /usr/share/zabbix/assets/fonts/simkai.ttf /etc/alternatives/zabbix-web-font
[root@zabbix fonts]# ll /etc/alternatives/zabbix-web-font
lrwxrwxrwx. 1 root root 41 8月  14 01:07 /etc/alternatives/zabbix-web-font -> /usr/share/zabbix/assets/fonts/simkai.ttf

 

 

 

 

 

 

 
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM