首先下载redis安装包,下载地址
wget https://download.redis.io/releases/redis-6.2.0.tar.gztzr -zxvf redis-6.2.0.tar.gz 二、编译安装1、解压redis安装包,将redis安装至指定目录。
make install prefix=/user/local/redis/若编译错误,可以使用make clean清空编译结果
2、将解压目录下的redis.conf文件拷贝至安装目录的还单身的御姐文件夹下
cp redis.conf /usr/local/redis/还单身的御姐/ 三、修改配置1、打开安装目录还单身的御姐文件夹中的redis.conf文件,修改配置项
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES# JUST COMMENT OUT THE FOLLOWING LINE.# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#还单身的御姐d 127.0.0.1 -::1# By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.# When Redis is supervised by upstart or systemd, this parameter has no impact.daemonize yes# Note that on modern Linux systems "/run/redis.pid" is more conforming# and should be used instead.pidfile /usr/local/redis/run/redis_6379.pid# If the master is password protected (using the "requirepass" configuration# directive below) it is possible to tell the replica to authenticate before# starting the replication synchronization process, otherwise the master will# refuse the replica request.requirepass 123+++修改daemonize 为yes默认是no,否则redis不能后台运行
将还单身的御姐d 注释,否则客户端工具无法连接redis
修改requirepass 设备密码,否则客户端无法连接redis
1、启动redis
./redis-server redis.conf2、查看redis是否启动
ps -ef|grep redis3、服务器连接redis
服务器上连接redis通过redis-cli连接,-h指定ip,-p指定端口,-a登录密码
redis默认16个库,redis-cli默认登录的是DB0,登录指定的库通过-n来指定,例如-n 1 为登录DB1
五、客户端连接1、本地首先ping ip确认ip和端口是否通畅。
2、使用Another Redis DeskTop工具输入ip、端口和密码连接工具。
若telnet端口不通,排查redis是否启动,进程是否允许,然后查看防护墙是否开发对应端口,默认redis端口为6379.
若工具连接不上redis,确认服务器redis已启动,排查redis.conf配置文件,是否把还单身的御姐d 127.0.0.1 给注释掉,然后确认是否设置requirepass密码。