yum install etcd -y
vi /etc/default/etcd
ETCD_DATA_DIR="/var/lib/etcd/default"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379
sed -i ‘s/localhost/0.0.0.0/g‘ /etc/etcd/etcd.conf
systemctl start etcd
tar xf flannel-v0.10.0-linux-amd64.tar.gz
cp flanneld mk-docker-opts.sh /usr/bin/
etcdctl set /coreos.com/network/config ‘{ "Network": "10.1.0.0/16" }‘
cat /usr/lib/systemd/system/flanneld.service
[Unit]
Description=Flanneld overlay address etcd agent
After=network.target
Before=docker.service
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/flanneld
ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD} $FLANNEL_OPTIONS
[Install]
RequiredBy=docker.service
WantedBy=multi-user.target
cat /etc/sysconfig/flanneld
FLANNEL_ETCD="http://10.130.0.252:2379"
FLANNEL_ETCD_KEY="/coreos.com/network"
cat /etc/init.d/start_flannel.sh
#!/bin/bash
systemctl stop docker
systemctl restart flanneld
mk-docker-opts.sh -i
source /run/flannel/subnet.env
ifconfig docker0 ${FLANNEL_SUBNET}
systemctl start docker
vi /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --bip=10.1.78.1/24 --mtu=1472
systemctl daemon-reload
docker run -itd --name bbox1 busybox
docker run -itd --name bbox2 busybox
docker exec bbox1 ip r
docker exec bbox2 ip r
docker exec bbox1 ping
docker exec bbox2 ping
原文地址:http://blog.51cto.com/13606492/2119822