==首先要升级到CentOS7.2,有一个XFS的Bug在7.2系统被修复了。==
echo "overlay" > /etc/modules-load.d/overlay.conf# lsmod | grep overoverlay 42451 0reboot
创建文件夹
mkdir -p /etc/systemd/system/docker.service.d
加入参数:
cat >/etc/systemd/system/docker.service.d/override.conf <<E[Service]ExecStart=ExecStart=/usr/bin/docker daemon --storage-driver=overlay -H fd://E
重启
systemctl daemon-reloadsystemctl restart docker
echo "overlay" > /etc/modules-load.d/overlay.conflsmod | grep overreboot
rm -rf /var/lib/docker
vi /usr/lib/systemd/system/docker.service
修改配置:
找到如下一行
ExecStart=/usr/bin/dockerd
加入参数:
--storage-driver=overlay
重启
systemctl daemon-reloadsystemctl restart docker
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuy
早就知道docker1.12有很大的改变,仰慕也是很久了,十一期间,抽了点时间(其他时间都在玩)根据官方文档试了下,还是挺好玩的,很多功能也很实用(服务发现、自动伸缩等),下面就是我的操作步奏,大家一起来看看
TCP 2377 集群管理节点通信的端口
TCP & UDP 7946 集群节点通信的端口
TCP & UDP 4789 overlay 网络通信端口
firewall-cmd --permanent --add-port={2377/tcp,2377/udp,7946/tcp,7946/udp,4789/tcp,4789/udp}firewall-cmd --reloadfirewall-cmd --list-all
# 主节点docker swarm init --advertise-addr 192.168.11.33# 子节点docker swarm join \--token SWMTKN-1-51w1r44gg7n392k4eti1i52zrbhwjwkmmqoe2zugtur483rdyb-9yb9ucnj23xc0k49sh7cddge3 \192.168.11.33:2377
# 创建服务docker service create --replicas 1 --name helloworld alpine ping docker.com# 查看服务docker service ls# 使用inspect查看服务docker service inspect --pretty helloworld# 使用inspect查看服务的详细信息docker service inspect helloworld# 查看服务在各个节点上运行的信息docker service ps helloworld
# 将helloworld节点拓展到5个docker service scale helloworld=5# 查看服务在节点上的运行信息docker servi
某些特殊情况下,需要将某些服务固定在一台宿主机上,K8S也适应这种方式,下面以mongo为例,来看看如何实现的:
kubectl label nodes kube-node node=kube-nodekubectl get node -a -l "node=kube-node"
pod或者rc的配置项中添加如下配置:
nodeSelector:node: kube-node4
如mongo启动的rc文件
apiVersion: v1kind: ReplicationControllermetadata:name: mongospec:replicas: 1template:metadata:labels:run: mongospec:containers:- name: mongoimage: daocloud.io/library/mongo:3.2.4ports:- containerPort: 27017volumeMounts:- mountPath: /data/dbname: mongovolumes: [{"name":"mongo","hostPath":{"path":"/root/volumes/mongo"}}]nodeSelector:node: kube-node4
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(==防止爬虫==):http://blog.liuyingguang.cn
本项目是将restful项目打包成可执行的war包,在docker中执行
docker 1.10.3jetty 8jersey 1.19
<build><finalName>${project.artifactId}</finalName><plugins><plugin><groupId>org.mortbay.jetty</groupId><artifactId>jetty-maven-plugin</artifactId><version>${jetty.version}</version><configuration><systemProperties></systemProperties><webApp><contextPath>/</contextPath></webApp></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>2.5.1</version><configuration><source>1.7</source><target>1.7</target></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>2.2</version><executions><execution><id>attach-sources</id><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><groupId>org.
Docker的使用中,尤为重要的是服务发现和docker的宿主机集群及跨主机overlay网络的搭建,这里来介绍下常用来配合使用的swarm+consul集群的搭建(此处全基于docker容器)
192.168.11.30 为consul服务的leader,swarm的集群server和client节点,并为primary
192.168.11.32 为consul服务的节点,swarm的集群server和client节点,并为备份节点
192.168.11.30:
consul、swarm、nginx
192.168.11.32:
consul、swarm、nexus、jenkins、registry
cluster-store 是consul的leader的地址
cluster-advertise 是swarm client的地址,即当前主机
11.30
vi /usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/docker daemon --tls=false -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 --cluster-store=consul://192.168.11.30:8500 --cluster-advertise=192.168.11.30:2375systemctl daemon-reloadsystemctl restart docker
11.32
vi /usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/docker daemon --tls=false -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 --cluster-store=consul://192.168.11.30:8500 --cluster-