Linux setup memcached boot up

Source: Internet
Author: User

memcached Boot Mode

Method One:

Append the start command to the /etc/rc.d/rc.local file

/usr/local/memcached/bin/memcached-u root-d-M 2048-l 192.168.137.99-p 11211-p/tmp/memcached.pid

You can also specify no IP, which is native by default, such as

/usr/local/memcached/bin/memcached-u deamon-d-M 2048-p 11211-p/tmp/memcached.pid

The user is preferably Apache or deamon

Method Two:

#写服务脚本

Vim/etc/init.d/memcached

Paste the following code

#!/bin/sh # # memcached:memcached Daemon # # Chkconfig:-# description:memcached Daemon # # #   Ource function Library. . /etc/rc.d/init.d/functions. /etc/sysconfig/network #[${networking} = "No"] && exit 0 #[-r/etc/sysconfig/dund] | | Exit 0 #. /etc/sysconfig/dund #[-Z "$DUNDARGS"] && exit 0 memcached= "/usr/local/memcached/bin/memcached" server_ip= "19 2.168.137.98 "server_port=" 11211 "[-F $MEMCACHED] | | Exit 1 start () {echo-n $ "starting memcached:" Daemon $MEMCACHED-u daemon-d-M 2048-l $SERVER _i          P-page $SERVER _port-p/tmp/memcached.pid echo} stop () {echo-n $ "shutting down memcached:"   Killproc memcached Echo} # See how we were called.     Case "$" in start) start;     stop) stop;;       Restart) Stop sleep 3 start; *) echo $ "Usage: $ start|stop|restarT} "Exit 1 Esac Exit 0   

#设置启动服务

chmod 755/etc/init.d/memcached  #增加执行权限chkconfig--add memcached  #添加memcached到服务项chkconfig--level 2345 memcached on  #设置开机启动chkconfig--list memcached  #查看是否设置成功

#服务管理命令

Service memcached start   # memcachedservice memcached Stop   # close Memcachedservice memcached Restart   # Restart memcached

memcached Start Parameter Description:

The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, default 64MB
-M return error on memory exhausted (rather than removing items)
-U is the user running memcache, and if it is currently root, you need to specify the user with this parameter.
-L is the server IP address of the listener, which defaults to all network cards.
-P is the port that sets the TCP listener for memcache, preferably a port above 1024
The-c option is the maximum number of concurrent connections that are running, by default 1024
-P is a PID file that is set to save Memcache
-F <factor> Chunk size growth factor (default:1.25)
-I Override the size of each slab page. Adjusts max item size (new 1.4.2 version)
You can also start multiple daemons, but the ports cannot be duplicated

-P Specify port number (default 11211)
-m Specifies maximum memory size (default 64MB, Max 2G)
-T thread count (default 4)

-L connected IP address, default is native
-D Start memcached Service (default = Start)
-D Restart Restart memcached service
-D Stop|shutdown Close the running memcached service
-d Uninstall Uninstall memcached service
-m maximum memory usage, in megabytes. Default 64MB
-M running out of memory and returning an error instead of deleting an item
-c Maximum number of simultaneous connections, default is 1024
-F Block size growth factor, default is 1.25
-N Minimum allocated space, key+value+flags default is 48
-H Display Help

Extended reading:

centos6.x Compile and install memcached PHP client Memcache

centos6.x Compiling and installing memcached

Linux setup memcached boot up

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.