【Linux】Linux安装redis(操作步骤)

目录

下载redis

 测试是否已经将源码安装

 将redis作为服务安装到系统中(提取安装环境分离源码)

 配置环境变量

在系统中安装redis


下载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

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

白鱼塘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值