安裝repcached memcached

來源:互聯網
上載者:User

安裝repcached memcached 分別在兩台伺服器中安裝libevent與repcached memcached  一、安裝libevent 1.先用:ls -al /usr/lib | grep libevent  查看是否已安裝,如果已安裝且版本低於1.3,則先通過:rpm -e libevent —nodeps 進行卸載。  2.下載libevent安裝包:libevent-1.4.13-stable.tar.gz,然後解壓。  3.切換到解壓後的 libevent 主目錄:cd libevent-1.4.13-stable  4.依次執行: Java代碼  ./configure --prefix=/usr (或 ./configure --program-prefix=/usr)    make    make install       注意: 1)執行 make install 時可能需要 root 許可權。  2)libevent會安裝到 /usr/lib 下。   5.測試libevent是否安裝成功:ls -al /usr/lib | grep libevent 出現類似如下結果則表示安裝成功: Java代碼  lrwxrwxrwx.  1 root root     21 Jun 17 00:35 libevent-1.4.so.2 -> libevent-1.4.so.2.1.3  -rwxr-xr-x.  1 root root 373214 Jun 17 00:35 libevent-1.4.so.2.1.3  -rw-r--r--.  1 root root 603890 Jun 17 00:35 libevent.a  lrwxrwxrwx.  1 root root     26 Jun 17 00:35 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.1.3  -rwxr-xr-x.  1 root root 137329 Jun 17 00:35 libevent_core-1.4.so.2.1.3  -rw-r--r--.  1 root root 228968 Jun 17 00:35 libevent_core.a  -rwxr-xr-x.  1 root root    860 Jun 17 00:35 libevent_core.la  lrwxrwxrwx.  1 root root     26 Jun 17 00:35 libevent_core.so -> libevent_core-1.4.so.2.1.3  lrwxrwxrwx.  1 root root     27 Jun 17 00:35 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.1.3  -rwxr-xr-x.  1 root root 295868 Jun 17 00:35 libevent_extra-1.4.so.2.1.3  -rw-r--r--.  1 root root 469074 Jun 17 00:35 libevent_extra.a  -rwxr-xr-x.  1 root root    867 Jun 17 00:35 libevent_extra.la  lrwxrwxrwx.  1 root root     27 Jun 17 00:35 libevent_extra.so -> libevent_extra-1.4.so.2.1.3  -rwxr-xr-x.  1 root root    825 Jun 17 00:35 libevent.la  lrwxrwxrwx.  1 root root     21 Jun 17 00:35 libevent.so -> libevent-1.4.so.2.1.3    6.如果libevent的安裝目錄為/usr/local/lib下,則還需要建立 libevent-1.4.so.2 到 /usr/lib 的軟串連,這樣其他程式運行時才能找到libevent庫:ln -s /usr/local/lib/libevent-1.4.so.2  /usr/lib/libevent-1.4.so.2  二、安裝repcached memcached 1.下載repcached安裝包:memcached-1.2.8-repcached-2.2.1.tar.gz,然後解壓。  2.切換到解壓後的 repcached memcached 主目錄:cd memcached-1.2.8-repcached-2.2.1  3.依次執行: Java代碼  ./configure --enable-replication   make    make install      4.如果在64位系統中運行memcached可能會出現如下錯誤: /usr/local/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory 則使用libs參數調試: LD_DEBUG=libs /usr/local/bin/memcached -v 可以看到以下輸出: Java代碼       10641:     find library=libevent-1.4.so.2 [0]; searching       10641:      search cache=/etc/ld.so.cache       10641:      search path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64                (system search path)       10641:       trying file=/lib64/tls/x86_64/libevent-1.4.so.2       10641:       trying file=/lib64/tls/libevent-1.4.so.2       10641:       trying file=/lib64/x86_64/libevent-1.4.so.2       10641:       trying file=/lib64/libevent-1.4.so.2       10641:       trying file=/usr/lib64/tls/x86_64/libevent-1.4.so.2       10641:       trying file=/usr/lib64/tls/libevent-1.4.so.2       10641:       trying file=/usr/lib64/x86_64/libevent-1.4.so.2       10641:       trying file=/usr/lib64/libevent-1.4.so.2       10641:  /usr/local/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory   可知memcached並沒有在/usr/lib中載入libevent-1.4.so.2,而是在/usr/lib64中。 故在/usr/lib64中建立/usr/lib/libevent-1.4.so.2的軟連結: ln -s /usr/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2  三、驗證 1.在第一個伺服器執行: Java代碼  [root@localhost ~]# /usr/local/bin/memcached -u nobody -l 192.168.73.201 -p 22122 -m 64 -x 192.168.73.202 -v  replication: connect (peer=192.168.73.202:11212)  replication: marugoto copying  replication: close  replication: listen    2.在第二個伺服器執行: Java代碼  [root@localhost ~]# /usr/local/bin/memcached -u nobody -l 192.168.73.202 -p 22122 -m 64 -x 192.168.73.201 -v  replication: connect (peer=192.168.73.201:11212)  replication: marugoto copying  replication: start   這時在第一個伺服器中會輸出: replication: accept  3.在第一個伺服器中設定key value對: Java代碼  [root@localhost ~]# telnet 192.168.73.201 22122  Trying 192.168.73.201...  Connected to 192.168.73.201.  Escape character is '^]'.  set hey 0 0 4  dude  STORED  get hey  VALUE hey 0 4  dude  END  quit  Connection closed by foreign host    4.在第二個伺服器中取出key value對: Java代碼  [root@localhost ~]# telnet 192.168.73.202 22122  Trying 192.168.73.202...  Connected to 192.168.73.202.  Escape character is '^]'.  get hey  VALUE hello 0 4  dude  END  quit  Connection closed by foreign host.    5.好了,repcached memcached已經安裝配置完成。 另外,安裝telnet用戶端的命令是: yum -y install telnet  #後台運行: /usr/local/bin/memcached -d -m 128 -u root -p 11211 -P /tmp/memcached.pid  # 結束memcache進程 kill `cat /tmp/memcached.pid`  參數:       -d 啟動守護進程(後台運行)       -m 分配給memcache使用的記憶體,單位是MB       -u 運行memcached的使用者       -l 監聽的伺服器IP       -p 監聽的伺服器連接埠,預設是11211       -c 最大啟動並執行並發串連數,預設是1024       -P(大寫) 儲存Memcache的pid檔案,後面跟路徑 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.