您的位置:首页 > 数据库 > Redis

Linux CentOS6下安装Ruby和RubyGems和OpenSSL和Zlib-devel 为了Redis 集群

2018-03-12 21:44 477 查看
安装Ruby:
到Ruby官网:https://www.ruby-lang.org/en/downloads/
找到最新版本的Ruby



进入linux,选择一个位置存放安装包,我的位置是/opt/soft
[root@localhost soft]# pwd

/opt/soft
输入命令wget + 刚刚复制的安装包URL
[root@localhost soft]# wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.gz 我安装的是2.2.7,解压缩:
[root@localhost soft]# tar zxf ruby-2.2.7.tar.gz

进入解压缩完成后的文件夹,执行命令:
[root@localhost ruby-2.2.7]# ./configure --prefix=/usr/local/ruby-2.2.7
[root@localhost ruby-2.2.7]# make && make install
[root@localhost ruby-2.2.7]# ln -s /usr/local/ruby-2.2.7 /bin/ruby /usr/bin/ruby

执行ruby -v可查看版本
[root@localhost 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... no
creating Makefile
[root@localhost zlib]# pwd

/opt/soft/ruby-2.2.7/ext/zlib
[root@localhost zlib]# make
compiling zlib.c
linking shared-object zlib.so
[root@localhost zlib]# make install
/usr/bin/install -c -m 0755 zlib.so /usr/local/ruby-2.2.7/lib/ruby/site_ruby/2.2.0/x86_64-linux
[root@localhost zlib]# 

安装RubyGems:
到官网 https://rubygems.org/pages/download


wget + URL,在线下载安装包:
[root@localhost soft]# wget https://rubygems.org/rubygems/rubygems-2.7.6.tgz --2018-03-13 05:37:49--  https://rubygems.org/rubygems/rubygems-2.7.6.tgz Resolving rubygems.org... 151.101.194.2, 151.101.66.2, 151.101.130.2, ...
Connecting to rubygems.org|151.101.194.2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 852486 (833K) [application/x-tar]
Saving to: ârubygems-2.7.6.tgzâ

100%[======================================>] 852,486     1.86M/s   in 0.4s 
解压缩:
[root@localhost soft]# tar xzf rubygems-2.7.6.tgz 

进入解压后的文件夹,执行命令:
[root@localhost soft]# cd rubygems-2.7.6
[root@localhost rubygems-2.7.6]# ruby setup.rb
setup.rb:27: warning: Insecure world writable dir /opt/soft in PATH, mode 040777
Bundler 1.16.1 installed
RubyGems 2.7.6 installed
Regenerating binstubs
Parsing documentation for rubygems-2.7.6
Installing ri documentation for rubygems-2.7.6
。。。。。。。。。。。。。。。。
RubyGems installed the following executables:
        /usr/local/ruby-2.2.7/bin/gem
        /usr/local/ruby-2.2.7/bin/bundle

[root@localhost rubygems-2.7.6]# 

[root@localhost rubygems-2.7.6]# ln -s /opt/soft/rubygems-2.7.6/bin/gem /usr/bin/gem
[root@localhost bin]# gem -v
2.7.6

安装OpenSSL:
官网: https://www.openssl.org/source/



Wget 下载安装包:
[root@localhost soft]# wget https://www.openssl.org/source/openssl-1.1.1-pre2.tar.gz
[root@localhost soft]# tar xzf openssl-1.1.1-pre2.tar.gz

[root@localhost soft]# cd openssl-1.1.1-pre2

[root@localhost openssl-1.1.1-pre2]# ./config --prefix=/usr/local/openssl --shared

[root@localhost openssl-1.1.1-pre2]# make

[root@localhost openssl-1.1.1-pre2]# make install

[root@localhost openssl-1.1.1-pre2]# cd /usr/local

[root@localhost local]# ls -s openssl ssl

[root@localhost local]# cd /etc/
添加黄色的哪一行代码
[root@localhost etc]# vi ld.so.conf 
include ld.so.conf.d/*.conf
/usr/local/openssl/lib
在文件最后添加黄色代码:
[root@localhost etc]# vi profile

unset i
unset -f pathmunge
export OPENSSL=/usr/local/openssl/bin
export PATH=$OPENSSL:$PATH:$HOME/bin

ldconfig
执行exec bash --login是更改生效。

[root@localhost etc]# exec bash --login
执行命令后看到下面黄色的输出就对了
[root@localhost etc]# echo $OPENSSL
/usr/local/openssl/bin
[root@localhost etc]# 

安装Zlib-devel:https://pkgs.org/download/zlib-devel
官网:





Wget下载:
[root@localhost soft]# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/zlib-devel-1.2.3-29.el6.x86_64.rpm --2018-03-13 06:44:35--  http://mirror.centos.org/centos/6/os/x86_64/Packages/zlib-devel-1.2.3-29.el6.x86_64.rpm Resolving mirror.centos.org... 213.184.126.230, 2605:9000:401:102::2
Connecting to mirror.centos.org|213.184.126.230|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44984 (44K) [application/x-rpm]
Saving to: âzlib-devel-1.2.3-29.el6.x86_64.rpmâ

100%[======================================>] 44,984      60.7K/s   in 0.7s    

2018-03-13 06:44:37 (60.7 KB/s) - âzlib-devel-1.2.3-29.el6.x86_64.rpmâsaved [44984/44984]

[root@localhost soft]# rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:zlib-devel             ########################################### [100%]

[root@localhost soft]# 

Redis集群:
[root@localhost redis-4.0.8]# gem install -l ./redis-4.0.1.gem
Successfully installed redis-4.0.1
Parsing documentation for redis-4.0.1
Installing ri documentation for redis-4.0.1
Done installing documentation for redis after 0 seconds

1 gem installed
[root@localhost redis-4.0.8]# cd src
[root@localhost src]# ./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:7004 to 127.0.0.1:7000
Adding replica 127.0.0.1:7005 to 127.0.0.1:7001
Adding replica 127.0.0.1:7003 to 127.0.0.1:7002
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 5a1169efa3c317686fb0dafa89e05b8bc34f0ac4 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
M: d7edc9bbb22f9c91dd8560eda6369c23dc6e7fdf 127
4000
.0.0.1:7001
   slots:5461-10922 (5462 slots) master
M: 1d07d860749940c3061ab7465244999c0e0dff0a 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
S: f9289b484ba197e0cf93c348323a5d029f334649 127.0.0.1:7003
   replicates 5a1169efa3c317686fb0dafa89e05b8bc34f0ac4
S: 42a7c77d2b9b8d13178aafce8b3e5169eb7286ca 127.0.0.1:7004
   replicates d7edc9bbb22f9c91dd8560eda6369c23dc6e7fdf
S: 93d5cb94094a860e369f04d74bc6bf635e47d57c 127.0.0.1:7005
   replicates 1d07d860749940c3061ab7465244999c0e0dff0a
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: 5a1169efa3c317686fb0dafa89e05b8bc34f0ac4 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 42a7c77d2b9b8d13178aafce8b3e5169eb7286ca 127.0.0.1:7004
   slots: (0 slots) slave
   replicates d7edc9bbb22f9c91dd8560eda6369c23dc6e7fdf
M: 1d07d860749940c3061ab7465244999c0e0dff0a 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: f9289b484ba197e0cf93c348323a5d029f334649 127.0.0.1:7003
   slots: (0 slots) slave
   replicates 5a1169efa3c317686fb0dafa89e05b8bc34f0ac4
S: 93d5cb94094a860e369f04d74bc6bf635e47d57c 127.0.0.1:7005
   slots: (0 slots) slave
   replicates 1d07d860749940c3061ab7465244999c0e0dff0a
M: d7edc9bbb22f9c91dd8560eda6369c23dc6e7fdf 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

[root@localhost src]# 
参数”--replicas 1”表示每个主节点需要一个从节点(replicas前面是两个减号)

上面黄色部分,表示16384个slots都被分配给了3个Master
[OK] All 16384 slots covered.表示集群配置成功运行正常。
测试:
[root@localhost src]# redis-cli -c -p 7000
127.0.0.1:7000> set cluster70001 7000success1
-> Redirected to slot [10982] located at 127.0.0.1:7002
OK
127.0.0.1:7002> set cluster70002 7000success2
-> Redirected to slot [6789] located at 127.0.0.1:7001
OK
127.0.0.1:7001> set cluster70003 7000success3
-> Redirected to slot [2724] located at 127.0.0.1:7000
OK
127.0.0.1:7000> set cluster70004 7000success4
-> Redirected to slot [14915] located at 127.0.0.1:7002
OK
127.0.0.1:7002> set cluster70005 7000success5
-> Redirected to slot [10850] located at 127.0.0.1:7001
OK
127.0.0.1:7001> set cluster70006 7000success6
OK
127.0.0.1:7001> set cluster70007 7000success7
-> Redirected to slot [2592] located at 127.0.0.1:7000
OK
127.0.0.1:7000> set cluster70008 7000success8
-> Redirected to slot [15311] located at 127.0.0.1:7002
OK
127.0.0.1:7002> set cluster70009 7000success9
OK
127.0.0.1:7002> get cluster70001
"7000success1"
127.0.0.1:7002> get cluster70002
-> Redirected to slot [6789] located at 127.0.0.1:7001
"7000success2"
127.0.0.1:7001> get cluster70003
-> Redirected to slot [2724] located at 127.0.0.1:7000
"7000success3"
127.0.0.1:7000> get cluster70004
-> Redirected to slot [14915] located at 127.0.0.1:7002
"7000success4"
127.0.0.1:7002> get cluster70005
-> Redirected to slot [10850] located at 127.0.0.1:7001
"7000success5"
127.0.0.1:7001> get cluster70006
"7000success6"
127.0.0.1:7001> get cluster70007
-> Redirected to slot [2592] located at 127.0.0.1:7000
"7000success7"
127.0.0.1:7000> get cluster70008
-> Redirected to slot [15311] located at 127.0.0.1:7002
"7000success8"
127.0.0.1:7002> get cluster70009
"7000success9"
127.0.0.1:7002> 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: