2

Linux服务器快速安装Redis-6.0

 1 month ago
source link: https://www.cnblogs.com/xfishup/p/17918291.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Linux服务器快速安装Redis-6.0

最近开始体验FastGPT开源知识库问答系统,用他们试着开发调试一些小助手。这中间需要使用到Redis,就在自己服务器上进行了安装,特此记录下。
环境说明:阿里云ECS,2核8G,X86架构,CentOS 7.9操作系统。

  • 1.打开Redis官网下载页面,可以选择需要的版本下载。我这里选择的是6.2.14版本。
file
  • 2.将下载好的Redis源码包上传到服务器。
  • 1.解压上一步中已经下载的Redis源码包。
# 进入/tmp目录(大家根据自己上传的目录决定)
cd /tmp

# 解压
tar -xzvf redis-6.2.14.tar.gz
  • 2.编译和安装。
# 切到解压后的Redis目录
cd redis-6.2.14

# 编译
make

# 安装(指定安装路径)
make PREFIX=/usr/local/redis-6.2.14 install
  • 3.将源码目录中的配置文件 redis.confsentinel.conf 拷贝到Redis安装目录。
# 拷贝配置文件(目录与上文路径一致)
cp /tmp/redis-6.2.14/*.conf /usr/local/redis-6.2.14/
  • 4.安装目录下配置redis.conf(sentinel模式这里不做说明了)。
# 编辑配置文件
vi /usr/local/redis-6.2.14/redis.conf

#常见修改内容如下
## 允许连接的IP(默认允许所有地址连接)
bind * -::*
## 保护模式运行
protected-mode yes
## 运行端口
port 6379
## 后台运行
daemonize yes
## 密码(自定义密码)
requirepass password
  • 5.将Redis添加为系统服务,并设置开机自启动。
# 编辑redis.service
vi /usr/lib/systemd/system/redis.service

# 将以下内容复制粘贴到redis.service
[Unit]
Description=redis-server
After=network.target
 
[Service]
Type=forking
ExecStart=/usr/local/redis-6.2.14/bin/redis-server /usr/local/redis-6.2.14/redis.conf
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target

# 修改redis.service文件权限
chmod 755 /usr/lib/systemd/system/redis.service

# 设置开机自启动
systemctl enable redis
  • 6.启动Redis。
# 启动
systemctl start redis

# 查看运行状态
systemctl status redis

至此,全部完成


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK