redis-3.2.1 伪集群安装配置

  |   0 评论   |   835 浏览

1.解压redis

localhost:redis ben$ tar -zxvf redis-3.2.1.tar.gz 

2.安装redis

localhost:redis-3.2.1 ben$ make

3.配置

    在redis目录新建目录cluster,然后再cluster在新建6个目录分别是7701,7702,7703,7704,7705,7706。把src目录和redis.conf分别复制到6个节点目录下。为每个节点的redis.conf修改ip,和端口号,并且设置为外网可访问状态。

daemonize yes

port  7701(每个节点对应自己的端口号。7702..7703)

bind 127.0.0.1

4.测试   

localhost:src ben$ ./redis-cli -c -h 127.0.0.1 -p 7701
127.0.0.1:7701> set 1 1
OK
127.0.0.1:7701> get 1
"1"
127.0.0.1:7701> exit

5.shell

    redis伪集群比较更的就是开启和关闭了,每次都要一个一个节点的开,一个一个的关,所以写个shell更方便。

#! /bin/bash
pid=$(ps x | grep "redis" | grep -v grep | awk '{print $1}')
echo $pid
if [ "$pid" != "" ] 
then
echo kill $pid
kill -9 $pid
echo kill ok
fi
echo start redis
cd /Users/ben/utils/redis/redis-3.2.1/cluster/7701/src && ./redis-server /Users/ben/utils/redis/redis-3.2.1/cluster/7701/redis.conf 
cd /Users/ben/utils/redis/redis-3.2.1/cluster/7702/src && ./redis-server /Users/ben/utils/redis/redis-3.2.1/cluster/7702/redis.conf 
cd /Users/ben/utils/redis/redis-3.2.1/cluster/7703/src && ./redis-server /Users/ben/utils/redis/redis-3.2.1/cluster/7703/redis.conf 
cd /Users/ben/utils/redis/redis-3.2.1/cluster/7704/src && ./redis-server /Users/ben/utils/redis/redis-3.2.1/cluster/7704/redis.conf 
cd /Users/ben/utils/redis/redis-3.2.1/cluster/7705/src && ./redis-server /Users/ben/utils/redis/redis-3.2.1/cluster/7705/redis.conf 
cd /Users/ben/utils/redis/redis-3.2.1/cluster/7706/src && ./redis-server /Users/ben/utils/redis/redis-3.2.1/cluster/7706/redis.conf 
echo start redis success

    shell写完别忘了赋予权限。

这个家伙很懒,连签名都不写。

评论

发表评论