编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

单节点Redis4 CentOS安装流程说明

wxchong 2024-07-07 00:00:09 开源技术 13 ℃ 0 评论

技术简介:

Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。从2010年3月15日起,Redis的开发工作由VMware主持。从2013年5月开始,Redis的开发由Pivotal赞助。redis 的作者,叫Salvatore Sanfilippo,来自意大利的西西里岛,现在居住在卡塔尼亚。目前供职于Pivotal公司。他使用的网名是antirez。

环境说明:

CentOS6.8

Java 1.7

SSH工具:XShell

安装账号: root

安装步骤:

1、安装依赖包

yum -y install ruby ruby-devel rubygems rpm-build

2、安装Redis

[root@bigdata006 redis-4.0.1]# gem install redis 
ERROR: Error installing redis: redis requires Ruby version >= 2.2.2.

如果出现ruby版本低的异常则说明先安装满足条件版本的ruby。

解决该问题,先安装rvm,再把ruby版本提升至2.3.3

2.1、安装curl命令

yum install curl

2.2、安装rvm

curl -L get.rvm.io | bash -s stable

如果报出下面的信息:

[root@bigdata006 ~]# curl -L get.rvm.io | bash -s stable

 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 24173 100 24173 0 0 12970 0 0:00:01 0:00:01 --:--:-- 54511
Downloading https://github.com/rvm/rvm/archive/1.29.7.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc
gpg: 于 2019年01月04日 星期五 06时01分48秒 CST 创建的签名,使用 RSA,钥匙号 39499BDB
gpg: 无法检查签名:No public key
GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.29.7.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:
 gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
or if it fails:
 command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
 command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
In case of further problems with validation please refer to https://rvm.io/rvm/security

则需要根据上面的提示先执行:

2.3、 设置gpg2的key

gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

再次执行:

curl -L get.rvm.io | bash -s stable

正确执行的情况下,得到下面提示信息:

[root@bigdata006 local]# curl -L get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 24173 100 24173 0 0 14731 0 0:00:01 0:00:01 --:--:-- 105k
Downloading https://github.com/rvm/rvm/archive/1.29.7.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc
gpg: 于 2019年01月04日 星期五 06时01分48秒 CST 创建的签名,使用 RSA,钥匙号 39499BDB
gpg: 完好的签名,来自于“Piotr Kuczynski <piotr.kuczynski@gmail.com>”
gpg: 警告:这把密钥未经受信任的签名认证!
gpg: 没有证据表明这个签名属于它所声称的持有者。
主钥指纹: 7D2B AF1C F37B 13E2 069D 6956 105B D0E7 3949 9BDB
GPG verified '/usr/local/rvm/archives/rvm-1.29.7.tgz'
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:
 * First you need to add all users that will be using rvm to 'rvm' group,
 and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.
 * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
 in all your open shell windows, in rare cases you need to reopen all shell windows.
 * Please do NOT forget to add your users to the rvm group.
 The installer no longer auto-adds root or users to the rvm group. Admins must do this.
 Also, please note that group memberships are ONLY evaluated at login time.
 This means that users must log out then back in before group membership takes effect!

2.4 执行提示信息中要求的操作:

source /etc/profile.d/rvm.sh

2.5 查看目前ruby的版本信息

rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.5]
[ruby-]2.5[.3]
[ruby-]2.6[.0]
ruby-head
# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby-9.1[.17.0]
jruby[-9.2.5.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.100]
rbx-head
# TruffleRuby
truffleruby[-1.0.0-rc10]
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
mruby-1.3.0
mruby-1[.4.1]
mruby-2[.0.0]
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# Topaz
topaz
# MagLev
maglev-1.0.0
maglev-1.1[RC1]
maglev[-1.2Alpha4]
maglev-head
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
ironruby-head

2.6 安装符合条件的ruby版本:

rvm install 2.3.3

正确执行情况下,得到的执行信息如下:

Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/centos/6/x86_64/ruby-2.3.3.tar.bz2
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: autoconf, automake, bison, libtool......
Requirements installation successful.
ruby-2.3.3 - #configure
ruby-2.3.3 - #download
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 21.9M 100 21.9M 0 0 45395 0 0:08:27 0:08:27 --:--:-- 249k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.3.3 - #validate archive
ruby-2.3.3 - #extract
ruby-2.3.3 - #validate binary
Libraries missing for ruby-2.3.3: libyaml-0.so.2. Refer to your system manual for installing libraries
Mounting remote ruby failed with status 10, trying to compile.
Checking requirements for centos.
Requirements installation successful.
-bash: /usr/local/rvm/scripts/functions/manage/install/centos: 没有那个文件或目录
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.3.3, this may take a while depending on your cpu(s)...
ruby-2.3.3 - #downloading ruby-2.3.3, this may take a while depending on your connection...
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 13.7M 100 13.7M 0 0 341k 0 0:00:41 0:00:41 --:--:-- 1844k
ruby-2.3.3 - #extracting ruby-2.3.3 to /usr/local/rvm/src/ruby-2.3.3.....
ruby-2.3.3 - #applying patch /usr/local/rvm/patches/ruby/ruby_2_3_gcc7.patch.
ruby-2.3.3 - #applying patch /usr/local/rvm/patches/ruby/2.3.3/random_c_using_NR_prefix.patch.
ruby-2.3.3 - #configuring..........................................................
ruby-2.3.3 - #post-configuration..
ruby-2.3.3 - #compiling.........................................................................................
ruby-2.3.3 - #installing...........................
ruby-2.3.3 - #making binaries executable..
ruby-2.3.3 - #downloading rubygems-2.7.9
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 842k 100 842k 0 0 13116 0 0:01:05 0:01:05 --:--:-- 14973
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.3.3 - #extracting rubygems-2.7.9.....
ruby-2.3.3 - #removing old rubygems........
ruby-2.3.3 - #installing rubygems-2.7.9....................................
ruby-2.3.3 - #gemset created /usr/local/rvm/gems/ruby-2.3.3@global
ruby-2.3.3 - #importing gemset /usr/local/rvm/gemsets/global.gems................................................................
ruby-2.3.3 - #generating global wrappers.......
ruby-2.3.3 - #gemset created /usr/local/rvm/gems/ruby-2.3.3
ruby-2.3.3 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.3.3 - #generating default wrappers.......
ruby-2.3.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.3.3 - #complete
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on an up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to ruby-2.6.0 which will have all of the latest security patches.
Ruby was built without documentation, to build it run: rvm docs generate-ri

2.7 选用满足条件的ruby版本:

[root@bigdata006 local]# rvm use 2.3.3
Using /usr/local/rvm/gems/ruby-2.3.3

3、安装Redis

正确执行得到的执行信息如下:

[root@bigdata006 local]# gem install redis
Fetching: redis-4.1.0.gem (100%)
Successfully installed redis-4.1.0
Parsing documentation for redis-4.1.0
Installing ri documentation for redis-4.1.0
Done installing documentation for redis after 1 seconds
1 gem installed

4、创建redis的规范目录软连接

ln -s /home/bigdata/application/redis-4.0.1 redis

5、修改redis的权限为普通用户

chown -R bigdata:bigdata redis

6、启动redis (start.sh的内容)

nohup src/redis-server conf/redis.conf >> logs/redis.log 2>&1 &

启动命令涉及指定配置文件,大家可以参考我的这种方式,能比较方便的启停和收集日志信息。 redis-server前面增加src的目的就是为了解决下面的问题,在有些时候,安装完没有把路径自动加到path中,因此需要执行详细路径。

[bigdata@bigdata006 logs]$ more redis.log
nohup: failed to run command `redis-server': No such file or directory
nohup: 无法运行命令"redis-server": 没有那个文件或目录
nohup: failed to run command `redis-server': No such file or directory

7、关闭redis(stop.sh的内容)

src/redis-cli -h 127.0.0.1 -p 16379 shutdown

注意端口号是redis.conf中配置的端口。

附录:

redis.conf 关键信息配置:

logfile "/usr/local/redis/logs/redis.log"
pidfile /usr/local/redis/run/redis.pid
port 1637
bind 0.0.0.0
save 900 1
save 300 10
save 60 10000
dbfilename dump.rdb

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表