(1).下载镜像
VERSION=1.2.1
sudo docker run --privileged --name kunlun1 -p 5401:5401 -p 5402:5402 -p 5403:5403 -p 5404:5404 -p 5405:5405 -itd registry.cn-hangzhou.aliyuncs.com/kunlundb/kunlun:$VERSION bash -c 'bash /kunlun/start_kunlun_rbr.sh'
//当值支持的VERSION值有: 0.9.2 v1.0.1 1.0.2 1.1.1 1.2.1
- 查看镜像
cmd> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-hangzhou.aliyuncs.com/kunlundb/kunlun latest f9f120ad7113 3 weeks ago 4.91GB
- 启动容器
cmd> docker run -itd f9f120ad7113 #docker run -it
//会自动进入运行镜像中的shell环境,-d表示后台执行
- 删除容器
cmd> docker rm 9e8f41aab197
9e8f41aab197
- 查看启动容器
cmd> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9e8f41aab197 f9f120ad7113 "bash" About a minute ago Exited (127) 3 seconds ago silly_carver
- 进入容器
cmd> docker exec -it c8e857ee31aa bash #docker run -it
(2).KunlunBase 操作(进入容器后)
- 启动数据库
cd /kunlun
sh start_kunlun_rbr.sh
- 查看计算节点
$ ps -ef|grep /bin/postgres
kunlun 21775 1 0 20:51 ? 00:00:00 /kunlun/kunlun-server-1.2.1/bin/postgres -D /kunlun/server_datadir/5401
kunlun 21778 1 0 20:51 ? 00:00:00 /kunlun/kunlun-server-1.2.1/bin/postgres -D /kunlun/server_datadir/5402
kunlun 21781 1 0 20:51 ? 00:00:00 /kunlun/kunlun-server-1.2.1/bin/postgres -D /kunlun/server_datadir/5403
//启动在5401\5402\5403三个端口
- 查看元数据集群
$ ps -ef|grep '6001|6002|6003'
kunlun 2507 32511 5 20:54 ? 00:00:03 /kunlun/instance_binaries/storage/6001/kunlun-storage-1.2.1/bin/mysqld --defaults-file=/kunlun/storage_datadir/6001/data/6001.cnf --basedir=/kunlun/instance_binaries/storage/6001/kunlun-storage-1.2.1 --datadir=/kunlun/storage_datadir/6001/data --plugin-dir=/kunlun/kunlun-storage-1.2.1/lib/plugin --log-error=/kunlun/storage_logdir/6001/mysqld.err --open-files-limit=100000 --pid-file=/kunlun/storage_logdir/6001/mysql.pid --socket=/kunlun/storage_logdir/6001/mysql.sock --port=6001
kunlun 4696 2459 2 20:50 ? 00:00:07 /kunlun/kunlun-storage-1.2.1/bin/mysqld --defaults-file=/kunlun/storage_datadir/6002/data/6002.cnf --basedir=/kunlun/kunlun-storage-1.2.1 --datadir=/kunlun/storage_datadir/6002/data --plugin-dir=/kunlun/kunlun-storage-1.2.1/lib/plugin --log-error=/kunlun/storage_logdir/6002/mysqld.err --open-files-limit=100000 --pid-file=/kunlun/storage_logdir/6002/mysql.pid --socket=/kunlun/storage_logdir/6002/mysql.sock --port=6002
kunlun 7099 4862 2 20:50 ? 00:00:09 /kunlun/kunlun-storage-1.2.1/bin/mysqld --defaults-file=/kunlun/storage_datadir/6003/data/6003.cnf --basedir=/kunlun/kunlun-storage-1.2.1 --datadir=/kunlun/storage_datadir/6003/data --plugin-dir=/kunlun/kunlun-storage-1.2.1/lib/plugin --log-error=/kunlun/storage_logdir/6003/mysqld.err --open-files-limit=100000 --pid-file=/kunlun/storage_logdir/6003/mysql.pid --socket=/kunlun/storage_logdir/6003/mysql.sock --port=6003
- 查看存储节点
$ ps -ef|grep '6004|6005|6006|6007|6008|6009'
...
6004 端口是存储节点分片1的主节点, 6005,6006 是存储节点分片1的两个从节点
6007 端口是存储节点分片2的主节点, 6008,6009 是存储节点分片2的两个从节点
(3).简单测试
PG 连接
$ cd /kunlun
$ source env.sh
$ psql -h 127.0.0.1 -p 5401 -U abc postgres #PG 启动在5401/5402/5403端口
psql (Kunlun-1.2.1 on x86_64-pc-linux-gnu, 64-bit)
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------+----------+------------+------------+-------------------
postgres | kunlun | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | kunlun | UTF8 | en_US.utf8 | en_US.utf8 | =c/kunlun +
| | | | | kunlun=CTc/kunlun
template1 | kunlun | UTF8 | en_US.utf8 | en_US.utf8 | =c/kunlun +
| | | | | kunlun=CTc/kunlun
MySQL 连接
$ cd /kunlun
$ source env.sh
$ mysql -h 127.0.0.1 -u abc -pabc -P 6401 -D postgres # MySQL 启动在6401/6402/6403端口
mysql> show databases;
+-----------+
| Database |
+-----------+
| postgres |
| template1 |
| template0 |
+-----------+