Ubuntu上安装、使用Redis的详细教程
sudo apt-get update
sudo apt-get install redis
启动方式二
systemctl start redis-server
启动方式三
service redis-server start
重启redis
service redis-server restart
关闭redis
service redis-server stop
查看redis状态
service redis-server status
4、在宿主机连接redis
根据以上步骤安装启动redis后,默认只能在虚拟机内访问redis,如果在其他机器上访问,需要修改配置文件。
默认情况下,redis的配置文件在/etc/redis/redis.conf,打开这个文件,注释掉下面的内容。
bind 127.0.0.1 -::1
然后就可以在windows上通过Another Redis Desktop Manager连接ubuntu上的redis了,当然了,如果你希望给redis设置一个密码,可以在配置文件中加上以下的配置。
requirepass 你的密码
# 密码,建议生产环境开启
- 将 bind 注释掉,允许非本机访问
- 关闭安全守护模式,将 protected-mode 设置为 no
- 加上安全认证,设置 requirepass 密码,但在我的测试中,不设置密码只执行上面两个步骤,也可以解决这个 bug
执行上面操作后,重启 Redis 服务端,报错就解决了
Caused by: java.util.concurrent.CompletionException: org.redisson.client.RedisException: ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?#
解决方案:
把yaml文件中连接Redis 的配置的密码字段改为 auth,然后发现就可以了。
目前我也没搞明白,什么时候用password,什么时候用auth,我另一个demo项目,用的也是redis-windows-6.2.6, 但是使用password字段就可以连接。。。感觉与redis-starter的版本有关。
posted on 2023-12-25 19:53 zyp_java_net 阅读(101) 评论(0) 编辑 收藏 举报