redis 拒绝远程访问解决
阅读原文时间:2023年07月14日阅读:1

启动时报的警告:

1、Warning: no config file specified, using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf

就因为这个原因,无法连接到远程redis:Unable to connect to 192.168.163.131:6379

解决:

[root@cent7-zuoys src]# ./redis-server ../redis.conf

2、

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

解决:

编辑/etc/sysctl.conf ,改vm.overcommit_memory=1,然后sysctl -p 使配置文件生效

3、The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

解决:

在/etc/sysctl.conf中添加:net.core.somaxconn = 2048,然后在终端中执行sysctl -p

4、

you have Transparent Huge Pages (THP) support enabled in your kernel.?This will create latency and memory usage issues with Redis.?To fix thisissue run the?command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root,?and add it to your /etc/rc.local in order to retain thesetting after a reboot.?Redis must be restarted after THP is disabled.

解决:

临时解决方法:

echo never > /sys/kernel/mm/transparent_hugepage/enabled。

永久解决方法:

将其写入/etc/rc.local文件中。

远程访问redis报错:

org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 10.134.253.30:6379

解决:

vi redis.conf

1、注释掉 bind 127.0.0.1,即可让所有ip访问
2、protected-mode no