阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7.2中Redis的下载安装

432次阅读
没有评论

共计 7769 个字符,预计需要花费 20 分钟才能阅读完成。

  • CentOS Linux release 7.2.1511 (Core)
  • redis-3.2.8.tar.gz

1. 下载(Download)、解压(extract)、完整性检查(How to verify files for integrity)

Redis uses a standard practice for its versioning: major.minor.patchlevel. Redis 使用标准做法进行版本控制:主版本号. 次版本号. 修订版本号 

An even minor marks a stable release, like 1.2, 2.0, 2.2, 2.4, 2.6, 2.8. 偶数次版本号表示一个稳定的发行版,如 1.2,2.0,2.2,2.4,2.6,2.8。

Odd minors are used for unstable releases, for example 2.9.x releases are the unstable versions of what will be Redis 3.0 once stable. 奇数次版本号被用于表示不稳定版本,例如 2.9.x 版本是不稳定版本,一旦稳定就是 3.0

完整性:与 redis-hashes 对照

$ wget 
$ sha1sum redis-3.2.8.tar.gz6780d1abb66f33a97aad0edbe020403d0a15b67f  redis-3.2.8.tar.gz
$ tar zxvf  redis-3.2.8.tar.gz
$ cd redis-3.2.8

2. 编译(compile)、安装(Installing)

In order to install Redis binaries into /usr/local/bin just use:

% make install

You can use make PREFIX=/some/other/directory install if you wish to use a different destination. 如果你想安装二进制命令到不同的目录

Make install will just install binaries in your system, but will not configure init scripts and configuration files in the appropriate place. This is not needed if you want just to play a bit with Redis, but if you are installing it the proper way for a production system, we have a script doing this for Ubuntu and Debian systems:

Make install 在系统中只会安装二进制文件,但不会在适当的位置配置 init 脚本和配置文件。如果你只想玩一点 Redis,这不是必需的。但如果你正在为生产系统安装它找一个更合适的方式,针对 Ubuntu 和 Debian 系统,我们有一个脚本做这些:

% cd utils
% ./install_server.sh

The script will ask you a few questions and will setup everything you need to run Redis properly as a background daemon that will start again on system reboots.

You’ll be able to stop and start Redis using the script named /etc/init.d/redis_<portnumber>

for instance /etc/init.d/redis_6379.

# cd redis-3.2.8
# make PREFIX=/usr/local/redis install

Hint: It's a good idea to run'make test' ;)
# make test...
...

\o/ All tests passed without errors!

Cleanup: may take some time... OK

# mkdir -pv /usr/local/redis/{etc,log,lib}mkdir: created directory‘/usr/local/redis/etc’mkdir: created directory‘/usr/local/redis/log’# cd utils
# ./install_server.shWelcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/redis/etc/6379.confPlease select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/log/redis_6379.logPlease select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/lib/6379
Please select the redis executable path [] /usr/local/redis/bin/redis-server
Selected config:
Port           : 6379
Config file    : /usr/local/redis/etc/6379.conf
Log file       : /usr/local/redis/log/redis_6379.log
Data dir       : /usr/local/redis/lib/6379
Executable     : /usr/local/redis/bin/redis-server
Cli Executable : /usr/local/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

# ps aux | grep redis
root      58811  0.2  0.1 136912  7524 ?        Ssl  18:31   0:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379


# The binaries that are now compiled are available in the src directory. 
现在被编译的二进制文件在 src 目录中。# cd src/
# md5sum redis*
3c507af948c7bc80cb92c66a5ed17bc1  redisassert.h
d7fcdd079f9fb025e5e380603dfecf4b  redis-benchmark
4230b5d20e23fc25411d99cc56429692  redis-benchmark.c
fd9d73aeb32a609957b77edb83e82fa9  redis-benchmark.o
d575a6cc0bc896a722a4d70cbe1352c2  redis-check-aof
991bf6ef06e1fc4d0a66a48c1505e498  redis-check-aof.c
2bdfdbbb16ec9c227128d6c239a5706c  redis-check-aof.o
1e3f0c6d96b88dcdca1b4d35d169b52f  redis-check-rdb
34cbd2a2be9ecf8ab21e65ca9095cc67  redis-check-rdb.c
3068ffe1e036d12b8df0d9f28290f972  redis-check-rdb.o
4e45e24376159a1121a54e9e5eee3f2f  redis-cli
2a2af684a4e598d024f1c606a5c7913e  redis-cli.c
9494101d9b9c68866ec95f8921574dcf  redis-cli.o
1e3f0c6d96b88dcdca1b4d35d169b52f  redis-sentinel  * 二者相同
1e3f0c6d96b88dcdca1b4d35d169b52f  redis-server    *
70b2284c8833a8773e26abe6ba7797c3  redis-trib.rb

# tree /usr/local/redis/
/usr/local/redis/
├── bin
│   ├── redis-benchmark
│   ├── redis-check-aof
│   ├── redis-check-rdb
│   ├── redis-cli│   
|   ├── redis-sentinel -> redis-server  # 两者相同
│   └── redis-server
├── etc
│   └── 6379.conf
├── lib
└── log

3. 修改 SysV 服务脚本

# cat /etc/init.d/redis_6379 #!/bin/sh#Configurations injected by install_server below....EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis_6379.pid
CONF="/usr/local/redis/etc/6379.conf"
REDISPORT="6379"
################ SysV Init Information
# chkconfig: - 30 50
# description: redis_6379 is the redis daemon.
### BEGIN INIT INFO
# Provides: redis_6379
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5# Default-Stop: 0 1 6
# Should-Start: $syslog $named# Should-Stop: $syslog $named
# Short-Description: start and stop redis_6379
# Description: Redis daemon
### END INIT INFO
case "$1" in
    start)        
        if [-f $PIDFILE]        
        then
            echo "$PIDFILE exists, process is already running or crashed"
        else
            echo "Starting Redis server..."
            $EXEC $CONF
        fi
        ;;
    stop)        
        if [! -f $PIDFILE]        
        then
            echo "$PIDFILE does not exist, process is not running"
        else
            PID=$(cat $PIDFILE)            
            echo "Stopping ..."
            $CLIEXEC -p $REDISPORT shutdown            
            while [-x /proc/${PID} ]            
            do
                echo "Waiting for Redis to shutdown ..."
                sleep 1
            done
            echo "Redis stopped"
        fi
        ;;
    status)
        PID=$(cat $PIDFILE 2> /dev/null)  # 原为 PID=$(cat $PIDFILE) stop 之后,文件不存在,抛出异常
        if [-z ${PID} ]  # 原为 if [! -x /proc/${PID} ] PID 即使为空,但 /proc 仍然存在,最后还是会回到 running 状态
        then
            echo 'Redis is not running'
        else
            echo "Redis is running ($PID)"
        fi
        ;;
    restart)        $0 stop        $0 start
        ;;
    *)        echo "Please use start, stop, restart or status as first argument"
        ;;esac

4. 连接测试

# redis-cli -h localhost -p 6379
localhost:6379> ping
PONG
localhost:6379> set foo bar
OK
localhost:6379> get foo"bar"
localhost:6379> ping 'zcy'
"zcy"

5. 关闭服务

# netstat -tlnp | grep 6379 127.0.0.1:6379          0.0.0.0:*               LISTEN      67387/redis-server  
# pkill -u root redis   # 方法 1
# netstat -tlnp | grep 6379
# service redis_6379 statusRedis is not running
# service redis_6379 stoppid does not exist, process is not running
# service redis_6379 startStarting Redis server...
# redis-cli -h localhost -p 6379 get foo"bar"
# redis-cli -h localhost -p 6379 shutdown   #方法 2:服务脚本用的是这一种。# service redis_6379 statusRedis is not running
#无论哪种方式关闭服务,都会产生如下日志 71428:M 25 Feb 22:06:09.131 
# User requested shutdown...  关闭用户的请求
71428:M 25 Feb 22:06:09.131 
* Saving the final RDB snapshot before exiting. 在关闭之前保存最后的 RDB 快照
71428:M 25 Feb 22:06:09.142 
* DB saved on disk  DB 保存到磁盘上
71428:M 25 Feb 22:06:09.142 
* Removing the pid file.   移除 PID 文件
71428:M 25 Feb 22:06:09.142 
# Redis is now ready to exit, bye bye.. pkill ,kill 默认发送信号 15 SINTERM
产生日志:67387:signal-handler (1488031433) Received SIGTERM scheduling shutdown... 接收到终止信号安排关闭...

下面关于 Redis 的文章您也可能喜欢,不妨参考下:

Ubuntu 14.04 下 Redis 安装及简单测试 http://www.linuxidc.com/Linux/2014-05/101544.htm

Redis 主从复制基本配置 http://www.linuxidc.com/Linux/2015-03/115610.htm

CentOS 7 下 Redis 的安装与配置 http://www.linuxidc.com/Linux/2017-02/140363.htm

Ubuntu 14.04 安装 Redis 与简单配置 http://www.linuxidc.com/Linux/2017-01/139075.htm

Ubuntu 16.04 环境中安装 PHP7.0 Redis 扩展 http://www.linuxidc.com/Linux/2016-09/135631.htm

CentOS 7.0 安装 Redis 3.2.1 详细过程和使用常见问题 http://www.linuxidc.com/Linux/2016-09/135071.htm

Ubuntu 16.04 环境中安装 PHP7.0 Redis 扩展 http://www.linuxidc.com/Linux/2016-09/135631.htm

Ubuntu 15.10 下 Redis 集群部署文档 http://www.linuxidc.com/Linux/2016-06/132340.htm

Redis 实战 中文 PDF http://www.linuxidc.com/Linux/2016-04/129932.htm

Redis 热迁移实战总结  http://www.linuxidc.com/Linux/2017-02/141083.htm

Redis3.0 配置文件详解  http://www.linuxidc.com/Linux/2017-03/141369.htm

Redis 的详细介绍:请点这里
Redis 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-03/141395.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计7769字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19348
评论数
4
阅读量
7789996
文章搜索
热门文章
开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南

开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南

开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南 大家好,我是星哥。之前介绍了腾讯云的 Code...
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
云服务器部署服务器面板1Panel:小白轻松构建Web服务与面板加固指南

云服务器部署服务器面板1Panel:小白轻松构建Web服务与面板加固指南

云服务器部署服务器面板 1Panel:小白轻松构建 Web 服务与面板加固指南 哈喽,我是星哥,经常有人问我不...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
颠覆 AI 开发效率!开源工具一站式管控 30+大模型ApiKey,秘钥付费+负载均衡全搞定

颠覆 AI 开发效率!开源工具一站式管控 30+大模型ApiKey,秘钥付费+负载均衡全搞定

  颠覆 AI 开发效率!开源工具一站式管控 30+ 大模型 ApiKey,秘钥付费 + 负载均衡全...
2025年11月28日-Cloudflare史诗级事故:一次配置失误,引爆全球宕机

2025年11月28日-Cloudflare史诗级事故:一次配置失误,引爆全球宕机

2025 年 11 月 28 日 -Cloudflare 史诗级事故: 一次配置失误,引爆全球宕机 前言 继今...
终于收到了以女儿为原型打印的3D玩偶了

终于收到了以女儿为原型打印的3D玩偶了

终于收到了以女儿为原型打印的 3D 玩偶了 前些日子参加某网站活动,获得一次实物 3D 打印的机会,于是从众多...
星哥带你玩飞牛NAS-1:安装飞牛NAS

星哥带你玩飞牛NAS-1:安装飞牛NAS

星哥带你玩飞牛 NAS-1:安装飞牛 NAS 前言 在家庭和小型工作室场景中,NAS(Network Atta...
Python自学26 – Cookie和Session

Python自学26 – Cookie和Session

Python 自学 26 – Cookie 和 Session 在学习 Web 开发时,Cooki...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
安装并使用谷歌AI编程工具Antigravity(亲测有效)

安装并使用谷歌AI编程工具Antigravity(亲测有效)

  安装并使用谷歌 AI 编程工具 Antigravity(亲测有效) 引言 Antigravity...
星哥带你玩飞牛NAS-7:手把手教你免费内网穿透-Cloudflare tunnel

星哥带你玩飞牛NAS-7:手把手教你免费内网穿透-Cloudflare tunnel

星哥带你玩飞牛 NAS-7:手把手教你免费内网穿透 -Cloudflare tunnel 前言 大家好,我是星...
星哥带你玩飞牛NAS-4:飞牛NAS安装istore旁路由,家庭网络升级的最佳实践

星哥带你玩飞牛NAS-4:飞牛NAS安装istore旁路由,家庭网络升级的最佳实践

星哥带你玩飞牛 NAS-4:飞牛 NAS 安装 istore 旁路由,家庭网络升级的最佳实践 开始 大家好我是...
零成本上线!用 Hugging Face免费服务器+Docker 快速部署HertzBeat 监控平台

零成本上线!用 Hugging Face免费服务器+Docker 快速部署HertzBeat 监控平台

零成本上线!用 Hugging Face 免费服务器 +Docker 快速部署 HertzBeat 监控平台 ...
三大开源投屏神器横评:QtScrcpy、scrcpy、escrcpy 谁才是跨平台控制 Android 的最优解?

三大开源投屏神器横评:QtScrcpy、scrcpy、escrcpy 谁才是跨平台控制 Android 的最优解?

  三大开源投屏神器横评:QtScrcpy、scrcpy、escrcpy 谁才是跨平台控制 Andr...