cat /etc/redhat-release CentOS release 6.7 (Final)
防火墙、selinux 关闭
192.168.12.30 安装libevent和memcached、magent192.168.12.43 安装libevent和memcached、magent192.168.12.42 安装libevent和memcached软件下载地址:https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/memagent/magent-0.5.tar.gzhttps://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/memcached/memcached-1.4.15.tar.gz安装:yum -y install gcc libevent-develtar zxvf libevent-2.0.21-stable.tar.gzcd libevent-2.0.21-stable./configure --prefix=/usr/local/libeventmakemake installln -s /usr/lib64/libm.so /usr/local/lib64/libm.amemcached安装:tar zxvf memcached-1.4.15.tar.gzcd memcached-1.4.15./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libeventmake&&make installcp /usr/local/memcached/bin/memcached /etc/rc.d/init.d//etc/init.d/memcached -d -m 512 -u root -l 192.168.12.30 -p 11211 -c 10000 -M -f 1.1 -P /tmp/memcached.pidps aux|grep memcachedroot 15059 0.0 0.0 331032 1072 ? Ssl 16:37 0:00 //etc/init.d/memcached -d -m 512 -u root -l 192.168.12.30 -p 11211 -c 10000 -M -f 1.1 -P /tmp/memcached.pidroot 15068 0.0 0.0 103320 832 pts/1 R+ 16:37 0:00 grep memcached-p <num> 设置端口号(默认不设置为: 11211)-U <num> UDP监听端口 (默认: 11211, 0 时关闭) -l <ip_addr> 绑定地址 (默认:所有都允许,无论内外网或者本机更换IP,有安全隐患,若设置为127.0.0.1就只能本机访问)-d duli进程运行-u <username> 绑定使用指定用于运行进程 <username>-m <num> 允许最大内存用量,单位M (默认: 64 MB)-P <file> 将PID写入文件<file>,这样可以使得后边进行快速进程终止, 需要与 -d 一起使用magent安装:mkdir magentcd magenttar zxvf magent-0.5.tar.gzvi ketama.h (开头加入)#ifndef SSIZE_MAX# define SSIZE_MAX 32767#endif/sbin/ldconfigsed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefilemakecp magent /etc/rc.d/init.d//etc/init.d/magent -u root -n 51200 -l192.168.12.30 -p 12000 -s 192.168.12.30:11211ps -ef | grep magentroot 15070 1 0 16:47 ? 00:00:00 /etc/init.d/magent -u root -n 51200 -l192.168.12.30 -p 12000 -s 192.168.12.30:11211root 15073 7508 0 16:47 pts/0 00:00:00 grep magent-h this message -u uid -g gid -p port, default is 11211. (0 to disable tcp support) -s ip:port, set memcached server ip and port -b ip:port, set backup memcached server ip and port -l ip, local bind ip address, default is 0.0.0.0 -n number, set max connections, default is 4096 -D do not go to background -k use ketama key allocation algorithm -f file, unix socket path to listen on. default is off -i number, max keep alive connections for one memcached server, default is 20 -v verbose启动magent实例 /etc/init.d/magent -u root -n 4096 -l 192.168.12.30 -p 11200 -s 192.168.12.30:11211 -s 192.168.12.43:11211 -b 192.168.12.42:11211/etc/init.d/magent -u root -n 4096 -l 192.168.12.43 -p 11200 -s 192.168.12.30:11211 -s 192.168.12.43:11211 -b 192.168.12.42:11211
转载于:https://www.cnblogs.com/zclzhao/p/5169083.html
相关资源:JAVA上百实例源码以及开源项目