银河麒麟服务器版V10 SP1编译部署zabbix 6服务

本篇博客看了一位博主的博客,当做笔记记录一下,不具有商业用途。需要删除私信告我

 

目录

1. 部署准备 2

1.1. 配置yum源 2

1.2. 下载源码包 3

2. 正式部署 3

2.1. Mariadb 3

2.1.1. 安装mariadb 3

2.1.2. 启动数据库 5

2.1.3. 创建zabbix数据库并授权 6

2.1.4. 导入zabbix表结构 6

2.2. Mysql 8.0.18 6

2.2.1. 安装 6

2.2.2. 启动 7

2.2.3. 创建zabbix数据库并授权 7

2.2.4. 导入zabbix表结构 7

2.3. 编译zabbix server 8

2.3.1. 创建zabbix账号 8

2.3.2. 创建zabbix目录并授权 8

2.3.3. 编译安装 8

2.4. 安装httpd 9

2.5. 安装php 10

2.6. 网页前端安装 10

3. 报错处理 12

3.1. 错误1 12

3.2. 错误2 13

3.3. 错误3 13

3.4. 错误4 14

3.5. 错误5 15

3.6. 错误6 15

3.7. 错误7 16

3.8. 错误8 17

3.9. 错误9 17

3.10. 错误10 17

3.11. 错误11 18

3.12. 错误12 18

3.13. 错误13 19

部署准备

编译安装参考文档: https://www.zabbix.com/documentation/6.0/en/manual/installation/install

https://www.zabbix.com/documentation/6.0/en/manual/appendix/install/db_scripts

虚拟机配置:

CPU:4

内存:8G

磁盘:400G

操作系统:Kylin-Server-10-SP1-Release-Build04-20200711-arm64-2020-07-11 17:16:54

配置yum源

[root@localhost yum.repos.d]# cat kylin_aarch64.repo

[ks10-os-media]

name = Kylin Linux Advanced Server 10 - Os

baseurl = http://archive.kylinos.cn/yum/v10/sp1-openstack-q/aarch64/os/

gpgcheck = 0

enabled = 1

下载源码包

wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.4.tar.gz

tar -zxvf zabbix-6.0.4.tar.gz

mv zabbix-6.0.4 zabbix

正式部署

Mariadb

说明:用mariadb数据库,启动zabbix服务时会提示不兼容当前版本,方法1:升级mariadb 2,根据提示忽略

参考:https://www.zabbix.com/documentation/current/en/manual/appendix/install/db_scripts

安装mariadb

yum install mariadb-server

启动数据库

systemctl start mariadb

mysql -uroot -p<回车>

#默认密码为空

# 为数据库root用户设置密码

MariaDB [(none)]> set password for root@localhost=password('passwd');

创建zabbix数据库并授权

shell> mysql -uroot -p'passwd'

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;

mysql> create user 'zabbix'@'localhost' identified by 'passwd';

mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';

mysql> quit;

导入zabbix表结构

shell> cd database/mysql

shell> mysql -uzabbix -p<password> zabbix < schema.sql

# stop here if you are creating database for Zabbix proxy

shell> mysql -uzabbix -p<password> zabbix < images.sql

shell> mysql -uzabbix -p<password> zabbix < data.sql

 

编译zabbix server

创建zabbix账号

groupadd --system zabbix

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

创建zabbix目录并授权

mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix

chown zabbix:zabbix /usr/lib/zabbix

编译安装

安转必要组件:

yum install mariadb-devel libxml2 libxml2-devel net-snmp-devel OpenIPMI-devel libevent-devel libcurl-devel

开始编译:

./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --prefix=/usr/local/zabbix

#如果是要加密:

./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openssl

make install

启动zabbix_server:

zabbix_server

安装httpd

yum install httpd

mkdir /var/www/html/zabbix

cd /usr/local/src/zabbix/ui

cp -a . /var/www/html/zabbix/

安装php

yum -y install php-bcmath php-gd php-xml php-mbstring php-mysqlnd php-ldapphp-fpm php-json

注意:php-ldapphp-fpm可能会安装失败,看目录错误11

根据官网要求修改php.ini参数

vim /etc/php.ini

memory_limit = 128M

post_max_size = 16M

upload_max_filesize = 2M

max_execution_time = 300

max_input_time = 300

session.auto_start = 0

mbstring.func_overload = 0

 

到此,已经安装环境到位,需要检查是否启动了mysql,httpd,php,zabbix服务。

然后浏览器输入“http://10.10.6.204/zabbix/”

注意,zabbix前端是PHP写的没有后台服务也可以启动,所以要去/tmp/下看zabbix系统zabbix_server.log看是否启动成功。

网页前端安装

默认账号:Admin,密码:zabbix

为了避免出现默认口令安全问题,请登陆后修改密码!

 

 

这个链接部署

https://blog.csdn.net/weixin_43631631/article/details/127497982?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EYuanLiJiHua%7EPosition-2-127497982-blog-126567101.pc_relevant_recovery_v2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EYuanLiJiHua%7EPosition-2-127497982-blog-126567101.pc_relevant_recovery_v2&utm_relevant_index=3

报错处理

错误1

ERROR 1071 (42000) at line 2039 in file: '/usr/local/src/zabbix/database/mysql/schema.sql': Specified key was too long; max key length is 767 bytes

ERROR 1709 (HY000) at line 8: Index column size too large. The maximum column size is 767 bytes.

解决方法:

升级mariadb数据库

Zabbix 6.0.4官方说明支持的mariadb版本是10.5.00-10.6.x

不过,惊奇的发现官方源提供mysql-server-8.0.18,满足要求!

错误2

yum install mysql-server时报错:

Error: Transaction test error:

试图安装 mysql-server-8.0.18-2.ky10.aarch64 和 mariadb-3:10.1.20-3.ky10.aarch64 会导致文件 /usr/bin/my_print_defaults 冲突

解决方法:

官方下载mysql-server-8.0.18-2.ky10.aarch64.rpm包

wget http://archive.kylinos.cn/yum/v10/sp1-openstack-q/aarch64/os/Packages/m/mysql-server-8.0.18-2.ky10.aarch64.rpm

yum安装下载好的rpm包

yum install mysql-server-8.0.18-2.ky10.aarch64.rpm

错误3

启动时报错,日志如下:

2022-05-12T06:09:14.092179Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

2022-05-12T06:09:14.093609Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.18) starting as process 19183

2022-05-12T06:09:14.115296Z 1 [System] [MY-011012] [Server] Starting upgrade of data directory.

2022-05-12T06:09:14.178470Z 1 [ERROR] [MY-013090] [InnoDB] Unsupported redo log format (0). The redo log was created before MySQL 5.7.9

2022-05-12T06:09:14.178649Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.

2022-05-12T06:09:14.637626Z 1 [ERROR] [MY-011013] [Server] Failed to initialize DD Storage Engine.

2022-05-12T06:09:14.638054Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.

2022-05-12T06:09:14.638341Z 0 [ERROR] [MY-010119] [Server] Aborting

2022-05-12T06:09:14.639065Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.18) Source distribution.

解决方法:

卸载mysql-server,删除mysql数据目录,重新安装

yum remove mysql-server

rm -rf /var/lib/mysql

yum install mysql-server-8.0.18-2.ky10.aarch64.rpm

错误4

checking for putenv... yes

checking for setenv... yes

checking for tzset... yes

checking for unsetenv... yes

checking for sigqueue... yes

checking for round... yes

checking for /proc filesystem... yes

checking for file /proc/stat... yes

checking for file /proc/cpuinfo... yes

checking for file /proc/0/psinfo... no

checking for file /proc/loadavg... yes

checking for file /proc/net/dev... yes

checking for long long format... no

checking for -rdynamic linking option... yes

checking for libperfstat 5.2.0.40 fileset... no

checking for libperfstat 5.3.0.60 fileset... no

checking for architecture... linux (linux-gnu)

checking for the linux kernel version... unknown family (4.19.90-17.ky10.aarch64)

checking size of void *... 8

checking for mysql_config... no

checking for mariadb_config... no

configure: error: MySQL library not found

解决方法:

yum install mysql-devel

错误5

checking for putenv... yes

checking for setenv... yes

checking for tzset... yes

checking for unsetenv... yes

checking for sigqueue... yes

checking for round... yes

checking for /proc filesystem... yes

checking for file /proc/stat... yes

checking for file /proc/cpuinfo... yes

checking for file /proc/0/psinfo... no

checking for file /proc/loadavg... yes

checking for file /proc/net/dev... yes

checking for long long format... no

checking for -rdynamic linking option... yes

checking for libperfstat 5.2.0.40 fileset... no

checking for libperfstat 5.3.0.60 fileset... no

checking for architecture... linux (linux-gnu)

checking for the linux kernel version... unknown family (4.19.90-17.ky10.aarch64)

checking size of void *... 8

checking for mysql_config... /usr/bin/mysql_config

checking for main in -lmysqlclient... no

configure: error: Not found mysqlclient library

解决方法:

卸载mysql-devel,安装mariadb-devel

错误6

checking for the linux kernel version... unknown family (4.19.90-17.ky10.aarch64)

checking size of void *... 8

checking for mysql_config... /usr/bin/mysql_config

checking for main in -lmysqlclient... yes

checking for main in -lpthread... yes

checking for main in -lz... yes

checking for main in -lm... yes

checking for main in -ldl... yes

checking for main in -lssl... yes

checking for main in -lcrypto... yes

checking for TLS support in MySQL library... no

checking for TLS support in MariaDB library... no

checking for MariaDB init options function... no

checking for MySQL init options function... yes

checking for Oracle support... no

checking for Zabbix server/proxy database selection... ok

checking for multirow insert statements... yes

checking for pkg-config... /usr/bin/pkg-config

checking pkg-config is at least version 0.9.0... yes

checking for pkg-config... (cached) /usr/bin/pkg-config

checking pkg-config is at least version 0.9.0... yes

Package libxml-2.0 was not found in the pkg-config search path.

Perhaps you should add the directory containing `libxml-2.0.pc'

to the PKG_CONFIG_PATH environment variable

Package 'libxml-2.0', required by 'virtual:world', not found

Package libxml-2.0 was not found in the pkg-config search path.

Perhaps you should add the directory containing `libxml-2.0.pc'

to the PKG_CONFIG_PATH environment variable

Package 'libxml-2.0', required by 'virtual:world', not found

checking for xmlReadMemory in -lxml2... no

解决方法:

yum install libxml2

yum install libxml2-devel

错误7

checking for xmlReadMemory in -lxml2... yes

/usr/bin/pkg-config: --version specified with other options or module names, assuming --modversion.

checking for net-snmp-config... no

configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

解决方法:

yum install net-snmp-devel

错误8

/usr/bin/pkg-config: --version specified with other options or module names, assuming --modversion.

checking for net-snmp-config... /usr/bin/net-snmp-config

checking version of netsnmp library... yes

checking for main in -lnetsnmp... yes

checking for strong SHA auth protocol support... yes

checking for strong AES privacy protocol support... no

checking for localname in struct snmp_session... yes

yes

checking for OPENIPMI support... no

configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h

解决方法:

yum install OpenIPMI-devel

错误9

checking for OPENIPMI support... yes

checking for zlib support... yes

checking for pthread.h... (cached) yes

checking for process shared libpthread support... yes

checking for libevent support... no

configure: error: Unable to use libevent (libevent check failed)

解决方法:

yum install libevent-devel

错误10

checking for OPENIPMI support... yes

checking for zlib support... yes

checking for pthread.h... (cached) yes

checking for process shared libpthread support... yes

checking for libevent support... yes

checking for gawk... (cached) gawk

checking for curl-config... no

configure: error: Curl library not found

解决方法:

yum install libcurl-devel

错误11

#网页报错:

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

#httpd日志报错:

[Fri May 13 10:03:52.004331 2022] [proxy:error] [pid 2176:tid 281458065272864] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php-fpm/www.sock (*) failed

[Fri May 13 10:03:52.004401 2022] [proxy_fcgi:error] [pid 2176:tid 281458065272864] [client 10.10.10.20:1582] AH01079: failed to make connection to backend: httpd-UDS

解决方法:

安装php-fpm,运行php-fpm

yum install php-fpm

mkdir -p /run/php-fpm

php-fpm

错误12

/var/log/php-fpm/www-error.log

[13-May-2022 13:50:23 Asia/Shanghai] PHP Fatal error: Uncaught Error: Call to undefined function json_decode() in /var/www/html/zabbix/include/classes/core/CCookieSession.php:101

Stack trace:

#0 [internal function]: CCookieSession->read('0e761bfd46aae4f...')

#1 /var/www/html/zabbix/include/classes/core/CCookieSession.php(147): session_start()

#2 /var/www/html/zabbix/include/classes/core/ZBase.php(243): CCookieSession->session_start('0e761bfd46aae4f...')

#3 /var/www/html/zabbix/setup.php(27): ZBase->run('setup')

#4 {main}

thrown in /var/www/html/zabbix/include/classes/core/CCookieSession.php on line 101

解决方案:

yum install php-json

错误13

启动zabbix_server报错:

tail -f /tmp/zabbix_server.log

12838:20220513:142754.402 Starting Zabbix Server. Zabbix 6.0.4 (revision 3d787ff402e).

12838:20220513:142754.402 ****** Enabled features ******

12838:20220513:142754.402 SNMP monitoring: YES

12838:20220513:142754.402 IPMI monitoring: YES

12838:20220513:142754.402 Web monitoring: YES

12838:20220513:142754.402 VMware monitoring: YES

12838:20220513:142754.402 SMTP authentication: YES

12838:20220513:142754.402 ODBC: NO

12838:20220513:142754.402 SSH support: NO

12838:20220513:142754.402 IPv6 support: YES

12838:20220513:142754.402 TLS support: NO

12838:20220513:142754.402 ******************************

12838:20220513:142754.402 using configuration file: /usr/local/etc/zabbix_server.conf

12838:20220513:142754.405 [Z3001] connection to database 'zabbix' failed: [2059] Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory

12838:20220513:142754.405 Cannot connect to the database. Exiting...

解决方法:

ALTER USER 'zabbixt'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';  

 FLUSH PRIVILEGES;   #刷新权限 

posted @ 2022-12-01 18:05  老油条666  阅读(2886)  评论(0编辑  收藏  举报