mac memcached_如何设置Memcached Server在Mac OS的启动时运行

mac memcached

In the last post we learnt how to install Memcached server on Mac OS. If you want to run Memcache when system boots for Mac OS, then you have to put the PList configuration file in /Library/LaunchDaemons/ directory and set the owner to root user.

在上一篇文章中,我们学习了如何在Mac OS上安装Memcached服务器 。 如果要在Mac OS引导系统时运行Memcache,则必须将PList配置文件放在/Library/LaunchDaemons/目录中,并将所有者设置为root用户。

Create a file in the /Library/LaunchDaemons/ directory with name memcached.plist with below content.

/Library/LaunchDaemons/目录中创建一个名称为memcached.plist ,内容如下。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.memcached</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/memcached</string>
<string>-d</string>
<string>-u</string>
<string>root</string>
<string>-p</string>
<string>11211</string>
<string>-m</string>
<string>64</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Once the file is created change the owner to root with below command:

创建文件后,使用以下命令将所有者更改为root:

$chown root:wheel memcached.plist

Now when you will boot your Mac OS, the Memcached server will get started automatically as a daemon process on port 11211, and allocated memory is 64 MB.

现在,当您启动Mac OS时,Memcached服务器将作为守护进程在端口11211上自动启动,并且分配的内存为64 MB。

Use ps -eaf | grep memcached or telnet command to verify it.

使用ps -eaf | grep memcached ps -eaf | grep memcached或telnet命令进行验证。

NOTE: I tried this on macOS Sierra (10.12.x) but this doesn’t seem to work. It seems we have to load the plist file using below command.

注意:我在macOS Sierra(10.12.x)上尝试了此操作,但这似乎不起作用。 看来我们必须使用以下命令加载plist文件。

$launchctl load -w /Library/LaunchDaemons/org.memcached.plist

But I am getting below error message in console.

但是我在控制台中收到以下错误消息。

Jul 25 14:11:58 --- last message repeated 1 time ---
Jul 25 14:11:58 pankaj com.apple.xpc.launchd[1] (org.memcached[1113]): Service could not initialize: 16F73: xpcproxy + 11769 [1505][34964CF1-9965-3B4D-ADC7-6FBC6669C56D]: 0xd
Jul 25 14:11:58 pankaj com.apple.xpc.launchd[1] (org.memcached): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

I tried many different options but it doesn’t seem to work. If you have faced something like this and able to get it working, please comment and let me know.

我尝试了许多不同的选项,但似乎不起作用。 如果您遇到了类似问题并能够使其正常运行,请发表评论并告诉我。

翻译自: https://www.journaldev.com/7/how-to-setup-memcached-server-to-run-at-boot-time-in-mac-os

mac memcached

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值