Docker Ignite 数据卷挂载安装和启动,两个命令就搞定了
sudo docker pull apacheignite/ignite
sudo docker run -it --net=host apacheignite/ignite
如果需要制定配置文件并且enable一些可选库文件(如 restful api)可以使用如下命令
sudo docker run -it --net=host -v /PATH/example-cache.xml:/opt/ignite/apache-ignite-fabric-2.1.0-bin/config/example-cache.xml -e "CONFIG_URI=/opt/ignite/apache-ignite-fabric-2.1.0-bin/config/example-cache.xml" -e "OPTION_LIBS=ignite-rest-http" apacheignite/ignite
NOTE: Ignite 的restful模块目前比较弱,基本属于不能使用状态。如cache只支持
修改配置文件 default-config.xml 开启Ignite的原生持久化
Docker 提交新版本
docker commit ignite apacheignite/ignite:2.6.0.1
创建数据卷
docker volume create my-vol
查看数据卷 docker volume ls
xiaows@basechina:~/sunzj/sql$ docker volume ls
local kevin
local my-vol
查看数据卷详情 docker inspect my-vol
xiaows@basechina:~/sunzj/sql$ docker inspect my-vol
[
{
"CreatedAt": "2018-11-07T13:48:48+08:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/my-vol/_data",
"Name": "my-vol",
"Options": {},
"Scope": "local"
}
]
启动ignite容器
docker run -itd --name ignite --hostname ignite -v my-vol:/opt/ignite/apache-ignite-fabric/work apacheignite/ignite:2.6.0.1
xiaows@basechina:~$ docker run -itd --name ignite --hostname ignite -v my-vol:/opt/ignite/apache-ignite-fabric/work apacheignite/ignite:2.6.0.1
0349d5a9ee2f7156a5e982fe097eb6f0062e3627aba30d4e369e415496c7e262
进入ignite 容器 docker exec -it ignite bash
xiaows@basechina:~$ docker exec -it ignite bash
bash-4.4#
激活集群节点 apache-ignite-fabric/bin/control.sh --activate
bash-4.4# apache-ignite-fabric/bin/control.sh --activate
Control utility [ver. 2.6.0#20180710-sha1:669feacc]
2018 Copyright(C) Apache Software Foundation
User: root
--------------------------------------------------------------------------------
Cluster activated
bash-4.4#
操作容器 apache-ignite-fabric/bin/sqlline.sh -u jdbc:ignite:thin://127.0.0.1
bash-4.4# apache-ignite-fabric/bin/sqlline.sh -u jdbc:ignite:thin://127.0.0.1
sqlline version 1.3.0
0: jdbc:ignite:thin://127.0.0.1>
执行内部sql 文件
!run apache-ignite-fabric/examples/sql/world.sql
查询表详情
!table
0: jdbc:ignite:thin://127.0.0.1> !table
+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+----+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | |
+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+----+
| | PUBLIC | COUNTRYLANGUAGE | TABLE | | | | | |
| | PUBLIC | COUNTRY | TABLE | | | | | |
| | PUBLIC | CITY | TABLE | | | | | |
+--------------------------------+--------------------------------+--------------------------------+--------------------------------+
执行sql 语句
select count(1) from CITY;
0: jdbc:ignite:thin://127.0.0.1> select count(1) from CITY;
+--------------------------------+
| COUNT(1) |
+--------------------------------+
| 4079 |
+--------------------------------+
1 row selected (0.115 seconds)
停止ignite容器
docker stop ignite
删除ignite容器
docker rm ignite
再次执行启动ignite 容器
docker run -itd --name ignite --hostname ignite -v my-vol:/opt/ignite/apache-ignite-fabric/work apacheignite/ignite:2.6.0.1
查询数据,数据仍然存在。
数据卷挂载成功!