feat(node): adding all in one node support
This commit is contained in:
108
resources/node/files/conf/replication.conf.tpl
Normal file
108
resources/node/files/conf/replication.conf.tpl
Normal file
@ -0,0 +1,108 @@
|
||||
################################## INCLUDES ###################################
|
||||
################################## MODULES #####################################
|
||||
################################## NETWORK #####################################
|
||||
bind 127.0.0.1 -::1
|
||||
protected-mode yes
|
||||
port 6379
|
||||
tcp-backlog 511
|
||||
timeout 0
|
||||
tcp-keepalive 300
|
||||
################################# TLS/SSL #####################################
|
||||
port {{ env "VALKEY_PORT" }}
|
||||
################################### RDMA ######################################
|
||||
################################# GENERAL #####################################
|
||||
daemonize yes
|
||||
pidfile /opt/bitnami/valkey/tmp/valkey.pid
|
||||
loglevel notice
|
||||
logfile ""
|
||||
databases 16
|
||||
always-show-logo no
|
||||
hide-user-data-from-log yes
|
||||
set-proc-title yes
|
||||
proc-title-template "{title} {listen-addr} {server-mode}"
|
||||
locale-collate ""
|
||||
################################ SNAPSHOTTING ################################
|
||||
stop-writes-on-bgsave-error yes
|
||||
rdbcompression yes
|
||||
rdbchecksum yes
|
||||
rdb-version-check strict
|
||||
dbfilename dump.rdb
|
||||
rdb-del-sync-files no
|
||||
dir {{ env "VALKEY_DATA_DIR" }}
|
||||
################################# REPLICATION #################################
|
||||
replica-serve-stale-data yes
|
||||
replica-read-only yes
|
||||
repl-diskless-sync yes
|
||||
repl-diskless-sync-delay 5
|
||||
repl-diskless-sync-max-replicas 0
|
||||
repl-diskless-load disabled
|
||||
dual-channel-replication-enabled no
|
||||
repl-disable-tcp-nodelay no
|
||||
replica-priority 100
|
||||
############################### KEYS TRACKING #################################
|
||||
################################## SECURITY ###################################
|
||||
acllog-max-len 128
|
||||
################################### CLIENTS ####################################
|
||||
############################## MEMORY MANAGEMENT ################################
|
||||
############################# LAZY FREEING ####################################
|
||||
lazyfree-lazy-eviction yes
|
||||
lazyfree-lazy-expire yes
|
||||
lazyfree-lazy-server-del yes
|
||||
replica-lazy-flush yes
|
||||
lazyfree-lazy-user-del yes
|
||||
lazyfree-lazy-user-flush yes
|
||||
################################ THREADED I/O #################################
|
||||
############################ KERNEL OOM CONTROL ##############################
|
||||
oom-score-adj no
|
||||
oom-score-adj-values 0 200 800
|
||||
#################### KERNEL transparent hugepage CONTROL ######################
|
||||
disable-thp yes
|
||||
############################## APPEND ONLY MODE ###############################
|
||||
appendonly no
|
||||
appendfilename "appendonly.aof"
|
||||
appenddirname "appendonlydir"
|
||||
appendfsync everysec
|
||||
no-appendfsync-on-rewrite no
|
||||
auto-aof-rewrite-percentage 100
|
||||
auto-aof-rewrite-min-size 64mb
|
||||
aof-load-truncated yes
|
||||
aof-use-rdb-preamble yes
|
||||
aof-timestamp-enabled no
|
||||
################################ SHUTDOWN #####################################
|
||||
################ NON-DETERMINISTIC LONG BLOCKING COMMANDS #####################
|
||||
################################ VALKEY CLUSTER ###############################
|
||||
########################## CLUSTER DOCKER/NAT support ########################
|
||||
################################## COMMAND LOG ###################################
|
||||
commandlog-execution-slower-than 10000
|
||||
commandlog-slow-execution-max-len 128
|
||||
commandlog-request-larger-than 1048576
|
||||
commandlog-large-request-max-len 128
|
||||
commandlog-reply-larger-than 1048576
|
||||
commandlog-large-reply-max-len 128
|
||||
################################ LATENCY MONITOR ##############################
|
||||
latency-monitor-threshold 0
|
||||
################################ LATENCY TRACKING ##############################
|
||||
############################# EVENT NOTIFICATION ##############################
|
||||
notify-keyspace-events ""
|
||||
############################### ADVANCED CONFIG ###############################
|
||||
hash-max-listpack-entries 512
|
||||
hash-max-listpack-value 64
|
||||
list-max-listpack-size -2
|
||||
list-compress-depth 0
|
||||
set-max-intset-entries 512
|
||||
set-max-listpack-entries 128
|
||||
set-max-listpack-value 64
|
||||
zset-max-listpack-entries 128
|
||||
zset-max-listpack-value 64
|
||||
hll-sparse-max-bytes 3000
|
||||
stream-node-max-bytes 4096
|
||||
stream-node-max-entries 100
|
||||
activerehashing yes
|
||||
client-output-buffer-limit normal 0 0 0
|
||||
client-output-buffer-limit replica 256mb 64mb 60
|
||||
client-output-buffer-limit pubsub 32mb 8mb 60
|
||||
hz 10
|
||||
aof-rewrite-incremental-fsync yes
|
||||
rdb-save-incremental-fsync yes
|
||||
########################### ACTIVE DEFRAGMENTATION #######################
|
||||
jemalloc-bg-thread yes
|
41
resources/node/files/conf/sentinel.conf.tpl
Normal file
41
resources/node/files/conf/sentinel.conf.tpl
Normal file
@ -0,0 +1,41 @@
|
||||
{{- $hostname := env "HOSTNAME" }}
|
||||
{{- $service := env "VALKEY_SERVICE" }}
|
||||
{{- $namespace := env "NAMESPACE" }}
|
||||
{{- $port := env "VALKEY_PORT" }}
|
||||
{{- $sentinel_port := env "VALKEY_SENTINEL_PORT" }}
|
||||
{{- $replicas := env "VALKEY_REPLICAS" }}
|
||||
{{- $domain := printf "%s.%s.svc.cluster.local" $service $namespace }}
|
||||
{{- $fqdn := printf "%s.%s" $hostname $domain }}
|
||||
{{- $hostid := sha1sum $hostname }}
|
||||
|
||||
dir "/tmp"
|
||||
port {{ $port }}
|
||||
sentinel monitor mymaster {{ printf "%s %s" $fqdn $port }} 2
|
||||
sentinel down-after-milliseconds mymaster 60000
|
||||
|
||||
# User-supplied sentinel configuration:
|
||||
# End of sentinel configuration
|
||||
{{- printf "sentinel myid %s" $hostid }}
|
||||
|
||||
sentinel announce-hostnames yes
|
||||
sentinel resolve-hostnames yes
|
||||
sentinel announce-port {{- $sentinel_port }}
|
||||
sentinel announce-ip {{- $fqdn }}
|
||||
|
||||
# Generated by CONFIG REWRITE
|
||||
latency-tracking-info-percentiles 50 99 99.9
|
||||
protected-mode no
|
||||
# gotemplate-pause!
|
||||
user default on nopass sanitize-payload ~* &* +@all
|
||||
# gotemplate-resume!
|
||||
sentinel config-epoch mymaster 0
|
||||
sentinel leader-epoch mymaster 0
|
||||
sentinel current-epoch 0
|
||||
|
||||
{{- range $i, $e := until ( int $replicas ) }}
|
||||
{{- $ndeHostname := printf "valkey-node-%d" $i }}
|
||||
{{- $ndeFQDN := printf "%s.%s" $ndeHostname $domain }}
|
||||
{{- $nodeID := sha1sum $ndeHostname }}
|
||||
sentinel {{ printf "known-sentinel mymaster %s %s %s" $ndeFQDN $sentinel_port $nodeID }}
|
||||
sentinel {{ printf "known-replica mymaster %s %s" $ndeFQDN $port }}
|
||||
{{- end}}
|
27
resources/node/files/scripts/liveness-local.sh
Normal file
27
resources/node/files/scripts/liveness-local.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
ping_valkey() {
|
||||
resp=$(timeout -s 15 $1 \
|
||||
valkey-cli \
|
||||
-h localhost \
|
||||
-p $VALKEY_PORT \
|
||||
ping)
|
||||
ret=${?}
|
||||
echo $resp
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
response=$(ping_valkey 5)
|
||||
if [ "$?" -eq "124" ]; then
|
||||
echo "Timed out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
firstWord=$(echo $response | awk 'NR==1 {print $1;}')
|
||||
if [ "$response" != "PONG" ] && [ "$firstWord" != "LOADING" ] && [ "$firstWord" != "MASTERDOWN" ]; then
|
||||
echo "Valey is not alive [${response}]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$( date +'[%Y/%m/%d %H:%M:%S]') Valkey is alive"
|
||||
exit 0
|
28
resources/node/files/scripts/ping-sentinel.sh
Normal file
28
resources/node/files/scripts/ping-sentinel.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
ping_sentinel() {
|
||||
resp=$(timeout -s 15 $1 \
|
||||
valkey-cli \
|
||||
-h localhost \
|
||||
-p $VALKEY_SENTINEL_PORT \
|
||||
ping)
|
||||
ret=${?}
|
||||
echo $resp
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
|
||||
response=$(ping_sentinel 5)
|
||||
if [ "${?}" -eq 124 ]; then
|
||||
echo "Sentinel ping timed out"
|
||||
exit 124
|
||||
fi
|
||||
|
||||
if [ "${response}" != "PONG" ];
|
||||
then
|
||||
echo "Sentinel is not responding"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$( date +'[%Y/%m/%d %H:%M:%S]') Sentinel is responding"
|
||||
exit 0
|
0
resources/node/files/scripts/pre-start-sentinel.sh
Normal file
0
resources/node/files/scripts/pre-start-sentinel.sh
Normal file
50
resources/node/files/scripts/pre-stop.sh
Normal file
50
resources/node/files/scripts/pre-stop.sh
Normal file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run Valkey command
|
||||
vcli() {
|
||||
valkey_cli -h 127.0.0.1 -P "${VALKEY_PORT}" "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
# Run Sentinel command
|
||||
vscli() {
|
||||
valkey-cli -h "$VALKEY_SERVICE" -p "$VALKEY_SENTINEL_PORT" sentinel "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
sentinelFailOverFinished() {
|
||||
# Check if the failover is finished
|
||||
local failoverStatus
|
||||
primaryInfo=$(vscli get-primary-by-name "mymaster")
|
||||
primaryHost=${primaryInfo[0]}
|
||||
fullPrimaryHostname="${primaryHost}.${HEADLESS_SERVICE}"
|
||||
[[ "${fullPrimaryHostname}" == "${HOSTNAME}}" ]]
|
||||
}
|
||||
|
||||
if [ "${VALKEY_ROLE}" = "replication"]; then
|
||||
echo "Stopping replication"
|
||||
ROLE=$(vcli role | head 1)
|
||||
if [ "${ROLE}" = "master" ]; then
|
||||
#Pausing write connections to avoid data loss"
|
||||
vcli CLIENT PAUSE "22000"
|
||||
|
||||
echo "Failover in progress"
|
||||
vscli failover "mymaster"
|
||||
i=0
|
||||
while true; do
|
||||
sentinelFailOverFinished
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Failover finished"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
i=$((i + 1))
|
||||
if [ $i -gt 60 ]; then
|
||||
echo "Failover timed out"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
fi
|
26
resources/node/files/scripts/readiness-local.sh
Normal file
26
resources/node/files/scripts/readiness-local.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
ping_valkey() {
|
||||
resp=$(timeout -s 15 $1 \
|
||||
valkey-cli \
|
||||
-h localhost \
|
||||
-p $VALKEY_PORT \
|
||||
ping)
|
||||
ret=${?}
|
||||
echo $resp
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
response=$(ping_valkey 5)
|
||||
if [ "$?" -eq "124" ]; then
|
||||
echo "Timed out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$response" != "PONG" ]; then
|
||||
echo "Valey is not ready [${response}]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$( date +'[%Y/%m/%d %H:%M:%S]') Valkey is ready"
|
||||
exit 0
|
Reference in New Issue
Block a user