在openEuler-24.03LTS安装zabbix
1、安装mysql
dnf -y install mysql-server
启动数据库
systemctl start mysqld && systemctl enable mysqld
初始化数据库
mysql_secure_installation
创建zabbix账号
create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'Zabbix#123';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
quit;
注意
相关数据导入完成后关掉log_bin_trust_function_creators功能
set global log_bin_trust_function_creators = 0;
quit;
2、安装Zabbix(在zabbix.com下载)
dnf -y install mysql-devel libevent-devel pcre-devel
cd /home/app/soft/
tar -xvf zabbix-6.0.38.tar.gz
cd zabbix-6.0.38
./configure --prefix=/home/app/zabbix --enable-server --enable-agent --with-mysql
make install
3、安装PHP
dnf -y install php php-fpm
安装PHP扩展
yum install php-mysqli php-bcmath php-gd php-ldap
启动
systemctl start php-fpm && systemctl enable php-fpm
4、导数据
这三个sql文件一定要完整导入否则在安装web版的zabbix时会出现很多错误
mysql -uroot -p zabbix < /home/app/soft/zabbix-6.0.38/database/mysql/schema.sql
mysql -uroot -p zabbix < /home/app/soft/zabbix-6.0.38/database/mysql/images.sql
mysql -uroot -p zabbix < /home/app/soft/zabbix-6.0.38/database/mysql/data.sql
注意上面三个表的数据一定要完整导入否则在安装zabbix的web版的时候会出好多问题
5、部署虚拟主机
apache操作系统自带已安装
配置虚拟主机
vim /etc/httpd/zabbix.conf
<VirtualHost *:80>
ServerAdmin admin@test.cc
DocumentRoot "/var/http/html/"
ServerName test.cc
DirectoryIndex index.html index.htm index.php
ErrorLog "logs/test.cc-error.log"
CustomLog "logs/test.cc-access.log" common
<Directory "/var/http/html/">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
关闭防火墙或给防火墙增加80端口
systemctl stop firewalld.service
否则会出现无法访问
暂时关闭SELinux
setenforce 0
否则会出现Access denied.
创建/var/http/html,复制zabbix的ui到html下
mv /home/app/soft/zabbix-6.0.38/ui/* /var/http/html
chown -R apache:apache /var/http/html
启动apache
systemctl start httpd && systemctl enable httpd
访问虚拟主机
开始zabbix的web界面安装
安装完后
登录账号
Admin/zabbix
6、Zabbix Server配置
1)制作 Zabbix server 守护文件(服务文件)
vim /usr/lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
After=postgresql.service
After=pgbouncer.service
After=postgresql-13.service
[Service]
Environment="CONFFILE=/app/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/tmp/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
-----------end
2)zabbix的日志存放位置、zabbix数据库的密码
vim /app/zabbix/etc/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBPassword=上面在mysql创建zabbix时设置的密码
注意PID存放的位置也是可以改动的,我没有改默认放在tmp下
mkdir /var/log/zabbix
chown zabbix:zabbix /var/log/zabbix
启动 Zabbix Server
systemctl start zabbix-server && systemctl enable zabbix-server
7、Zabbix agent配置
1)与Server一样,先创建服务
vim /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=/tmp/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
-----------end
2)修改zabbix agent配置文件,修改日志存放位置、Server、ServerActive
vim /app/zabbix/etc/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=zabbix服务端的IP地址
ServerActive=zabbix服务端的IP地址
启动zabbix agent
systemctl start zabbix-agent && systemctl enable zabbix-agent
***注意以上的配置文件中的相关路径地址一定要写对,配置文件的名称也要写对,相关参数要填写对,否则服务可能无法正常启动
鲲鹏昇腾开发者社区是面向全社会开放的“联接全球计算开发者,聚合华为+生态”的社区,内容涵盖鲲鹏、昇腾资源,帮助开发者快速获取所需的知识、经验、软件、工具、算力,支撑开发者易学、好用、成功,成为核心开发者。
更多推荐
所有评论(0)