安裝配置memcached
1. 安裝libeventspa
# tar zxf libevent-1.4.6-stable.tar.gz # cd libevent-1.4.6-stable # ./configure # make && make install
2. 安裝memcachedrest
# tar zxvf memcached-1.2.6.tar.gz # cd memcached-1.2.6 # ./configure --prefix=/usr/local/memcached-1.2.6 # make && make install
3. 運行memcachedcode
# /usr/local/memcached-1.2.6/bin/memcached -d -m 128 -l localhost -p 11211 -u root
參數說明:
-d 以守護程序(daemon)方式運行 memcached;
-m 設置 memcached 可使用的內存大小,單位爲 M;
-l 設置監聽的 IP 地址,若是是本機的話,一般能夠不設置此參數;
-p 設置監聽的端口,默認爲 11211,因此也能夠不設置此參數;
-u 指定用戶;blog
4.設置memcache開機自啓動ip
#!/bin/sh # # memcached: MemCached Daemon # # chkconfig: - 90 25 # description: MemCached Daemon # # Source function library. . /etc/rc.d/init.d/functions . /etc/sysconfig/network start() { echo -n $"Starting memcached: " daemon /usr/local/bin/memcached -u daemon -d -m 4096 -l 10.10.10.220 -p 58728 echo } stop() { echo -n $"Shutting down memcached: " killproc memcached echo } [ -f /usr/local/bin/memcached ] || exit 0 # See how we were called. case "$1" in start) start ;; stop) stop ;; restart|reload) stop start ;; condrestart) stop start ;; *) echo $"Usage: $0 {start|stop|restart|reload|condrestart}" exit 1 esac exit 0 chmod +x /etc/init.d/memcached chkconfig --level 2345 memcached on service memcached start