redis分佈式集羣部署5.0.5版本安裝腳本

安裝redis

#!/bin/bash

#This is a script to install redis, the source code is compiled and installed. The version number of redis is 5.0.5

#Installation dependency package

yum -y install gcc gcc-c++

#關閉selinux、firewalld
systemctl stop firewalld 
systemctl disable firewalld
setenforce 0 
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux


#Download the installation package

wget http://download.redis.io/releases/redis-5.0.5.tar.gz



#Extract to the specified directory

tar zxvf redis-5.0.5.tar.gz -C /usr/src

cd /usr/src/redis-5.0.5/

make MALLOC=libc

make && make install


mkdir -p /opt/redis/{db,etc,bin,logs}

cd  /usr/src/redis-5.0.5/src/
cp mkreleasehdr.sh redis-benchmark redis-check-aof redis-server redis-cli redis-sentinel /opt/redis/bin 


cat >/opt/redis/etc/redis.conf << EOF
bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /opt/redis/logs/redis.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /opt/redis/db
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
masterauth 123456
requirepass 123456
maxclients 10000
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
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
cluster-enabled yes
cluster-config-file redis.conf
cluster-node-timeout 15000
cluster-slave-validity-factor 10
cluster-migration-barrier 1
cluster-require-full-coverage yes
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
EOF



#Start service
redis-server /opt/redis/etc/redis.conf

#查看服務
ps -aux |grep  redis

集羣創建



創建集羣

```bash
redis-cli --cluster create IP:端口  IP:端口 IP:端口 IP:端口 IP:端口 IP:端口  --cluster-replicas 1 -a 密碼

出現下面的字樣說明創建成功

[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

登陸驗證

redis-cli -c -p 端口
auth 密碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章