CentOS7.5安装zabbix-3.4

一、安装环境

操作系统 IP地址 域名 内存
CentOS7.5 10.0.0.200 my.zabbix.com 1G

二、安装步骤

zabbix3.4 中文手册地址

2.1配置zabbix仓库

[root@zabbix-server ~]# rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

//实际为下载zabbix.repo
[root@zabbix-server ~]# cat /etc/yum.repos.d/zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch 
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

2.2安装Zabbix程序包,以及MySQL、Zabbix-agent

[root@zabbix-server ~]# yum -y install  zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server

2.3创建Zabbix数据库以及用户授权

#启动mariadb
[root@zabbix-server ~]# systemctl start mariadb && systemctl enable mariadb

#mariadb默认root用户密码为空
[root@zabbix-server ~]# mysql -uroot -e "create database zabbix character set utf8 collate utf8_bin;" && mysql -uroot -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';" && mysql -uroot -e "flush privileges;"

2.4导入Zabbix数据至数据库中

[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.15/create.sql.gz |mysql -uroot zabbix

2.5编辑/etc/zabbix/zabbix_server.conf文件,修改数据库配置

#修改/etc/zabbix/zabbix_server.conf文件
91行,取消DBHost=localhost注释
125行,修改为DBPassword=zabbix

#用以下命令修改
[root@zabbix-server ~]# sed -i.bak '/# DBHost=localhost/c DBHost=localhost' /etc/zabbix/zabbix_server.conf  
[root@zabbix-server ~]# sed -i '/# DBPassword=/c DBPassword=zabbix' /etc/zabbix/zabbix_server.conf

#修改后的配置文件
[root@zabbix-server ~]# grep  ^[a-Z]  /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

2.6启动Zabbix服务进程,并加入开机自启

[root@zabbix-server ~]# systemctl start zabbix-server && systemctl enable zabbix-server

2.7配置Apache的配置文件/etc/httpd/conf.d/zabbix.conf,修改时区

#用以下命令修改
[root@zabbix-server ~]# sed -i.bak '/Riga$/c php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf


[root@zabbix-server ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1

//取消注释,设置正确的时区
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai

2.8整合nginx,让zabbix可以以域名访问

因为本文用到了apache来展示zabbix web界面,因此设置apache监听8080端口,nginx监听80端口

#安装nginx,提前上传nginx离线包,也可以直接yum安装nginx
[root@zabbix-server ~]# ls
nginx-1.14.0-1.el7_4.ngx.x86_64.rpm  
[root@zabbix-server ~]# rpm -ivh nginx-1.14.0-1.el7_4.ngx.x86_64.rpm


#配置apache主配置文件,修改监听端口
将Listen80修改为Listen 8080
[root@zabbix-server ~]# sed -i.bak '/Listen 80/c Listen 8080' /etc/httpd/conf/httpd.conf

#配置nginx虚拟主机配置文件
[root@zabbix-server ~]# cat >> /etc/nginx/conf.d/my.zabbix.com.conf  <<EOF
server {
    listen 80;
    server_name my.zabbix.com;

    location / {
        proxy_pass http://localhost:8080;
        include proxy_params;
    }
}
EOF

#编辑nginx头文件
[root@zabbix-server ~]# cat >> /etc/nginx/proxy_params <<EOF
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffering on;
proxy_buffer_size 32k;
proxy_buffers 4 128k;
EOF

#检测nginx语法,OK即为正确
[root@zabbix-server ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

#启动nginx并加入开机自启
[root@zabbix-server ~]# systemctl enable nginx && systemctl start nginx

#绑定windows hosts文件,能以域名访问 mac编辑/etc/hosts文件
C:\Windows\System32\drivers\etc\hosts
10.0.0.200 my.zabbix.com

2.9启动Apache Web服务器

[root@zabbix-server ~]# systemctl enable httpd && systemctl start httpd

2.10浏览器输入地址my.zabbix.com/zabbix开始安装

iShot2020-10-16 09.06.34

第一步

iShot2020-10-16 09.06.52

第二步,全部为OK才可以

iShot2020-10-16 09.07.15

第三步 配置数据库连接

iShot2020-10-16 09.07.33

第四步

iShot2020-10-16 09.07.52

第五步,确认信息

iShot2020-10-16 09.08.12

第六步,完成安装

iShot2020-10-16 09.08.29

完成安装后会生成一个配置信息文件

iShot2020-10-16 09.08.58

第七步,登陆

iShot2020-10-16 09.09.18

第八步,修改zabbix语言为中

iShot2020-10-16 09.09.39

iShot2020-10-16 09.09.59

完成安装后首界面

iShot2020-10-16 09.10.35

2.11 解决图形中文乱码问题

iShot2020-10-16 09.10.55

2.11.1从windows找到楷体字体simkai,搜索楷体即可

windows路径 c盘-->Windows-->Fonts

mac路径/Library/Fonts

iShot2020-10-16 09.11.34

2.11.2在zabbix-server上备份zabbix默认字体并且上传新字体

[root@zabbix-server ~]# cd /usr/share/fonts/dejavu/
[root@zabbix-server dejavu]# ls
DejaVuSans-BoldOblique.ttf  DejaVuSansCondensed-BoldOblique.ttf  DejaVuSansCondensed-Oblique.ttf  DejaVuSans-ExtraLight.ttf  DejaVuSans.ttf
DejaVuSans-Bold.ttf         DejaVuSansCondensed-Bold.ttf         DejaVuSansCondensed.ttf          DejaVuSans-Oblique.ttf


#然后上传字体,修改名称为DejaVuSans.ttf
[root@zabbix-server dejavu]# mv DejaVuSans.ttf DejaVuSans.ttf.bak
[root@zabbix-server dejavu]# mv simkai.ttf DejaVuSans.ttf

#注意字体的权限要让zabbix用户可以读
[root@zabbix-server dejavu]# ll DejaVuSans.ttf
-rw-r--r-- 1 root root 19647736 Jan 13 16:29 DejaVuSans.ttf

2.11.3验证效果

监测中-->图形

iShot2020-10-16 09.11.56

泡泡吐肥皂o © gitbook.pptfz.top 2021 all right reserved,powered by Gitbook文件修订时间: 秃笔南波湾!!!

results matching ""

    No results matching ""