CentOS 7.6 部署zabbix 6.0 支持Kubernetes
# 基础信息
系统版本: CentOS Linux release 7.6.1810 (Core)
内核版本: 4.19.0-9.el7.ucloud.x86_64
# 听说最新版的zabbix6.0 支持Kubernetes的监控了。自己部署亲眼看了一下确实是支持了。
先来个 截图
# 依赖安装
yum -y install gcc gcc-c++ unixODBC-devel httpd mysql-devel libcurl libcurl-devel libevent libevent-devel fping curl-devel libxml2 libxml2-devel snmpd net-snmp-devel net-snmp
# nginx安装
yum install -y http://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.20.1-1.el7.ngx.x86_64.rpm
# 安装php7
#首先安装 EPEL 源
yum install epel-release -y
#安装 REMI 源:
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum -y install yum-utils
yum-config-manager --enable remi-php74
yum -y install php php-opcache
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel
yum -y install php-mbstring
yum -y install php-json
yum -y install php-xml
yum -y install php-fedora-autoloader
yum -y install php-sodium
yum -y install php
yum -y install php-gd
yum -y install php-devel
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-gd
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pdo
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pdo php-process
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-mysqlnd
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-ldap
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-cli
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack php-pecl-redis5
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack php-pecl-redis5 php-pear
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack php-pecl-redis5 php-bcmath
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack php-pecl-redis5 php-bcmath php-pecl-zip oniguruma5php
yum install -y php-fpm
# rpm -qa|grep php
php-pdo-7.4.20-1.el7.remi.x86_64
oniguruma5php-6.9.7.1-1.el7.remi.x86_64
php-mbstring-7.4.20-1.el7.remi.x86_64
php-soap-7.4.20-1.el7.remi.x86_64
php-devel-7.4.20-1.el7.remi.x86_64
php-pecl-zip-1.19.3-2.el7.remi.7.4.x86_64
php-common-7.4.20-1.el7.remi.x86_64
php-cli-7.4.20-1.el7.remi.x86_64
php-sodium-7.4.20-1.el7.remi.x86_64
php-opcache-7.4.20-1.el7.remi.x86_64
php-xml-7.4.20-1.el7.remi.x86_64
php-process-7.4.20-1.el7.remi.x86_64
php-gd-7.4.20-1.el7.remi.x86_64
php-xmlrpc-7.4.20-1.el7.remi.x86_64
php-odbc-7.4.20-1.el7.remi.x86_64
php-ldap-7.4.20-1.el7.remi.x86_64
php-pecl-msgpack-2.1.2-1.el7.remi.7.4.x86_64
php-pecl-redis5-5.3.4-1.el7.remi.7.4.x86_64
php-json-7.4.20-1.el7.remi.x86_64
php-7.4.20-1.el7.remi.x86_64
php-pear-1.10.12-8.el7.remi.noarch
php-mysqlnd-7.4.20-1.el7.remi.x86_64
php-fedora-autoloader-1.0.1-2.el7.noarch
php-pecl-igbinary-3.2.3-1.el7.remi.7.4.x86_64
php-bcmath-7.4.20-1.el7.remi.x86_64
#设置开机启动、运行服务:如果无法启动php就重启一下主机
sed -i 's#nobody#zabbix#g' /etc/php-fpm.d/www.conf
systemctl restart php-fpm.service
systemctl status php-fpm.service
# mysql 安装
#卸载自带的mariadb
yum remove mariadb mariadb-libs -y
#下载mysql5.7的repo
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
#然后进行repo的安装
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum clean all
yum makecache
yum install mysql-community-server -y
yum install mysql-devel -y
# 启动mysql和设置开机自启动
systemctl enable mysqld
systemctl start mysqld
#查看临时密码
grep 'temporary password' /var/log/mysqld.log
#登陆msyql
mysql -uroot -p 查看临时密码
#首先需要设置密码的验证强度等级,设置 validate_password_policy 的全局参数为 LOW 即可,
set global validate_password_policy=LOW;
set global validate_password_length=6;#修改默认密码长度
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'zabbix';
flush privileges;
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'zabbix';
grant all privileges on zabbix.* to zabbix@localhost;
quit;
# zabbix_server安装
wget -c https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.13.tar.gz
tar xf zabbix-6.0.13.tar.gz
cd zabbix-6.0.13/
yum install -y net-snmp-devel
./configure --prefix=/usr/local/zabbix/zabbix-server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc && make && make install
#参数说明
--prefix #编译安装路径
--enable-server #启动server端
--enable-agent #启动agent端
--with-mysql #编译连接mysql相关依赖包
--with-net-snmp #启动snmp相关,用于snmp监控设备
--with-libcurl #启动curl相关
--with-libxml2 #启动xml相关
--with-unixodbc #启动odbc相关用于监控数据库
--enable-java #启动java-agent 用于监控java类
sed -i 's/# DBPassword=/DBPassword=zabbix/g' /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf
sed -i 's/# DBHost=localhost/DBHost=localhost/g' /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf
# 创建zabbix需要的数据
mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/double.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
useradd zabbix -s /sbin/nologin
# 启动
/usr/local/zabbix/zabbix-server/sbin/zabbix_server -c /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf
tail -200f /tmp/zabbix_server.log
#检查
netstat -lntup|grep 10051
# 杀死
ps aux |grep zabbix_server |grep -v grep |awk '{print $2}'|xargs kill -9
# systemd管理zabbix_server进程
cat /usr/lib/systemd/system/zabbix_server.service
[Unit] Description=Zabbix Server After=syslog.target After=network.target [Service] Environment="CONFFILE=/usr/local/zabbix/zabbix-server/etc/zabbix_server.conf" EnvironmentFile=-/etc/sysconfig/zabbix_server Type=forking Restart=on-failure PIDFile=/tmp/zabbix_server.pid KillMode=control-group ExecStart=/usr/local/zabbix/zabbix-server/sbin/zabbix_server -c $CONFFILE ExecStop=/bin/kill -SIGTERM $MAINPID RestartSec=10s User=zabbix Group=zabbix [Install] WantedBy=multi-user.target
### 重载
systemctl daemon-reload
### 启动zabbix
systemctl restart zabbix_server
systemctl enable zabbix_server
# nginx添加配置
cp -a /root/zabbix-6.0.13/ui /usr/share/
mv /usr/share/ui /usr/share/zabbix
cat /etc/nginx/conf.d/default.conf
server { listen 80 default_server; listen [::]:80 default_server; server_name localhost; root /usr/share/zabbix/; index index.php; location ~ .*\.php$ { fastcgi_read_timeout 300; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
nginx -t
nginx
nginx -s reload
systemctl enable nginx
systemctl enable php-fpm.service
systemctl restart php-fpm.service
# 访问
http://192.168.1.1/setup.php
# 问题1:
The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-libs-5.7.37-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
执行下面的指令然后再执行《yum install mysql-community-server -y》
sed -i 's#gpgcheck=1#gpgcheck=0#g' /etc/yum.repos.d/mysql-community.repo
# 问题2:
提示必须是 mysql 8.0以上
echo "AllowUnsupportedDBVersions=1" >> /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf systemctl restart zabbix_server