Docker安装Zabbix-server出现[its "users" table is empty]问题的解决
简述安装过程
docker run --name zabbix-db --network zabbixnet -e MYSQL_ROOT_PASSWORD="password" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_DATABASE="zabbix" -d mysql
docker run --name zabbix-server --network zabbixnet -e DB_SERVER_HOST="zabbix-db" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -d zabbix/zabbix-server-mysql docker run --name zabbix-front --network zabbixnet --link zabbix-server -p80:8080 -e DB_SERVER_HOST="zabbix-db" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e PHP_TZ="Europe/Madrid" -d zabbix/zabbix-web-apache-mysql
然后启动报错:
** Preparing Zabbix server ** Using MYSQL_USER variable from ENV ** Using MYSQL_PASSWORD variable from ENV ******************** * DB_SERVER_HOST: zabbix-db * DB_SERVER_PORT: 3306 * DB_SERVER_DBNAME: zabbix ******************** ** Database 'zabbix' already exists. Please be careful with database COLLATE! ** Creating 'zabbix' schema in MySQL ** Preparing Zabbix server configuration file ** Updating '/etc/zabbix/zabbix_server.conf' parameter "ListenIP": ''...removed ** Updating '/etc/zabbix/zabbix_server.conf' parameter "ListenPort": ''...removed ** Updating '/etc/zabbix/zabbix_server.conf' parameter "ListenBacklog": ''...removed ** Updating '/etc/zabbix/zabbix_server.conf' parameter "SourceIP": ''...removed ** Updating '/etc/zabbix/zabbix_server.conf' parameter "LogType": 'console'...updated ** Updating '/etc/zabbix/zabbix_server.conf' parameter "LogFile": ''...removed ** Updating '/etc/zabbix/zabbix_server.conf' parameter "LogFileSize": ''...removed [...] ** Updating '/etc/zabbix/zabbix_server.conf' parameter "ProxyDataFrequency": ''...removed ** Updating '/etc/zabbix/zabbix_server.conf' parameter "SSLCertLocation": '/var/lib/zabbix/ssl/certs/'...updated ** Updating '/etc/zabbix/zabbix_server.conf' parameter "SSLKeyLocation": '/var/lib/zabbix/ssl/keys/'...updated ** Updating '/etc/zabbix/zabbix_server.conf' parameter "SSLCALocation": '/var/lib/zabbix/ssl/ssl_ca/'...updated ** Updating '/etc/zabbix/zabbix_server.conf' parameter "LoadModulePath": '/var/lib/zabbix/modules/'...updated ** Updating '/etc/zabbix/zabbix_server.conf' parameter "HANodeName": ''...removed ** Updating '/etc/zabbix/zabbix_server.conf' parameter "NodeAddress": ''...removed ** Updating '/etc/zabbix/zabbix_server.conf' parameter "User": 'zabbix'...updated Starting Zabbix Server. Zabbix 6.2.2 (revision 3545586). Press Ctrl+C to exit. 7:20220913:082616.221 Starting Zabbix Server. Zabbix 6.2.2 (revision 3545586). 7:20220913:082616.221 ****** Enabled features ****** 7:20220913:082616.221 SNMP monitoring: YES 7:20220913:082616.221 IPMI monitoring: YES 7:20220913:082616.221 Web monitoring: YES 7:20220913:082616.221 VMware monitoring: YES 7:20220913:082616.221 SMTP authentication: YES 7:20220913:082616.221 ODBC: YES 7:20220913:082616.221 SSH support: YES 7:20220913:082616.221 IPv6 support: YES 7:20220913:082616.221 TLS support: YES 7:20220913:082616.221 ****************************** 7:20220913:082616.221 using configuration file: /etc/zabbix/zabbix_server.conf 7:20220913:082616.223 cannot use database "zabbix": its "users" table is empty (is this the Zabbix proxy database?)
查看数据库:
mysql> select * from users; Empty set (0.00 sec)
无法启动。
解决方案:
用Docker再起一个数据库,注意使用mariadb image而不是mysql。
docker run --name zabbix-db -t \ -p 3306:3306 \ -e MYSQL_DATABASE="zabbix" \ -e MYSQL_USER="zabbix" \ -e MYSQL_PASSWORD="zabbix_pwd" \ -e MYSQL_ROOT_HOST="%" \ -e MYSQL_ROOT_PASSWORD="root_pwd" \ --network=zabbixnet \ -v mysql-data22:/var/lib/mysql \ --restart unless-stopped \ --cap-add=sys_nice \ -d mariadb \ --character-set-server=utf8 \ --collation-server=utf8_bin \ --default-authentication-plugin=mysql_native_password \ --disable-log-bin
-----