惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
N
News and Events Feed by Topic
S
Schneier on Security
G
GRAHAM CLULEY
Scott Helme
Scott Helme
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
CERT Recently Published Vulnerability Notes
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
Cisco Talos Blog
Cisco Talos Blog
P
Privacy & Cybersecurity Law Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 司徒正美
Blog — PlanetScale
Blog — PlanetScale
Project Zero
Project Zero
MyScale Blog
MyScale Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
The Last Watchdog
The Last Watchdog
Vercel News
Vercel News
The Cloudflare Blog
C
Check Point Blog
Help Net Security
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
AWS News Blog
AWS News Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
S
Securelist
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Vulnerabilities – Threatpost
S
Secure Thoughts

Hsu Yeung 的博客

三圣花市 | Hsu Yeung 的博客 网站支持 Live Photo 图片展示 | Hsu Yeung 的博客 梦 | Hsu Yeung 的博客 周末午餐 | Hsu Yeung 的博客 张家界 | Hsu Yeung 的博客 话剧《寻她芳踪·张爱玲》 | Hsu Yeung 的博客 博客自动生成文章目录 | Hsu Yeung 的博客 灭螂行动! | Hsu Yeung 的博客 张靓颖成都演唱会 | Hsu Yeung 的博客 最近对博客做的一些微调总结 | Hsu Yeung 的博客 Windows 上安装 Lua | Hsu Yeung 的博客 网站支持展示 B 站 iframe 视频 SpringBoot 中使用 RedisTemplate 存取整数值的坑 | Hsu Yeung 的博客 SQL JOIN 中 ON 与 WHERE 的区别 值得记录的一些工作近况 | Hsu Yeung 的博客 周传雄成都演唱会 | Hsu Yeung 的博客 并行操作导致获取数据库连接超时 | Hsu Yeung 的博客 风信子 | Hsu Yeung 的博客 Linux 安装并配置 Nginx | Hsu Yeung 的博客 使用 logrotate 切割 nginx 日志 郁金香土培结果 | Hsu Yeung 的博客 MySQL LEFT JOIN 右表有多条数据但只取最新的一条 | Hsu Yeung 的博客 获取数据库锁等待超时问题 | Hsu Yeung 的博客 从零开始挑选相机 | Hsu Yeung 的博客 郁金香 | Hsu Yeung 的博客 我的第一束花 | Hsu Yeung 的博客 快乐的一周 | Hsu Yeung 的博客 重庆,来了 | Hsu Yeung 的博客 散步 | Hsu Yeung 的博客 Git 工作区、暂存区、版本库之间的关系 | Hsu Yeung 的博客 Collectors.toMap() 操作 value 为 null 的情况 AOP 记录请求参数时序列化异常问题 | Hsu Yeung 的博客 第一次参加演唱会 | Hsu Yeung 的博客 MySQL FIND_IN_SET 函数的使用 | Hsu Yeung 的博客 自动拆箱机制导致编译失败 | Hsu Yeung 的博客 最近 | Hsu Yeung 的博客 夜爬龙泉山 | Hsu Yeung 的博客 在 Windows 上安装多个版本 JDK 并切换使用的版本 安装 Windows Terminal 和 gsudo 记录 意外的奖励 | Hsu Yeung 的博客 记第一次修热水器 | Hsu Yeung 的博客 在 Windows 电脑上调试 iPhone Safari 浏览器的网页 给网站加上 RSS | Hsu Yeung 的博客 打雷了 | Hsu Yeung 的博客 豉汁蒸排骨 | Hsu Yeung 的博客 我的 2022 年 | Hsu Yeung 的博客 如何使用 Git 给代码打 tag | Hsu Yeung 的博客 记一次有趣的上班经历 | Hsu Yeung 的博客 我记得 | Hsu Yeung 的博客 Spring 新增或修改请求 header 参数 | Hsu Yeung 的博客 Spring 事务传播机制 | Hsu Yeung 的博客 在家自制“周黑鸭” | Hsu Yeung 的博客 晚餐 | Hsu Yeung 的博客 如何解决逻辑删除与数据库唯一约束冲突 | Hsu Yeung 的博客 [转]漫画赏析:Linux 内核到底长啥样 | Hsu Yeung 的博客 数据库逻辑设计之三大范式通俗理解 | Hsu Yeung 的博客 计算机中的大小端是指什么 | Hsu Yeung 的博客 MySQL 学习笔记 | Hsu Yeung 的博客 [转]《玉子市场》的人物魅力 | Hsu Yeung 的博客 Linux 安装 MySQL | Hsu Yeung 的博客 Linux 安装 JDK | Hsu Yeung 的博客 [转]Thymeleaf 表达式工具类 | Hsu Yeung 的博客 Shell 基础入门介绍 | Hsu Yeung 的博客 Linux 中的软链接和硬链接 | Hsu Yeung 的博客 MySQL 将某些字段的值排在最前或最后 | Hsu Yeung 的博客 数据结构与算法学习笔记 | Hsu Yeung 的博客 Visual Studio Code 如何编写运行 C 程序?
Linux 安装 Redis | Hsu Yeung 的博客
2021-07-15 · via Hsu Yeung 的博客

本文主要记录如何在 Linux 中安装 Redis。

环境:CentOS 7.6

Redis 版本:6.0.16

1. 下载 Redis

官网下载链接:Download|Redis

这里我们直接下载最新的稳定版就好了。往下翻是一些历史稳定版本,如果需要更旧的版本的可以在 Google Code Archive 中找到。

2. 上传并解压

先创建一个目录用于存放等会儿要上传的 Redis 文件。

cd /usr/local/env/
mkdir redis
cd redis

下载下来后使用 ftp 工具将压缩包上传到服务器的 /usr/local/env/redis/ 目录下并解压:

tar -zxvf redis-6.0.16.tar.gz

# 切换到安装目录下
cd redis-6.0.16

Redis 安装里面最主要的就是 reidis.conf 这个文件了,这个是 Redis 的配置文件。稍后我们需要使用这个配置文件。

3. 安装 Redis 需要的环境

3.1. 安装 gcc

由于 Redis 是用 C/C++ 写的,所以需要安装 gcc

# 安装 gcc 环境
yum install -y gcc-c++

# 安装完成后可以查看 gcc 版本
gcc -v

# 由于 CentOS 7 默认安装的 gcc 版本是 4.8.5
# 但是 Redis 在编译源码的时候需要 gcc
# 并且 redis-6.x 版本要求的 gcc 版本不能低于 5.3
# 所以这里我们需要升级一下 gcc 版本到 5.3 以上
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# 执行完上述命令,在 /opt/rh/ 目录下会多出来一个 devtoolset-9 的目录。
# 接着执行以下命令
# 注意 scl 命令启用只是临时的,退出 shell 或重新打开一个 shell 就会恢复原系统 gcc 版本
scl enable devtoolset-9 bash
gcc -v
# 还需要执行以下命令使这个版本的 gcc 永久生效,否则下一次使用就自动恢复为原来的版本了。
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
# 执行完此命令后,其它的 shell 窗口需要关闭重新打开才会生效。

3.2. 安装 8.6 版本的 tcl

官方的 issue:Tests: drop TCL 8.6 dependency.

总结下来就是要使用 8.6 版本的 tcl。不得不说使用新版本的东西问题就是多啊(:。

先查看下我们使用的版本是多少

tclsh
% set tcl_version

发现我们使用的版本是 8.5 低于 8.6, 所以需要升级。这里步骤也有点多,慢慢来。

3.2.1 首先卸载系统中存在的旧版本的 tcl

yum remove tcl

3.2.2. 删除完成后下载 8.6 版本的 TCL并上传到服务器。

下载地址:Download Tcl/Tk Sources

先创建个文件夹作为 TCL 的安装目录。

cd /usr/local/env/
mkdir tcl
cd tcl

上传成功后进行解压:

tar -zxvf tcl8.6.10-src.tar.gz 

3.2.3. 进入到 tcl 安装目录中的 unix 目录中

cd tcl8.6.10/unix

然后依次执行如下命令:

./configure
make
make install

接下来我们回到 Redis 的安装步骤上来。

4. 构建 Redis

构建需要使用 make 命令,该命令会根据 makefile 文件编译源代码、连接、生成目标文件、可执行文件。

make test
make
make install

5. 启动 Redis

Redis 的默认安装目录在 /usr/local/bin/ 下,执行以下命令:

cd /usr/local/bin
mkdir redisconf
cp /usr/local/env/redis/redis-6.0.16/redis.conf /usr/local/bin/redisconf/
cd ./redisconf/

6. 修改 Redis 配置

vim ./redis.conf

6.1. 设置 Redis 后台运行

daemonize nono 改为 yes 即可。

6.2. 允许远程链接 Redis

  1. bind 127.0.0.1 -::1 注释掉则不限制连接 IP,修改为指定 IP 则表示只允许固定 IP 连接。
  2. protected-mode yes 中的 yes 改为 no,否则无法远程连接。

6.3. 配置 Redis 连接密码

删除 # requirepass foobared 前面的 #,并将后面的 foobared 修改为你想要的密码即可。

7. 启动 Redis 服务

cd /usr/local/bin
# 通过指定的配置文件启动服务
./redis-server ./redisconf/redis.conf

8. 测试连接

启动 Redis 客户端

cd /usr/local/bin
./redis-cli -h localhost -p 6379
# 如果主机和端口都是默认配置的话直接使用 ./redis-cli 命令也可以启动