Centos7 source code installation Redis Cluster 6.2.9 Redis Cluster Proxy

Install and compile

sudo su -

yum install -y gcc g++ gcc-c++ make tcl

cd /tmp && wget http://download.redis.io/releases/redis-6.2.9.tar.gz

tar -zxvf redis-6.2.9.tar.gz && cd redis-6.2.9

make -j8 # Use multi-core compilation, otherwise it will take a long time. If you are compiling on this configuration for the first time, it is recommended to make test first

make PREFIX=/usr/local install # Customize the installation path

cat /tmp/redis-6.2.9/redis.conf |grep -v '^#' |grep -v "^$" > /etc/redis/redis-6379.conf #Remove the comments and blanks in the official configuration file OK

system tuning

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf

echo 2048 > /proc/sys/net/core/somaxconn

echo 'net.core.somaxconn=2048' >> /etc/sysctl.conf && sysctl -p

sysctl vm.overcommit_memory=1

Turn on the cluster and limit the memory of a single node and the elimination strategy

echo 'maxmemory 64GB

maxmemory-policy volatile-ttl

cluster-enabled yes

cluster-node-timeout 10000' >>/etc/redis/redis-6379.conf

cat /etc/redis/redis-6379.conf

Generate configuration files for multiple ports

#The server has 512G memory, and a single instance is allocated 64G, so start 8 instances (you can open one less if the pressure is high)

#copy file

for i in {8001..8008} ;do cp /etc/redis/redis-6379.conf "/etc/redis/redis-${i}.conf" ;done

#Replace the port in the file

for i in {8001..8008};do

config_file="/etc/redis/redis-${i}.conf"

sed -i "s/6379/${i}/g" $config_file

done

Distribute configuration files and create folders

ansible redis -m copy -a "src=/etc/redis dest=/etc/"

ansible redis -m shell -a "mkdir /data/log/"

ansible redis -m shell -a "mkdir -p /data/redis/{8001..8008}"

Launch and test

Start a single node and need to stop manually after completion

redis-server /etc/redis/redis-6379.conf #

#Start the service, which can be made into a shell and started with ansible

for i in {8001..8008} ; do

redis-server "/etc/redis/redis-${i}.conf" ;

done

n/redis_6379.pid
loglevel notice
logfile "/data/log/redis_6379.log"
databases 16
always-show-logo no
set-proc-title yes
proc-title-template "{title} {listen-addr} {server-mode}"
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /data/redis/6379
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no
oom-score-adj no
oom-score-adj-values 0 200 800
disable-thp yes
appendonly no
appendfilename "appendonly.aof"
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
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-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
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes
cluster-enabled yes
cluster-node-timeout 10000
maxmemory 8GB
maxmemory-policy volatile-ttl

# Shut down the service, not required

#pkill redis

Build a cluster 64G*6*8

redis-cli --cluster create --cluster-replicas 1 172.20.192.22:8001 172.20.192.22:8002 172.20.192.22:8003 172.20.192.22:8004 172.20.192.23:8001 172.20.192.23:8002 172.20.192.23:8003 172.20.192.23:8004 172.20.192.31:8001 172.20.192.31:8002 172.20.192.31:8003 172.20.192.31:8004 172.20.192.32:8001 172.20.192.32:8002 172.20.192.32:8003 172.20.192.32:8004 172.20.192.33:8001 172.20.192.33:8002 172.20.192.33:8003 172.20.192.33:8004 172.20.192.34:8001 172.20.192.34:8002 172.20.192.34:8003 172.20.192.34:8004 172.20.192.22:8005 172.20.192.22:8006 172.20.192.22:8007 172.20.192.22:8008 172.20.192.23:8005 172.20.192.23:8006 172.20.192.23:8007 172.20.192.23:8008 172.20.192.31:8005 172.20.192.31:8006 172.20.192.31:8007 172.20.192.31:8008 172.20.192.32:8005 172.20.192.32:8006 172.20.192.32:8007 172.20.192.32:8008 172.20.192.33:8005 172.20.192.33:8006 172.20.192.33:8007 172.20.192.33:8008 172.20.192.34:8005 172.20.192.34:8006 172.20.192.34:8007 172.20.192.34:8008

Todo Redis cluster proxy solves the problem of too many application connection nodes

https://github.com/RedisLabs/redis-cluster-proxy

Attached: complete configuration file

cd /tmp && git clone https://github.com/RedisLabs/redis-cluster-proxy

# Just temporarily use it, it will fail after exiting

yum install centos-release-scl

yum install devtoolset-7-gcc*

scl enable devtoolset-7 bash # source /opt/rh/devtoolset-7/enable

gcc -v

make

make PREFIX=/usr/local install

configuration file:

bind 0.0.0.0
port 16379
connections-pool-size 10
connections-pool-min-size 10
daemonize yes
enable-cross-slot yes
log-level error
logfile "/data/log/proxy.log"
max-clients 5000
pidfile /var/run/redis-cluster-proxy.pid
threads 16
entry-point 172.20.192.22:8001
entry-point 172.20.192.22:8002
entry-point 172.20.192.22:8003
entry-point 172.20.192.22:8004
entry-point 172.20.192.23:8001
entry-point 172.20.192.23:8002
entry-point 172.20.192.23:8003
entry-point 172.20.192.23:8004
entry-point 172.20.192.31:8001
entry-point 172.20.192.31:8002
entry-point 172.20.192.31:8003
entry-point 172.20.192.31:8004
entry-point 172.20.192.32:8001
entry-point 172.20.192.32:8002
entry-point 172.20.192.32:8003
entry-point 172.20.192.32:8004
entry-point 172.20.192.33:8001
entry-point 172.20.192.33:8002
entry-point 172.20.192.33:8003
entry-point 172.20.192.33:8004
entry-point 172.20.192.34:8001
entry-point 172.20.192.34:8002
entry-point 172.20.192.34:8003
entry-point 172.20.192.34:8004
entry-point 172.20.192.22:8005
entry-point 172.20.192.22:8006
entry-point 172.20.192.22:8007
entry-point 172.20.192.22:8008
entry-point 172.20.192.23:8005
entry-point 172.20.192.23:8006
entry-point 172.20.192.23:8007
entry-point 172.20.192.23:8008
entry-point 172.20.192.31:8005
entry-point 172.20.192.31:8006
entry-point 172.20.192.31:8007
entry-point 172.20.192.31:8008
entry-point 172.20.192.32:8005
entry-point 172.20.192.32:8006
entry-point 172.20.192.32:8007
entry-point 172.20.192.32:8008
entry-point 172.20.192.33:8005
entry-point 172.20.192.33:8006
entry-point 172.20.192.33:8007
entry-point 172.20.192.33:8008
entry-point 172.20.192.34:8005
entry-point 172.20.192.34:8006
entry-point 172.20.192.34:8007
entry-point 172.20.192.34:8008

# start up

redis-cluster-proxy -c /etc/redis/proxy.conf

Guess you like

Origin blog.csdn.net/lansye/article/details/129098294