openEuler 2203sp3 X86_64 安装 zabbix6.4.12

分类:学习资料, 技术文章, 网 络

基础准备

开启SSH服务

systemctl enable --now sshd

配置selinux

vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.

修改 SELINUXTYPE=targeted

临时生效 setenforce 0

关闭防火墙

systemctl stop firewalld && systemctl disable firewalld

安装依赖包

dnf -y install gcc pcre-devel gcc-c++ make cmake zlib zlib-devel openssl openssl-devel vim net-tools man wget tar mysql-devel libevent-devel curl crul-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel sqlite-devel oniguruma-devel pcre* pcre-devel libxml2-devel net-snmp-devel
或
yum -y install gcc gcc-c++ make cmake zlib zlib-devel openssl openssl-devel pcre-devel vim net-tools man wget tar mysql-devel libevent-devel curl crul-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel sqlite-devel oniguruma-devel pcre* pcre-devel libxml2-devel net-snmp-devel

数据库安装

6.0 以上版本需要安装mysql8.0以上版本 openEuler 自带mysql8.0源

dnf -y install mysql-server mysql-devel libevent-devel pcre-devel

启动数据库

systemctl enable --now mysqld

初始化数据库

mysql_secure_installation

下载源码包

cd /tmp

wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.12.tar.gz

解压源码包

tar -zxvf zabbix-6.4.12.tar.gz

zabbix 安装

创建zabbix用户和组

groupadd --system zabbix

useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

创建安装目录

mkdir -p /app/zabbix

编译zabbix

cd /tmp/zabbix-6.4.12

./configure --prefix=/app/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2

#prefix 指定目录
#enable-server 启用zabbix server
#enable-agent 启用 zabbix agent
#with-mysql 后端指定数据库为mysql
#net-snmp 支持snmp协议

安装zabbix

make install

PHP部分

安装php openEuler 自带8.0版本

dnf -y install php php-fpm 
dnf -y install php-gd php-mysqlnd php-bcmath php-xml php-mbstring

php.ini 配置

vi /etc/php.ini

post_max_size = 16M
max_execution_time = 300
max_input_time = 300

启动php

systemctl enable --now php-fpm

Apache部分

安装php时自动安装apache服务
将前端服务文件移动到apache网页目录下

mv /tmp/zabbix-6.4.12/ui/* /var/www/html

启动
systemctl enable --now httpd

程序文件路径为 /app/zabbix/sbin/
配置文件路径为/app/zabbix/etc/

数据库配置

创建zabbix所需要的数据库和用户

mysql -uroot -p 

create database zabbix character set utf8mb4 callate utf8mb4_bin;
create user zabbix@localhost identified by 'abc_123';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
flush privileges;
quit;

导入zabbix数据文件

cat /tmp/zabbix-6.4.12/database/mysql/schema.sql | mysql -uzabbix -pabc_123 zabbix

cat /tmp/zabbix-6.4.12/database/mysql/images.sql | mysql -uzabbix -pabc_123 zabbix

cat /tmp/zabbix-6.4.12/database/mysql/data.sql | mysql -uzabbix -pabc_123 zabbix

数据导入完成后关闭导入功能

mysql -uroot -pabc_123

set global log_bin_trust_function_creators = 0;

flush privileges;

quit;

制作Zabbix server守护文件

[root@localhost ~]# vi /usr/lib/systemd/system/zabbix-server.service 

[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
After=postgresql.service
After=pgbouncer.service
After=mysqld.service

[Service]
Environment="CONFFILE=/app/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/app/zabbix/zabbix_server.pid
KillMode=control-group
ExecStart=/app/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0

[Install]
WantedBy=multi-user.target

修改zabbix_server.conf

vi /app/zabbix/etc/zabbix_server.conf
ListenPort=10051            # 默认监听端口
SourceIP=10.10.2.43     # 发采样数据请求的 IP
DBHost=10.10.2.43       #数据库对外的主机
DBName=zabbix               #数据库名称
DBUser=zabbix              #数据库用户
DBPassword=abc_123             #数据库密码
DBPort=3306                 #数据库启动端口
LogFile=/var/log/zabbix/zabbix_server.log #设置目录存放路径
PidFile=/app/zabbix/zabbix_server.pid     #修改PID文件路径

创建日志目录 并授权

mkdir /var/log/zabbix
chown zabbix:zabbix -R /var/log/zabbix

给zabbix 目录授权

chown zabbix:zabbix -R /app/zabbix/

启动zabbix

systemctl enable --now zabbix-server.service

zabbix-agent 配置

创建服务

[root@localhost ~]# vi /usr/lib/systemd/system/zabbix-agent.service 

[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/app/zabbix/etc/zabbix_agentd.conf"
Type=simple
Restart=on-failure
PIDFile=/app/zabbix/zabbix_agentd.pid
KillMode=control-group
ExecStart=/app/zabbix/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix

[Install]
WantedBy=multi-user.target

修改zabbix_agent.conf

vi /app/zabbix/etc/zabbix_agentd.conf

PidFile=/app/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=127.0.0.1,10.10.2.43
ListenPort=10050
ListenIP=0.0.0.0
StartAgents=3
ServerActive=127.0.0.1,10.10.2.43

再执行一下

chown zabbix:zabbix -R /app/zabbix/

启动zabbix agent

systemctl enable --now zabbix-agent

web图形中文乱码
安装字体

yum -y install wqy-microhei-fonts

备份字体

mv /usr/share/fonts/dejavu/DejaVuSans.ttf  /usr/share/fonts/dejavu/DejaVuSans.ttf_bak

修改字体

cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
备份zabbix字体
mv /var/www/html/assets/fonts/DejaVuSans.ttf  /var/www/html/assets/fonts/DejaVuSans.ttf_bak

软链接zabbix字体

ln -s /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /var/www/html/assets/fonts/DejaVuSans.ttf

暂时没有评论,期待你说点什么。

发表评论

可用快捷键(Ctrl + Enter)

RSS 虎嗅网

2024年7月
1234567
891011121314
15161718192021
22232425262728
293031  

近期评论