欢迎来到天天文库
浏览记录
ID:34464586
大小:106.67 KB
页数:8页
时间:2019-03-06
《工作日志memcached在linux下实现开机自启动》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、工作日志:Memcached在Linux下实现开机自启动在服务器部署好memcached以后,优势不用明说,稍微麻烦一点的是,每次重启服务器后就要重新手动启动memcached,为了方便,因此需要一个memcached开机自启动脚本。设置Memcached开机自启动vim/etc/init.d/memcached然后输入以下代码:图片中代码如下:#!/bin/sh##Startupscriptformemcached##processname:memcached#pidfile:/tmp/memcached.pid#logfile:/v
2、ar/log/memcached/memcached_log#memcached_home:/usr/local/bin/memcached#chkconfig:352179#description:StartorstopmemcachedService./lib/lsb/init-functionsRETVAL=0prog="memcached"basedir=/usr/local/bin/memcachedcmd=/usr/local/bin/memcachedpidfile=/tmp/memcached.pidip="127.0.
3、0.1"#绑定侦听的IP地址port="11211"#服务端口username="root"#运行程序的用户身份max_memory=1024#default:64M
4、最大使用内存max_connection=2048#default:1024
5、最大同时连接数start(){echo-n$"Startingservice:$prog"$cmd-d-l$ip-p$port-u$username-m$max_memory-c$max_connection-P$pidfileRETVAL=$?if[!-d/var/lock/subsys];t
6、henmkdir-p/var/lock/subsysfiecho[$RETVAL-eq0]&&touch/var/lock/subsys/$prog}stop(){echo-n$"Stoppingservice:$prog"current_user=$(whoami)pidlist=$(ps-ef
7、grep$current_user
8、grepmemcached
9、grep-vgrep
10、awk'{print$2}')forpidin$pidlist;dokill-9$pidif[$?-ne0];thenreturn1fidoneRETVAL
11、=$?echo[$RETVAL-eq0]&&rm-f/var/lock/subsys/$prog}case"$1"instart)start;;stop)stop;;restart)stopstart;;status)statusmemcached;;*)echo"Usage:$0{start
12、stop
13、restart
14、status}"exit1esacexit$RETVAL在上述指定目录创建了上述某一个脚本以后,就可以进行以下操作:[root@*****~]#chkconfig–addmemcached[root@*****~]#ch
15、kconfig–level235memcachedon[root@*****~]#chkconfig–list
16、grepmemmemcached0:off1:off2:on3:on4:off5:on6:off接下来,可以用以下命令启动与停止memcached[root@*****~]#/etc/rc.d/init.d/memcachedstart[root@*****~]#/etc/rc.d/init.d/memcachedstop[root@*****~]#/etc/rc.d/init.d/memcachedstatu[root@**
17、***~]#/etc/rc.d/init.d/memcachedrestart或者:[root@*****~]#servicememcachedstart[root@*****~]#servicememcachedstop[root@*****~]#servicememcachedstatu[root@*****~]#servicememcachedrestart然后,可以用ps命令查看进程信息。[root@*****~]#psaux
18、grepmemroot42040.00.03252403380?Ssl10:190:00/usr/lo
19、cal/bin/memcached-d-l127.0.0.1-p11211-uroot-m1024-c2048-P/tmp/memcached.pid说明memcached已启动然后打开linux下的开机启
此文档下载收益归作者所有