Docker MySQL exits after docker-compose up - mysql

I'm trying to run docker in Ubuntu, and I have a problem with MySQL. I always get this:
"/usr/bin/mysqld_safe" 5 seconds ago Exited (0).
I have installed this docker image without problems on two machines, but this one doesn't work.
Docker Info:
Client:
Version: 1.8.1
API version: 1.20
Go version: go1.4.2
Git commit: d12ea79
Built: Thu Aug 13 02:35:49 UTC 2015
OS/Arch: linux/amd64
Server:
Version: 1.8.1
API version: 1.20
Go version: go1.4.2
Git commit: d12ea79
Built: Thu Aug 13 02:35:49 UTC 2015
OS/Arch: linux/amd64
UNAME -A:
Linux xps 3.13.0-61-generic #100-Ubuntu SMP Wed Jul 29 11:21:34 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Any idea? Thanks!!

Related

apt upgrade mysqlserver freezes and will not upgrade (ubuntu server 20.04)

I had to kill the session and then the databases are inaccessible until I reboot the server.
When I log back in and issue ‘apt upgrade’ i get the following error.
E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
I run ‘dpkg --configure -a’ and get the following and then it just freezes
Setting up mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) ...
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 86150
On another tty
journalctl -xe gives this when the upgrade freezes.
-- The unit mysql.service has successfully entered the 'dead' state.
Jan 13 22:18:12 arpradio systemd[1]: Stopped MySQL Community Server.
-- Subject: A stop job for unit mysql.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit mysql.service has finished.
--
-- The job identifier is 582 and the job result is done.
Jan 13 22:18:13 arpradio audit[6057]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/usr/sbin/mysqld" pid>
Jan 13 22:18:13 arpradio kernel: audit: type=1400 audit(1610572693.036:16): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="uncon>
When I reboot and login mysqld is running
I have tried the following.
# cp -r /etc/mysql /etc/mysql_old
# apt autoremove
E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
# dpkg --configure -a
Setting up mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) ...
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 7451
And we are back here with the freeze.
If I check the mysql processes I find no process 7451 but this is the output.
# ps aux | grep mysql
root 1679 0.0 0.0 8644 4688 ? Ssl 22:23 0:00 dockerize -template /tmp/db.cnf.tmpl:/etc/mysql/conf.d/db.cnf /usr/local/bin/docker-entrypoint.sh mysqld
systemd+ 2526 0.3 0.1 2446780 99836 ? Sl 22:23 0:03 mysqld
root 7370 0.3 0.0 27940 19836 pts/0 S+ 22:38 0:00 /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/mysql-server-8.0.postinst configure 8.0.22-0ubuntu0.20.04.2
root 7379 0.0 0.0 9756 3772 pts/0 S+ 22:38 0:00 /bin/bash /var/lib/dpkg/info/mysql-server-8.0.postinst configure 8.0.22-0ubuntu0.20.04.2
mysql 7657 1.9 0.5 1869164 358336 pts/0 Sl+ 22:39 0:01 mysqld --user=mysql --init-file=/var/lib/mysql-files/tmp.gQukBE7GtT --socket=/tmp/tmp.KUFQmDDseF/mysqld.sock --pid-file=/tmp/tmp.KUFQmDDseF/mysqld.pid
root 7759 0.0 0.0 9032 724 pts/1 S+ 22:39 0:00 grep --color=auto mysql
I checked the status of mysql.service
# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Wed 2021-01-13 22:38:59 CET; 17min ago
Process: 649 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
Main PID: 649 (code=exited, status=0/SUCCESS)
Status: "Server shutdown complete"
Jan 13 22:21:43 arpradio systemd[1]: Starting MySQL Community Server...
Jan 13 22:21:45 arpradio systemd[1]: Started MySQL Community Server.
Jan 13 22:38:57 arpradio systemd[1]: Stopping MySQL Community Server...
Jan 13 22:38:59 arpradio systemd[1]: mysql.service: Succeeded.
Jan 13 22:38:59 arpradio systemd[1]: Stopped MySQL Community Server.
I fixed it, what I did was while the upgrade was hanging I ran
apt update && apt upgrade
on another tty and it upgraded everything, rebooted, I checked again after reboot and everything looks good.
# apt update
Hit:1 http://asi-fs-n.contabo.net/ubuntu focal InRelease
Hit:2 http://asi-fs-n.contabo.net/ubuntu focal-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:4 https://download.docker.com/linux/ubuntu focal InRelease
Hit:5 http://asi-fs-n.contabo.net/ubuntu focal-backports InRelease
Get:6 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Fetched 109 kB in 1s (112 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
root#arpradio:~# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root#arpradio:~# ps aux | grep mysql
mysql 657 1.2 0.6 2067208 378684 ? Ssl 23:09 0:02 /usr/sbin/mysqld
root 2148 0.1 0.0 9796 4784 ? Ssl 23:11 0:00 dockerize -template /tmp/db.cnf.tmpl:/etc/mysql/conf.d/db.cnf /usr/local/bin/docker-entrypoint.sh mysqld
systemd+ 2930 0.8 0.1 2380944 99508 ? Sl 23:11 0:00 mysqld
root 5507 0.0 0.0 9032 732 pts/0 S+ 23:12 0:00 grep --color=auto mysql
root#arpradio:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-01-13 23:09:06 CET; 3min 26s ago
Process: 560 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 657 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 72284)
Memory: 419.9M
CGroup: /system.slice/mysql.service
└─657 /usr/sbin/mysqld
Jan 13 23:09:04 arpradio systemd[1]: Starting MySQL Community Server...
Jan 13 23:09:06 arpradio systemd[1]: Started MySQL Community Server.

QEMU+Virt-manager can't connect to virtlxcd-sock

I've installed qemu virt-manager libvirt on Linux Mint 20, I have a AMD FX(tm)-4300 Quad-Core Processor with AMD-V enabled in the bios, restarted a lot but virt-manager(Virtual Machine Manager) is saying:
Unable to connect to libvirt lxc:///.
Failed to connect socket to '/var/run/libvirt/virtlxcd-sock': No such file or directory
Libvirt URI is: lxc:///
I am running this locally. The file/socket does not exist, but there is a "libvirt-sock" (and other files) in that folder.
The service is running, but reporting the same error:
libvirtd.service - Virtualization daemon
Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-09-01 10:11:27 BST; 12min ago
TriggeredBy: ● libvirtd.socket
● libvirtd-ro.socket
● libvirtd-admin.socket
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 731 (libvirtd)
Tasks: 19 (limit: 32768)
Memory: 34.2M
CGroup: /system.slice/libvirtd.service
├─ 731 /usr/sbin/libvirtd
├─1041 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt>
└─1042 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt>
Sep 01 10:11:29 mainlinux dnsmasq[1041]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Sep 01 10:11:29 mainlinux dnsmasq-dhcp[1041]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Sep 01 10:12:35 mainlinux libvirtd[731]: libvirt version: 6.0.0, package: 0ubuntu8.3 (Marc Deslauriers <marc.deslauriers#ubuntu.com> Thu, 30 >
Sep 01 10:12:35 mainlinux libvirtd[731]: hostname: mainlinux
Sep 01 10:12:35 mainlinux libvirtd[731]: Failed to connect socket to '/var/run/libvirt/virtlxcd-sock': No such file or directory
Sep 01 10:12:35 mainlinux libvirtd[731]: End of file while reading data: Input/output error
I'm updated my kernel to 5.8.5-generic, but other than that, running Mint 20 (based on Ubuntu focal). Anyone know how to fix this, or display a log as to why virtlxcd-sock is not being created?
Also tried sudo chmod 777 on the libvirt subfolder and restarted libvirtd, same error.
Been googling for hours, finally found the one that worked for me, seems like installing libvirt and lxc does not install this package:
sudo apt install libvirt-daemon-driver-lxc
sudo systemctl restart libvirtd

Sonarqube setup in Ubuntu

Trying to setup Sonarqube in Ubuntu 18.04 (on Ec2) using mysql, Went thru this digital Ocean tutorial
But after all that sudo service sonarqube start errors out:
ubuntu#ip-:/opt/sonarqube$ sudo service sonarqube start
Job for sonarqube.service failed because the control process exited with error code.
See "systemctl status sonarqube.service" and "journalctl -xe" for details.
ubuntu#ip-:/opt/sonarqube$ systemctl status sonarqube.service
sonarqube.service - SonarQube service
Loaded: loaded (/etc/systemd/system/sonarqube.service; disabled; vendor prese
Active: failed (Result: exit-code) since Fri 2019-10-04 16:45:33 UTC; 1min 43
Process: 11036 ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start (code=
Oct 04 16:45:32 ip-172-31-41-243 systemd[1]: sonarqube.service: Control process
Oct 04 16:45:32 ip-172-31-41-243 systemd[1]: sonarqube.service: Failed with resu
Oct 04 16:45:32 ip-172-31-41-243 systemd[1]: Failed to start SonarQube service.
Oct 04 16:45:33 ip-172-31-41-243 systemd[1]: sonarqube.service: Service hold-off
Oct 04 16:45:33 ip-172-31-41-243 systemd[1]: sonarqube.service: Scheduled restar
Oct 04 16:45:33 ip-172-31-41-243 systemd[1]: Stopped SonarQube service.
Oct 04 16:45:33 ip-172-31-41-243 systemd[1]: sonarqube.service: Start request re
Oct 04 16:45:33 ip-172-31-41-243 systemd[1]: sonarqube.service: Failed with resu
Oct 04 16:45:33 ip-172-31-41-243 systemd[1]: Failed to start SonarQube service.
Tried another tutorial and with different version of sonarqube and different DB - same result. Is there a resource requirement (memory) for sonarqube - I am deploying on EC2 t2.micro - 8GB - assuming that should be enough?
Tried /opt/sonarqube/bin/linux-x86-64/sonar.sh start this gives error:
Syntax error: newline unexpected (expecting ")"). I had Not edited the sonar.sh file
SonarQube Docker
Tried going Docker route - did not work.
Connection refused on port 9000. I have TCP/9000 opened in the Security Group and NACL is all open.
http://IP:9000 This site can’t be reached x.x.x.x refused to connect
I had a similar issue. Mine was caused by an extra white space in the systemctl service config file. I suggest you check properly, or delete and recreate the service file. More carefully this time.

Docker Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Ubuntu

I was playing with docker and mounted my local mysql to a docker container and connected MySql-Workbench so I could view the DB (experimenting) here is the command I ran.
docker run -d --name alldb-mysql -v /var/lib/mysql:/var/lib/mysql -e MYSQL_USER=root -e MYSQL_PASSWORD=password -p 3306:3306 mysql:latest
after I stopped my container and removed it, I can't start/restart mysql (local install). when I run sudo /etc/init.d/mysql start it returns
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
failed!
so I checked systemctl status mysql.service
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Mon 2017-04-03 22:26:15 IST; 26s ago
Process: 5470 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 5465 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 5470 (code=exited, status=1/FAILURE); : 5471 (mysql-systemd-s)
Tasks: 2
Memory: 1.6M
CPU: 222ms
CGroup: /system.slice/mysql.service
└─control
├─5471 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─6579 sleep 1
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.980564Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explici
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.980614Z 0 [Warning] Can't create test file /var/lib/mysql/n.lower-test
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.980638Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.17-0ubuntu0.16.04.1) starting as process 5470 .
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.981928Z 0 [Warning] Can't create test file /var/lib/mysql/n.lower-test
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.981936Z 0 [Warning] Can't create test file /var/lib/mysql/n.lower-test
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.982122Z 0 [ERROR] failed to set datadir to /var/lib/mysql/
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.982142Z 0 [ERROR] Aborting
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.982162Z 0 [Note] Binlog end
Apr 03 22:26:15 n mysqld[5470]: 2017-04-03T21:26:15.982213Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
Apr 03 22:26:15 n systemd[1]:
I also tried to login mysql with my detail:
mysql -uroot -ppassword1 which returned
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
when I run the following command ls -la /var/lib/ | grep mysql on the var lib directory it returns.
drwx------ 12 root docker 4096 Apr 3 21:17 mysql
drwx------ 2 mysql mysql 4096 Feb 23 22:35 mysql-files
drwx------ 2 mysql mysql 4096 Feb 23 22:35 mysql-keyring
drwxr-xr-x 2 root root 4096 Jan 18 21:45 mysql-upgrade
By the looks of things I (well docker did) messed up my ownership on my mysql directory.
If I run ls -la /var/lib/mysql it returns
ls: cannot open directory '/var/lib/mysql': Permission denied
and running same command with sudo sudo ls -la /var/lib/mysql
it returns
total 188480
drwx------ 12 root docker 4096 Apr 3 21:17 .
drwxr-xr-x 80 root root 4096 Mar 29 19:28 ..
-rw-r----- 1 guest-okauxv docker 56 Feb 23 22:35 auto.cnf
drwxr-x--- 2 guest-okauxv docker 4096 Mar 24 23:51 concretepage
-rw-r--r-- 1 guest-okauxv docker 0 Feb 23 22:35 debian-5.7.flag
drwxr-x--- 2 guest-okauxv docker 4096 Mar 25 00:10 myfidser
drwxr-x--- 2 guest-okauxv docker 4096 Mar 4 00:54 myotherFliDB
drwxr-x--- 2 guest-okauxv docker 4096 Mar 1 12:33 testFFAPI
-rw-r----- 1 guest-okauxv docker 679 Apr 3 21:16 ib_buffer_pool
-rw-r----- 1 guest-okauxv docker 79691776 Apr 3 21:17 ibdata1
-rw-r----- 1 guest-okauxv docker 50331648 Apr 3 21:17 ib_logfile0
-rw-r----- 1 guest-okauxv docker 50331648 Feb 23 22:35 ib_logfile1
-rw-r----- 1 guest-okauxv docker 12582912 Apr 3 21:17 ibtmp1
drwxr-x--- 2 guest-okauxv docker 4096 Feb 23 22:35 mysql
drwxr-x--- 2 guest-okauxv docker 4096 Mar 25 16:58 NodeRestDB
drwxr-x--- 2 guest-okauxv docker 4096 Feb 23 22:35 performance_schema
drwxr-x--- 2 guest-okauxv docker 12288 Feb 23 22:35 sys
drwxr-x--- 2 guest-okauxv docker 4096 Mar 29 10:34 testDB
drwxr-x--- 2 guest-okauxv docker 4096 Mar 1 11:52 demoDB
By the looks of this, I (well docker did) managed to changed the owner and group of all the directories in mysql directory.
Do I need to do a complete reinstall of MySQL Server?
What is the simplest, easiest way to fix this?
your help will be much appreciated.
Updated with FIX
Just what Andy Shinn said in point one, I just ran sudo chown -R
mysql:mysql /var/lib/mysql to change the owner back and started mysql
by running sudo /etc/init.d/mysql start and mysql returned
[ ok ]Starting mysql (via systemctl): mysql.service.
G
Some more information will be needed. But two things come to mind.
It is likely the permission issue. Based on your output, why don't you first just try changing the owner and group back to mysql? This should be a simple sudo chown -R mysql:mysql /var/lib/mysql.
It is possible that running mysql:latest image is a different version of MySQL that you were running locally and it could have upgraded the MySQL data to newer formats which may be incompatible with older versions. Check that the version of MySQL you were running locally is the same that the mysql:latest image tag points to (at least the same minor version eg. 5.6 and 5.6).
What version is mysql:latest and what version were you running locally? Do you have any log output from the MySQL container that you started?

opennebula libvirt live migration failire

From the sunstone GUI I tried performing a live migration from luther to blackout but the migration failed. Kindly see below excerpt from oned.log. Thanks for assistance and leads in advance.
Wed Feb 12 13:15:34 2014 [VMM][I]: Successfully execute transfer manager driver operation: tm_premigrate.
Wed Feb 12 13:15:34 2014 [VMM][I]: ExitCode: 0
Wed Feb 12 13:15:34 2014 [VMM][I]: Successfully execute network driver operation: pre.
Wed Feb 12 13:15:35 2014 [VMM][I]: Command execution fail: /var/tmp/one/vmm/kvm/migrate 'one-4' 'blackout' 'luther' 4 luther
Wed Feb 12 13:15:35 2014 [VMM][E]: migrate: Command "virsh --connect qemu:///system migrate --live one-4 qemu+ssh://blackout/system" failed: error: unable to connect to server at 'blackout:49152': No route to host
Wed Feb 12 13:15:35 2014 [VMM][E]: Could not migrate one-4 to blackout
Wed Feb 12 13:15:35 2014 [VMM][I]: ExitCode: 1
Wed Feb 12 13:15:35 2014 [VMM][I]: Failed to execute virtualization driver operation: migrate.
Wed Feb 12 13:15:35 2014 [VMM][E]: Error live migrating VM: Could not migrate one-4 to blackout
Wed Feb 12 13:15:35 2014 [LCM][I]: Fail to live migrate VM. Assuming that the VM is still RUNNING (will poll VM).
Wed Feb 12 13:56:36 2014 [LCM][I]: New VM state is SAVE_STOP
Wed Feb 12 13:56:44 2014 [VMM][I]: ExitCode: 0
iptables was the culprit. Simple turn of iptables or add libvirt default port ranges