TeamSpeak-Systems / teamspeak-linux-docker-images

docker build files for TeamSpeak servers
Other
114 stars 52 forks source link

Database connection fails #37

Closed christianvw closed 3 years ago

christianvw commented 4 years ago

Hi,

every time I want to create a teamspeak server using docker-compose, the database connection can't be established even using the example docker-compoye.yml.

docker-compose.yml

version: '3.1'
services:
  teamspeak:
    image: teamspeak
    restart: always
    ports:
      - 9987:9987/udp
      - 10011:10011
      - 30033:30033
    environment:
      TS3SERVER_DB_PLUGIN: ts3db_mariadb
      TS3SERVER_DB_SQLCREATEPATH: create_mariadb
      TS3SERVER_DB_HOST: db
      TS3SERVER_DB_USER: root
      TS3SERVER_DB_PASSWORD: example
      TS3SERVER_DB_NAME: teamspeak
      TS3SERVER_DB_WAITUNTILREADY: 30
      TS3SERVER_LICENSE: accept
  db:
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: teamspeak

error

Recreating teamspeak_db_1        ... done
Recreating teamspeak_teamspeak_1 ... done
Attaching to db, teamspeak
teamspeak    | 2019-10-26 22:11:32.785654|INFO    |ServerLibPriv |   |TeamSpeak 3 Server 3.9.1 (2019-07-02 13:17:23)
teamspeak    | 2019-10-26 22:11:32.785830|INFO    |ServerLibPriv |   |SystemInformation: Linux 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u3 (2019-06-16) x86_64 Binary: 64bit
teamspeak    | 2019-10-26 22:11:32.786245|INFO    |DatabaseQuery |   |dbPlugin name:    MariaDB plugin, version 3, (c)TeamSpeak Systems GmbH
teamspeak    | 2019-10-26 22:11:32.786307|INFO    |DatabaseQuery |   |dbPlugin version: 2
db           | 2019-10-26 22:11:33 0 [Note] mysqld (mysqld 10.4.8-MariaDB-1:10.4.8+maria~bionic) starting as process 1 ...
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Using Linux native AIO
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Uses event mutexes
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Number of pools: 1
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Using SSE2 crc32 instructions
db           | 2019-10-26 22:11:33 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Completed initialization of buffer pool
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=7164945
db           | 2019-10-26 22:11:33 0 [Note] InnoDB: Starting final batch to recover 238 pages from redo log.
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: Waiting for purge to start
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: 10.4.8 started; log sequence number 8798519; transaction id 8852
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db           | 2019-10-26 22:11:34 0 [Note] Plugin 'FEEDBACK' is disabled.
db           | 2019-10-26 22:11:34 0 [Note] Server socket created on IP: '::'.
db           | 2019-10-26 22:11:34 0 [Note] InnoDB: Buffer pool(s) load completed at 191026 22:11:34
db           | 2019-10-26 22:11:34 0 [Warning] 'user' entry 'root@60157fcf4e5a' ignored in --skip-name-resolve mode.
db           | 2019-10-26 22:11:34 0 [Warning] 'user' entry '@60157fcf4e5a' ignored in --skip-name-resolve mode.
db           | 2019-10-26 22:11:34 0 [Warning] 'proxies_priv' entry '@% root@60157fcf4e5a' ignored in --skip-name-resolve mode.
db           | 2019-10-26 22:11:34 0 [Note] Reading of all Master_info entries succeeded
db           | 2019-10-26 22:11:34 0 [Note] Added new Master_info '' to hash table
db           | 2019-10-26 22:11:34 0 [Note] mysqld: ready for connections.
db           | Version: '10.4.8-MariaDB-1:10.4.8+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
db           | 2019-10-26 22:11:34 8 [Warning] Aborted connection 8 to db: 'unconnected' user: 'unauthenticated' host: '172.25.0.3' (This connection closed normally without authentication)
db           | 2019-10-26 22:11:34 9 [Warning] Aborted connection 9 to db: 'unconnected' user: 'unauthenticated' host: '172.25.0.3' (This connection closed normally without authentication)
db           | 2019-10-26 22:11:34 10 [Warning] Aborted connection 10 to db: 'unconnected' user: 'unauthenticated' host: '172.25.0.3' (This connection closed normally without authentication)
db           | 2019-10-26 22:11:35 11 [Warning] Aborted connection 11 to db: 'unconnected' user: 'unauthenticated' host: '172.25.0.3' (This connection closed normally without authentication)
db           | 2019-10-26 22:11:35 12 [Warning] Aborted connection 12 to db: 'unconnected' user: 'unauthenticated' host: '172.25.0.3' (This connection closed normally without authentication)
db           | 2019-10-26 22:11:35 13 [Warning] Aborted connection 13 to db: 'unconnected' user: 'unauthenticated' host: '172.25.0.3' (This connection closed normally without authentication)
^CGracefully stopping... (press Ctrl+C again to force)
Stopping teamspeak               ... done
Stopping db                      ... done

What could be the mistake here?

BRUTTUZ commented 4 years ago

Hi,

I'm getting the same error when trying to start a server on a fresh machine. Sometimes I'll also get Could not connect to mariadb server: Can't connect to MySQL server on 'db' Sorry, this is no help for you, but at least you're not alone :-)

muenchow commented 4 years ago

@christianvw tested the docker-compose and it worked fine.

geropan commented 4 years ago

I was getting the following error as well: Could not connect to mariadb server: Can't connect to MySQL server on 'db'

I believe the issue is that the teamspeak service can be created before the db one, therefore not being able to resolve db as an address.

Adding db as a dependency to the teamspeak services seems to solve the issue (see below).

docker-compose.yml

version: '3.1'
services:
  teamspeak:
    image: teamspeak
    restart: always
    ports:
      - 9987:9987/udp
      - 10011:10011
      - 30033:30033
    environment:
      TS3SERVER_DB_PLUGIN: ts3db_mariadb
      TS3SERVER_DB_SQLCREATEPATH: create_mariadb
      TS3SERVER_DB_HOST: db
      TS3SERVER_DB_USER: root
      TS3SERVER_DB_PASSWORD: example
      TS3SERVER_DB_NAME: teamspeak
      TS3SERVER_DB_WAITUNTILREADY: 30
      TS3SERVER_LICENSE: accept
    depends_on:
      - db
  db:
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: teamspeak

Maybe the documentation should be updated to reflect this.

zumindestens commented 4 years ago

I ran into the same issue. Reason for me was the firewall. Ubuntu Server 18.04. ships with ufw. Make sure to allow the necessary ports.

sjuswede commented 4 years ago

I get the same problem. It appeared spontaneously, after the image working for months. Now I can't get it to run again. Not firewall related, and I tried adding the db dependency, but it makes no difference.

christianvw commented 3 years ago

I have no problem anymore for whatever reason with the docker-compose.yml by @geropan - even without the addition of the dependecy, but this might help nevertheless.