redis集群离线安装环境搭建过程
本文是继上次redis集群重新整理的离线搭建环境,关于前期的redis集群准备工作参考我另一篇博客:
http://www.cnblogs.com/qlqwjy/p/8566573.html
由于集群搭建redis的安装环境甚是复杂,在这里新开一篇记录搭建安装环境的过程。
离线安装需要准备的软件:下载地址在文章最后贴出:
一、安装ruby运行环境
1.将ruby-2.3.7.tar.gz上传到服务器
2.解压文件
tar -zxvf ./ruby-2.3.7.tar.gz
3.编译安装
# 配置
./configure
#编译
make
#编译安装
make install
4.测试ruby运行环境
[root@iz2ze46xi6pjjj69ailg9lz ruby-2.3.7]# ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux]
二、安装redis接口
1.直接安装报错
[root@iz2ze46xi6pjjj69ailg9lz ruby-2.3.7]# gem install redis
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
2.修改gem镜像
[root@iz2ze46xi6pjjj69ailg9lz ruby-2.3.7]# gem sources -l
*** CURRENT SOURCES *** https://rubygems.org/
[root@iz2ze46xi6pjjj69ailg9lz ruby-2.3.7]# gem sources -a http://gems.ruby-china.org/
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::RemoteFetcher::Zlib
发现报错,需要安装zlib
3.安装zlib
(1)将zlib-1.2.11.tar.gz上传到服务器
(2)解压安装
mkdir zlib
tar -vxf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure --prefix=/usr/local/zlib
make
make install
(3)编译 ruby 中的zlib
进入到/opt/ruby/ruby-2.3.7/ext/zlib目录下:
[root@iz2ze46xi6pjjj69ailg9lz zlib]# ruby ./extconf.rb
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for crc32_combine() in zlib.h... yes
checking for adler32_combine() in zlib.h... yes
checking for z_crc_t in zlib.h... yes
creating Makefile
接着编译安装
make
make install
4.接着继续修改gem镜像地址安装redis接口
- 修改gem镜像
gem sources -a http://gems.ruby-china.org/
- 查看镜像
[root@iz2ze46xi6pjjj69ailg9lz ruby]# gem source -l
*** CURRENT SOURCES *** https://rubygems.org/
http://gems.ruby-china.org/
- 离线安装redis接口(前提是下载好redis-3.2.1.gem)
[root@iz2ze46xi6pjjj69ailg9lz ruby]# gem install -l redis-3.2.1.gem #安装本地的redis接口
Successfully installed redis-3.2.1
Parsing documentation for redis-3.2.1
Installing ri documentation for redis-3.2.1
Done installing documentation for redis after 1 seconds
1 gem installed
至此redis集群的环境基本算是安装完成
三、启动集群进行测试
1.将/usr/local/redis-4.0.2/src目录下的redis-trib.rb文件拷贝到/usr/local/redis/bin/目录下
[root@iz2ze46xi6pjjj69ailg9lz src]# pwd
/usr/local/redis-4.0.2/src
[root@iz2ze46xi6pjjj69ailg9lz src]# ls | grep rb
redis-trib.rb
[root@iz2ze46xi6pjjj69ailg9lz src]# cp ./redis-trib.rb /usr/local/redis/bin/redis-trib/
cp: cannot create regular file 鈥usr/local/redis/bin/redis-trib/鈥 Not a directory
[root@iz2ze46xi6pjjj69ailg9lz src]# cp ./redis-trib.rb /usr/local/redis/bin/
[root@iz2ze46xi6pjjj69ailg9lz src]# ls /usr/local/redis/bin/ | grep rb
redis-trib.rb
2.进入/usr/local/redis/bin/目录下创建集群
[root@iz2ze46xi6pjjj69ailg9lz bin]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
>>> Creating cluster
[ERR] Node 127.0.0.1:7000 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.
错误:
将集群目录下的nodes-700x.conf和appendonly-700x.aof文件删除后重启集群
...删除文件操作...
[root@iz2ze46xi6pjjj69ailg9lz redis]# cd cluster/
[root@iz2ze46xi6pjjj69ailg9lz cluster]# ls
redis7000 redis7001 redis7002 redis7003 redis7004 redis7005
[root@iz2ze46xi6pjjj69ailg9lz cluster]# cd ..
[root@iz2ze46xi6pjjj69ailg9lz redis]# ./startcluster.sh #启动6个redis
10398:C 16 Apr 20:16:33.460 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10398:C 16 Apr 20:16:33.461 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10398, just started
10398:C 16 Apr 20:16:33.461 # Configuration loaded
10400:C 16 Apr 20:16:33.481 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10400:C 16 Apr 20:16:33.481 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10400, just started
10400:C 16 Apr 20:16:33.481 # Configuration loaded
10404:C 16 Apr 20:16:33.499 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10404:C 16 Apr 20:16:33.499 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10404, just started
10404:C 16 Apr 20:16:33.499 # Configuration loaded
10412:C 16 Apr 20:16:33.514 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10412:C 16 Apr 20:16:33.514 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10412, just started
10412:C 16 Apr 20:16:33.514 # Configuration loaded
10417:C 16 Apr 20:16:33.544 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10417:C 16 Apr 20:16:33.545 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10417, just started
10417:C 16 Apr 20:16:33.545 # Configuration loaded
10419:C 16 Apr 20:16:33.565 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10419:C 16 Apr 20:16:33.565 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10419, just started
10419:C 16 Apr 20:16:33.565 # Configuration loaded
[root@iz2ze46xi6pjjj69ailg9lz redis]# ps -le | grep redis
5 S 0 10399 1 0 80 0 - 36823 ep_pol ? 00:00:00 redis-server
5 S 0 10401 1 0 80 0 - 36823 ep_pol ? 00:00:00 redis-server
5 S 0 10406 1 0 80 0 - 36823 ep_pol ? 00:00:00 redis-server
5 S 0 10413 1 0 80 0 - 36823 ep_pol ? 00:00:00 redis-server
5 S 0 10418 1 0 80 0 - 36823 ep_pol ? 00:00:00 redis-server
5 S 0 10421 1 0 80 0 - 36823 ep_pol ? 00:00:00 redis-server
[root@iz2ze46xi6pjjj69ailg9lz redis]# cd bin/
[root@iz2ze46xi6pjjj69ailg9lz bin]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 #创建集群
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7003 to 127.0.0.1:7000
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
M: 1bf9a0eed5e0add7790b09557e36842bb4c2b925 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: c7a14c5963783ae9b7cebb39eadfa4f02f4e6b6c 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: a86d777008d1e7933805a538e2d65db9a4013286 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
S: f5fdc874642c219412cb6429e45cf41652df3de9 127.0.0.1:7003
replicates 1bf9a0eed5e0add7790b09557e36842bb4c2b925
S: 710f238a33d494b4ec0c5a18208337dcd8b59c5e 127.0.0.1:7004
replicates c7a14c5963783ae9b7cebb39eadfa4f02f4e6b6c
S: 03b76c043fe6745bc49a7881b1c61c9f37f4aff3 127.0.0.1:7005
replicates a86d777008d1e7933805a538e2d65db9a4013286
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join...
>>> Performing Cluster Check (using node 127.0.0.1:7000)
M: 1bf9a0eed5e0add7790b09557e36842bb4c2b925 127.0.0.1:7000
slots:0-5460 (5461 slots) master
1 additional replica(s)
M: a86d777008d1e7933805a538e2d65db9a4013286 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
1 additional replica(s)
S: 710f238a33d494b4ec0c5a18208337dcd8b59c5e 127.0.0.1:7004
slots: (0 slots) slave
replicates c7a14c5963783ae9b7cebb39eadfa4f02f4e6b6c
S: 03b76c043fe6745bc49a7881b1c61c9f37f4aff3 127.0.0.1:7005
slots: (0 slots) slave
replicates a86d777008d1e7933805a538e2d65db9a4013286
M: c7a14c5963783ae9b7cebb39eadfa4f02f4e6b6c 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
1 additional replica(s)
S: f5fdc874642c219412cb6429e45cf41652df3de9 127.0.0.1:7003
slots: (0 slots) slave
replicates 1bf9a0eed5e0add7790b09557e36842bb4c2b925
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
3.登录集群的一个节点进行测试:
[root@iz2ze46xi6pjjj69ailg9lz bin]# ./redis-cli -c -p 7000
127.0.0.1:7000> CLUSTER NODES
a86d777008d1e7933805a538e2d65db9a4013286 127.0.0.1:7002@17002 master - 0 1523881191237 3 connected 10923-16383
710f238a33d494b4ec0c5a18208337dcd8b59c5e 127.0.0.1:7004@17004 slave c7a14c5963783ae9b7cebb39eadfa4f02f4e6b6c 0 1523881192311 5 connected
03b76c043fe6745bc49a7881b1c61c9f37f4aff3 127.0.0.1:7005@17005 slave a86d777008d1e7933805a538e2d65db9a4013286 0 1523881191000 6 connected
c7a14c5963783ae9b7cebb39eadfa4f02f4e6b6c 127.0.0.1:7001@17001 master - 0 1523881190000 2 connected 5461-10922
f5fdc874642c219412cb6429e45cf41652df3de9 127.0.0.1:7003@17003 slave 1bf9a0eed5e0add7790b09557e36842bb4c2b925 0 1523881191000 4 connected
1bf9a0eed5e0add7790b09557e36842bb4c2b925 127.0.0.1:7000@17000 myself,master - 0 1523881189000 1 connected 0-5460
127.0.0.1:7000> set test test1
-> Redirected to slot [6918] located at 127.0.0.1:7001
OK
127.0.0.1:7001> get test
"test1"
附上三个文件的下载地址:
http://qiaoliqiang.cn/fileDown/redis-3.2.1.gem
http://qiaoliqiang.cn/fileDown/ruby-2.3.7.tar.gz
http://qiaoliqiang.cn/fileDown/zlib-1.2.11.tar.gz
redis集群离线安装环境搭建过程的更多相关文章
- redis单点、redis主从、redis哨兵sentinel,redis集群cluster配置搭建与使用
目录 redis单点.redis主从.redis哨兵 sentinel,redis集群cluster配置搭建与使用 1 .redis 安装及配置 1.1 redis 单点 1.1.2 在命令窗口操作r ...
- 超详细,多图文介绍redis集群方式并搭建redis伪集群
超详细,多图文介绍redis集群方式并搭建redis伪集群 超多图文,对新手友好度极好.敲命令的过程中,难免会敲错,但为了截好一张合适的图,一旦出现一点问题,为了好的演示效果,就要从头开始敲.且看且珍 ...
- redis集群环境的搭建和错误分析
redis集群环境的搭建和错误分析 redis集群时,出现的几个异常问题 09 redis集群的搭建 以及遇到的问题
- 一文轻松搞懂redis集群原理及搭建与使用
今天早上由于zookeeper和redis集群不在同一虚拟机导致出了点很小错误(人为),所以这里总结一下redis集群的搭建以便日后所需同时也希望能对你有所帮助. 笔主这里使用的是Centos7.如果 ...
- Redis | 一文轻松搞懂redis集群原理及搭建与使用
转载:https://juejin.im/post/5ad54d76f265da23970759d3 作者:SnailClimb 这里总结一下redis集群的搭建以便日后所需同时也希望能对你有所帮助. ...
- Redis集群~windows下搭建Sentinel环境及它对主从模式的实际意义
回到目录 关于redis-sentinel出现的原因 Redis集群的主从模式有个最大的弊端,就是当主master挂了之前,它的slave从服务器无法提升为主,而在redis-sentinel出现之后 ...
- Redis 集群环境的搭建
下载与解压 [root@localhost ~]# cd /usr/temp/ [root@localhost temp]# wget http://download.redis.io/release ...
- Linux下Redis集群环境的搭建
一.安装redis(使用redis3.0版本) 1.需要gcc环境,如果没有执行命令安装gcc yum install gcc-c++ 2.下载redis3.0的源码包并上传至服务器 3.解压源码包 ...
- redis 集群方案及搭建
由于Redis出众的性能,其在众多的移动互联网企业中得到广泛的应用.Redis在3.0版本前只支持单实例模式,虽然现在的服务器内存可以到100GB.200GB的规模,但是单实例模式限制了Redis没法 ...
随机推荐
- BZOJ4887 Tjoi2017可乐(动态规划+矩阵快速幂)
设f[i][j]为第i天到达j号城市的方案数,转移显然,答案即为每天在每个点的方案数之和.矩乘一发即可. #include<iostream> #include<cstdio> ...
- [洛谷P4503][CTSC2014]企鹅QQ
题目大意:给你$n(n\leqslant3\times10^4)$个长度为$l(l\leqslant200)$的字符串,要你求出有多少对字符串是相似的,相似的定义是两个字符串只在一位上不同. 题解:可 ...
- Tajo--一个分布式数据仓库系统(分布式环境安装试用)
前面两篇介绍了一下tajo,下面就说一下安装和使用吧. 一.分布式安装 前提:hadoop2中的hdfs和yarn已经安装并运行正常. 1.下载source并build源码 $git clone ht ...
- 【JavaScript】离线应用与客户端存储
一.前言 这章非常重要,由于之后需要负责平台手机APP的日后维护,如何让用户在离线状态下正常使用,以及联网后的数据合并变得非常重要. 二.内容 离线检测 navigator ...
- CAS单点登录详细流程
一.CAS简介和整体流程 CAS 是 Yale 大学发起的一个开源项目,旨在为 Web 应用系统提供一种可靠的单点登录方法,CAS 在 2004 年 12 月正式成为 JA-SIG 的一个项目.CAS ...
- Codeforces 576D. Flights for Regular Customers(倍增floyd+bitset)
这破题调了我一天...错了一大堆细节T T 首先显然可以将边权先排序,然后逐个加进图中. 加进图后,倍增跑跑看能不能到达n,不能的话加新的边继续跑. 倍增的时候要预处理出h[i]表示转移矩阵的2^0~ ...
- dfs序七个经典问题(转)
我这个人不怎么喜欢写轻重链剖分和LCT 还是喜欢dfs序.括号序列之类的 毕竟线段树好写多了 然后就有了这篇转载的文章 写在这边以后有时间看看 原文链接:https://www.cnblogs.com ...
- LOJ #6036.「雅礼集训 2017 Day4」编码 Trie树上2-sat
记得之前做过几道2-sat裸体,以及几道2-sat前缀优化建图,这道题使用了前缀树上前缀树优化建图.我们暴力建图肯定是n^2级别的,那么我们要是想让边数少点,就得使用一些骚操作.我们观察我们的限制条件 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 折腾到死:matlab7.0 安装
matlab7.0应该是2004年的东西了吧,装起来相当费劲!为什么不用更高的版本呢?其实我也想,之前安装的2013a安装包就5个多G,安装完之后就十多个G了.我习惯将软件安装到C盘,可怜我那100G ...