docker container wont start with Mysql docker image - docker

I use docker container with mysql offical images to create more than 11 database container, (container1 to container11). after setting up, all container running fine until container9. At container10, it only starts up about 1 mins and stop again. using docker logs to check container but I do not see anything. stop container9, and restart container10. It runs fine again. The situation seems only happen when I have 9 mysql container and trying to raise up 10th. If I stop one of them, and raise it up again. Then there is no problem. Is it bugs? or I miss some setting for docker bridge?
root#ec8dcb82f64d:/dev/shm# docker restart f4801b57c4cc
f4801b57c4cc
root#ec8dcb82f64d:/dev/shm# docker ps -a | grep f4801b57c4cc
f4801b57c4cc mysql/mysql-server:5.7 "/entrypoint.sh my..." 2 weeks ago Exited (1) 3 seconds ago db
root#ec8dcb82f64d:/dev/shm# docker logs f4801b57c4cc
Initializing database
Database initialized
MySQL init process in progress...
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
/entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
MySQL init process done. Ready for start up.
root#ec8dcb82f64d:/dev/shm#

I think I hit the solution after one week even though I do not really understand what happens. the following is what I tried and so far, I can bring up mysql container up to 20 with no problems.
1: Try to create a dummpy mysql container for testing
$ docker run -e MYSQL_ROOT_PASSWORD=password mysql
Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql
...
Initializing database
2017-08-09T17:58:30.034595Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-09T17:58:30.039274Z 0 [Warning] InnoDB: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
2017-08-09T17:58:30.039294Z 0 [Warning] InnoDB: io_setup() attempt 1.
2017-08-09T17:58:30.539495Z 0 [Warning] InnoDB: io_setup() attempt 2.
2017-08-09T17:58:31.039701Z 0 [Warning] InnoDB: io_setup() attempt 3.
2017-08-09T17:58:31.539902Z 0 [Warning] InnoDB: io_setup() attempt 4.
2017-08-09T17:58:32.040115Z 0 [Warning] InnoDB: io_setup() attempt 5.
2017-08-09T17:58:32.540330Z 0 [ERROR] InnoDB: io_setup() failed with EAGAIN after 5 attempts.
2017-08-09T17:58:32.540378Z 0 [ERROR] InnoDB: Cannot initialize AIO sub-system
2017-08-09T17:58:32.540390Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-08-09T17:58:32.540401Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-08-09T17:58:32.540408Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-08-09T17:58:32.540412Z 0 [ERROR] Failed to initialize plugins.
2017-08-09T17:58:32.540415Z 0 [ERROR] Aborting
and hit the error code for io_setup() failed with EAGAIN
2: Examines the current value of aio-max-nr
$ sysctl fs.aio-max-nr
fs.aio-max-nr = 65536
3: Increase the value of aio-max-nr to 2097152
$ sudo sysctl -w fs.aio-max-nr=2097152
3: Start mysql service
4: Try to create more mysql-containers and bring up original one with no problems

Run docker events in background and then try starting your 10th container. You will surely see what's going wrong. Given below is an example to start an exited container and error while starting it. Commands below in sequence:
~$ sudo docker events &
[1] 9414
~$ sudo docker start 48137950f1b7
2017-08-03T00:01:18.971406558+05:30 network connect c79096ff0fef046d24b2a23907b3cc82c4df0838db2475909f8fa9f796a0418e (container=48137950f1b714797143529d63ec7221d3cbcd38bb6c8d20a241b06ddbd3d27a, name=bridge, type=bridge)
2017-08-03T00:01:19.305063392+05:30 container start 48137950f1b714797143529d63ec7221d3cbcd38bb6c8d20a241b06ddbd3d27a (image=ubuntu, name=modest_northcutt)
48137950f1b7
2017-08-03T00:01:19.305915636+05:30 container die 48137950f1b714797143529d63ec7221d3cbcd38bb6c8d20a241b06ddbd3d27a (exitCode=0, image=ubuntu, name=modest_northcutt)
Hope you will figure out.

Related

Mounting mariadb backup to docker container

I took mariadb backup of my mariadb server using below command:
mariabackup --backup --target-dir=/root/mariabackup --databases='MYDATABASE' -- tables='Table7' --user=root
ls /root/mariabackup
MYDATABASE backup-my.cnf ibdata1
aria_log.00000001 ib_buffer_pool xtrabackup_checkpoints
aria_log_control ib_logfile0 xtrabackup_info
I run my container and mount above directory with /var/lib/mysql using below command:
docker run --name=BackupCont -e MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=Y -p 3309:3309 --mount type=bind,src=/root/mariabackup,dst=/var/lib/mysql -d mariadb
I run docker logs BackupCont and it shows below:
2022-05-30 07:59:18+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.8.3+maria~jammy started.
2022-05-30 07:59:18+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-05-30 07:59:18+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.8.3+maria~jammy started.
2022-05-30 07:59:18+00:00 [Note] [Entrypoint]: Initializing database files
2022-05-30 7:59:18 0 [Warning] mariadbd: io_uring_queue_init() failed with ENOMEM: try larger memory locked limit, ulimit -l, or https://mariadb.com/kb/en/systemd/#configuring-limitmemlock under systemd (262144 bytes required)
2022-05-30 7:59:18 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
2022-05-30 7:59:18 0 [ERROR] InnoDB: File ./ib_logfile0 is too small
2022-05-30 7:59:18 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2022-05-30 7:59:18 0 [ERROR] Plugin 'InnoDB' init function returned error.
2022-05-30 7:59:18 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2022-05-30 7:59:18 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2022-05-30 7:59:18 0 [ERROR] Aborting
Installation of system tables failed! Examine the logs in
/var/lib/mysql/ for more information.
The problem could be conflicting information in an external
my.cnf files. You can ignore these by doing:
shell> /usr/bin/mariadb-install-db --defaults-file=~/.my.cnf
You can also try to start the mysqld daemon with:
shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &
and use the command line tool /usr/bin/mariadb
to connect to the mysql database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables;
Try 'mysqld --help' if you have problems with paths. Using
--general-log gives you a log in /var/lib/mysql/ that may be helpful.
The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
You can find the latest source at https://downloads.mariadb.org and
the maria-discuss email list at https://launchpad.net/~maria-discuss
Please check all of the above before submitting a bug report
at https://mariadb.org/jira
You can see after running the container when I run docker logs BackupCont, this is the error I am getting while mounting. The backup directory have backup of mariadb version 10.3.34

Cannot run nodetool commands and cqlsh to Scylla in Docker

I am new to Scylla and I am following the instructions to try it in a container as per this page: https://hub.docker.com/r/scylladb/scylla/.
The following command ran fine.
docker run --name some-scylla --hostname some-scylla -d scylladb/scylla
I see the container is running.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e6c4e19ff1bd scylladb/scylla "/docker-entrypoint.…" 14 seconds ago Up 13 seconds 22/tcp, 7000-7001/tcp, 9042/tcp, 9160/tcp, 9180/tcp, 10000/tcp some-scylla
However, I'm unable to use nodetool or cqlsh. I get the following output.
$ docker exec -it some-scylla nodetool status
Using /etc/scylla/scylla.yaml as the config file
nodetool: Unable to connect to Scylla API server: java.net.ConnectException: Connection refused (Connection refused)
See 'nodetool help' or 'nodetool help <command>'.
and
$ docker exec -it some-scylla cqlsh
Connection error: ('Unable to connect to any servers', {'172.17.0.2': error(111, "Tried connecting to [('172.17.0.2', 9042)]. Last error: Connection refused")})
Any ideas?
Update
Looking at docker logs some-scylla I see some errors in the logs, the last one is as follows.
2021-10-03 07:51:04,771 INFO spawned: 'scylla' with pid 167
Scylla version 4.4.4-0.20210801.69daa9fd0 with build-id eb11cddd30e88ef39c32c847e70181b5cf786355 starting ...
command used: "/usr/bin/scylla --log-to-syslog 0 --log-to-stdout 1 --default-log-level info --network-stack posix --developer-mode=1 --overprovisioned --listen-address 172.17.0.2 --rpc-address 172.17.0.2 --seed-provider-parameters seeds=172.17.0.2 --blocked-reactor-notify-ms 999999999"
parsed command line options: [log-to-syslog: 0, log-to-stdout: 1, default-log-level: info, network-stack: posix, developer-mode: 1, overprovisioned, listen-address: 172.17.0.2, rpc-address: 172.17.0.2, seed-provider-parameters: seeds=172.17.0.2, blocked-reactor-notify-ms: 999999999]
ERROR 2021-10-03 07:51:05,203 [shard 6] seastar - Could not setup Async I/O: Resource temporarily unavailable. The most common cause is not enough request capacity in /proc/sys/fs/aio-max-nr. Try increasing that number or reducing the amount of logical CPUs available for your application
2021-10-03 07:51:05,316 INFO exited: scylla (exit status 1; not expected)
2021-10-03 07:51:06,318 INFO gave up: scylla entered FATAL state, too many start retries too quickly
Update 2
The reason for the error was described on the docker hub page linked above. I had to start container specifying the number of CPUs with --smp 1 as follows.
docker run --name some-scylla --hostname some-scylla -d scylladb/scylla --smp 1
According to the above page:
This command will start a Scylla single-node cluster in developer mode
(see --developer-mode 1) limited by a single CPU core (see --smp).
Production grade configuration requires tuning a few kernel parameters
such that limiting number of available cores (with --smp 1) is the
simplest way to go.
Multiple cores requires setting a proper value to the
/proc/sys/fs/aio-max-nr. On many non production systems it will be
equal to 65K. ...
As you have found out, in order to be able to use additional CPU cores you'll need to increase fs.aio-max-nr kernel parameter.
You may run as root:
# sysctl -w fs.aio-max-nr=65535
Which should be enough for most systems. Should you still have any error preventing it to use all of your CPU cores, increase its value further.
Do notice that the above configuration is not persistent. Edit /etc/sysctl.conf in order to make it persistent across reboots.

Running a Chainlink Node - Can't connect to database

Using docker-desktop on macOS.
I'm trying to run a node following the instructions on this page.
The database name is node, which is the same as the username: node. The user has access to the database and can log in using psql client.
Connection strings I've tried in the .env file:
postgresql://node#localhost/node
postgresql://node:password#localhost/node
postgresql://node:password#localhost:5432/node
postgresql://node:password#127.0.0.1:5432/node
postgresql://node:password#127.0.0.1/node
When I run the start command: cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink local n , using docker-desktop on macOS, I get the following stack trace:
2020-09-15T14:24:41Z [INFO] Starting Chainlink Node 0.8.15 at commit a904730bd62c7174b80a2c4ccf885de3e78e3971 cmd/local_client.go:50
2020-09-15T14:24:41Z [INFO] SGX enclave *NOT* loaded cmd/enclave.go:11
2020-09-15T14:24:41Z [INFO] This version of chainlink was not built with support for SGX tasks cmd/enclave.go:12
2020-09-15T14:24:41Z [INFO] Locking postgres for exclusive access with 500ms timeout orm/orm.go:69
2020-09-15T14:24:41Z [ERROR] unable to lock ORM: dial tcp 127.0.0.1:5432: connect: connection refused logger/default.go:139 stacktrace=github.com/smartcontractkit/chainlink/core/logger.Error
/chainlink/core/logger/default.go:117
...
Does anyone know how I can resolve this?
The problem probably caused by the fact that your chainlink database has been locked with Exclusive Lock and before stopping node that locks never removed.
What you do in this situation (as what works for me) is use PgAdmin Ui or similar way to find all Locks then find the Exclusive Lock that is held on the chainlink database and note down its Process id or ids (if multiple exclusive locks there are on chainlink DB)
Log in to your pg client and run SELECT pg_terminate_backend(<pid>) or SELECT pg_cancel_backend(<pid>); Enter PID of those locks here without quotes and meanwhile keep refreshing on pg admin URL to see if those processes stopped If stopped then rerun your chainlink node.
The problem is with docker networking.
Add --network host to the docker run command so that it is:
cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink --network host local n
This fixes the issue.

Thingsboard installation using docker on Ubuntu

I'm facing issues when installing thingsboard using docker-compose on ubuntu
images are correctly pulled , container seems to be up but logs shows :
logs for thingsboard/application:1.2.2 :
thingsboard-db-schema container is still in progress. waiting until it
completed...
thingsboard-db-schema container is still in progress. waiting until it
completed...
thingsboard-db-schema container is still in progress. waiting until it
completed...
thingsboard-db-schema container is still in progress. waiting until it
completed...
thingsboard-db-schema container is still in progress. waiting until it
completed...
thingsboard-db-schema container is still in progress. waiting until it
completed...
logs for thingsboard/thingsboard-db-schema:1.2.2
Wait for Cassandra...
Failed to resolve "db".
WARNING: No targets were specified, so 0 hosts scanned.
Wait for Cassandra...
Failed to resolve "db".
WARNING: No targets were specified, so 0 hosts scanned.
Wait for Cassandra...
seems that the first container waiting cassandra to be up which is not the case
Any suggestions ?
Thanks in advance
Please check output of the DB container using command 'docker-compose logs -f db' and verify that cassandra is ready to accept client on 9042 port:
db_1 | INFO 11:02:07 Waiting for gossip to settle before accepting client requests...
db_1 | INFO 11:02:15 No gossip backlog; proceeding
db_1 | INFO 11:02:15 Netty using native Epoll event loop
db_1 | INFO 11:02:15 Using Netty Version: [netty-buffer=netty-buffer-4.0.39.Final.38bdf86, netty-codec=netty-codec-4.0.39.Final.38bdf86, netty-codec-haproxy=netty-codec-haproxy-4.0.39.Final.38bdf86, netty-codec-http=netty-codec-http-4.0.39.Final.38bdf86, netty-codec-socks=netty-codec-socks-4.0.39.Final.38bdf86, netty-common=netty-common-4.0.39.Final.38bdf86, netty-handler=netty-handler-4.0.39.Final.38bdf86, netty-tcnative=netty-tcnative-1.1.33.Fork19.fe4816e, netty-transport=netty-transport-4.0.39.Final.38bdf86, netty-transport-native-epoll=netty-transport-native-epoll-4.0.39.Final.38bdf86, netty-transport-rxtx=netty-transport-rxtx-4.0.39.Final.38bdf86, netty-transport-sctp=netty-transport-sctp-4.0.39.Final.38bdf86, netty-transport-udt=netty-transport-udt-4.0.39.Final.38bdf86]
db_1 | INFO 11:02:15 Starting listening for CQL clients on /0.0.0.0:9042 (unencrypted)...
Output should be like logs above.
Plus additionally verify that no errors happened during the cassandra start up.

can't connect to local mysql server through socket while running db using volume

while running my db container it shows error
start-database.sh file:
!/bin/bash
# This script starts the database server.
echo "Creating user $user for databases loaded from $url"
Import database if provided via docker run --env url="http:/ex.org/db.sql"
echo "Adding data into MySQL"
/usr/sbin/mysqld &
sleep 5
curl $url -o import.sql
Fixing some phpmysqladmin export problems
sed -ri.bak 's/-- Database: (.*?)/CREATE DATABASE \1;\nUSE \1;/g' import.sql
Fixing some mysqldump export problems (when run without --databases switch)
This is not tested so far.
if grep -q "CREATE DATABASE" import.sql; then :;
else
sed -ri.bak 's/-- MySQL dump/CREATE DATABASE `database_1`;\nUSE `database_1`;\n-- MySQL dump/g' import.sql;
fi
mysql --default-character-set=utf8 < import.sql
rm import.sql
mysqladmin shutdown
echo "finished"
Now the provided user credentials are added
/usr/sbin/mysqld &
sleep 5
echo "Creating user"
echo "CREATE USER '$user' IDENTIFIED BY '$password'" | mysql --default-character-set=utf8
echo "REVOKE ALL PRIVILEGES ON *.* FROM '$user'#'%'; FLUSH PRIVILEGES" | mysql --default-character-set=utf8
echo "GRANT SELECT ON *.* TO '$user'#'%'; FLUSH PRIVILEGES" | mysql --default-character-set=utf8
echo "finished"
if [ "$right" = "WRITE" ]; then
echo "adding write access"
echo "GRANT ALL PRIVILEGES ON *.* TO '$user'#'%' WITH GRANT OPTION; FLUSH PRIVILEGES" | mysql --default-character-set=utf8
fi
And we restart the server to go operational
mysqladmin shutdown
echo "Starting MySQL Server"
/usr/sbin/mysqld
ERROR:
docker_admin#ubuntu:~$ **sudo docker run -v /home/docker_admin/datadb:/var/lib/mysql:rw --name mysqldb sqldb**
Creating user root for databases loaded from file:/var/db/database.sql
Adding data into MySQL
151218 11:31:51 [Warning] Using unique option prefix
lower_case_table_name instead of lower_case_table_names is deprecated
and will be removed in a future release. Please use the full name
instead. 151218 11:31:51 [Warning] Using unique option prefix
key_buffer instead of key_buffer_size is deprecated and will be
removed in a future release. Please use the full name instead. 151218
11:31:51 [Note] /usr/sbin/mysqld (mysqld 5.5.46-0ubuntu0.14.04.2)
starting as process 5 ... % Total % Received % Xferd Average
Speed Time Time Time Current
Dload Upload Total Spent Left Speed 100 1105M 100 1105M 0 0 49.7M 0 0:00:22 0:00:22
--:--:-- 22.1M ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) mysqladmin: connect
to server at 'localhost' failed error: 'Can't connect to local MySQL
server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that
mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock'
exists! finished 151218 11:32:30 [Warning] Using unique option prefix
lower_case_table_name instead of lower_case_table_names is deprecated
and will be removed in a future release. Please use the full name
instead. 151218 11:32:30 [Warning] Using unique option prefix
key_buffer instead of key_buffer_size is deprecated and will be
removed in a future release. Please use the full name instead. 151218
11:32:30 [Note] /usr/sbin/mysqld (mysqld 5.5.46-0ubuntu0.14.04.2)
starting as process 25 ... Creating user ERROR 2002 (HY000): Can't
connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2) ERROR 2002 (HY000): Can't connect to
local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2) finished adding write access ERROR
2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2) mysqladmin: connect to server at
'localhost' failed error: 'Can't connect to local MySQL server through
socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running
and that the socket: '/var/run/mysqld/mysqld.sock' exists! Starting
MySQL Server 151218 11:32:35 [Warning] Using unique option prefix
lower_case_table_name instead of lower_case_table_names is deprecated
and will be removed in a future release. Please use the full name
instead. 151218 11:32:35 [Warning] Using unique option prefix
key_buffer instead of key_buffer_size is deprecated and will be
removed in a future release. Please use the full name instead. 151218
11:32:35 [Note] /usr/sbin/mysqld (mysqld 5.5.46-0ubuntu0.14.04.2)
starting as process 52 ...

Resources