diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6203f38 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +data-mysql \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 04901d6..dd99fa7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,16 @@ -FROM ubuntu:trusty +FROM ubuntu:12.04 MAINTAINER Fernando Mayo , Feng Honglin +ENV http_proxy http://00026898:Stefan1@165.222.184.232:8080 +ENV https_proxy http://00026898:Stefan1@165.222.184.232:8080 + + # Install packages RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive apt-get -y install supervisor mysql-server pwgen # Remove pre-installed database -RUN rm -rf /var/lib/mysql +RUN rm -rf /var/lib/mysql/* # Add MySQL configuration ADD my.cnf /etc/mysql/conf.d/my.cnf diff --git a/README.md b/README.md index 2900f28..5625351 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ tutum-docker-mysql Base docker image to run a MySQL database server +MySQL version +------------- + +`master` branch maintains MySQL from Ubuntu trusty official source. If you want to get different version of MySQL, please checkout `5.5` branch and `5.6` branch. + Usage ----- @@ -79,7 +84,7 @@ Mounting the database file volume from other containers Another way to persist the database data is to store database files in another container. To do so, first create a container that holds database files: - docker run -d -v /var/lib/mysql --name db_vol tutum/ubuntu-trusty + docker run -d -v /var/lib/mysql --name db_vol -p 22:22 tutum/ubuntu-trusty This will create a new ssh-enabled container and use its folder `/var/lib/mysql` to store MySQL database files. You can specify any name of the container by using `--name` option, which will be used in next step. diff --git a/my.cnf b/my.cnf index 84e7bbf..d73d4b6 100644 --- a/my.cnf +++ b/my.cnf @@ -1,2 +1,105 @@ +# +# The MySQL database server configuration file. +# +# You can copy this to one of: +# - "/etc/mysql/my.cnf" to set global options, +# - "~/.my.cnf" to set user-specific options. +# +# One can use all long options that the program supports. +# Run program with --help to get a list of available options and with +# --print-defaults to see which it would actually understand and use. +# +# For explanations see +# http://dev.mysql.com/doc/mysql/en/server-system-variables.html + +# This will be passed to all mysql clients +# It has been reported that passwords should be enclosed with ticks/quotes +# escpecially if they contain "#" chars... +# Remember to edit /etc/mysql/debian.cnf when changing the socket location. +[client] +port = 3306 +socket = /var/run/mysqld/mysqld.sock + +# Here is entries for some specific programs +# The following values assume you have at least 32M ram + +# This was formally known as [safe_mysqld]. Both versions are currently parsed. +[mysqld_safe] +socket = /var/run/mysqld/mysqld.sock +nice = 0 + [mysqld] -bind-address=0.0.0.0 +# +# * Basic Settings +# +user = mysql +pid-file = /var/run/mysqld/mysqld.pid +socket = /var/run/mysqld/mysqld.sock +port = 3306 +basedir = /usr +datadir = /var/lib/mysql +tmpdir = /tmp + +lc-messages-dir = /usr/share/mysql +skip-external-locking +max_allowed_packet = 32M +key_buffer_size = 96M +query_cache_size= 72M + +# Try number of CPU's*2 for thread_concurrency +thread_concurrency = 6 +table_cache = 1024 +# +# Instead of skip-networking the default is now to listen only on +# localhost which is more compatible and is not less secure. +bind-address = 0.0.0.0 + +# +# * Query Cache Configuration +# +query_cache_limit = 1M +# +# Error log - should be very few entries. +# +log_error = /var/log/mysql/error.log + +# +# Here you can see queries with especially long duration +#log_slow_queries = /var/log/mysql/mysql-slow.log +#long_query_time = 2 +#log-queries-not-using-indexes +# +expire_logs_days = 10 +max_binlog_size = 100M +# +# * InnoDB +# +# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. +# Read the manual for more InnoDB related options. There are many! + +innodb_buffer_pool_size = 1024M +# Set .._log_file_size to 25 % of buffer pool size +innodb_log_file_size = 256M +innodb_log_buffer_size = 64M + +innodb_file_per_table = 1 +innodb_flush_log_at_trx_commit = 2 +innodb_support_xa = 0 +innodb_flush_method= O_DIRECT + +[mysqldump] +quick +quote-names +max_allowed_packet = 16M + +[mysql] +#no-auto-rehash # faster start of mysql but no tab completition + +[isamchk] +key_buffer = 16M + +# +# * IMPORTANT: Additional settings that can override those from this file! +# The files must end with '.cnf', otherwise they'll be ignored. +# + diff --git a/run-server.sh b/run-server.sh new file mode 100755 index 0000000..2b4fa5a --- /dev/null +++ b/run-server.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# rm -rf data-mysql +mkdir -p data-mysql + +# as daemon +docker run --name mysql -d -p 3306:3306 -v $(pwd)/data-mysql:/var/lib/mysql -e MYSQL_PASS="samba" tutum/mysql + +# interactive +#docker run -i -t -p 3306:3306 -v $(pwd)/data-mysql:/var/lib/mysql -e MYSQL_PASS="samba" tutum/mysql bash \ No newline at end of file diff --git a/run.sh b/run.sh index df4bca1..1b3ff37 100644 --- a/run.sh +++ b/run.sh @@ -1,15 +1,14 @@ #!/bin/bash VOLUME_HOME="/var/lib/mysql" +HOME=/etc/mysql/conf.d/ if [[ ! -d $VOLUME_HOME/mysql ]]; then echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME" echo "=> Installing MySQL ..." - mkdir -p $VOLUME_HOME - chown mysql:mysql -R $VOLUME_HOME mysql_install_db > /dev/null 2>&1 echo "=> Done!" - /create_mysql_admin_user.sh + /create_mysql_admin_user.sh else echo "=> Using an existing volume of MySQL" fi