redis集群(离线版)安装手册
1. 依赖包:apr-1.3.9-5.el6_2.src.rpmapr-util-1.3.9-3.el6_0.1.src.rpmcurl-7.19.7-52.el6.src.rpmhttpd-2.2.15-59.el6.centos.src.rpmmysql-5.1.73-8.el6_8.src.rpmopenssl-1.0.1e-57.el6.src.rpm
欢迎关注“程序杂货铺”公众号,里面有精彩内容,欢迎大家收看^_^
1. 依赖包:
apr-1.3.9-5.el6_2.src.rpm
apr-util-1.3.9-3.el6_0.1.src.rpm
curl-7.19.7-52.el6.src.rpm
httpd-2.2.15-59.el6.centos.src.rpm
mysql-5.1.73-8.el6_8.src.rpm
openssl-1.0.1e-57.el6.src.rpm
zlib-1.2.3-29.el6.src.rpm
2. 安装依赖包:
rpm -ivh apr-1.3.9-5.el6_2.src.rpm
注:此时会报错,需添加mockbuild组,同时使用root。
groupadd mockbuild
useradd mockbuild -g mockbuild
rpm -ivh apr-1.3.9-5.el6_2.src.rpm
rpm -ivh apr-util-1.3.9-3.el6_0.1.src.rpm
rpm -ivh curl-7.19.7-52.el6.src.rpm
rpm -ivh httpd-2.2.15-59.el6.centos.src.rpm
rpm -ivh mysql-5.1.73-8.el6_8.src.rpm
rpm -ivh openssl-1.0.1e-57.el6.src.rpm
rpm -ivh zlib-1.2.3-29.el6.src.rpm
3. 安装redis:(redis-4.0.6.tar.gz)
mkdirredis_cluster
cdredis_cluster
tar -zxvf redis-4.0.6.tar.gz
cd redis-4.0.6
make &&make install
4. 安装ruby:
1) ruby-2.4.3.tar.gz
tar -zxvf ruby-2.4.3.tar.gz
cd ruby-2.4.3
./configure
make
make install
2) zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make
make install
进入ruby-2.4.3目录cd ruby-2.4.3
cd ext/zlib
ruby extconf.rb --with-zlib-include=/usr/local/zlib/include/--with-zlib-lib=/usr/local/zlib/lib
make && make install
注:此时会报错,方法:
vi Makefile
将文件中所有的$(top_srcdir)替换为../..
修改完成,然后保存
make && make install
3) openssl-1.0.2j.tar.gz
tar -zxvf openssl-1.0.2j.tar.gz
cd openssl-1.0.2j
./config -fPIC --prefix=/usr/local/opensslenable-shared
./config -t
make && make install
进入ruby-2.4.3目录cd ruby-2.4.3
cd ext/openssl
ruby extconf.rb --with-openssl-include=/usr/local/openssl/include/--with-openssl-lib=/usr/local/openssl/lib
make && make install
注:此时会报错,方法:
vi Makefile
将文件中所有的$(top_srcdir)替换为../..
修改完成,然后保存
make && make install
4) redis-4.0.0.gem
geminstall redis-4.0.0.gem
5. 配置redis集群
ip:
192.168.52.130
192.168.52.131
a) 192.168.52.130
cdredis_cluster
创建3个节点7000、7001、7002
mkdir7000
mkdir7001
mkdir7002
cpredis-4.0.6/redis.conf 7000
cpredis-4.0.6/redis.conf 7001
cpredis-4.0.6/redis.conf 7002
vi7000/redis.conf
vi7001/redis.conf
vi7002/redis.conf
将文件中的对应信息填好
daemonizeyes #redis后台运行
pidfile/var/run/redis_7000.pid #pidfile文件对应7000,7001,7002
port7000 #端口7000,7001,7002
cluster-enabledyes #开启集群 把注释#去掉
cluster-config-filenodes_7000.conf #集群的配置,配置文件首次启动自动生成7000,7001,7002
cluster-node-timeout5000 #请求超时,设置5秒够了
appendonlyyes #aof日志开启 有需要就开启,它会每次写操作都记录一条日志
bind192.168.52.130
修改完成,然后保存
b) 192.168.52.131
cdredis_cluster
创建3个节点7003、7004、7005
mkdir7003
mkdir7004
mkdir7005
cpredis-4.0.6/redis.conf 7003
cpredis-4.0.6/redis.conf 7004
cpredis-4.0.6/redis.conf 7005
vi7003/redis.conf
vi7004/redis.conf
vi7005/redis.conf
将文件中的对应信息填好
daemonizeyes #redis后台运行
pidfile/var/run/redis_7003.pid #pidfile文件对应7003,7004,7005
port7003 #端口7003,7004,7005
cluster-enabledyes #开启集群 把注释#去掉
cluster-config-filenodes_7003.conf #集群的配置,配置文件首次启动自动生成7003,7004,7005
cluster-node-timeout5000 #请求超时,设置5秒够了
appendonlyyes #aof日志开启 有需要就开启,它会每次写操作都记录一条日志
bind192.168.52.131
修改完成,然后保存
6. 启动redis服务
A. 192.168.52.130
cdredis_cluster
./redis-4.0.6/src/redis-server7000/redis.conf
./redis-4.0.6/src/redis-server7001/redis.conf
./redis-4.0.6/src/redis-server7002/redis.conf
B. 192.168.52.131
cdredis_cluster
./redis-4.0.6/src/redis-server7003/redis.conf
./redis-4.0.6/src/redis-server7004/redis.conf
./redis-4.0.6/src/redis-server7005/redis.conf
7. 查看redis服务
ps -ef| grep redis #查看是否启动成功
netstat-tnlp | grep redis #可以看到redis监听端口
8. 启动redis集群
cdredis_cluster
./redis-4.0.6/src/redis-trib.rbcreate --replicas 1 192.168.52.130:7000 192.168.52.130:7001 192.168.52.130:7002 192.168.52.131:7003 192.168.52.131:7004 192.168.52.131:7005
9. 登陆redis集群
cdredis_cluster
./redis-4.0.6/src/redis-cli-h 192.168.52.130 -p 7000 -c
./redis-4.0.6/src/redis-cli-h 192.168.52.130 -p 7001 -c
./redis-4.0.6/src/redis-cli-h 192.168.52.130 -p 7002 -c
./redis-4.0.6/src/redis-cli-h 192.168.52.131 -p 7003 -c
./redis-4.0.6/src/redis-cli-h 192.168.52.131 -p 7004 -c
./redis-4.0.6/src/redis-cli-h 192.168.52.131 -p 7005 -c
注:redis集群的软件包及依赖包详见:
http://download.csdn.net/download/u013473512/10202505
https://github.com/Emmitte/RedisDemo
欢迎关注“程序杂货铺”公众号,里面有精彩内容,欢迎大家收看^_^
更多推荐
所有评论(0)