使用自制程序安装Redis,但当我尝试ping Redis时,它显示这个错误:
Could not connect to Redis at 127.0.0.1:6379: Connection refused
注意: 我尝试关闭防火墙并编辑conf文件,但仍然无法ping通。 我使用的是macOS Sierra和自制版本1.1.11
使用自制程序安装Redis,但当我尝试ping Redis时,它显示这个错误:
Could not connect to Redis at 127.0.0.1:6379: Connection refused
注意: 我尝试关闭防火墙并编辑conf文件,但仍然无法ping通。 我使用的是macOS Sierra和自制版本1.1.11
当前回答
我在这件事上耽搁了很长时间。经过多次尝试,我终于能够正确地配置它了。
产生误差的原因有很多。我试图提供原因和解决方案,以克服这种情况。确保正确安装了redis-server。
6379 Port is not allowed by ufw firewall. Solution: type following command sudo ufw allow 6379 The issue can be related to permission of redis user. May be redis user doesn't have permission of modifying necessary redis directories. The redis user should have permissions in the following directories: /var/lib/redis /var/log/redis /run/redis /etc/redis To give the owner permission to redis user, type the following commands: sudo chown -R redis:redis /var/lib/redis sudo chown -R redis:redis /var/log/redis sudo chown -R redis:redis /run/redis sudo chown -R redis:redis /etc/redis. Now restart redis-server by following command: sudo systemctl restart redis-server
希望这对某些人有所帮助。
其他回答
首先,您需要使用以下命令启动/启动所有redis节点,一个接一个地启动所有的conf文件。 @注:如果你正在建立集群,那么你应该有6个节点,3个主节点和3个从节点。Redis-cli将使用——cluster命令从6个节点中自动选择主节点和从节点,如下所示。
[xxxxx@localhost redis-stable]$ redis-server xxxx.conf
然后运行
[xxxxx@localhost redis-stable]$ redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1
上述输出应如下:
>>> Performing hash slots allocation on 6 nodes...
自动设置所有东西的第二种方法: 您可以使用utils/create-cluster脚本来设置您喜欢的任何东西 启动所有节点,创建集群 你可以关注https://redis.io/topics/cluster-tutorial
谢谢
Mac版Redis:
1-酿造安装redis 2-酿造服务启动redis 3- redis-cli ping
$ brew services start redis
$ brew services stop redis
$ brew services restart redis
午餐自动启动选项:
$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
# autostart activate
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
# autostart deactivate
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Redis conf默认路径:/usr/local/etc/redis.conf
在我的情况下,它是包含一些字符的密码,如',修改后,服务器启动没有问题。
安装完redis后,从终端输入:
redis-server
Redis-Server将启动
我试图连接我的Redis运行在wsl2从vs代码运行在Windows。
我列出了对我有效的方法,以及我执行这些方法的顺序:
1) sudo ufw allow 6379
2) Update redis.conf to bind 127.0.0.1 ::1 192.168.1.7
3) sudo service redis-server restart
注意:这是我第一次在wsl2上安装Redis,而且还没有运行任何命令。
如果对你有用,请告诉我。 谢谢。