本机
CentOS 7 x64
docker镜像
centos6 x64
启动一个容器
[root@localhost ~]# docker run -t -i --rm --hostname=mariadb centos:centos6 /bin/bash
在容器中操作
添加mariadb, epel yum仓库
查询mariadb资源
MariaDB包含普通版server和支持同步复制Galera wsrep的版本.
[root@mariadb /]# vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@mariadb /]# vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
查询mariadb资源
[root@mariadb /]# yum search all mariadb
========================================================= Matched: mariadb =========================================================
MariaDB-Galera-server.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-Galera-test.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-cassandra-engine.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-client.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-common.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-compat.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-connect-engine.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-devel.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-oqgraph-engine.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-server.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-shared.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-test.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB包含普通版server和支持同步复制Galera wsrep的版本.
安装普通版的方法
安装支持同步复制的版本的方法
依赖几个东西, libaio, 异步IO, readline记录输入历史, rsync文件同步, socat(cat、netcat、rinetd、stunnel)
保存docker镜像
启动数据库
[root@mariadb /]# yum install -y MariaDB-server MariaDB-client
安装支持同步复制的版本的方法
[root@mariadb /]# yum install -y MariaDB-Galera-server MariaDB-client galera socat
依赖几个东西, libaio, 异步IO, readline记录输入历史, rsync文件同步, socat(cat、netcat、rinetd、stunnel)
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
MariaDB-Galera-server x86_64 10.0.14-1.el6 mariadb 30 M
MariaDB-client x86_64 10.0.15-1.el6 mariadb 11 M
galera x86_64 25.3.5-1.rhel6 mariadb 5.9 M
socat x86_64 1.7.2.3-1.el6 epel 246 k
Installing for dependencies:
MariaDB-common x86_64 10.0.15-1.el6 mariadb 23 k
MariaDB-compat x86_64 10.0.15-1.el6 mariadb 2.7 M
compat-readline5 x86_64 5.2-17.1.el6 base 130 k
libaio x86_64 0.3.107-10.el6 base 21 k
lsof x86_64 4.82-4.el6 base 319 k
perl x86_64 4:5.10.1-136.el6_6.1 updates 10 M
perl-DBI x86_64 1.609-4.el6 base 705 k
perl-Module-Pluggable x86_64 1:3.90-136.el6_6.1 updates 40 k
perl-Pod-Escapes x86_64 1:1.04-136.el6_6.1 updates 32 k
perl-Pod-Simple x86_64 1:3.13-136.el6_6.1 updates 212 k
perl-libs x86_64 4:5.10.1-136.el6_6.1 updates 578 k
perl-version x86_64 3:0.77-136.el6_6.1 updates 51 k
rsync x86_64 3.0.6-12.el6 base 335 k
Transaction Summary
====================================================================================================================================
Install 17 Package(s)
保存docker镜像
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e23c3c37c8d6 centos:centos6 "/bin/bash" 20 minutes ago Up 20 minutes suspicious_goldstine
[root@localhost ]# docker commit -a digoal -m "mariadb 10 with galera" -p e23c3c37c8d6 digoal/mariadb-galera-10
启动数据库
[root@mariadb /]# /etc/init.d/mysql start
[参考]