mac port 安装redis 并设置为系统服务 自定义配置方法

mac系统中,port 包管理工具比brew的速度快N倍,今天就给大家分享一下在macos系统中如何使用 port安装 redis数据库并配置为服务自动启动和自定义redis.conf配置的方法。

1. 安装redis

bash 复制代码
sudo port install redis

2. 启动redis服务

bash 复制代码
sudo port load redis

这个命令在安装的时候最后已经提示我们了。

手动启动redis命令: redis-server /opt/local/etc/redis.conf

配置文件: /opt/local/etc/redis.conf 修改链接密码,打开这个文件搜索 requirepass foobared

去掉前面的注释,修改foobared为你自己想要的密码即可。

重启redis服务命令:

sudo port reload redis

到这里我们就把redis安装和配置好了!

下面我们在了解一些 port 安装的redis软件包的一些路径和文件信息。

redis软件包的信息和安装路径:

redis port软件包的文件信息和安装路径信息见上图中红色部分, port路径为:

/opt/local/var/macports/software/redis/redis-7.4.0_0.darwin_19.x86_64

配置文件路径:

/opt/local/etc/redis.conf

/opt/local/etc/sentinel.conf

redis的macos服务plist参考

从下面的这个plist文件中我们可以看到redis在macos中是如何自动启动的以及启动的配置文件路径等信息。

/opt/local/etc/LaunchDaemons/org.macports.redis/org.macports.redis.plist

XML 复制代码
<?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>Label</key><string>org.macports.redis</string>
<key>ProgramArguments</key>
<array>
	<string>/opt/local/bin/daemondo</string>
	<string>--label=redis</string>
	<string>--start-cmd</string>
	<string>/opt/local/bin/redis-server</string>
	<string>/opt/local/etc/redis.conf</string>
	<string>;</string>
	<string>--pid=exec</string>
</array>
<key>Disabled</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>
相关推荐
云老大TG:@yunlaoda36012 分钟前
华为云国际站代理商DAS的跨境合规适配的应用场景有哪些?
网络·数据库·华为云
38242782732 分钟前
python3网络爬虫开发实战 第二版:绑定回调
开发语言·数据库·python
wniuniu_44 分钟前
ceph的参数
java·数据库·ceph
一只专注api接口开发的技术猿1 小时前
智能决策数据源:利用 1688 商品详情 API 构建实时比价与供应链分析系统
大数据·前端·数据库
山峰哥1 小时前
SQL查询优化秘籍:从Explain分析到性能飞跃
开发语言·数据库·sql·oracle·性能优化·系统优化
刘一说1 小时前
MySQL 版本演进全景图:从 5.6 到 8.4 的技术变革与行业实践
数据库·mysql
风跟我说过她1 小时前
HBase完全分布式部署详细教程(含HA高可用版+普通非HA版)
大数据·数据库·分布式·centos·hbase
writeone1 小时前
数据库课后题重点摘要
数据库·oracle
杨云龙UP1 小时前
Oracle释放磁盘空间:alert.log和listener.log清理实战记录_20251225
运维·服务器·数据库·sql·oracle
爱吃山竹的大肚肚2 小时前
优化SQL:如何使用 EXPLAIN
java·数据库·spring boot·sql·spring