Redis服务器是一种非关系型数据存储服务器,它经常和Linux系统搭配使用。那么如何在Linux系统中安装Redis服务器呢?下面我给大家分享一下。
工具/材料Linux命令行
01首先我们运用tar命令解压redis安装包,如下图所示,这里在使用tar命令的时候运用的是zxvf参数
02接下来进入解压后的文件夹我们执行make命令,对redis进行编译,如下图所示
03编译完了以后我们通过cd命令进入src目录,然后执行make install进行安装,如下图所示
04安装完了以后我们需要创建两个文件夹,如下图所示,etc用来放置配置文件,bin用来放置执行文件
05接下来我们通过cp命令将redis.conf配置文件复制到etc目录下面,如下图所示
06然后将src目录下的命令复制到bin目录下面,这里我只复制了几个比较常用的,如下图所示
07接下来我们就可以执行redis-server命令来运行redis服务器了,注意后面加了配置文件路径,如下图所示
08最后当我们看到如下图所示的界面则代表redis安装启动成功,后面我们就可以用它进行数据存储了
一:问题如下
[sql] view plain copy
在192.168.56.57客户端登录192.168.56.56的redis服务器时,报错如下:
[root@localhost src]# ./redis-cli -h 192.168.56.56 -p 6379 -a"aabbcc"
192.168.56.56:6379> ping
Error:Connection reset by peer
再telnet一下192.168.56.56的redis服务器的6379端口,提示redis服务有保护模式,需要解除
[root@localhost src]# telnet 192.168.56.56 6379
Trying 192.168.56.56...
Connectedto 192.168.56.56.
Escape character is '^]'.
DENIED Redisis running in protected modebecause protected mode is enabled, no bind address was specified, noauthentication password is requested to clients.
In this mode connections areonly accepted from the loopback interface. If you want to connect from externalcomputers to Redis you may adopt one of the following
solutions: 1) Justdisable protected mode sending the command'CONFIG SET protected-mode no' fromthe loopback interface by connecting to Redis from the same host
the server isrunning, however MAKE SURE Redisis not publicly accessible from internet ifyou do so. Use CONFIG REWRITE to make this change permanent.
2) Alternativelyyou can just disable the protected modeby editing the Redis configurationfile, and setting the protected mode option to 'no', and then restarting theserver.
3) If you started the server manually justfor testing, restart it withthe '--protected-mode no' option.
4) Setup a bind addressor an authenticationpassword. NOTE: You only need to do one of the above things in order for theserver to start accepting connections from the outside.
Connection closed by foreign host.
二:解决方案
[sql] view plain copy
1、修改redis服务器的配置文件
vi redis.conf
注释以下绑定的主机地址
# bind 127.0.0.1
2、修改redis服务器的参数配置
修改redis的守护进程为no ,不启用
127.0.0.1:6379> configset daemonize "no"
OK
修改redis的保护模式为no,不启用
127.0.0.1:6379> configset protected-mode "no"
OK
三:问题解决
[sql] view plain copy
再次telnet一下192.168.56.56的redis服务器的6379端口,无问题
[root@localhost Packages]# telnet 192.168.56.56 6379
Trying 192.168.56.56...
Connectedto 192.168.56.56.
Escape character is '^]'.
再次在192.168.56.57客户端登录192.168.56.56的redis服务器,无问题
[root@localhost src]# ./redis-cli -h 192.168.56.56 -p 6379 -a"aabbcc"
192.168.56.56:6379> ping
PONG
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)