分布式memcached伺服器代理magent安裝配置(CentOS6.6)

來源:互聯網
上載者:User

標籤:local   Proxy 伺服器   編譯器   光碟機   

分布式memcached伺服器代理magent安裝配置(CentOS6.6)



參考:http://blog.snsgou.com/post-800.html
四台伺服器:192.168.1.246~249

MagentProxy 伺服器:192.168.1.246
Memcache備份伺服器1:192.168.1.249
Memcache儲存伺服器1:192.168.1.247
Memcache儲存伺服器2:192.168.1.248
Memcache伺服器安裝配置(192.168.1.247~249)
首先:配置本地YUM源,掛載光碟機,安裝編譯器

1
yum install gcc gcc-c++

1、編譯安裝libevent:

123456
wget http://monkey.org/~provos/libevent-1.4.9-stable.tar.gztar zxvf libevent-1.4.9-stable.tar.gzcd libevent-1.4.9-stable/mkdir /usr/local/libevent./configure --prefix=/usr/local/libeventmake && make install

2、編譯安裝Memcached:

123456
wget http://danga.com/memcached/dist/memcached-1.2.6.tar.gztar zxvf memcached-1.2.6.tar.gzcd memcached-1.2.6/mkdir /usr/local/memcached./configure --prefix=/usr/local/memcached  --with-libevent=/usr/local/libeventmake && make install

3、啟動memcached伺服器:

1
/usr/local/memcached/bin/memcached -m 100 -u root  -d  -l 127.0.0.1  -p 11211

memcached參數詳解:
-p       TCP port number to listen on (default: 11211)
-U       UDP port number to listen on (default: 0, off)
-s      unix socket path to listen on (disables network support)
-a      access mask for unix socket, in octal (default 0700)
-l   interface to listen on, default is INDRR_ANY
-d            run as a daemon
-r            maximize core file limit
-u  assume identity of  (only when run as root)
-m       max memory to use for items in megabytes, default is 64 MB
-M            return error on memory exhausted (rather than removing items)
-c       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  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      save PID in , only used with -d option
-f    chunk size growth factor, default 1.25
-n     minimum space allocated for key+value+flags, default 48

memcacheProxy 伺服器magent安裝配置(192.168.1.246)
1、magent是一款開源的MemcachedProxy 伺服器軟體,其項目網址為:http://code.google.com/p/memagent/ 目前最新版本為0.6
2、安裝,先配置本地源,掛載光碟機,安裝編譯器

1
 Yum install gcc gcc-c++ libgnomeui-devel

3、編譯安裝libevent:

123456
wget http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz   //下載安裝libeventtar zxvf libevent-1.4.9-stable.tar.gzcd libevent-1.4.9-stable/mkdir /usr/local/libevent./configuremake && make install

4、安裝magent

1234567
mkdir magent  cp magent-0.6.tar.gz  ./magent   cd magent    tar xzvf ./magent-0.6.tar.gz    /sbin/ldconfig    sed -i "s/LIBS = -levent/LIBS = -levent -lm/g" Makefile     make

magent.c:729: 錯誤:‘SSIZE_MAX’未聲明(在此函數內第一次使用)
magent.c:729: 錯誤:(即使在一個函數內多次出現,每個未聲明的標識符在其
magent.c:729: 錯誤:所在的函數內也只報告一次。)
make: *** [magent.o] 錯誤 1
解決方案:
#在ketama.h開頭加入(過濾掉特殊字元)

123
#ifndef SSIZE_MAX#define SSIZE_MAX      32767#endif

繼續make

1
cp magent /usr/bin/magent

啟動memagent:

1
/usr/bin/magent -u root -n 4096 -l 192.168.1.246 -p 12000 -s 192.168.1.247:11211 -s 192.168.1.248:11211  -b 192.168.1.249:11211

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

PHP開啟擴充php_memcache.Dll注意版本的問題

1234567891011121314
//phpinfo();  //查看擴充是否開啟$mem = new Memcache();//直接連接Proxy 伺服器$mem->connect(‘192.168.1.246‘,12000) or die(‘connect fail!<br>‘); echo "connect success!<br>"; for($i=0;$i<10;$i++){    if($mem->set(‘key‘.$i , ‘data‘.$i , 0 , 3600)){            echo "set ok!";                }else{            echo "set false!";    }}

報錯提示:
Notice: Memcache::set(): Server 192.168.1.246 (tcp 12000) failed with: Failed reading line from stream (0)
原因是:代理magent沒有串連到memcached伺服器

解決方案:
啟動memcached的時候,不能使用 –l  127.0.0.1或者-l  localhost,要設定當前IP

1
/usr/local/memcached/bin/memcached -m 100 -u root  -d  -l 192.168.1.247  -p 11211

使用memadmin監控memcached伺服器的儲存狀態:
備份伺服器bak_249請求次數10次,s1_247五次,s2_248五次,memadmin統計資訊如:

備份伺服器249:
650) this.width=650;" src="http://blog.bwphp.cn/wp-content/uploads/2015/01/magent_bak.jpg" alt="magent_bak" class="alignnone size-full wp-image-470" height="731" width="817" />

S1_247:
650) this.width=650;" src="http://blog.bwphp.cn/wp-content/uploads/2015/01/s1.jpg" alt="s1" class="alignnone size-full wp-image-472" height="728" width="824" />

S2_248:
650) this.width=650;" src="http://blog.bwphp.cn/wp-content/uploads/2015/01/s2.jpg" alt="s2" class="alignnone size-full wp-image-473" height="731" width="825" />



分布式memcached伺服器代理magent安裝配置(CentOS6.6)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.