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

wmtdaxz3  于 2023-05-06  发布在  其他
关注(0)|答案(3)|浏览(154)

我已经在Ubuntu上安装了memcached。我怎样才能把它作为一个守护进程来运行,这样它就可以在后台运行,并且我可以在我的Rails应用程序中使用它?

bkhjykvo

bkhjykvo1#

memcached默认配置为在 Boot 时运行,至少在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
bfhwhh0e

bfhwhh0e2#

只是为了防止其他人在这里寻找如何直接运行守护进程(比如在一个docker容器中)。

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

ulmd4ohb3#

在ubuntu上安装memcached
/etc/init.d/memcached start
若要启动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上运行,并且默认情况下配置为在 Boot 时运行

相关问题