linux下Memcached的安装和启动
原帖地址:http://dapeng725.blog.sohu.com/136682788.html
下载libevent、memcached
wget http://www.danga.com/memcached/dist/ memcached-1.4.0.tar.gz
wget http://www.monkey.org/~provos/libevent-1.2.tar.gz
解包
cd /usr/local
tar -xzvf libevent-1.4.tar.gz
tar -xzvf memcached-1.2.5.tar.gz
处理libevent
cd /usr/local/libevent-1.2/
./configure --prefix=/usr/local/libevent
make
make install
处理memcached
cd /usr/local/memcached-1.2.5/
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make
make install
ll/usr/local/libevent/lib/
存在类似如下文件
libevent-1.4.so.1 -> libevent-1.4.so.1.0.3
libevent-1.4.so.1.0.3
libevent.a
libevent.la
libevent.so -> libevent-1.4.so.1.0.3
添加memcached lib
利用 LD_DEBUG=libs bin/memcached –v 确定lib
32位机
ln -s /usr/local/libevent/lib/libevent-1.4.so.1 /usr/lib
ln -s /usr/local/libevent/lib/libevent-1.4.so.2 /usr/lib
64位机
ln -s /usr/local/libevent/lib/libevent-1.2.so.1 /usr/lib64
cd /usr/local/memcached
/usr/local/memcached/bin/memcached -h
-p <num> TCP port number to listen on (default: 11211)
-U <num> UDP port number to listen on (default: 0, off)
-s <file> unix socket path to listen on (disables network support)
-a <mask> access mask for unix socket, in octal (default 0700)
-l <ip_addr> interface to listen on, default is INDRR_ANY
-d run as a daemon
-r maximize core file limit
-u <username> assume identity of <username> (only when run as root)
-m <num> max memory to use for items in megabytes, default is 64 MB
-M return error on memory exhausted (rather than removing items)
-c <num> max simultaneous connections, default is 1024
-k lock down all paged memory. Note that there is a
limit on how much memory you may lock. Trying to
allocate more than that would fail, so be sure you
set the limit correctly for the user you started
the daemon with (not for -u <username> user;
under sh this is done with 'ulimit -S -l NUM_KB').
-v verbose (print errors/warnings while in event loop)
-vv very verbose (also print client commands/reponses)
-h print this help and exit
-i print memcached and libevent license
-b run a managed instanced (mnemonic: buckets)
-P <file> save PID in <file>, only used with -d option
-f <factor> chunk size growth factor, default 1.25
-n <bytes> minimum space allocated for key+value+flags, default 48
出现如上信息是,表明安装正常
注意:查看需要加的lib文件夹,当出现:
memcached: error while loading shared libraries: libevent-1.3c.so.1: cannot open shared object file: No such file or directory
时,利用 LD_DEBUG=libs bin/memcached –v 调试
启动memcache:
./memcached -help
./memcached -d -m 1024 -u root -p 11211 -c 1024 -p /tmp/memcached.pid
开机启动
echo /usr/local/memcached/bin/memcached -d -m 10 -u root -l 218.16.118.105 -p 11211 -c 256 -P /tmp/memcached.pid >> /etc/rc.local
启动参数说明:
-d 选项是启动一个守护进程,
-m 是分配给Memcache使用的内存数量,单位是MB,默认64MB
-M return error on memory exhausted (rather than removing items)
-u 是运行Memcache的用户,如果当前为root 的话,需要使用此参数指定用户。
-l 是监听的服务器IP地址,默认为所有网卡。
-p 是设置Memcache的TCP监听的端口,最好是1024以上的端口
-c 选项是最大运行的并发连接数,默认是1024
我正在玩搜狐微博,快来“关注”我,了解我的最新动态吧。
http://dapeng725.t.sohu.com/
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com