我有以下SH文件:
#------------ bootstrap the cluster nodes --------------------
start_cmd='redis-server --port 6379 --cluster-enabled yes --cluster-config-
file nodes.conf --cluster-node-timeout 5000 --appendonly yes'
redis_image='redis:5.0.3'
network_name='redis_cluster_net'
docker network create $network_name
echo $network_name " created"
#---------- create the cluster ------------------------
for port in `seq 6379 6384`; do \
docker run -d --name "redis-"$port -p $port:6379 --net $network_name
$redis_image $start_cmd;
echo "created redis cluster node redis-"$port
done
cluster_hosts=''
for port in `seq 6379 6384`; do \
hostip=`docker inspect -f '{{(index .NetworkSettings.Networks
"redis_cluster_net").IPAddress}}' "redis-"$port`;
echo "IP for cluster node redis-"$port "is" $hostip
cluster_hosts="$cluster_hosts$hostip:6379 ";
done
echo "cluster hosts "$cluster_hosts
echo "creating cluster...."
echo 'yes' | docker run -i --rm --net $network_name $redis_image redis-cli --cluster create $cluster_hosts --cluster-replicas 1;
我曾尝试将其转换为bat文件,但是这是我的第一次尝试,并且下面的文件似乎不起作用“无效的地址格式:“'这时是意外的。”
我猜可能还有其他错误。
有人可以帮助他们找到我,以便我进行更改吗?
@echo off
REM bootstrap the cluster nodes
SET start_cmd="redis-server --port 6379 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes"
SET redis_image="redis:5.0.3"
SET network_named="redis_cluster_net"
docker network create %network_named%
echo %network_name% " created"
REM Create the cluster
for /l %%i in (6379, 1, 6384) do (
docker run -d --name redis-%%i -p %%i:6379 --net %network_named% %redis_image% %start_cmd%;
echo created redis cluster node redis-%%i
)
SET cluster_hosts=""
for /l %%j in (6379, 1, 6384) do (
SET hostip="docker inspect -f '{{(index .NetworkSettings.Networks ""redis_cluster_net"").IPAddress}}' redis-%%j"
echo IP for cluster node redis-%%j is %hostip%
SET cluster_hosts= "%cluster_hosts% %hosthip% :6379 "
)
echo "cluster hosts " %cluster_hosts%
echo "creating cluster...."
docker run -i --rm --net %network_named% %redis_image% redis-cli --cluster create %cluster_hosts% --cluster-replicas 1;