linux下redis安装 及常用命令

安装及常用命令

redis的yum方式安装

  1. 先查看是否已经安装redis执行命令 
    rpm -qa | grep redis
  2. 如果存在,将存在的卸载:(-y 代表自动选择)
    yum remove xxx -y
  3. 在线安装redis
    yum install redis
  4. 安装本地已经下载好的redis安装包
    yum localinstall redis6.2.7.rpm -y
  5. 安装成功后,查看已经安装好之后的目录
    rpm -ql redis
  6. 查看已经安装的redis版本
    redis-cli --version
  7. 启动redis服务
    systemctl start redis
  8. 查看redis服务启用状态
    systemctl status redis
  9. 关闭redis服务
    systemctl stop redis
  10. 重启redis服务
    systemctl restart redis
  11. 将redis服务设置为开启启动
    systemctl enable redis
  12. 显示所有已启动的服务
    systemctl list-units  --type=service
  13. 查询redis进程
    ps -ef | grep redis
  14. 根据端口号查询redis进程
    netstat -lnp|grep 6379
  15. 查找redis的配置文件redis.conf     find / -name redis.conf

问题

reids服务器的6379端口telnet不通

查看reids进程和端口,都是存在的。只是ip地址是127.0.0.1而不是0.0.0.0,只是本机能使用 

3.查找redis的配置文件redis.conf

使用命令:find / -name redis.conf

4. 编辑配置文件vim /etc/redis.conf

bind 127.0.0.1修改为bind 0.0.0.0

 

5.重启redis-server 

如果bind 改成0.0.0.0会被阿里云服务器动态感知为安全漏洞。可以设置密码,直接在redis.conf里面设置加一行

bind 0.0.0.0下面加上

requirepass 123456(123456是要设置的密码)

ERR Client sent AUTH错误

Caused by: io.lettuce.core.RedisCommandExecutionException: ERR Client sent AUTH, but no password is

错误提示:

主要错误信息:
Caused by: io.lettuce.core.RedisCommandExecutionException: 
 
ERR Client sent AUTH, but no password is 
 
原因:RedisCommandExecutionException:错误客户端发送了身份验证,但没有密码 
 
 
具体错误信息:
Caused by: io.lettuce.core.RedisCommandExecutionException: ERR Client sent AUTH, but no password is set
	at io.lettuce.core.ExceptionFactory.createExecutionException(ExceptionFactory.java:135)
	at io.lettuce.core.ExceptionFactory.createExecutionException(ExceptionFactory.java:108)
	at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:120)
	at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:111)
	at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:59)
	at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:646)
	at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:604)
	at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:556)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:648)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:583)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:500)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:750)
Disconnected from the target VM, address: '127.0.0.1:51913', transport: 'socket'
 
Process finished with exit code 1

解决方法:

找到 redis 文件夹下的 redis.windows.conf 文件,添加修改 requirepass

重启redis服务即可:

redis-server.exe redis.windows.conf

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值