`
liuxingguome
  • 浏览: 23800 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
文章分类
社区版块
存档分类
最新评论

redis6.06集群环境搭建

阅读更多
一、安装 redis6.06

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

cd redis-6.0.6/

make

make install PREFIX=/redis/redis6

mkdir -p /redis/redis-cluster/8001 /redis/redis-cluster/8002

cp redis.conf /redis/redis-cluster/8001/

修改 redis.conf 为以下内容:


protected-mode no

port 8001


tcp-backlog 511


timeout 0

tcp-keepalive 300

daemonize yes

supervised no

pidfile /var/run/redis_8001.pid


loglevel notice


logfile "/logs/193-8001.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

rdb-del-sync-files no

dir /redis/redis-cluster/8001/

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


lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no

lazyfree-lazy-user-del no

appendonly yes


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 nodes-8001.conf


cluster-node-timeout 5000

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



启动 redis 各节点:

/opt/redis-6.0.6/src/redis-server /redis/redis-cluster/8002/redis.conf

集群:

/opt/redis-6.0.6/src/redis-cli  --cluster create --cluster-replicas 1 172.16.6.193:8001 172.16.6.193:8002 172.16.6.194:8001 172.16.6.194:8002 172.16.6.237:8001 172.16.6.237:8002









redis单台安装

一、下载Redis
  下载地址:wget http://download.redis.io/releases/redis-5.0.7.tar.gz

  解压:tar -xzvf redis-5.0.7.tar.gz

二、准备编译:
  1、请在操作前确认gcc是否已安装

    安裝gcc命令:yum install gcc

  2、请在操作前确认tcl是否已安装

    安裝tcl命令:yum install tcl

三、编译:
  1、cd redis-5.0.7/

  2、make MALLOC=libc

    make 后加 MALLOC的参数的原因:

    避免提示找不到 jemalloc/jemalloc.h

四,测试编译:
  测试编译命令:make test

  \o/ All tests passed without errors! 看到这一行表示测试没问题

五、安装:
  1、cd /opt

  2、mkdir redis5  

    

    

  3、cd redis5

  4、mkdir bin

  5、mkdir conf

  6、cd bin/

  7、cp /root/softwares/redis-5.0.7/src/redis-cli ./

  8、cp /root/softwares/redis-5.0.7/src/redis-server ./

  9、在进入到conf文件:cd /opt/redis5/conf

  10、cp /root/softwares/redis-5.0.7/redis.conf ./

六、配置:
  vim /opt/redis5/conf/redis.conf

  1、requirepass ******    你的redis密码

  2、# bind 127.0.0.1       注释掉这一行

  3、daemonize no  改为 yes

  4、protected-mode yes 改为 no

七、运行
  /opt/redis5/bin/redis-server /opt/redis5/conf/redis.conf

  

八、使redis可以用systemd方式启动和管理
   vim /lib/systemd/system/redis.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=Redis
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/opt/redis5/bin/redis-server /opt/redis5/conf/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  重载系统服务:systemctl daemon-reload

启动:systemctl start redis   
停止:systemctl stop redis
查看状态 systemctl status redis
开机启动 systemctl enable redis



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics