欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Redis简单cluster集群搭建

程序员文章站 2022-07-05 21:54:56
...

一.安装Redis环境

  • 1.创建redis安装路径
    /tmp/redis/3.2.3

  • 把redis_install.sh 和 redis-3.2.3.tar 放在路径下
    chmod +x redis_install.sh
    执行脚本安装

#! /bin/bash

version=$1

INSTALL_DIR=/tmp/redis/${version}

cd ${INSTALL_DIR}

echo "当前目录 : "$(pwd)

# 安装需要用到的包
echo "准备安装redis需要的包"
yum install -y gcc make g++ gcc-c++ automake lrzsz openssl-devel zlib-* bzip2-* readline* zlib-* bzip2-*

echo "编译安装redis"
tar -xzf redis-${version}.tar.gz
cd redis-${version}
make
make install

二.搭建集群

  • 1.判断是否存在redis
    redis-server -v

  • 2.确认用户是否存在
    cat /etc/passwd
    不存在就添加,用户:cachecloud,密码:cachecloud
    useradd cachecloud
    passwd cachecloud

  • 3.确认端口是否可用
    lsof -i:8010 | grep -v COMMAND

  • 4./根路径下创建路径
    mkdir /var/cachecloud
    cd /var/cachecloud
    mkdir conf
    mkdir data
    mkdir logs

  • 5.创建配置文件
    vi redis-cluster-8010.conf
    修改bind, port , appendfilename, cluster-config-file, dbfilename

  • 6.启动
    redis-server /var/cachecloud/conf/redis-cluster-8228.conf > /var/cachecloud/logs/redis-8228-20180918162224181.log 2>&1 &

activerehashing yes
aof-load-truncated yes
aof-rewrite-incremental-fsync yes
appendfilename "appendonly-8010.aof"
auto-aof-rewrite-min-size 62500kb
auto-aof-rewrite-percentage 94
bind 172.17.160.241
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 512mb 128mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
cluster-config-file "nodes-8010.conf"
cluster-enabled yes
cluster-migration-barrier 5
cluster-node-timeout 15000
cluster-require-full-coverage yes
cluster-slave-validity-factor 10
daemonize no
databases 16
dbfilename "dump-8010.rdb"
dir "/var/cachecloud/data"
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
hll-sparse-max-bytes 3000
hz 10
list-max-ziplist-entries 512
list-max-ziplist-value 64
loglevel notice
lua-time-limit 5000
maxclients 10000
maxmemory 1111mb
maxmemory-policy volatile-lru
min-slaves-max-lag 10
min-slaves-to-write 0
no-appendfsync-on-rewrite yes
notify-keyspace-events ""
port 8010
rdbchecksum yes
rdbcompression yes
repl-backlog-size 10000000
repl-backlog-ttl 7200
repl-disable-tcp-nodelay no
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-ping-slave-period 10
repl-timeout 60
set-max-intset-entries 512
slave-priority 100
slave-read-only yes
slave-serve-stale-data yes
slowlog-log-slower-than 10000
slowlog-max-len 128
stop-writes-on-bgsave-error no
tcp-backlog 511
tcp-keepalive 60
timeout 0
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
protected-mode no
rename-command FLUSHDB "OPPO_BDHSULF"
rename-command FLUSHALL "OPPO_LLAHSULF"
rename-command KEYS "OPPO_SYEK

# aof
save ""
appendonly yes
appendfsync everysec

# aof
save 900 1
save 300 10
save 60 10000
appendonly no

# no persistence

以下见https://blog.csdn.net/men_wen/article/details/72853078
7.cluster meet
8.分配槽
9.cluster replicate