银河麒麟系统arrch64架构安装zabbix监控

【ZABBIX监控系统】银河麒麟系统arrch64架构安装zabbix监控*

    • 系统版本查看
    • 一、zabbix服务版本
    • 二、zabbix服务组件安装
      • 2.1 服务依赖安装
      • 2.2 部署存储引擎
        • 2.2.1 YUM安装MariaDB
        • 2.2.2 安装SQLITE3
    • 三、Zabbix编译安装
      • 3.1 下载离线编译包
      • 3.2 Zabbix Server安装
        • 3.2.1 zabbix-server编译
        • 3.2.2 配置Zabbix-Server.Conf文件
        • 3.2.3 创建Zabbix Server管理脚本
        • 3.2.4 创建Systemd系统级自启动脚本
      • 3.3 Zabbix Proxy安装
        • 3.3.1 zabbix-Proxy编译
        • 3.3.2 配置Zabbix-Proxy.Conf文件
        • 3.3.3 创建Zabbix Proxy管理脚本
        • 3.3.4 创建Systemd系统级自启动脚本
      • 3.4 Zabbix Agentd安装
        • 3.4.1 zabbix-Agentd编译
        • 3.4.2 配置Zabbix-Agentd.Conf文件
        • 3.2.3 创建Zabbix Agentd管理脚本
        • 3.2.4 创建Systemd系统级自启动脚本
    • 四、本机简单验证
    • 五、zabbix-web前端部署

系统版本查看

安装zabbix的主机系统版本及架构
操作系统: 银河麒麟V10
CPU: Arrch64 架构
系统版本: 4.19.90-52.19.v2207.ky10.aarch64
在这里插入图片描述

一、zabbix服务版本

Zabbix5.0.13 进行部署

二、zabbix服务组件安装

2.1 服务依赖安装

Zabbix Server主要Lib依赖库有:libpcre、libevent、libpthread、zlib、libcurl、libxml2、net-snmp、gnutls、openssl or libressl;
## 安装命令
yum -y install net-snmp-devel libxml2-devel libcurl-devel libevent-devel pcre-devel libxml2-devel openssl-devel zlib-devel

2.2 部署存储引擎

Zabbix Server选择MariaDB、Zabbix Proxy选择SQLite3
2.2.1 YUM安装MariaDB
# 搜索yum仓库是否有mysql
yum search mariadb
# 安装mysql数据库及依赖组件
yum -y install mariadb mariadb-devel mariadb-server mariadb-connector-c
# 查看安装版本
mysql -V

2.2.1.1 初始换MariaDB数据库实例

# 设置开启自启 和 启动数据库
systemctl enable mariadb && systemctl start mariadb
# 初始化
mysql_secure_installation
Enter current password for root (enter for none):      
Set root password? [Y/n] y											
New password:  												# 输入新的root密码
Re-enter new password:   									# 再次输入密码
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

2.2.1.2 创建数据库

# Linux登录 Mysql
mysql -uroot -p
# 创建数据库并授权
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user 'zabbix'@'localhost' identified by 'zabbix@pw';
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost';
MariaDB [(none)]> quit

2.2.1.3 导入表结构(sql文件在zabbix下)

# 进入mysql文件路径下
cd zabbix/database/mysql/
# 导入SQL文件命令
mysql -uzabbix -p  zabbix < schema.sql
mysql -uzabbix -p  zabbix < images.sql
mysql -uzabbix -p  zabbix < data.sql
2.2.2 安装SQLITE3
# 下载SQLITE3
wget https://www.sqlite.org/2021/sqlite-autoconf-3360000.tar.gz
tar xf sqlite-autoconf-3360000.tar.gz
cd sqlite-autoconf-3360000/
# 编译安装
./configure --prefix=/usr/local/sqlite3 CC=/usr/bin/aarch64-linux-gnu-gcc --host=arm-linux
make -j8 && make install
# 查看SQLITE3版本
/usr/local/sqlite3/bin/sqlite3 -version
3.36.0 2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5

三、Zabbix编译安装

3.1 下载离线编译包

# 下载zabbix安装包并解压
wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.13.tar.gz
# tar xf zabbix-5.0.13.tar.gz
# mv zabbix-5.0.13 /usr/local/zabbix
# cd zabbix

3.2 Zabbix Server安装

3.2.1 zabbix-server编译
#  安装zabbix-server依赖
./configure --prefix=/usr/local/zabbix --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-libevent=/usr/local/libevent
# 编译
make install
# 查看版本信息
/usr/local/zabbix/sbin/zabbix_server -V |head -n 1 #验证版本号
zabbix_server (Zabbix) 5.0.13
3.2.2 配置Zabbix-Server.Conf文件
cd  /usr/local/zabbix/etc  
cp zabbix_server.conf zabbix_server.conf.bak # 备份原配置文件
# 导入配置文件
cat > zabbix_server.conf <<-EOF   
ListenPort=10052
LogFile=/data/zabbix/logs/zabbix_server.log
LogFileSize=10
SocketDir=/data/zabbix/socket/
DBHost=localhost
DBName=zabbix
DBUser=zabbix
AllowRoot=1
DBPassword=
Timeout=30
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
EOF
3.2.3 创建Zabbix Server管理脚本
cat  /usr/local/zabbix/bin/zabbix_server <<-EOF   
#!/bin/bash
. /etc/init.d/functions
RETVAL=0
prog="Zabbix Server"
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server"
if [ ! -x ${ZABBIX_BIN} ] ; then
        echo -n "${ZABBIX_BIN} not installed! "
        # Tell the user this has skipped
        exit 5
fi
start() {
        echo -n $"Starting $prog: "
        $ZABBIX_BIN
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_server
        echo
}
stop() {
        echo -n $"Stopping $prog: "
        pids=$(pidof $ZABBIX_BIN)
        (test -n "$pids" && kill -15 $pids) || true
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_server
        echo
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload|restart)
        stop
        sleep 10
        start
        RETVAL=$?
        ;;
  status)
        status $ZABBIX_BIN
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit $RETVAL
EOF
chmod +x /usr/local/zabbix/bin/zabbix_server    # 版本查看
3.2.4 创建Systemd系统级自启动脚本
cat >/usr/lib/systemd/system/zabbix_server.service <<-EOF
[Unit]
Description="Zabbix Server"
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/usr/local/zabbix/bin/zabbix_server start
ExecStop=/usr/local/zabbix/bin/zabbix_server stop
Restart=always
RestartSec=10s
User=zabbix
Group=zabbix

[Install]
WantedBy=multi-user.target
EOF
# 重载,设置zabbix-server服务开机自启
systemctl daemon-reload
systemctl enable zabbix_server.service
systemctl start zabbix_server.service
# 验证服务是否正常
systemctl status zabbix_server.service

3.3 Zabbix Proxy安装

3.3.1 zabbix-Proxy编译
#  安装zabbix-Proxy依赖
./configure --prefix=/usr/local/zabbix --enable-proxy --with-net-snmp --with-libevent=/usr/local/libevent --with-sqlite3=/usr/local/sqlite3 --with-libcurl --with-openssl
# 编译
make install
# 查看版本信息
/usr/local/zabbix/sbin/zabbix_proxy -V |head -n 1 #验证版本号
zabbix_proxy (Zabbix) 5.0.13
3.3.2 配置Zabbix-Proxy.Conf文件
cd  /usr/local/zabbix/etc
cp zabbix_proxy.conf zabbix_proxy.conf.bak
# 导入配置文件
cat > zabbix_proxy.conf <<-EOF
ProxyMode=0
Server=
ServerPort=10052
Hostname=Zabbix-Proxy
LogFile=/data/zabbix/logs/zabbix_proxy.log
LogFileSize=10
AllowRoot=1
SocketDir=/data/zabbix/socket/
DBName=/data/zabbix/data/sqlite3.db
ProxyOfflineBuffer=72
Timeout=30
LogSlowQueries=3000
ConfigFrequency=180
EOF
3.3.3 创建Zabbix Proxy管理脚本
cat  /usr/local/zabbix/bin/zabbix_proxy <<-EOF
#!/bin/bash
. /etc/init.d/functions
RETVAL=0
prog="Zabbix Proxy"
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_proxy"
if [ ! -x ${ZABBIX_BIN} ] ; then
        echo -n "${ZABBIX_BIN} not installed! "
        # Tell the user this has skipped
        exit 5
fi
start() {
        echo -n $"Starting $prog: "
        $ZABBIX_BIN
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_proxy
        echo
}
stop() {
        echo -n $"Stopping $prog: "
        pids=$(pidof $ZABBIX_BIN)
        (test -n "$pids" && kill -15 $pids) || true
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_proxy
        echo
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload|restart)
        stop
        sleep 10
        start
        RETVAL=$?
        ;;
  status)
        status $ZABBIX_BIN
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit $RETVAL
EOF
chmod +x /usr/local/zabbix/bin/zabbix_proxy  # 版本查看
3.3.4 创建Systemd系统级自启动脚本
cat > /usr/lib/systemd/system/zabbix_proxy.service <<-EOF
[Unit]
Description="Zabbix Proxy"
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/usr/local/zabbix/bin/zabbix_proxy start
ExecStop=/usr/local/zabbix/bin/zabbix_proxy stop
Restart=always
RestartSec=10s
User=zabbix
Group=zabbix

[Install]
WantedBy=multi-user.target
EOF
# 重载,设置zabbix-server服务开机自启
systemctl daemon-reload
systemctl enable zabbix_proxy.service
systemctl start zabbix_proxy.service
# 验证服务是否正常
systemctl status zabbix_server.service

3.4 Zabbix Agentd安装

3.4.1 zabbix-Agentd编译
#  安装zabbix-Agentd依赖
./configure --prefix=/usr/local/zabbix --enable-agent --with-net-snmp --with-libcurl --with-openssl
# 编译
make install
# 查看版本信息
/usr/local/zabbix/sbin/zabbix_agentd -V | head -n 1 #验证版本号
zabbix_agentd (daemon) (Zabbix) 5.0.13
3.4.2 配置Zabbix-Agentd.Conf文件
cd  /usr/local/zabbix/etc
cp zabbix_agentd.conf zabbix_agentd.conf.bak
# 导入配置文件
cat > zabbix_agentd.conf <<-EOF
LogFile=/data/zabbix/logs/zabbix_agentd.log
LogFileSize=10
Server=127.0.0.1
ServerActive=127.0.0.1
AllowRoot=1
Hostname=Zabbix server
HostMetadataItem=system.uname
Timeout=30
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
EOF
3.2.3 创建Zabbix Agentd管理脚本
cat /usr/local/zabbix/bin/zabbix_agentd <<-EOF
#!/bin/bash
. /etc/init.d/functions
RETVAL=0
prog="Zabbix Agentd"
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"
if [ ! -x ${ZABBIX_BIN} ] ; then
        echo -n "${ZABBIX_BIN} not installed! "
        # Tell the user this has skipped
        exit 5
fi
start() {
        echo -n $"Starting $prog: "
        $ZABBIX_BIN
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agentd
        echo
}
stop() {
        echo -n $"Stopping $prog: "
        pids=$(pidof $ZABBIX_BIN)
        (test -n "$pids" && kill -15 $pids) || true
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_agentd
        echo
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload|restart)
        stop
        sleep 10
        start
        RETVAL=$?
        ;;
  status)
        status $ZABBIX_BIN
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit $RETVAL
EOF
chmod +x /usr/local/zabbix/bin/zabbix_agentd  # 版本查看
3.2.4 创建Systemd系统级自启动脚本
cat > /usr/lib/systemd/system/zabbix_agentd.service <<-EOF
[Unit]
Description="Zabbix Agentd"
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/usr/local/zabbix/bin/zabbix_agentd start
ExecStop=/usr/local/zabbix/bin/zabbix_agentd stop
Restart=always
RestartSec=10s
User=zabbix
Group=zabbix

[Install]
WantedBy=multi-user.target
EOF
# 重载,设置zabbix-server服务开机自启
systemctl daemon-reload
systemctl enable zabbix_agentd.service
systemctl start zabbix_agentd.service
# 验证服务是否正常
systemctl status zabbix_agentd

四、本机简单验证

# /usr/local/zabbix/bin/zabbix_get -s 127.0.0.1 -k agent.ping
1
# /usr/local/zabbix/bin/zabbix_get -s 127.0.0.1 -k system.uname
Linux localhost 4.19.90-23.6.ky10.aarch64 #1 SMP Wed Mar 17 14:45:17 CST 2021 aarch64

五、zabbix-web前端部署

zabbix监控php-fpm主要是通过nginx配置php-fpm的状态输出页面

yum install php-fpm php httpd
# 修改php.ini配置文件
sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
# 设置php-fpm开机自启
systemctl enable php-fpm
systemctl restart php-fpm
# 修改httpd.conf
vim /etc/httpd/conf/httpd.conf

银河麒麟系统arrch64架构安装zabbix监控_第1张图片
银河麒麟系统arrch64架构安装zabbix监控_第2张图片

将zabbix静态文件复制到  /var/www/html 下
mkdir /var/www/html/zabbix
cp /data/tools/zabbix/ui/*  /var/www/html/zabbix

# 重启httpd服务
systemctl restart php-fpm
systemctl restart httpd
访问地址:http://IP:port/zabbix/hosts.php

你可能感兴趣的:(zabbix)