Ubuntu:将 Memcached 作为守护进程运行

发布于 2024-10-26 09:16:51 字数 92 浏览 4 评论 0原文

我已经在 Ubuntu 上安装了 memcached。如何将它作为守护进程运行,以便它在后台运行并且我可以在我的 Rails 应用程序中使用它?

I have installed memcached on Ubuntu. How can I run it as a daemon so that it runs in the background and I can use it in my rails application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟火散人牵绊 2024-11-02 09:16:51

memcached 默认配置为在启动时运行,至少在 10.10 上:

# apt-get install memcached
...
Setting up memcached (1.4.5-1ubuntu1) ...
Starting memcached: memcached.
# ls -l /etc/rc*.d/*memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc0.d/K20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc1.d/K20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc2.d/S20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc3.d/S20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc4.d/S20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc5.d/S20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc6.d/K20memcached -> ../init.d/memcached
#  

在运行级别 2、3、4 和 5 中,memcached 将运行。

如果您不确定,可以使用 status 运行 initscript:

# /etc/init.d/memcached status
 * memcached is running

memcached is configured to run at boot by default, at least on 10.10:

# apt-get install memcached
...
Setting up memcached (1.4.5-1ubuntu1) ...
Starting memcached: memcached.
# ls -l /etc/rc*.d/*memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc0.d/K20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc1.d/K20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc2.d/S20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc3.d/S20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc4.d/S20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc5.d/S20memcached -> ../init.d/memcached
lrwxrwxrwx 1 root root 19 2011-03-23 13:36 /etc/rc6.d/K20memcached -> ../init.d/memcached
#  

In runlevels 2, 3, 4, and 5, memcached will be running.

If you're not sure, you can run the initscript with status:

# /etc/init.d/memcached status
 * memcached is running
夜清冷一曲。 2024-11-02 09:16:51

以防万一其他人最终在这里寻找如何直接运行守护进程(例如在 docker 容器内)。您要查找的标志是 -d

/usr/bin/memcached start -u memcached -d

Just in case anyone else ends up here looking for how to run the daemon directly (like inside a docker container for example). The flag you're looking for is -d.

/usr/bin/memcached start -u memcached -d
有木有妳兜一样 2024-11-02 09:16:51

在 ubuntu 上安装 memcached

apt-get install memcached

启动 memcached

/etc/init.d/memcached start

重新启动 memcached

/etc/init.d/memcached start

检查memcached的状态

/etc/init.d/memcached status

编辑memcached配置

sudo vi /etc/memcached.conf

默认情况下memcached将在 127.0.0.1:11211 上运行,并配置为默认在启动时运行

To install memcached on ubuntu

apt-get install memcached

To start memcached

/etc/init.d/memcached start

To restart memcached

/etc/init.d/memcached start

To check the status of memcached

/etc/init.d/memcached status

To edit memcached config

sudo vi /etc/memcached.conf

By default memcached will run on 127.0.0.1:11211 and is configured to run at boot by default

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文