目录
下载redis
指令:wget http://download.redis.io/releases/redis-6.0.8.tar.gz
如下👇:
解压:tar xzf redis-6.0.8.tar.gz
如下👇:
进入解压的文件夹中:cd redis-6.0.8
如下👇:
读取一下:make
如下👇:
测试是否已经将源码安装
cd src
./redis-server
如下👇:
到这里就不需要动了
进入本机链接虚拟机终端
连接虚拟机
输入指令👇:
cd src
(服务端): ./redis-cli
redis> set foo bar
redis> get foo
如下👇:
将redis作为服务安装到系统中(提取安装环境分离源码)
cd /redis/redis-6.0.8/src/ //进入src
make install PREFIX=/opt/redis --- 安装到/opt/redis目录
如下👇:
配置环境变量
进入cd然后在cd ~ 输入:vim /etc/profile 添加
export REDIS_HOME=/opt/redis
export PATH=$PATH:$REDIS_HOME/bin
如下👇:
然后刷新环境变量:source /etc/profile
在系统中安装redis
[root@localhost utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server
This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
------------------------------------------出现上述问题,将如下内容注释掉即可------------------------------------------
#bail if this system is managed by systemd
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
进入vim /install_server.sh注释71行到83行
如下👇:
配置完成后再次安装服务
[root@localhost utils]# ./install_server.sh 一直回车即可
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] ---端口号
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] ----配置文件
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] ----日志文件
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] -----数据文件
Selected default - /var/lib/redis/6379
Please select the redis executable path [/opt/redis/bin/redis-server] -----服务安装路径(根据配置好得path得来的)
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /opt/redis/bin/redis-server
Cli Executable : /opt/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort. ----提示回车表示同意执行 Ctrl-C取消
Copied /tmp/6379.conf => /etc/init.d/redis_6379 ----可执行文件得位置
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
/var/run/redis_6379.pid exists, process is already running or crashed
Installation successful!
测试是否可以执行 redis的执行文件
[root@localhost /]# service redis_6379 status
Redis is not running