安装及常用命令
redis的yum方式安装
- 先查看是否已经安装redis执行命令
rpm -qa | grep redis - 如果存在,将存在的卸载:(-y 代表自动选择)
yum remove xxx -y - 在线安装redis
yum install redis - 安装本地已经下载好的redis安装包
yum localinstall redis6.2.7.rpm -y - 安装成功后,查看已经安装好之后的目录
rpm -ql redis - 查看已经安装的redis版本
redis-cli --version - 启动redis服务
systemctl start redis - 查看redis服务启用状态
systemctl status redis - 关闭redis服务
systemctl stop redis - 重启redis服务
systemctl restart redis - 将redis服务设置为开启启动
systemctl enable redis - 显示所有已启动的服务
systemctl list-units --type=service - 查询redis进程
ps -ef | grep redis - 根据端口号查询redis进程
netstat -lnp|grep 6379 - 查找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