创建 zabbix 用户
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
1.安装mysql 8数据库
wget https://dev.mysql.com/get/mysql80-community-release-el8-3.noarch.rpm
rpm -ivh mysql80-community-release-el8-3.noarch.rpm
yum -y install mysql-server
mkdir -p /mysql8/{data,log}
chown -R mysql:mysql /mysql8/
# 初始化
mysqld --initialize --user=mysql --datadir=/mysql8/data/
vi /etc/my.cnf.d/mysql-server.cnf
# 修改以下内容
datadir=/mysql8/data
socket=/mysql8/mysql.sock
basedir=/mysql8
socket=/mysql8/mysql.sock
#log-bin=/mysql8/log/zabbix-db1
systemctl start mysqld
systemctl enable mysqld
2.配置zabbix数据库
grep 'temporary password' /var/log/mysql/mysqld.log
mysql -uroot -p
mysql> alter user 'root'@'localhost' identified by 'xxxxxx';
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user 'zabbix'@'localhost' identified by 'xxxxxx';
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
mysql> quit;
cd /opt/zabbix-6.0.0/database/mysql/
mysql -uzabbix -p zabbix < schema.sql
mysql -uzabbix -p zabbix < images.sql
mysql -uzabbix -p zabbix < data.sql
# 注意 proxy 数据库只需导入 schema.sql 即可
1.安装zabbix支持功能依赖包
yum install -y gcc mysql-devel net-snmp-devel libxml2-devel unixODBC-devel libcurl-devel libssh2-devel openssl-devel openldap-devel libevent-devel pcre-devel OpenIPMI-devel
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
yum install -y fping
2.OpenIPMI-devel 无法安装,添加PowerTools存储库
vi Centos-Linux-PowerTools.repo
[powertools]
name=CentOS Linux $releasever - PowerTools
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra
baseurl=https://mirrors.aliyun.com/centos-vault/8.2.2004/PowerTools/x86_64/os/
#baseurl=https://mirrors.tuna.tsinghua.edu.cn/$contentdir/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
yum -y install OpenIPMI-devel (报错时添加此选项安装--nobest --skip-broken)
3.编译安装Zabbix ,webservice需要配置go环境(无 --with-openipmi )
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-libcurl --with-libxml2 --with-net-snmp --with-ssh2 --with-unixodbc --with-openssl --enable-java --with-ldap --enable-webservice
make && make install
chown -R zabbix:zabbix /usr/local/zabbix/
4.修改配置文件
修改server配置文件
LogFile=/usr/local/zabbix/log/zabbix_server.log
LogFileSize=5
PidFile=/usr/local/zabbix/zabbix_server.pid
DBHost=192.0.0.38
DBName=zabbix
DBUser=zabbix
DBPassword=
AllowRoot=1
修改agent配置文件
PidFile=/usr/local/zabbix/zabbix_agentd.pid
LogType=file
LogFile=/usr/local/zabbix/log//zabbix_agentd.log
Server=
ServerActive=
Hostname=
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
AllowRoot=1
UnsafeUserParameters=1
1.安装依赖包
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel gd-*
2.编译安装
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-file-aio --with-http_image_filter_module
make && make install
3.修改nginx配置文件使其支持php-fpm
server {
1.listen 80; ###端口可改可不改
2.server_name localhost; ###改成本机ip
3.index index.html index.htm index.php; ###添加index.php
4.location /nginx_status {
stub_status on;
} ###添加该字段开启nginx_status模块,监控nginx需要
5.#location ~ \.php$ {
# root html; ###/usr/local/nginx/html
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
#}
###取消注释该部分,修改fastcgi_param字段:$document_root$fastcgi_script_name
1.安装依赖包
yum install -y sqlite-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel freetype-devel gd openldap-devel openssl-devel
yum install -y oniguruma oniguruma-devel
2.编译安装
# php 7.3版本 正常编译
./configure --prefix=/usr/local/php --enable-fpm --enable-mbstring --with-openssl --with-mysqli --with-mysql-sock --with-gd --enable-pdo --with-pdo-mysql --with-gettext --enable-sockets --enable-bcmath --enable-xml --with-bz2 --with-freetype-dir=/usr/local --with-libxml-dir=/usr/local --with-zlib --with-curl --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-ldap --with-libdir=lib64
# php 7.4 版本之后
./configure --prefix=/usr/local/php --enable-fpm --enable-mbstring --with-openssl --with-mysqli --with-mysql-sock --enable-pdo --with-pdo-mysql --with-gettext --enable-sockets --enable-bcmath --enable-xml --with-bz2 --with-zlib --with-curl --with-ldap --with-libdir=lib64 --enable-gd --with-jpeg --with-freetype
make && make install
3.配置php
cd /opt/php-7.4.28
cp php.ini-production /usr/local/php/lib/php.ini
vi /usr/local/php/lib/php.ini
date.timezone = Asia/Shanghai
post_max_size = 20M
upload_max_filesize = 20M
max_execution_time = 300
max_input_time = 300
memory_limit = 1024M
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf
cd /usr/local/nginx/html
mv ./* old/
cd /opt/zabbix-6.0.0
cp -a ui/* /usr/local/nginx/html/
1. vi /usr/lib/systemd/system/zabbix_server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf"
Type=forking
PIDFile=/usr/local/zabbix/zabbix_server.pid
Restart=on-failure
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
[Install]
WantedBy=multi-user.target
2. vi /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
3. vi /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=php-fpm
After=network.targe
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
PrivateTmp=true
[Install]
WantedBy=multi-user.target
4. vi /usr/lib/systemd/system/zabbix_agentd.service
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf"
Type=forking
PIDFile=/usr/local/zabbix/zabbix_agentd.pid
Restart=on-failure
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
[Install]
WantedBy=multi-user.target