weixin_39621860
weixin_39621860
2021-01-01 07:37

MySQL server is not available. Waiting 5 seconds...

Hi, I cannot run the default version of zabbix. I'm trying to run a docker-compose version, I didn't change anything in config and I cannot connect to webserver.

MySQL log is OK. Apache log: docker logs 5a999feccdb4 Preparing Zabbix proxy Using MYSQL_USER variable from ENV Using MYSQL_PASSWORD variable from ENV ** Using MYSQL_ROOT_PASSWORD variable from ENV

  • DB_SERVER_HOST: mysql-server
  • DB_SERVER_PORT: 3306
  • DB_SERVER_DBNAME: zabbix_proxy

* MySQL server is not available. Waiting 5 seconds... MySQL server is not available. Waiting 5 seconds... *** MySQL server is not available. Waiting 5 seconds...

I can connect directly to mysql and also from mysql container.

I tried this on multiple machines with CentOS8.

该提问来源于开源项目:zabbix/zabbix-docker

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

19条回答

  • u012940672 talentL 1月前

    如果是zabbix-server-mysql镜像,建议看下数据库权限是否给足

    点赞 评论 复制链接分享
  • weixin_39855634 weixin_39855634 3月前

    what image do you use?

    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    Alpine MySQL latest.

    点赞 评论 复制链接分享
  • weixin_39855634 weixin_39855634 3月前

    Start the container with "DEBUG_MODE" = "true" env variable and attach container log output to the issue.

    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    Which container do you mean? I used docker-composed before.

    点赞 评论 复制链接分享
  • weixin_39855634 weixin_39855634 3月前

    Container with:

    
    **** MySQL server is not available. Waiting 5 seconds...
    
    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    Could you please be more specific, I'm not that skilled. Where should I add DEBUG_MODE exactly?

    Container with this error is zabbix/zabbix-web-apache-mysql:alpine

    Thank you for your patience.

    点赞 评论 复制链接分享
  • weixin_39855634 weixin_39855634 3月前

    if you use compose file from our distribution, you need add that env variable with the value to .env_prx file and restart Proxy container.

    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    I tried to add "DEBUG_MODE" = "true" to .env_prx but it hasn't any had any impact on logs. I also tried to change the value on DEBUG_LEVEL to 5 and the result is the same. I tried it with or without # at the beginning of the line and with and without ZBX_ prefix.

    cat .env_prx

    ZBX_PROXYMODE=0

    ZBX_SERVER_HOST=zabbix-server

    ZBX_SERVER_PORT=10051

    ZBX_HOSTNAME=zabbix-proxy-$db_type

    ZBX_ENABLEREMOTECOMMANDS=0 # Available since 3.4.0

    ZBX_LOGREMOTECOMMANDS=0 # Available since 3.4.0

    ZBX_HOSTNAMEITEM=system.hostname

    ZBX_SOURCEIP=

    ZBX_DBTLSCONNECT=require # Available since 5.0.0

    ZBX_DBTLSCAFILE=/run/secrets/root-ca.pem # Available since 5.0.0

    ZBX_DBTLSCERTFILE=/run/secrets/client-cert.pem # Available since 5.0.0

    ZBX_DBTLSKEYFILE=/run/secrets/client-key.pem # Available since 5.0.0

    ZBX_DBTLSCIPHER= # Available since 5.0.0

    ZBX_DBTLSCIPHER13= # Available since 5.0.0

    ZBX_DEBUGLEVEL=5

    ZBX_PROXYLOCALBUFFER=0

    ZBX_PROXYOFFLINEBUFFER=1

    ZBX_PROXYHEARTBEATFREQUENCY=60

    ZBX_CONFIGFREQUENCY=3600

    ZBX_DATASENDERFREQUENCY=1

    ZBX_STARTPOLLERS=5

    ZBX_IPMIPOLLERS=0

    ZBX_STARTPOLLERSUNREACHABLE=1

    ZBX_STARTTRAPPERS=5

    ZBX_STARTPINGERS=1

    ZBX_STARTDISCOVERERS=1

    ZBX_STARTHTTPPOLLERS=1

    ZBX_JAVAGATEWAY_ENABLE=false

    ZBX_JAVAGATEWAY=zabbix-java-gateway

    ZBX_JAVAGATEWAYPORT=10052

    ZBX_STARTJAVAPOLLERS=0

    ZBX_STARTVMWARECOLLECTORS=0

    ZBX_VMWAREFREQUENCY=60

    ZBX_VMWAREPERFFREQUENCY=60

    ZBX_VMWARECACHESIZE=8M

    ZBX_VMWARETIMEOUT=10

    ZBX_ENABLE_SNMP_TRAPS=false

    ZBX_LISTENIP=

    ZBX_HOUSEKEEPINGFREQUENCY=1

    ZBX_CACHESIZE=8M

    ZBX_STARTDBSYNCERS=4

    ZBX_HISTORYCACHESIZE=16M

    ZBX_HISTORYINDEXCACHESIZE=4M

    ZBX_TIMEOUT=4

    ZBX_TRAPPERIMEOUT=300

    ZBX_UNREACHABLEPERIOD=45

    ZBX_UNAVAILABLEDELAY=60

    ZBX_UNREACHABLEDELAY=15

    ZBX_LOGSLOWQUERIES=3000

    ZBX_LOADMODULE="dummy1.so,dummy2.so,dummy10.so"

    ZBX_TLSCONNECT=unencrypted

    ZBX_TLSACCEPT=unencrypted

    ZBX_TLSCAFILE=

    ZBX_TLSCRLFILE=

    ZBX_TLSSERVERCERTISSUER=

    ZBX_TLSSERVERCERTSUBJECT=

    ZBX_TLSCERTFILE=

    ZBX_TLSKEYFILE=

    ZBX_TLSPSKIDENTITY=

    ZBX_TLSPSKFILE=

    ZBX_DEBUG_MODE=true

    I probably did something wrong.

    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    OK, I attached the log file from the proxy container. proxy-log.txt

    点赞 评论 复制链接分享
  • weixin_39855634 weixin_39855634 3月前

    Now I see the proxy is running. I do not see any issues.

    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    At the very end of the log, you can see

    "Unable to connect to the server [zabbix-server]:10051 [cannot connect to [[zabbix-server]:10051]: [113] Host is unreachable]."

    At the web-apache log:

    "[zabbix-server]:10051 [cannot connect to [[zabbix-server]:10051]: [113] Host is unreachable]."

    I attached apache log.

    I still cannot connect to web server and docker ps shows Unhealthy on web apache and nginx.

    docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6a416e8a20d6 zabbix/zabbix-proxy-sqlite3:alpine-trunk "/sbin/tini -- /usr/…" 42 minutes ago Up 42 minutes 0.0.0.0:10061->10051/tcp zabbix-docker_zabbix-proxy-sqlite3_1 98b4e1b61c61 zabbix/zabbix-proxy-mysql:alpine-trunk "/sbin/tini -- /usr/…" 42 minutes ago Up 42 minutes 0.0.0.0:10071->10051/tcp zabbix-docker_zabbix-proxy-mysql_1 52f04d722ae3 zabbix/zabbix-web-nginx-mysql:alpine-trunk "docker-entrypoint.sh" 42 minutes ago Up 42 minutes (unhealthy) 0.0.0.0:8443->8443/tcp, 0.0.0.0:8081->8080/tcp zabbix-docker_zabbix-web-nginx-mysql_1 fc63ada09d98 zabbix/zabbix-web-apache-mysql:alpine-trunk "docker-entrypoint.s…" 42 minutes ago Up 42 minutes (unhealthy) 0.0.0.0:80->8080/tcp, 0.0.0.0:443->8443/tcp zabbix-docker_zabbix-web-apache-mysql_1 4f504cad0b0c zabbix/zabbix-agent:alpine-trunk "/sbin/tini -- /usr/…" 42 minutes ago Up 42 minutes zabbix-docker_zabbix-agent_1 c0e6cd79d9fb zabbix/zabbix-server-mysql:alpine-trunk "/sbin/tini -- /usr/…" 43 minutes ago Up 42 minutes 0.0.0.0:10051->10051/tcp zabbix-docker_zabbix-server_1 f07f6ca80f3c zabbix/zabbix-java-gateway:alpine-trunk "docker-entrypoint.s…" 43 minutes ago Up 43 minutes zabbix-docker_zabbix-java-gateway_1 14877ee09910 mysql:8.0 "docker-entrypoint.s…" 43 minutes ago Up 43 minutes zabbix-docker_mysql-server_1 61c9ae22412a zabbix/zabbix-snmptraps:alpine-trunk "/usr/bin/supervisor…" 43 minutes ago Up 43 minutes 0.0.0.0:162->1162/udp zabbix-docker_zabbix-snmptraps_1 web-apache.log

    点赞 评论 复制链接分享
  • weixin_39855634 weixin_39855634 3月前

    The error:

    "Unable to connect to the server [zabbix-server]:10051 [cannot connect to [[zabbix-server]:10051]: [113] Host is unreachable]."

    Is not related to Zabbix containers, it means that Zabbix proxy just can not reach Zabbix server host. Why... you need to check c0e6cd79d9fb container.

    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    I tried to connect to mysql from container zabbix/zabbix-server-mysql which didn't work. However I'm able to connect from docker host to mysql. I can ping from the container to mysql.

    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    Hi again,

    I found where the problem is - ContOS 8.

    It works well on CentOS 7 or the latest Ubuntu.

    点赞 评论 复制链接分享
  • weixin_39855634 weixin_39855634 3月前

    I can not reproduce the issue. Please tell where you have the issue and what is environment.

    点赞 评论 复制链接分享
  • weixin_39621860 weixin_39621860 3月前

    Fresh install of CentOS 8, nothing changed in your files, just start docker-compose.

    点赞 评论 复制链接分享
  • weixin_39855634 weixin_39855634 3月前

    CentOS 8 does not have docker-compose. At least officially yet.

    点赞 评论 复制链接分享
  • weixin_39531229 weixin_39531229 3月前

    I have problem this... and my OS Centos 8!! Start from docker-compose without option --host

    It works well with --host

    点赞 评论 复制链接分享