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>
相关推荐
夜泉_ly23 分钟前
MySQL -安装与初识
数据库·mysql
qq_529835351 小时前
对计算机中缓存的理解和使用Redis作为缓存
数据库·redis·缓存
月光水岸New4 小时前
Ubuntu 中建的mysql数据库使用Navicat for MySQL连接不上
数据库·mysql·ubuntu
狄加山6754 小时前
数据库基础1
数据库
我爱松子鱼4 小时前
mysql之规则优化器RBO
数据库·mysql
chengooooooo4 小时前
苍穹外卖day8 地址上传 用户下单 订单支付
java·服务器·数据库
Rverdoser5 小时前
【SQL】多表查询案例
数据库·sql
Galeoto5 小时前
how to export a table in sqlite, and import into another
数据库·sqlite
希忘auto6 小时前
详解Redis在Centos上的安装
redis·centos
人间打气筒(Ada)6 小时前
MySQL主从架构
服务器·数据库·mysql