Docker中使用Dockerfile构建 MariaDB 主从集群镜像

一、使用方法

1、单独MySQL模式
docker run -d \
-e TIMEZONE=Asia/Shanghai \
-v /data/mariadb-master:/data/mariadb \
-e MYSQL_ROOT_PASSWORD=lookback \
-p 3306:3306 \
mariadb:10.0.21
2、MariaDB MASTER
docker run -d \
-e TIMEZONE=Asia/Shanghai \
-v /data/mariadb-master:/data/mariadb \
-e MYSQL_ROOT_PASSWORD=lookback \
-e MASTER=1 \
-e SERVER_ID=1 \
-e REPLICATION_PASSWORD=lookback \
-p 3306:3306 \
mariadb:10.0.21
3、MariaDB SLAVE
#情景1 没有sql导入的情况
docker run -d \
-e TIMEZONE=Asia/Shanghai \
-v /data/mariadb-slave:/data/mariadb \
-e MYSQL_ROOT_PASSWORD=lookback \
-e SLAVE=1 \
-e SERVER_ID=3 \
-e REPLICATION_PASSWORD=lookback \
-e MASTER_LOG_FILE=mysql-bin.000003 \
-e MASTER_LOG_POS=326 \
-e MASTER_PORT=3306 \
-e MASTER_HOST=172.17.0.2 \
-p 3307:3306 \
mariadb:10.0.21

#情景2 先用sql文件导入再同步
docker run -d \
-e TIMEZONE=Asia/Shanghai \
-v /data/mariadb-slave:/data/mariadb \
-e MYSQL_ROOT_PASSWORD=lookback \
-e SLAVE=1 \
-e SERVER_ID=3 \
-e REPLICATION_PASSWORD=lookback \
-e DATABASE_FILE=database.sql \
-e MASTER_LOG_FILE=mysql-bin.000003 \
-e MASTER_LOG_POS=326 \
-e MASTER_PORT=3306 \
-e MASTER_HOST=172.17.0.2 \
-p 3307:3306 \
mariadb:10.0.21
#需要把database.sql文件存提前存放在/data/mariadb-slave目录
二、各种参数的介绍

后补。。。。。。
三、先来看看MariaDB主从

#启动MariaDB主
[root@Legion135 /docker/image/mariadb]# docker run -d \
-e MYSQL_ROOT_PASSWORD=lookback \
-e MASTER=1 \
-e SERVER_ID=1 \
-e REPLICATION_PASSWORD=lookback \
-p 3306:3306 \
mariadb:10.0.21
35e0f6fd2fd08b4e503d4d01f49797179f91f43d85acf05f06049eb430880362
#查询MariaDB主的ip地址
[root@Legion135 /docker/image/mariadb]# docker exec -it 35e ifconfig | sed -rn '/^[^ \t]/{N;s/(^[^ ]*).*addr:([^ ]*).*/\1=\2/p}'
eth0=172.17.0.2
#启动MariaDB的SLAVE
[root@Legion135 /docker/image/mariadb]# docker run -d \
-e MYSQL_ROOT_PASSWORD=lookback \
-e SLAVE=1 \
-e SERVER_ID=3 \
-e REPLICATION_PASSWORD=lookback \
-e MASTER_LOG_FILE=mysql-bin.000003 \
-e MASTER_LOG_POS=326 \
-e MASTER_PORT=3306 \
-e MASTER_HOST=172.17.0.2 \
-p 3307:3306 \
mariadb:10.0.21
20b79e28546b222e863af83056474f5784a73e1f25668d47bc21db5a24c57b67
#查看SLAVE的ip地址
[root@Legion135 /docker/image/mariadb]# docker exec -it 20b ifconfig | sed -rn '/^[^ \t]/{N;s/(^[^ ]*).*addr:([^ ]*).*/\1=\2/p}'
eth0=172.17.0.3
#查看SLAVE的状态
[root@Legion135 /docker/image/mariadb]# yum install -y -q mysql
Delta RPMs reduced 1.5 M of updates to 126 k (91% saved)
[root@Legion135 /docker/image/mariadb]# mysql -uroot -plookback -h172.17.0.3
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.0.21-MariaDB-wsrep-log Source distribution, wsrep_25.10.r4144

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 172.17.0.2
                  Master_User: replication
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 326
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 535
        Relay_Master_Log_File: mysql-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 326
              Relay_Log_Space: 832
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
               Master_SSL_Crl:
           Master_SSL_Crlpath:
                   Using_Gtid: No
                  Gtid_IO_Pos:
1 row in set (0.00 sec)

MariaDB [(none)]> \q
Bye
[root@Legion135 /docker/image/mariadb]#
四、然后来看看MariaDB的MASTER和SLAVE的启动情况

[root@Legion135 /docker/image/mariadb]# docker exec -it 35e0f6fd2fd0 cat /tmp/mysql-first-time.sql
-- What's done in this file shouldn't be replicated
--  or products like mysql-fabric won't work
SET @@SESSION.SQL_LOG_BIN=0;

DELETE FROM mysql.user;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'lookback' WITH GRANT OPTION;
--GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'lookback' WITH GRANT OPTION;
--GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'lookback' WITH GRANT OPTION;
DROP DATABASE IF EXISTS test;
GRANT REPLICATION SLAVE ON *.* TO 'replication'@'' IDENTIFIED BY 'lookback';
START MASTER;
FLUSH PRIVILEGES ;
[root@Legion135 /docker/image/mariadb]# docker exec -it 20b79e28546b cat /tmp/mysql-first-time.sql
-- What's done in this file shouldn't be replicated
--  or products like mysql-fabric won't work
SET @@SESSION.SQL_LOG_BIN=0;

DELETE FROM mysql.user;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'lookback' WITH GRANT OPTION;
--GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'lookback' WITH GRANT OPTION;
--GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'lookback' WITH GRANT OPTION;
DROP DATABASE IF EXISTS test;
GRANT REPLICATION SLAVE ON *.* TO 'replication'@'172.17.0.2' IDENTIFIED BY 'lookback';
CHANGE MASTER TO MASTER_HOST='172.17.0.2',MASTER_PORT=3306,MASTER_USER='replication',MASTER_PASSWORD='lookback',MASTER_LOG_FILE='mysql-bin.000003',MASTER_LOG_POS= 326;
START SLAVE;
FLUSH PRIVILEGES ;
[root@Legion135 /docker/image/mariadb]# docker exec -it 35e0f6fd2fd0 cat /data/mariadb/general.log
mysqld, Version: 10.0.21-MariaDB-wsrep-log (Source distribution, wsrep_25.10.r4144). started with:
Tcp port: 3306  Unix socket: /tmp/mysql.sock
Time                 Id Command    Argument
151202  8:36:22     4 Connect   replication@172.17.0.3 as anonymous on
            4 Query SET NAMES utf8mb4
            4 Query SELECT UNIX_TIMESTAMP()
151202  8:36:23     4 Query SHOW VARIABLES LIKE 'SERVER_ID'
            4 Query SET @master_heartbeat_period= 1799999979520
            4 Query SET @master_binlog_checksum= @@global.binlog_checksum
            4 Query SELECT @master_binlog_checksum
            4 Query SET @mariadb_slave_capability=4
            4 Query SELECT binlog_gtid_pos('mysql-bin.000003',326)
            4 Binlog Dump   Log: 'mysql-bin.000003'  Pos: 326
[root@Legion135 /docker/image/mariadb]# docker exec -it 20b79e28546b cat /data/mariadb/general.log
mysqld, Version: 10.0.21-MariaDB-wsrep-log (Source distribution, wsrep_25.10.r4144). started with:
Tcp port: 3306  Unix socket: /tmp/mysql.sock
Time                 Id Command    Argument
151202  8:36:22     4 Connect Out   replication@172.17.0.2:3306
151202  8:55:37     6 Connect   root@172.17.0.1 as anonymous on
            6 Query select @@version_comment limit 1
151202  8:55:47     6 Query SHOW SLAVE STATUS
151202  8:56:54     6 Quit
[root@Legion135 /docker/image/mariadb]#
最后是Dockerfile文件
FROM centos-x86_64-minimal:6.7

MAINTAINER from www.dwhd.org by lookback (mondeolove@gmail.com)

ARG PATH=/bin:$PATH
ARG MARIADB_VERSION=10.0.21

ENV INSTALL_DIR=/usr/local/mariadb \
    DATA_DIR=/data/mariadb

ADD my.cnf /etc/my.cnf

RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-* && \
    yum install -y libxml2-devel lz4-devel openssl-devel libpcap nmap lsof socat wget cmake which && \
    groupadd --system mysql && \
    useradd --system --gid mysql mysql && \
    mkdir -p $DATA_DIR && \
    chown -R mysql.mysql $DATA_DIR && \
    wget -c https://downloads.mariadb.org/interstitial/mariadb-galera-${MARIADB_VERSION}/source/mariadb-galera-${MARIADB_VERSION}.tar.gz && \
    wget -c http://www.phontron.com/kytea/download/kytea-0.4.7.tar.gz && \
    tar xf kytea-0.4.7.tar.gz && \
    cd kytea-0.4.7/ && \
    ./configure && \
    make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && \
    make install && cd .. && \
    tar xf mariadb-galera-${MARIADB_VERSION}.tar.gz && \
    cd mariadb-${MARIADB_VERSION}/ && \
    cmake . -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DMYSQL_DATADIR=$DATA_DIR \
-DWITH_SSL=system \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_SPHINX_STORAGE_ENGINE=1 \
-DWITH_ARIA_STORAGE_ENGINE=1 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATEDX_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_READLINE=1 -DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1 && \
    make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && \
    make install && cd .. && \
    /bin/rm -rf /{kytea-0.4.7.tar.gz,mariadb-$MARIADB_VERSION,mariadb-galera-$MARIADB_VERSION.tar.gz,kytea-0.4.7,mariadb.conf} && \
    /bin/rm -rf $DATA_DIR/*.err

ENV PATH=/usr/local/mariadb/bin:$PATH \
    MAX_CONNECTIONS=100 \
    PORT=3306 \
    MAX_ALLOWED_PACKET=16M \
    QUERY_CACHE_SIZE=16M \
    QUERY_CACHE_TYPE=1 \
    INNODB_BUFFER_POOL_SIZE=128M \
    INNODB_LOG_FILE_SIZE=48M \
    INNODB_FLUSH_METHOD= \
    INNODB_OLD_BLOCKS_TIME=1000 \
    INNODB_FLUSH_LOG_AT_TRX_COMMIT=1 \
    SYNC_BINLOG=0 \
    GENERAL_LOG=ON

ADD run.sh /run.sh
RUN chmod +x /run.sh

VOLUME ["/usr/local/mariadb","/data/mariadb"]

EXPOSE 3306

ENTRYPOINT ["/run.sh"]

CMD ["mysqld"]
#!/bin/bash
#########################################################################
# File Name: run.sh
# Author: LookBack
# Email: admin#dwhd.org
# Version:
# Created Time: 2015年12月02日 星期三 15时54分27秒
#########################################################################

set -e
INSTALL_DIR=/usr/local/mariadb
DATE_DIR=/data/mariadb

if [ -n "$TIMEZONE" ]; then
    rm -rf /etc/localtime && \
    ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime
fi

[ -d "$DATE_DIR" ] || mkdir -p $DATE_DIR

sed -ri "s@^(port).*@\1=${PORT}@" /etc/my.cnf
sed -ri "s@^(basedir).*@\1=${INSTALL_DIR}@" /etc/my.cnf
sed -ri "s@^(datadir).*@\1=${DATA_DIR}@" /etc/my.cnf
sed -ri "s@^(pid-file).*@\1=${DATA_DIR}/mysql.pid@" /etc/my.cnf
sed -ri "s@^(max_connections).*@\1=${MAX_CONNECTIONS}@" /etc/my.cnf
sed -ri "s@^(max_allowed_packet).*@\1=${MAX_ALLOWED_PACKET}@" /etc/my.cnf
sed -ri "s@^(query_cache_size).*@\1=${QUERY_CACHE_SIZE}@" /etc/my.cnf
sed -ri "s@^(query_cache_type).*@\1=${QUERY_CACHE_TYPE}@" /etc/my.cnf
sed -ri "s@^(innodb_log_file_size).*@\1=${INNODB_LOG_FILE_SIZE}@" /etc/my.cnf
sed -ri "s@^(sync_binlog).*@\1=${SYNC_BINLOG}@" /etc/my.cnf
sed -ri "s@^(innodb_buffer_pool_size).*@\1=${INNODB_BUFFER_POOL_SIZE}@" /etc/my.cnf
sed -ri "s@^(innodb_old_blocks_time).*@\1=${INNODB_OLD_BLOCKS_TIME}@" /etc/my.cnf
sed -ri "s@^(innodb_flush_log_at_trx_commit).*@\1=${INNODB_FLUSH_LOG_AT_TRX_COMMIT}@" /etc/my.cnf
sed -ri "s@^(general_log\s).*@\1= ${GENERAL_LOG}@" /etc/my.cnf

if [ -n "$INNODB_FLUSH_METHOD" ]; then
    sed -ri "/^innodb_flush_log_at_trx_commit/a innodb_flush_method=${INNODB_FLUSH_METHOD}" /etc/my.cnf
fi

if [ "${1:0:1}" = '-' ]; then
    set -- mysqld "$@"
fi

if [ "$1" = 'mysqld' ]; then
    if [ -z "$MYSQL_ROOT_PASSWORD" ]; then
        echo >&2 'error:  missing MYSQL_ROOT_PASSWORD'
        echo >&2 '  Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
        exit 1
    fi

    if [ ! -d "$DATA_DIR/mysql" ]; then
        echo 'Running mysql_install_db ...'
        cd $INSTALL_DIR/ && $INSTALL_DIR/scripts/mysql_install_db --user=mysql --datadir="$DATA_DIR" >/dev/null 2>&1
        echo 'Finished mysql_install_db'

        tempSqlFile='/tmp/mysql-first-time.sql'
        cat > "$tempSqlFile" <<-EOF
            -- What's done in this file shouldn't be replicated
            --  or products like mysql-fabric won't work
            SET @@SESSION.SQL_LOG_BIN=0;

            DELETE FROM mysql.user;
            GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' WITH GRANT OPTION;
            --GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' WITH GRANT OPTION;
            --GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' WITH GRANT OPTION;
            DROP DATABASE IF EXISTS test;
        EOF

        if [[ "1" =~ ^($MASTER|$SLAVE)$ ]]; then
            [ -z "${REPLICATION_USERNAME}" ] && REPLICATION_USERNAME=replication
            [ -z "${SLAVE_HOST}" ] && SLAVE_HOST="%"

            if [ -z ${SERVER_ID} ]; then
                echo >&2 'error:  missing SERVER_ID'
                echo >&2 '  Did you forget to add -e SERVER_ID=... ?'
                exit 1
            elif [ "${MASTER}" = "1" ]; then
                SERVER_ID=1
            fi
            sed -ri "s@^(server-id).*@\1=${SERVER_ID}@" /etc/my.cnf

            if [ -z "$REPLICATION_PASSWORD" ]; then
                echo >&2 'error:  missing REPLICATION_PASSWORD'
                echo >&2 '  Did you forget to add -e REPLICATION_PASSWORD=... ?'
                exit 1
            fi

            echo "GRANT REPLICATION SLAVE ON *.* TO '${REPLICATION_USERNAME}'@'${MASTER_HOST}' IDENTIFIED BY '${REPLICATION_PASSWORD}';" >> "$tempSqlFile"
            #cat >> "$tempSqlFile" <<-EOF
            #   GRANT REPLICATION SLAVE ON *.* TO '${REPLICATION_USERNAME}'@'${MASTER_HOST}' IDENTIFIED BY '${REPLICATION_PASSWORD}';
            #   --CREATE USER '${REPLICATION_USERNAME}'@'%' IDENTIFIED BY '${REPLICATION_PASSWORD}' ;
            #   --GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT,FILE ON *.* TO '${REPLICATION_USERNAME}'@'%' ;
            #   --CREATE USER '${REPLICATION_USERNAME}'@'%' IDENTIFIED BY '${REPLICATION_PASSWORD}';
            #   --GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT,REPLICATION SLAVE,FILE ON *.* TO '${REPLICATION_USERNAME}'@'%';
            #EOF
        fi

    fi
fi

if [ "$SLAVE" = 1 ]; then
#if [[ ! "1" =~ ^($SLAVE)$ ]]; then
    if [ -z "$MASTER_LOG_FILE" ]; then
        echo >&2 'error:  missing MASTER_LOG_FILE'
        echo >&2 '  Did you forget to add -e MASTER_LOG_FILE=...?'
        exit 1
    fi

    if [ -z "$MASTER_LOG_POS" ] ; then
        echo >&2 'error:  missing MASTER_LOG_POS'
        echo >&2 '  Did you forget to add -e MASTER_LOG_POS=...?'
        exit 1
    fi

    if [ -z "$MASTER_PORT" ] ; then
        echo >&2 'error:  missing MASTER_PORT'
        echo >&2 '  Did you forget to add -e MASTER_PORT=...?'
        exit 1
    fi

    if [ -z "$MASTER_HOST" ] ; then
        echo >&2 'error:  missing MASTER_HOST'
        echo >&2 '  Did you forget to add -e MASTER_HOST=...?'
        exit 1
    fi

    if [ -n "$DATABASE_FILE" ]; then
        if [ ! -f "$DATA_DIR/$DATABASE_FILE" ]; then
            echo >&2 'error: missing DATABASE_FILE'
            echo >&2 '  $DATABASE_FILE must be a sql file in $DATA_DIR directory!'
            exit 1
        fi
        echo "source $DATA_DIR/${DATABASE_FILE};" >> "$tempSqlFile"
    fi

    echo "CHANGE MASTER TO MASTER_HOST='${MASTER_HOST}',MASTER_PORT=${MASTER_PORT},MASTER_USER='${REPLICATION_USERNAME}',MASTER_PASSWORD='${REPLICATION_PASSWORD}',MASTER_LOG_FILE='${MASTER_LOG_FILE}',MASTER_LOG_POS= ${MASTER_LOG_POS};" >> "$tempSqlFile"
    echo "START SLAVE;" >> "$tempSqlFile"
fi

if [ "$MASTER" = "1" ]; then
    echo "START MASTER;" >> "$tempSqlFile"
fi

echo "FLUSH PRIVILEGES ;" >> "$tempSqlFile"
set -- "$@" --init-file="$tempSqlFile"
chown -R mysql:mysql "$DATA_DIR"

exec "$@"
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4

[mysqld]
port = 3306
socket = /tmp/mysql.sock

basedir = /usr/local/mariadb
datadir = /data/mariadb
pid-file = /data/mariadb/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1

init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4

skip-name-resolve
#skip-networking
back_log = 300

max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 1024
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 128M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 256M

thread_cache_size = 64

query_cache_type = 1
query_cache_size = 64M
query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin
binlog_format = ROW
expire_logs_days = 30

log_error = /data/mariadb/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mariadb/mysql-slow.log
general_log = ON
log_output = FILE
general_log_file =  /data/mariadb/general.log

performance_schema = 0

#lower_case_table_names = 1

skip-external-locking

default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 1024M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 64M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

时间: 2024-09-23 22:01:48

Docker中使用Dockerfile构建 MariaDB 主从集群镜像的相关文章

用Docker构建分布式Redis集群

本文讲的是用Docker构建分布式Redis集群,[编者的话]本文介绍了如何使用Docker搭建Redis集群,很多读者都在问Docker能带来哪些实质性的好处,我想本文就是一个很好的例子.不使用Docker你也可以搭建Redis集群,那使用Docker后会有怎么样的优势了?我想可以用两个词总结:快速和复用. 我们经常会遇到这样一个问题:当我们想进行一个完整的测试的时候,往往缺少硬件或者其它资源.为了满足需求,我可能需要三台服务,或者说三个虚拟机.但是我发现我们没有时间来创建它们,并且如果要物理

Hadoop集群遭遇勒索软件攻击 据称中国有8300多个Hadoop集群暴露在互联网上

继上周绿盟科技发布 ElasticSearch专项报告 以来,又监测到勒索软件正在攻击Hadoop集群,这再次表明黑客正在尝试从"大数据"中获利,绿盟科技给出的建议是关闭端口.启用安全认证机制.使用WVSS Web应用漏洞扫描等方式进行安全扫描.绿盟科技发布的专项报告全文如下: 勒索软件攻击Hadoop事件综述 最近,部分黑客组织针对几款特定产品展开了勒索攻击.截止到上周,已有至少34000多台MongoDB数据库被黑客组织入侵,数据库中的数据被黑客擦除并索要赎金.随后,在2017年1

使用Docker在本地搭建hadoop,spark集群

本环境使用的单个宿主主机,而不是跨主机集群,本spark集群环境存在的意义可能在于便于本地开发测试使用,非常轻量级和便捷.这个部署过程,最好在之前有过一定的hadoop,spark集群部署经验的基础,本文重点在于docker相关的操作,至于hadoop和spark集群的部署,极力推荐这两个网页: Hadoop集群:http://blog.csdn.net/stark_sum ... 24279. Spark集群:http://blog.csdn.net/stark_sum ... 58081 主

在Docker上建立多节点的Hadoop集群

在上篇文章中你已经看到了在你的devbox创建一个单点Hadoop 集群是多么简单. 现在我们提高门槛,在Docker上创建一个多点hadoop集群.在开始前,确保你有最新的Ambari镜像: 一行命令 一旦你得到了最新的镜像,你就可以启动Docker容器.我们已经创建了几个shell 函数来帮你输入Docker命令,从而避免输入像docker run [options] image [command]这样冗长的命令. 有了这些功能,创建3个节点的hadoop簇,只需要下面一行代码搞定: 默认参

在 Docker 上建立多节点的 Hadoop 集群 【已翻译100%】

在上篇文章中你已经看到了在你的devbox创建一个单点Hadoop 集群是多么简单. 现在我们提高门槛,在Docker上创建一个多点hadoop集群.在开始前,确保你有最新的Ambari镜像: docker pull sequenceiq/ambari:latest 一行命令 一旦你得到了最新的镜像,你就可以启动Docker容器.我们已经创建了几个shell 函数来帮你输入Docker命令,从而避免输入像docker run [options] image [command]这样冗长的命令. 有

如何为大数据处理构建高性能Hadoop集群

越来越多的企业开始使用Hadoop来对大数据进行处理分析,但Hadoop集群的整体性能却取决于CPU.内存.网络以及存储之间的性能平衡.而在这篇文章中,我们将探讨如何为Hadoop集群构建高性能网络,这是对大数据进行处理分析的关键所在. 关于Hadoop "大数据"是松散的数据集合,海量数据的不断增长迫使企业需要通过一种新的方式去管理.大数据是结构化或非结构化的多种数据类型的大集合.而Hadoop则是Apache发布的软件架构,用以分析PB级的非结构化数据,并将其转换成其他应用程序可管

怎么为大数据处理构建高性能Hadoop集群

越来越多的企业开始使用Hadoop来对大数据进行处理分析,但Hadoop集群的整体性能却取决于CPU.内存.网络以及存储之间的性能平衡.而在这篇文章中,我们将探讨如何为Hadoop集群构建高性能网络,这是对大数据进行处理分析的关键所在. 关于Hadoop "大数据"是松散的数据集合,海量数据的不断增长迫使企业需要通过一种新的方式去管理.大数据是结构化或非结构化的多种数据类型的大集合.而 Hadoop则是Apache发布的软件架构,用以分析PB级的非结构化数据,并将其转换成其他应用程序可

㉕云上场景:炫云,基于ECS构建的渲染集群

炫我一直专注于为用户提供成熟的渲染管理软件.最佳的混合云渲染解决方案和体验最好的云渲染服务:是业界首家拿到风险投资的企业:其产品也是唯一一款我国自主设计的.综合性能优于世界上众多集群管理软件并更加简便易操作的集群管理软件. 对于中小型制作机构而言,自行搭建渲染集群是一笔不菲的开支,并且从TCO的角度衡量性价比很低.为了更好的服务中小型工作室,炫我携手阿里云推出炫云,开启了在三维设计软件(包括3dsmax/Maya/Cinema4D/Blender)中一键提交云渲染任务的新纪元.阿里云服务满足炫云

Docker之利用 Dockerfile构建 Redis 服务的教程

Dockerfile   ENV REDIS_VERSION=3.2.1 ENV REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-${REDIS_VERSION}.tar.gz \         REDIS_DOWNLOAD_SHA1=26c0fc282369121b4e278523fce122910b65fbbf   RUN \         REDIS_FILE=${REDIS_DOWNLOAD_URL##*/} &&a