Redis——Redis安装
1. Linux 源码安装Redis
1.1 复制官网Redis下载链接
1.2 Ubuntu安装 wget
安装命令:
sudo apt-get install wget
1.3 wget
下载
通过 wget
使用官网的下载链接下载redis 或者使用github链接Releases · redis/redis (github.com)
官网链接下载
wget https://download.redis.io/releases/redis-6.2.5.tar.gz
github链接下载 多试几次
wget https://github.com/redis/redis/archive/refs/tags/6.2.5.tar.gz
1.4 解压
tar xf filename
1.5 make
进入解压后的目录,使用 make
命令编译(可能需要安装gcc,根据提示安装即可)
**注意:**如果make 失败 使用 make distclean 命令清理编译,再次使用 make 命令编译
root@Voryla:/soft/redis-6.2.5# make
1.6 使用redis脚本 将其安装到某个目录中
root@Voryla:/soft/redis-6.2.5# make install PREFIX=/opt/voryla/redis6
1.7 配置环境变量
编辑 /etc/profile
文件
root@Voryla:/opt/voryla/redis6/bin# vi /etc/profile
添加
export REDIS_HOME=/opt/voryla/redis6
export PATH=$PATH:$REDIS_HOME/bin
1.8 加载配置文件
root@Voryla:/opt/voryla/redis6/bin# source /etc/profile
root@Voryla:/opt/voryla/redis6/bin# echo $PATH
1.9 安装服务
进入 redis 的解压目录
root@Voryla:/# cd /soft/redis-6.2.5/utils/
执行目录下的 install_server.sh 脚本
root@Voryla:/soft/redis-6.2.5/utils# ./install_server.sh
以下是配置redis 服务,redis可以配置多个,只要不是同一端口即可
Welcome 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] 6380 //选择端口 默认为6379
Please select the redis config file name [/etc/redis/6380.conf] //选择配置文件目录
Selected default - /etc/redis/6380.conf
Please select the redis log file name [/var/log/redis_6380.log] // 选择日志文件目录
Selected default - /var/log/redis_6380.log
Please select the data directory for this instance [/var/lib/redis/6380] // 选择数据文件目录 持久化目录
Selected default - /var/lib/redis/6380
Please select the redis executable path [] /opt/voryla/redis6/bin/redis-server //选择可执行文件目录,即redis的安装目录
Selected config:
Port : 6380
Config file : /etc/redis/6380.conf
Log file : /var/log/redis_6380.log
Data dir : /var/lib/redis/6380
Executable : /opt/voryla/redis6/bin/redis-server
Cli Executable : /opt/voryla/redis6/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6380.conf => /etc/init.d/redis_6380
Installing service...
Success!
Starting Redis server...
Installation successful!
进入安装目录启动服务
./redis-server /etc/redis/6380.conf
1.10 连接端口
root@Voryla:/opt/voryla/redis6/bin# redis-cli -p 6380