Linux安装Redis

Posted pannijingling

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux安装Redis相关的知识,希望对你有一定的参考价值。

1. 环境配置

1.1 Redis下载

1.2 C语言环境安装

2. 安装Redis

2.1 上传Redis

进入 redis-6.2.5 目录

[root@localhost opt]# cd redis-6.2.5

查看 redis/redis-6.2.5/ 目录信息

[root@localhost redis-6.2.5]# ls

![图片.png](https://s2.51cto.com/images/20210813/1628818757771748.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
![图片.png](https://s2.51cto.com/images/20210814/1628915973441849.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)

### 2.2 安装
> 1. 编译
```shell
# 编译
[root@localhost redis-6.2.5]# make
# 再次输入make命令检查
[root@localhost redis-6.2.5]# make



2.3 自定义配置

2.3.1 将Redis作为守护进程运行(后台运行)

2.3.2 允许Redis远程连接

2.3.3 过期事件通知发送

2.3.4 设置连接密码

3. 连接Redis

4 设置开启启动

[root@localhost redis6_01]# vi /etc/rc.d/rc.local

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run \'chmod +x /etc/rc.d/rc.local\' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local

# redis开机启动
/opt/redis/redis6_01/bin/redis-server /opt/redis/redis6_01/redis.conf
# 查看文件默认权限
[root@localhost nginx_01]# ll /etc/rc.d/rc.local
# 给文件赋予执行权限
[root@localhost nginx_01]# chmod +x /etc/rc.d/rc.local
# 查看修改文件权限是否生效
[root@localhost nginx_01]# ll /etc/rc.d/rc.local

5 删除加压缩文件

以上是关于Linux安装Redis的主要内容,如果未能解决你的问题,请参考以下文章

linux安装好redis,怎么启动?

02 Redis 菜鸟到高手 | Linux 平台安装 Redis

redis数据库在linux上的学习

linux下安装与配置Redis

Linux下安装Redis

Linux下Redis 的安装