Open wittyResry opened 7 years ago
启动Memcached服务: 1.启动Memcache的服务器端: # /usr/local/bin/memcached -d -m 256 -u root -l 127.0.0.1 -p 12000 -c 256 -P /tmp/memcached.pid (对外网 /usr/local/bin/memcached -d -m 256 -u weblogic -l 0.0.0.0 -p 12000 -c 256 -P /tmp/memcached.pid) -d选项是启动一个守护进程 -m是分配给Memcache使用的内存数量,单位是MB -u是运行Memcache的用户,我这里是root -l是监听的服务器IP地址 -p是设置Memcache监听的端口 -c选项是最大运行的并发连接数,默认是1024 -P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid, 2.如果要结束Memcache进程,执行: # kill `cat /tmp/memcached.pid` 3. test ➜ memcached-1.4.36 /usr/local/bin/memcached -d -m 256 -u root -l 127.0.0.1 -p 12000 -c 256 -P /tmp/memcached.pid ➜ memcached-1.4.36 telnet localhost 12000 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. set key 0 1 4 resry CLIENT_ERROR bad data chunk ERROR set key1 0 60 4 zhou STORED get key1 VALUE key1 0 4 zhou END set key1 0 60 5 resry STORED get key1 VALUE key1 0 5 resry END 伪分布式 ➜ scripts /usr/local/bin/memcached -d -m 16 -u root -l 127.0.0.1 -p 12000 -c 256 -P /tmp/memcached.pid ➜ scripts /usr/local/bin/memcached -d -m 16 -u root -l 127.0.0.1 -p 12001 -c 256 -P /tmp/memcached.pid ➜ scripts /usr/local/bin/memcached -d -m 16 -u root -l 127.0.0.1 -p 12002 -c 256 -P /tmp/memcached.pid ➜ scripts ps -ef|grep memcached 501 65864 1 0 10:08下午 ?? 0:00.03 /usr/local/bin/memcached -d -m 16 -u root -l 127.0.0.1 -p 12000 -c 256 -P /tmp/memcached.pid 501 65872 1 0 10:08下午 ?? 0:00.02 /usr/local/bin/memcached -d -m 16 -u root -l 127.0.0.1 -p 12001 -c 256 -P /tmp/memcached.pid 501 65879 1 0 10:08下午 ?? 0:00.02 /usr/local/bin/memcached -d -m 16 -u root -l 127.0.0.1 -p 12002 -c 256 -P /tmp/memcached.pid 501 65887 42282 0 10:08下午 ttys012 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn memcached ➜ scripts cat /tmp/memcached.pid 65879