Mac brew安装Redis之后更新配置文件的方法

本文介绍了如何使用Homebrew在Mac上安装Redis,包括查看安装位置、配置文件路径、保护模式设置、重启和停止服务的过程,以及解决Celery连接问题的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装命令

brew install redis

查看安装位置命令

brew list redis  #查看redis安装的位置
% brew list redis
/usr/local/Cellar/redis/6.2.5/.bottle/etc/ (2 files)
/usr/local/Cellar/redis/6.2.5/bin/redis-benchmark
/usr/local/Cellar/redis/6.2.5/bin/redis-check-aof
/usr/local/Cellar/redis/6.2.5/bin/redis-check-rdb
/usr/local/Cellar/redis/6.2.5/bin/redis-cli
/usr/local/Cellar/redis/6.2.5/bin/redis-sentinel
/usr/local/Cellar/redis/6.2.5/bin/redis-server
/usr/local/Cellar/redis/6.2.5/homebrew.mxcl.redis.plist
/usr/local/Cellar/redis/6.2.5/homebrew.redis.service

对应安装目录是/usr/local/Cellar/redis/6.2.5/

查看配置文件

配置文件位置记录在homebrew.mxcl.redis.plist properties list文件中

cd /usr/local/Cellar/redis/6.2.5/
% open .
% vim /usr/local/etc/redis.conf

对应内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>homebrew.mxcl.redis</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/local/opt/redis/bin/redis-server</string>
		<string>/usr/local/etc/redis.conf</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>/usr/local/var/log/redis.log</string>
	<key>StandardOutPath</key>
	<string>/usr/local/var/log/redis.log</string>
	<key>WorkingDirectory</key>
	<string>/usr/local/var</string>
</dict>
</plist>

所以配置文件是/usr/local/etc/redis.conf

修改配置文件

遇到下面连接问题:

原因:

这个错误表明你的应用程序(consumer)试图连接到本地运行的Redis服务器实例,但是连接认证失败了。这通常是因为提供的密码(通常以<password>表示)与Redis服务器配置的密码不匹配。

解决办法

redis的保护模式关闭
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
# 受保护模式, 默认是开启的
# protected-mode yes
protected-mode no

重启redis命令

brew services restart redis

尝试celery连接成功

关闭Redis

brew services stop redis   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值