centos 安装zabbix 6.4.16 server client

Zabbix Server 采用源码包部署,数据库采用 MySQL8.0 版本,zabbix-web 使用 nginx+php 来实现。具体信息如下:

软件名

版本

安装方式

Zabbix Server

6.4.16

源码安装

Zabbix Agent

6.4.16

源码安装

MySQL

8.0.28

yum安装

Nginx

1.20.1

yum安装

Php

7.4.29

yum安装

官网参考文档:3 Installation from sources

1. 安装nginx

#1.添加CentOS 7 Nginx yum资源库
yum -y install  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
#2、安装nginx
[root@localhost ~]# yum -y install nginx   //安装nginx
#3.启动并设置开机自启
systemctl enable nginx
systemctl start nginx
#4.检查端口和进程
ss -tuanlp|grep nginx
ps -ef|grep nginx

2. 安装php-fpm

#1.安装源
yum install -y epel-release
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
#2.安装YUM管理工具
yum -y install yum-utils
#3. 查看PHP(可忽略此步骤)
#yum search php74
#4.安装PHP
yum install -y php74-php-gd  php74-php-pdo php74-php-mbstring php74-php-cli php74-php-fpm php74-php-mysqlnd php74-php-pecl-redis6  php74-php-bcmath php74-php-xml php74-php-ldap
#5.查询配置文件路径
# rpm -ql php74-php-fpm |grep www.conf
#/etc/opt/remi/php74/php-fpm.d/www.conf
#6.修改/etc/opt/remi/php74/php-fpm.d/www.conf中user和group为nginx
sed -i 's#user = apache#user = nginx#g' /etc/opt/remi/php74/php-fpm.d/www.conf
sed -i 's#group = apache#group = nginx#g' /etc/opt/remi/php74/php-fpm.d/www.conf
#7.启动FPM
systemctl enable php74-php-fpm
systemctl start php74-php-fpm

3. 安装MySQL

3.1. 下载mysql源,安装,并修改密码

wget https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
rpm -ivh mysql80-community-release-el7-7.noarch.rpm
#修改为不校验
sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/mysql-community.repo
yum -y install mysql-community-server
mysql -V
----------------------------------
cat >> /etc/my.cnf << EOF
log_bin_trust_function_creators=1
EOF
----------------------------------
systemctl restart mysqld
pass=`grep "temporary password" /var/log/mysqld.log|awk '{print $NF}'`
mysql -uroot -p$pass
mysql>alter user root@localhost identified by 'Mysql123...'; 

3.2. 创建zabbix需要的数据库


mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user 'zabbix'@'%' identified by 'Zabbix123...';
mysql> grant all privileges on zabbix.* to 'zabbix'@'%' with grant option;

4. 安装Zabbix-server

下载软件包Download Zabbix sources

4.1. 解压软件包

tar -zxvf zabbix-6.4.16.tar.gz

4.2. 创建 zabbix 用户

useradd zabbix -s /sbin/nologin

4.3. 初始化数据(进入解压目录下的 database 目录下)

cd zabbix-6.4.16/database/mysql
mysql -uzabbix -pZabbix123... zabbix < schema.sql
mysql -uzabbix -pZabbix123... zabbix < images.sql
mysql -uzabbix -pZabbix123... zabbix < data.sql

4.4. 安装编译所需的依赖,这里根据启用的模块不一样,所需要的依赖也不一样

yum install -y mysql-devel pcre-devel openssl-devel zlib-devel libxml2-devel net-snmp-devel   net-snmp libssh2-devel OpenIPMI-devel libevent-devel openldap-devel   libcurl-devel java-devel

4.5. 进行编译安装

cd /app/tools/zabbix-6.4.16
./configure --sysconfdir=/etc/zabbix/ --enable-server --with-mysql --with-net-snmp --with-libxml2 --with-ssh2 --with-openipmi --with-zlib --with-libpthread --with-libevent --with-openssl  --with-libcurl --with-libpcre
make install

4.6. 修改配置文件

]# egrep -v '^$|^#' /etc/zabbix/zabbix_server.conf
ListenPort=10051
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix123...
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

4.7. 配置systemd启动

cat <<EOF > /etc/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target network.target network-online.target

[Service]
Type=simple
User=zabbix
ExecStart=/usr/local/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

4.8. 加入开机启动并启动

systemctl daemon-reload
systemctl enable zabbix-server --now
systemctl status zabbix-server
ps -ef|grep zabbix-server

5. 安装zabbix-web

5.1. 修改zabbix依赖php的相关配置,/etc/opt/remi/php74/php.ini

]# egrep -n '^(max_.*_time|post_max)' /etc/opt/remi/php74/php.ini
388:max_execution_time = 300
398:max_input_time = 600
694:post_max_size = 80M

systemctl restart php74-php-fpm.service

5.2. 添加nginx的zabbix域名相关

cat > /etc/nginx/conf.d/zabbix.conf  << 'EOF'
server {
  listen 80;
  server_name zabbix.tom.cn;
  root /app/code/zabbix;
  location / {
    index index.php;
  }
  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_NAME      $fastcgi_script_name;
    include        fastcgi_params;
  } 
}
EOF

5.3. 将 Zabbix 源码包中的 PHP 文件复制到 Nginx 的根目录下。

mkdir -p /app/code/zabbix
cp -r /app/tools/zabbix-6.0.31/ui/* /app/code/zabbix
chown -R nginx.nginx /app/code/zabbix/

5.4. 重启nginx

nginx -t
systemctl restart nginx

6. Web界面配置

6.1. 访问Web界面,如下图,并选择自己所使用的语言

6.2. 基础环境检测

6.3. 配置数据库连接信息

6.4. 配置主机名称和时区

6.5. 检查配置

6.6. 配置完成后如下图所示,点击完成。

6.7. 进入登陆界面(默认账号/密码:Admin/zabbix)

7. 客户端启用zabbix-agent2
 

wget https://repo.zabbix.com/zabbix/6.4/rhel/7/x86_64/zabbix-agent2-6.4.16-release1.el7.x86_64.rpm
yum -y localinstall zabbix-agent2-6.4.16-release1.el7.x86_64.rpm
]# egrep '^Server' /etc/zabbix/zabbix_agent2.conf
Server=172.16.1.162
ServerActive=172.16.1.162
systemctl enable zabbix-agent2.service
systemctl start zabbix-agent2.service
systemctl status zabbix-agent2.service

8. 再次检查状态(此时可以看到主机列表有机器了)

9. zabbix显示中文乱码解决

原因:zbx显示中文的字体有问题,导致显示中文异常。

解决:把zbx中文字体替换即可。

上传一个中文的ttf(C:\Windows\Fonts里面有 )字体替换zabbix自用的字体即可.

cp /app/code/zabbix/assets/fonts/DejaVuSans.ttf{,.bak}

cp msyh.ttc /app/code/zabbix/assets/fonts/DejaVuSans.ttf

 

  • 16
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值