This commit is contained in:
2026-05-19 15:36:16 +08:00
parent 431dd2ab36
commit cb6c0202f7
7 changed files with 39 additions and 13 deletions

View File

@@ -58,6 +58,8 @@ function ModifyConf {
protected-mode no
maxmemory 6442450944
maxmemory-policy volatile-random
timeout 300
maxclients 8192
" > /etc/redis.conf
while read kv; do
[ 'cluster-enabled=yes' == "$kv" ] && clusterEnabled=1
@@ -73,21 +75,20 @@ function DeployCluster {
local i=
local node=
local nodesId=
local clusterEnabled=
local clusterInfo=
local redisCliCmd="redis-cli ${REQUIREPASS:+-a $REQUIREPASS --no-auth-warning}"
[ 0 -ne ${#SLAVE_NODES[@]} -a ${#SLAVE_NODES[@]} -ne ${#MASTER_NODES[@]} ] \
&& Print The num of slave nodes not equal to the num of master nodes! \
&& exit 100
Print Checking the state of all nodes ...
for node in ${MASTER_NODES[@]} ${SLAVE_NODES[@]}; do
for i in {0..5}; do
[ 5 -eq $i ] \
&& Print Failed to connect to $node! \
&& exit 100
sleep 6
clusterEnabled=$($redisCliCmd --raw -d , -h ${node/:/ -p } \
CONFIG GET cluster-enabled) \
|| continue
[[ "$clusterEnabled" =~ ,yes$ ]] && break
sleep 2
clusterInfo=$($redisCliCmd -h ${node/:/ -p } info cluster) || continue
echo "$clusterInfo" | grep -q cluster_enabled:1 && break
Print $node not enable cluster mode! && exit 100
done
done

10
redis/Dockerfile-5 Normal file
View File

@@ -0,0 +1,10 @@
ARG ARCH
FROM harbor.colben.cn/general/alpine$ARCH:3.23
MAINTAINER Colben colbenlee@gmail.com
ADD --chown=root:root /ADD/ /opt/
RUN curl -sSLO https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.12/main/$(uname -m)/redis-5.0.14-r0.apk \
&& apk add --allow-untrusted redis-5.0.14-r0.apk \
&& mv /etc/redis.conf /etc/redis.conf.origin \
&& rm -rf /var/cache/apk/* redis-5.0.14-r0.apk
CMD ["/opt/ccmd"]

View File

@@ -2,8 +2,7 @@ ARG ARCH
FROM harbor.colben.cn/general/alpine$ARCH:3.20
MAINTAINER Colben colbenlee@gmail.com
ADD --chown=root:root /ADD/ /opt/
RUN apk update \
&& curl -sSLO https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.15/main/$(uname -m)/redis-6.2.18-r0.apk \
RUN curl -sSLO https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.15/main/$(uname -m)/redis-6.2.18-r0.apk \
&& apk add --allow-untrusted redis-6.2.18-r0.apk \
&& mv /etc/redis.conf /etc/redis.conf.origin \
&& rm -rf /var/cache/apk/* redis-6.2.18-r0.apk

View File

@@ -9,7 +9,8 @@ export LANG=en_US.UTF-8
[ 'x86_64' == "$(uname -m)" ] && ARCH='' || ARCH="-$(uname -m)"
ROOT_DIR="$(cd $(dirname $0) && pwd)"
IMAGE="harbor.colben.cn/general/$(basename ${0%.sh})$ARCH:latest"
TAG=$1
IMAGE="harbor.colben.cn/general/$(basename ${0%.sh})$ARCH:$TAG"
if [ -t 0 ]; then
function Print { echo -e "\033[36;1m$(date +'[%F %T]')\033[32;1m $*\033[0m"; }
@@ -51,7 +52,7 @@ function Build {
&& Warn Removing image $IMAGE ... \
&& docker rmi $IMAGE
Warn Building image: $IMAGE ...
docker build --force-rm --build-arg ARCH="$ARCH" -t $IMAGE .
docker build --force-rm --build-arg ARCH="$ARCH" -t $IMAGE -f Dockerfile-$TAG .
YesOrNo Push image: $IMAGE? && docker push $IMAGE
}