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

 

 

 

 

 

 


posted @ 2020-08-14 01:09  laoxiaomingming  阅读(1592)  评论(4编辑  收藏  举报