下载资源:https://download.youkuaiyun.com/download/ppjsyw/39736382(0积分即可下载)
该资源包包含了windows版无需安装的版本和要安装的版本以及linux的版本
一、Widows下安装Redis
1.双击Redis-x64-5.0.14.1.msi文件,然后点击next
2.勾选复选框,然后点击Next
3.点击change
4.在想要的安装目录创一个redis文件夹,然后选择安装目录,然后点击ok
5.点击next
5.默认端口是6379,点击Next
6.点击勾选则是设置最大缓存大小,不点则不设置,然后点击Next
7.点击Install
8.安装完成
9.然后我们打开redis-cli.exe,输入ping
127.0.0.1:6379> ping
PONG
提示PONG则Redis则安装完后会自动给你启动Redis的服务。
二、linux下安装redis
下载地址:https://download.youkuaiyun.com/download/ppjsyw/46126897(无需积分即可下载)
1.将下载的文件拖入linux里面
2.使用命令行切换到指定目录并解压文件
[root@iZbp1i4wxp7w05anj3yq6tZ ~]# cd /usr/local/redis/
[root@iZbp1i4wxp7w05anj3yq6tZ redis]# tar -vcf redis-6.2.6.tar.gz
3.安装gcc环境: 因为redis是由C语言编写的,它的运行需要C环境,因此我们需要先安装gcc。安装命令如下
[root@iZbp1i4wxp7w05anj3yq6tZ redis]# yum install gcc-c++
4.进入到redis根目录下面,然后进行安装与编译
[root@iZbp1i4wxp7w05anj3yq6tZ redis]# cd redis-6.2.6 //切换到指定目录
[root@iZbp1i4wxp7w05anj3yq6tZ redis-6.2.6]# make //对解压的文件进行编译
[root@iZbp1i4wxp7w05anj3yq6tZ redis-6.2.6]# cd sr //进入到redis的src目录
[root@iZbp1i4wxp7w05anj3yq6tZ src]# make instal //对redis进行安装
5.为了方便管理,在redis-6.2.6目录下创建bin和etc两个文件夹
[root@iZbp1i4wxp7w05anj3yq6tZ redis-6.2.6]# mkdir bin //创建bin文件夹
[root@iZbp1i4wxp7w05anj3yq6tZ redis-6.2.6]# mkdir etc //创建etc文件夹
6.将redis-6.2.6目录下的 redis.conf 移动到 redis-6.2.6目录下的etc文件夹下
将mkreleasehdr.sh、redis-benchmark、redis-check-aof、redis-cli、redis-server 移动到redis-6.2.6/bin/ 目录下
[root@iZbp1i4wxp7w05anj3yq6tZ redis-6.2.6]# mv redis.conf etc //移动到etc文件夹
[root@iZbp1i4wxp7w05anj3yq6tZ redis-6.2.6]# cd src //切换到src目录
[root@iZbp1i4wxp7w05anj3yq6tZ src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-cli redis-server ../bin //移到到bin目录
7.进入到edis-6.2.6/etc/ 目录下
[root@iZbp1i4wxp7w05anj3yq6tZ src]# cd ../etc
8.编辑redis.conf文件,设置后台启动服务
[root@iZbp1i4wxp7w05anj3yq6tZ etc]# vim redis.conf
把文件中的daemonize属性改为yes(表示在后台运行)
9.编辑配置文件,设置远程访问
(1)把 redis.conf配置文件中的 bind 127.0.0.1 这一行给注释掉,这里的bind指的是只有只有指定的ip才能访问.
(2)把 redis.conf中的 protected-mode 设置成no(默认是设置成yes的, 防止了远程访问,在redis3.2.3版本后)
10.修改redis.conf的密码,redis默认是没有密码的
(1)在配置文件中找到 # requirepass foobared
(2)删除前面的# 并设置自己想要的密码
11.设置redis开启启动
[root@localhost etc]# vi /etc/rc.d/rc.local
添加如下代码到 /etc/rc.d/rc.local 中
你的redis路径/bin/redis-server 你的redis路径/etc/redis.conf
12.切换到redis下的bin目录,然后使用redis.conf来启动redis服务
[root@iZbp1i4wxp7w05anj3yq6tZ bin]# redis-server ../etc/redis.conf
至此在linux上安装redis已完成