docker mariadb集群_Docker之利用Dockerfile创建MariaDB Garela Cluester镜像

摘要

一句话就是,很蛋疼,为了实验用docker编译MariaDB Galera创建镜像,第一个自建的镜像,中间遇到很多的坑,感谢Google、github.com、hub.docker.com。

镜像获取方法

1、使用Dockerfile创建

wget http://www.dwhd.org/wp-content/uploads/2015/11/MariaDB-Galera-Cluster.tar.gz

tar xf MariaDB-Galera-Cluster.tar.gz

wget -c http://download.openvz.org/template/precreated/centos-6-x86_64-minimal.tar.gz

cat centos-6-x86_64-minimal.tar.gz |docker import - centos_ovz_x86-64:6

docker build -t mariadb-galera-cluster:latest ./

2、通过公共仓库搜索下载(我已经上传了)

docker search mariadb_build

docker pull benyoo/mariadb_build:frist_image

镜像使用说明

Available environment configuration MariaDB

变量名默认值说明

INSTALL_DIR/usr/local/mariadb构建镜像时候MariaDB编译安装的路径

DATA_DIR/data/mariadbMariaDB的数据库文件存放路径

TIMEZONE设置系统默认时区

PORT13306默认MariaDB监听端口

PORT24444MariaDB Galera Cluster模式的时候所会用到的端口

PORT34567

PORT44568

MYSQL_ROOT_PASSWORDroot账户密码

MYSQL_DATABASE如果值不为空将新建一个库,库名为值

MYSQL_USER如果不为空则添加一个用户

MYSQL_PASSWORD如果MYSQL_USER值不为空,此值为MYSQL_USER值的密码

MAX_CONNECTIONS100最大并行连接数

SYNC_BINLOG0Controls the number of binary log commit groups to collect before synchronizing the binary log to disk. When sync_binlog=0, the binary log is never synchronized to disk, and when sync_binlog is set to a value greater than 0 this number of binary log commit groups is periodically synchronized to disk. When sync_binlog=1, all transactions are synchronized to the binary log before they are committed

REPLICATION_USERNAME用于复制的帐号的用户名

REPLICATION_PASSWORD用于复制的帐号的密码

QUERY_CACHE_TYPE10=OFF, 1=ON, 2=DEMAND

QUERY_CACHE_SIZE16M分配的内存来缓存查询结果的数量

MAX_ALLOWED_PACKET16M一个数据分组的最大大小

LOG_BIN_INDEX二进制日志索引文件的位置

LOG_BIN二进制日志

INNODB_OLD_BLOCKS_TIME1000Non-zero values protect against the buffer pool being filled up by data that is referenced only for a brief period, such as during a full table scan. Increasing this value offers more protection against full table scans interfering with data cached in the buffer pool.

INNODB_LOG_FILE_SIZE48M二进制日志文件切割大小

INNODB_FLUSH_METHODDefines the method used to flush data to the InnoDB data files and log files, which can affect I/O throughput

INNODB_FLUSH_LOG_AT_TRX_COMMIT1Controls the balance between strict ACID compliance for commit operations, and higher performance that is possible when commit-related I/O operations are rearranged and done in batches. You can achieve better performance by changing the default value, but then you can lose up to a second of transactions in a crash.

INNODB_BUFFER_POOL_SIZE128MThe size in bytes of the buffer pool, the memory area where InnoDB caches table and index data

GALERA如果给值则启动Galera模式

CLUSTER_NODE_ADDRESS当前节点IP

NODE_NAME节点名称

CLUSTER_NAME集群名称

CLUSTER_METHODGalera Cluster同步使用的模式

CLUSTER_ADDRESSgcomm:// style resource identifier that provides topology information about the Galera Cluster

Running MariaDB in Standalone Mode

docker run -dit --name=mariadb_cluster_node1 -p 3306:3306 \

-v /data/mariadb:/data/mariadb \

-e TIMEZONE=Asia/Shanghai \

-e MYSQL_ROOT_PASSWORD=MDhjZTRlYzYzNTRl \

benyoo/mariadb_build:latest

Running MariaDB in Galera Cluster Mode

Initializing a new cluster

docker run -d --name=mariadb_cluster_node1 \

-p 3306:3306 -p 4444:4444 -p 4567-4568:4567-4568 \

-p 4444:4444/udp -p 4567-4568:4567-4568/udp \

-v /data/mariadb:/data/mariadb \

-e TIMEZONE=Asia/Shanghai \

-e MYSQL_ROOT_PASSWORD=MDhjZTRlYzYzNTRl \

-e REPLICATION_USERNAME=replication \

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值