Redis简单集群配置

参考链接为:http://blog.csdn.net/u014230881/article/details/71123494

比较系统学习和熟练使用Redis命令可参考该教程:http://www.runoob.com/redis/redis-tutorial.html

另外关于Redis+Java学习使用可以参考我的这篇文章:Java连接Redis之redis的增删改查

关于SSM框架如何整合Redis,可以参考我的这篇文章:网站性能优化小结和spring整合redis

集群配置:

 

1.准备环境

必须执行如下命令,否则会报错

apt-get install ruby
apt-get install rubygems  
sudo gem install redis

 

 

2.安装软件

在/usr/目录执行如下命令:

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

tar -xzvf redis-3.2.6.tar.gz

                         

3.建立目录

# mkdir -p /usr/local/cluster
# mkdir -p /usr/local/cluster/6000
# mkdir -p /usr/local/cluster/6001
# mkdir -p /usr/local/cluster/6002
# mkdir -p /usr/local/cluster/6003
# mkdir -p /usr/local/cluster/6004
# mkdir -p /usr/local/cluster/6005

//redis-3.2.6复制到/usr/local/cluster目录下

# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6000/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6001/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6002/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6003/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6004/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6005/

4.修改配置文件

# vi /usr/local/cluster/6000/redis.conf
修改配置文件中的下面选项(把有注释的打开)
daemonize yes
port  6000
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
用6000/redis.conf覆盖6001,6002,6003,6004,6005目录下的redis.conf

再修改6001,6002,6003,6004,6005目录下的redis.conf中的port,使得redis.conf中的port与其父目录名称一致,比如6001/redis.conf中的port为6001

 

5.启动六个Redis

//分别进入目录启动Redis

# cd /usr/local/cluster/6000/src
# redis-server ../redis.conf


# cd /usr/local/cluster/6001/src
# redis-server ../redis.conf


# cd /usr/local/cluster/6002/src
# redis-server ../redis.conf

 

可参考链接如下:

1.redis集群 一主多从 可参考如下网站:
http://blog.csdn.net/a60782885/article/details/70232240

2.集群具体配置 参考如下网站:
http://blog.csdn.net/u014230881/article/details/71123494

3.redis持久化
https://www.cnblogs.com/mrhgw/p/Redis.html
# cd /usr/local/cluster/6003/src
# redis-server ../redis.conf


# cd /usr/local/cluster/6004/src
# redis-server ../redis.conf


# cd /usr/local/cluster/6005/src
# redis-server ../redis.conf

 

 

//进入该目录下启动Redis,创建集群

# cd /usr/redis-3.2.6/src
# ./redis-trib.rb create --replicas 1 127.0.0.1:6000 127.0.0.1:6001 127.0.0.1:6002 127.0.0.1:6003 127.0.0.1:6004 127.0.0.1:6005

 

posted @ 2018-08-02 20:09  挑战者V  阅读(224)  评论(0编辑  收藏  举报