Linux setup memcached boot up

Source: Internet
Author: User
Tags memcached

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:

#写服务脚本

View Source print?
1 vim /etc/init.d/memcached

Paste the following code

View Source print?
01 #!/bin/sh   
02 #   
03 # memcached:    MemCached Daemon   
04 #   
05 # chkconfig:    - 90 25  
06 # description:  MemCached Daemon   
07 #   
08 # Source function library.
09     
10 . /etc/rc.d/init.d/functions   
11 . /etc/sysconfig/network   
12  
13 #[ ${NETWORKING} = "no" ] && exit 0  
14 #[ -r /etc/sysconfig/dund ] || exit 0  
15 #. /etc/sysconfig/dund   
16 #[ -z "$DUNDARGS" ] && exit 0  
17  
18 MEMCACHED="/usr/local/memcached/bin/memcached"
19 SERVER_IP="192.168.137.98"
20 SERVER_PORT="11211"
21  
22 [ -f $MEMCACHED ] || exit1  
23  
24 start()   
25 {   
26         echo-n $"Starting memcached: "
27         daemon $MEMCACHED -u daemon -d -m 2048 -l $SERVER_IP -p $SERVER_PORT -P /tmp/memcached.pid
28         echo
29 }   
30 stop()   
31 {   
32         echo-n $"Shutting down memcached: "
33         killproc memcached   
34         echo
35
36  
37 # See how we were called.   
38 case"$1" in
39   start)   
40         start   
41         ;;   
42   stop)   
43         stop   
44         ;;   
45   restart)   
46         stop   
47         sleep3  
48         start   
49         ;;   
50     *)   
51         echo$"Usage: $0 {start|stop|restart}"
52         exit1  
53 esac   
54 exit0

#设置启动服务

View Source print?
1 chmod755 /etc/init.d/memcached  #增加执行权限 
2 chkconfig --add memcached  #添加memcached到服务项
3 chkconfig --level 2345 memcached on #设置开机启动
4 chkconfig --list memcached  #查看是否设置成功

#服务管理命令

View Source print?
1 service memcached start   # 启动memcached
2 service memcached stop   # 关闭memcached
3 service memcached 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

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.