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>
相关推荐
belldeep18 分钟前
本草纲目:如何应用 PostgreSQL 实现【中医药】主题数据库 ?
数据库·postgresql·本草纲目
Bert.Cai29 分钟前
MySQL CURTIME()函数详解
数据库·mysql
Bert.Cai30 分钟前
MySQL CURDATE()函数详解
数据库·mysql
NGSI vimp43 分钟前
MySQL|MySQL 中 `DATE_FORMAT()` 函数的使用
数据库·mysql
HAWK eoni1 小时前
Mysql 驱动程序
数据库·mysql
二哈赛车手1 小时前
新人笔记---实现简易版的rag的bm25检索(利用ES),以及RAG上传时的ES与向量数据库双写
java·数据库·笔记·spring·elasticsearch·ai
sthnyph1 小时前
docker compose安装redis
redis·docker·容器
何中应1 小时前
CentOS 7安装、卸载MySQL数据库(二)
数据库·mysql·centos
KmSH8umpK1 小时前
Redis分布式锁从原生手写到Redisson高阶落地,附线上死锁复盘优化方案进阶第六篇
数据库·redis·分布式
梁萌2 小时前
mysql使用事件做日志表数据转移
数据库·mysql