Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL container won't start on Ubuntu 16.04 #346

Open
lucacerone opened this issue Jul 27, 2018 · 8 comments
Open

MySQL container won't start on Ubuntu 16.04 #346

lucacerone opened this issue Jul 27, 2018 · 8 comments

Comments

@lucacerone
Copy link

Hi everybody.

I wanted to try wasabi, so I followed the steps explained to install Wasabi on my Ubuntu 16.04 machine.
I cloned the repo, run the bootstrap script and rebooted.

Next I tried to start wasabi with:
./bin/wasabi.sh build start

The cassandra container started with no issues, but the MySQL failed starting.

I tried again using the command "./bin/wasabi.sh start" but again MySQL container fails starting
(it complains about a missing environment variable), you can find the full error message below:

#> ./bin/wasabi.sh start
wasabi: [Start] creating keyspace and migration schemas
cqlsh  --cqlversion="3.2.1"  -e "CREATE KEYSPACE IF NOT EXISTS wasabi_experiments WITH replication = {'class' : 'SimpleStrategy', 'replication_factor' : 1};" --username= --password="" wasabi-cassandra 9042
java -jar -Dcassandra.migration.keyspace.name=wasabi_experiments     -Dcassandra.migration.cluster.port=9042     -Dcassandra.migration.cluster.username=     -Dcassandra.migration.cluster.password=     -Dcassandra.migration.scripts.locations=filesystem:/wasabi/mutation    -Dcassandra.migration.cluster.contactpoints=wasabi-cassandra     /wasabi/cassandra-migration.jar migrate
Cassandra Migration 0.9
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Connected to cluster: Test Cluster
Data center: datacenter1; Host: wasabi-cassandra/172.19.0.2
Current version of keyspace wasabi_experiments: 036
Keyspace wasabi_experiments is up to date, no migration necessary
wasabi: [DONE] creating keyspace and migration schemas
Warning: Using a password on the command line interface can be insecure.
ERROR 2005 (HY000): Unknown MySQL server host '-P3306' (0)
error: unable to run command: % docker run --net=wasabi_nw -it --rm mysql:5.6 mysql -h -P3306 -uroot -pmypass -e "    create database if not exists wasabi;
    grant all privileges on wasabi.* to 'readwrite'@'localhost' identified by 'readwrite';
    grant all on *.* to 'readwrite'@'%' identified by 'readwrite';
    flush privileges;"

usage: container.sh [options] [commands]

options:
  -v | --verify [ true | false ]         : verify installation configuration; default: false
  -m | --migration [ true | false ]      : refresh cassandra migration scripts; default: false
  -s | --sleep [ sleep-time ]            : sleep/wait time in seconds; default: 3
  -h | --help                            : help message

commands:
  start[:wasabi,cassandra,mysql,docker]  : start all, wasabi, cassandra, mysql, docker
  stop[:wasabi,cassandra,mysql,docker]   : stop all, wasabi, cassandra, mysql, docker
  console[:cassandra,mysql]              : console all, cassandra, mysql
  status                                 : status
  remove[:wasabi,cassandra,mysql]]       : remove all, wasabi, cassandra, mysql

[ERROR] Mysql container must be running or MYSQL_HOST environment variable must be set

So I set MYSQL_HOST=localhost and re-run ./bin/wasabi.sh start
This times it triggered the "pull" of a docker image, but then the container failed to start.
Here is the error message:

#Removing intermediate container 23556cc94e3f
#Successfully built 5618d926f75c
#Successfully tagged wasabi-main:luca-1532708739
#Successfully tagged wasabi-main:latest
wasabi: starting
f65add41fcab7a62637abb5ef197da22a77630ad5c939835fc1acad6aa522816
chill'ax error: not started

usage: container.sh [options] [commands]

options:
  -v | --verify [ true | false ]         : verify installation configuration; default: false
  -m | --migration [ true | false ]      : refresh cassandra migration scripts; default: false
  -s | --sleep [ sleep-time ]            : sleep/wait time in seconds; default: 3
  -h | --help                            : help message

commands:
  start[:wasabi,cassandra,mysql,docker]  : start all, wasabi, cassandra, mysql, docker
  stop[:wasabi,cassandra,mysql,docker]   : stop all, wasabi, cassandra, mysql, docker
  console[:cassandra,mysql]              : console all, cassandra, mysql
  status                                 : status
  remove[:wasabi,cassandra,mysql]]       : remove all, wasabi, cassandra, mysql

Can you help me figure out what I am doing wrong?

Thanks a lot for the help!
Luca

@shaikhimran786
Copy link

I am also facing the same issue.

@zaidaquel
Copy link

me too..

@sixty4bit
Copy link

This is a duplicate of #340

@abdulelbieh
Copy link

have anyone reached a soultion for this issue? i am stuck in it too.

@fanker
Copy link

fanker commented Jun 8, 2019

It means that your server container have not access to your mysql container by the default user, you should update the privilege of mysql, you can try like this:

  1. exec docker ps, show all docker container, and find mysql's containerID, such as 123456asdfgh
  2. then exec docker exec -it 123456asdfgh bash go into container
  3. mysql -uroot mysql
  4. grant all on *.* to 'root'@'%', update the privilege of root
  5. flush privileges, let privilege take a effect
  6. reexec ./bin/wasabi.sh build start
    Congratulations! It worked.

@lucacerone
Copy link
Author

Many thanks!

@Dragon-Of-Dojima
Copy link

Hi everybody.

I wanted to try wasabi, so I followed the steps explained to install Wasabi on my Ubuntu 16.04 machine.
I cloned the repo, run the bootstrap script and rebooted.

Next I tried to start wasabi with:
./bin/wasabi.sh build start

The cassandra container started with no issues, but the MySQL failed starting.

I tried again using the command "./bin/wasabi.sh start" but again MySQL container fails starting
(it complains about a missing environment variable), you can find the full error message below:

#> ./bin/wasabi.sh start
wasabi: [Start] creating keyspace and migration schemas
cqlsh  --cqlversion="3.2.1"  -e "CREATE KEYSPACE IF NOT EXISTS wasabi_experiments WITH replication = {'class' : 'SimpleStrategy', 'replication_factor' : 1};" --username= --password="" wasabi-cassandra 9042
java -jar -Dcassandra.migration.keyspace.name=wasabi_experiments     -Dcassandra.migration.cluster.port=9042     -Dcassandra.migration.cluster.username=     -Dcassandra.migration.cluster.password=     -Dcassandra.migration.scripts.locations=filesystem:/wasabi/mutation    -Dcassandra.migration.cluster.contactpoints=wasabi-cassandra     /wasabi/cassandra-migration.jar migrate
Cassandra Migration 0.9
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Connected to cluster: Test Cluster
Data center: datacenter1; Host: wasabi-cassandra/172.19.0.2
Current version of keyspace wasabi_experiments: 036
Keyspace wasabi_experiments is up to date, no migration necessary
wasabi: [DONE] creating keyspace and migration schemas
Warning: Using a password on the command line interface can be insecure.
ERROR 2005 (HY000): Unknown MySQL server host '-P3306' (0)
error: unable to run command: % docker run --net=wasabi_nw -it --rm mysql:5.6 mysql -h -P3306 -uroot -pmypass -e "    create database if not exists wasabi;
    grant all privileges on wasabi.* to 'readwrite'@'localhost' identified by 'readwrite';
    grant all on *.* to 'readwrite'@'%' identified by 'readwrite';
    flush privileges;"

usage: container.sh [options] [commands]

options:
  -v | --verify [ true | false ]         : verify installation configuration; default: false
  -m | --migration [ true | false ]      : refresh cassandra migration scripts; default: false
  -s | --sleep [ sleep-time ]            : sleep/wait time in seconds; default: 3
  -h | --help                            : help message

commands:
  start[:wasabi,cassandra,mysql,docker]  : start all, wasabi, cassandra, mysql, docker
  stop[:wasabi,cassandra,mysql,docker]   : stop all, wasabi, cassandra, mysql, docker
  console[:cassandra,mysql]              : console all, cassandra, mysql
  status                                 : status
  remove[:wasabi,cassandra,mysql]]       : remove all, wasabi, cassandra, mysql

[ERROR] Mysql container must be running or MYSQL_HOST environment variable must be set

So I set MYSQL_HOST=localhost and re-run ./bin/wasabi.sh start
This times it triggered the "pull" of a docker image, but then the container failed to start.
Here is the error message:

#Removing intermediate container 23556cc94e3f
#Successfully built 5618d926f75c
#Successfully tagged wasabi-main:luca-1532708739
#Successfully tagged wasabi-main:latest
wasabi: starting
f65add41fcab7a62637abb5ef197da22a77630ad5c939835fc1acad6aa522816
chill'ax error: not started

usage: container.sh [options] [commands]

options:
  -v | --verify [ true | false ]         : verify installation configuration; default: false
  -m | --migration [ true | false ]      : refresh cassandra migration scripts; default: false
  -s | --sleep [ sleep-time ]            : sleep/wait time in seconds; default: 3
  -h | --help                            : help message

commands:
  start[:wasabi,cassandra,mysql,docker]  : start all, wasabi, cassandra, mysql, docker
  stop[:wasabi,cassandra,mysql,docker]   : stop all, wasabi, cassandra, mysql, docker
  console[:cassandra,mysql]              : console all, cassandra, mysql
  status                                 : status
  remove[:wasabi,cassandra,mysql]]       : remove all, wasabi, cassandra, mysql

Can you help me figure out what I am doing wrong?

Thanks a lot for the help!
Luca

You have to stop MySQL service in the background, bc it will take up port 3306. Once you do that, you'll be good to go.

@nkhdiscovery
Copy link

nkhdiscovery commented Jan 29, 2020

guys, I noticed another possible scenario:
You have a local, or another container with, mysqld running on port 3306 for example. For some reason, your wasabi was not running on that time (assuming also using 3306 for mysql container), so you never got a port:3306 already in use.

Before, you had wasabi successfully running, so with ./bin/wasabi.sh start tries to get the previous wasabi-mysql container, which still exists and is assumed as working but it will not work now because port 3306 is in use. Somehow, you will never get a chance to see this error - because of the way wasabi uses containers or simply bad luck! - and then wasabi tries to execute a docker run [some commands] on the previous container which is not properly working because of port already in use, so it just fails with something like Mysql container must be running or MYSQL_HOST environment variable must be set or ERROR 2003 (HY000): Can't connect to MySQL server on '172.18.0.3' (111), cause it really can't.

The solution is to stop your already running mysqld with sudo service mysql stop, then prune all containers visible to docker ps -aq with running docker container prune [watch out! Do not harm yourself if you have something not to be pruned, I am not a docker master but I feel there maybe possible scenarios.]
Why to do it? because in container.sh wasabi uses that in the function start_container : cid=$(docker ps -aqf name=${1}) to decide what to do (name will be wasabi-mysql here) and it will get the ID of that not-anymore-working container.

You may think why not just stopping the local mysqld service solves the problem, it is because your older container has already failed in starting its own mysqld service, needs to be pruned and made again by wasabi scripts.

Then simply run ./bin/wasabi.sh start.

And remember to either change your local mysqld port or configure your wasabi containers' ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants