etcd

本文内容纲要:etcd

etcd 0.5.0-alpha.4版本中

先用普通方式启用一边。

/bin/etcd -initial-advertise-peer-urls http://your_ip:7001 -advertise-client-urls http://your_ip:4001 -listen-peer-urls http://0.0.0.0:7001 -listen-client-urls http://0.0.0.0:4001 &

#!/bin/bash  

if [ -z $1 ]; then

echo "Usage: c run <image name>:<version>"

echo " c stop <container name>"

exit 1

fi

if [ -z $ETCD_HOST ]; then

ETCD_HOST="10.250.0.186:4001"

fi

if [ -z $ETCD_PREFIX ]; then

ETCD_PREFIX="app/servers"

fi

if [ -z $CPORT ]; then

CPORT="8069"

fi

if [ -z $FORREST_IP ]; then

FORREST_IP=`ifconfig eth0| grep "inet addr" | head -1 | cut -d : -f2 | awk '{print $1}'`

fi

function launch_container {

echo "Launching $1 on $FORREST_IP ..."

CONTAINER_ID=`docker run -d -p :8069 $1`

PORT=`docker inspect $CONTAINER_ID|grep "\"Ports\"" -A 50|grep "\"$CPORT/tcp\"" -A 3| grep HostPort|cut -d '"' -f4|head -1`

NAME=`docker inspect $CONTAINER_ID | grep Name | cut -d '"' -f4 | sed "s/\///g"|sed -n 2p`

echo "Announcing to $ETCD_HOST..."

curl -XPUT "http://$ETCD_HOST/v2/keys/$ETCD_PREFIX/$NAME" -d value="$FORREST_IP:$PORT"

echo "$1 running on Port $PORT with name $NAME"

}

function stop_container {

echo "Stopping $1..."

CONTAINER_ID=`docker ps -a| grep $1 | awk '{print $1}'`

echo "Found container $CONTAINER_ID"

docker stop $CONTAINER_ID

echo http://$ETCD_HOST/v2/keys/$ETCD_PREFIX/$1

curl -XDELETE http://$ETCD_HOST/v2/keys/$ETCD_PREFIX/$1 &> /dev/null

echo "Stopped."

}

if [ $1 = "run" ]; then

launch_container $2

else

stop_container $2

fi

本文内容总结:etcd

原文链接:https://www.cnblogs.com/zxpgo/p/4138361.html

以上是 etcd 的全部内容, 来源链接: utcz.com/z/297037.html

回到顶部