转载

试用swarmkit

准备工作:
1.准备三台机器,配置如下:
机器名                            系统                        IP
swarmkit-manager ubuntu 14.04 192.168.65.133
swarmkit-node1 ubuntu 14.04 192.168.65.134
swarmkit-node1 ubuntu 14.04 192.168.65.135
2.安装git,make
apt-get install git
apt-get install make
3.安装golang
wget https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
sudo tar -xzf go1.6.linux-amd64.tar.gz -C /usr/local
4.修改/etc/profile,在最后加入如下内容
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=/usr/local/go/bin
export PATH=$PATH:$GOBIN
5.下载swarmkit项目
go get github.com/docker/swarmkit/...
go get -d github.com/docker/swarmkit/...
执行以上两句可以避免安装出现 $GOPATH/src/github.com/docker/swarmkit.
6.执行成功后,你会找到当前系统目录下面有
cd /root/go/src/github.com/docker/swarmkit
目录
7.执行make binaries
执行成功后可以在 /root/go/src/github.com/docker/swarmkit/bin 目录下面找到以下文件
protoc-gen-gogoswarm  swarm-bench  swarmctl  swarmd
拷贝命令到/usr/bin/以便快速启动
cp protoc-gen-gogoswarm swarm-bench swarmctl swarmd /usr/bin/
8.启动manager(192.168.65.133)
swarmd -d /tmp/node-1 --listen-control-api /tmp/manager1/swarm.sock --hostname node-1
9.设置node节点(192.168.65.134,192.168.65.135)
swarmd -d /tmp/node-2 --hostname node-2 --join-addr 192.168.65.133:4242
swarmd -d /tmp/node-3 --hostname node-3 --join-addr 192.168.65.133:4242
10.验证集群(在manager节点操作下面命令)
$  export SWARM_SOCKET=/tmp/manager1/swarm.sock
$ swarmctl node ls
ID Name Status Availability Manager status
87pn3pug404xs4x86b5nwlwbr node-1 READY ACTIVE REACHABLE *
by2ihzjyg9m674j3cjdit3reo node-2 READY ACTIVE
87pn3pug404xs4x86b5nwlwbr node-3 READY ACTIVE
11.创建服务
swarmctl service create --name mysql --image 192.168.65.133:5000/mysql-5.5:v1
12.查看服务列表
$  swarmctl service ls
ID Name Image Instances
-- ---- ----- ---------
89831rq7oplzp6oqcqoswquf2 mysql 192.168.65.133:5000/mysql-5.5:v1 1
13.查看服务信息
$ swarmctl service inspect mysql
ID : 89831rq7oplzp6oqcqoswquf2
Name : mysql
Instances : 1
Template
Container
Image : 192.168.65.133:5000/mysql-5.5:v1
Task ID Service Instance Image Desired State Last State Node
------- ------- -------- ----- ------------- ---------- ----
0dsiq9za9at3cqk4qx07n6v8j mysql 1 192.168.65.133:5000/mysql-5.5:v1 RUNNING RUNNING 2 seconds ago node-1
14.更改实例数
$ swarmctl service update mysql --instances 6
89831rq7oplzp6oqcqoswquf2
$ swarmctl service inspect mysql
ID : 89831rq7oplzp6oqcqoswquf2
Name : mysql
Instances : 6
Template
Container
Image : 192.168.65.133:5000/mysql-5.5:v1
Task ID Service Instance Image Desired State Last State Node
------- ------- -------- ----- ------------- ---------- ----
0dsiq9za9at3cqk4qx07n6v8j mysql 1 192.168.65.133:5000/mysql-5.5:v1 RUNNING RUNNING 1 minute ago node-1
9fvobwddp5ve3k0f4al1mhuhn mysql 2 192.168.65.133:5000/mysql-5.5:v1 RUNNING RUNNING 3 seconds ago node-2
e7pxax9mhjd4zamohobefqpy0 mysql 3 192.168.65.133:5000/mysql-5.5:v1 RUNNING RUNNING 3 seconds ago node-2
ceuwhcffcavur7k9q57vqw0zg mysql 4 192.168.65.133:5000/mysql-5.5:v1 RUNNING RUNNING 3 seconds ago node-1
8vqmbo95l6obbtb7fpmvz522f mysql 5 192.168.65.133:5000/mysql-5.5:v1 RUNNING RUNNING 3 seconds ago node-3
385utv15nalm2pyupao6jtu12 mysql 6 192.168.65.133:5000/mysql-5.5:v1 RUNNING RUNNING 3 seconds ago node-3
15.总结
以上为刚搭建的swarmkit集群,本来想试一下manager多节点,但是swarmkit只能是单个,查看了一下各节点的ca文件,目前好像只支持单个ca证书
总体来说,swarmkit安装比较简单,目前功能不是很多(还在尝试研究中),后续会跟进
原文  http://dockone.io/article/1385
正文到此结束
Loading...