Install repcached memcached on the two servers respectively. Install libevent and repcached memcached 1. Install libevent 1. first Run: ls-al/usr/lib | grep libevent to check whether it is installed. If it is installed and the version is earlier than 1.3, run: rpm-e libevent-nodeps to uninstall it. 2. Download The libevent installation package: libevent-1.4.13-stable.tar.gz and unzip it. 3. switch to the decompressed libevent Home Directory: cd libevent-1.4.13-stable 4. run the Java code in sequence. /configure -- prefix =/usr (or. /configure -- program-prefix =/usr) make install Note: 1) the root permission may be required for executing make install. 2) The libevent will be installed under/usr/lib. 5. test whether the libevent is successfully installed: ls-al/usr/lib | grep libevent. If the following result is displayed, the installation is successful: Java code lrwxrwxrwx. 1 root 21 Jun 17 libevent-1.4.so.2-> libevent-1.4.so.2.1.3-rwxr-xr-x. 1 root 373214 Jun 17 libevent-1.4.so.2.1.3-rw-r --. 1 root 603890 Jun 17 libevent. a lrwxrwxrwx. 1 root 26 Jun 17 libevent_core-1.4.so.2-> libevent_core-1.4.so.2.1.3-rwxr-xr-x. 1 root 1373 29 Jun 17 libevent_core-1.4.so.2.1.3-rw-r --. 1 root 228968 Jun 17 00:35 libevent_core.a-rwxr-xr-x. 1 root 860 Jun 17 00:35 libevent_core.la lrwxrwxrwx. 1 root 26 Jun 17 00:35 libevent_core.so-> libevent_core-1.4.so.2.1.3 lrwxrwxrwx. 1 root 27 Jun 17 libevent_extra-1.4.so.2-> libevent_extra-1.4.so.2.1.3-rwxr-xr-x. 1 root 295868 Jun 17 00:35 libevent_extr A-1.4.so.2.1.3-rw-r --. 1 root 469074 Jun 17 00:35 libevent_extra.a-rwxr-xr-x. 1 root 867 Jun 17 00:35 libevent_extra.la lrwxrwxrwx. 1 root 27 Jun 17 libevent_extra.so-> libevent_extra-1.4.so.2.1.3-rwxr-xr-x. 1 root 825 Jun 17 libevent. la lrwxrwxrwx. 1 root 21 Jun 17 libevent. so-> libevent-1.4.so.2.1.3 6. if the installation directory of libevent is/usr/local/lib Ent-1.4.so.2 to the soft connection of/usr/lib so that other programs can find the libevent Library: ln-s/usr/local/lib/libevent-1.4.so.2/usr/lib/libevent-1.4.so.2 2. Install repcached memcached 1. download the repcached installation package: memcached-1.2.8-repcached-2.2.1.tar.gz and unzip it. 2. switch to the decompressed repcached memcached Home Directory: cd memcached-1.2.8-repcached-2.2.1 3. run the Java code in sequence. /configure -- enable-replication make install 4. if you run memcached on a 64-bit system, the following error may occur:/usr/local/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: no such file or directory, use the libs parameter for debugging: LD_DEBUG = libs/usr/local/bin/memcached-v to see the following output: Java code 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 we know that memcached does not The libevent-1.4.so.2 is loaded in/usr/lib, but in/usr/lib64. Therefore, in the/usr/lib64 create/usr/lib/libevent-1.4.so.2 soft link: ln-s/usr/lib/libevent-1.4.so.2/usr/lib64/libevent-1.4.so.2 3, verify 1. run the Java code [root @ localhost ~] on the first server. #/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. run the Java code [root @ localhost ~] on the second server. #/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 at this time, the first server will output: replication: accept 3. set the key-value pair in the first server: Java code [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. obtain the key-value pair in the second server: Java code [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. all right, repcached memcached has been installed and configured. In addition, the command for installing the telnet client is: yum-y install telnet # Run in the background: /usr/local/bin/memcached-d-m 128-u root-p 11211-P/tmp/memcached. pid # kill the memcache process 'cat/tmp/memcached. pid 'parameter:-d start the daemon (running in the background)-m is allocated to the memory used by memcache, the Unit is the IP address of the server listening port of the User-l listening that runs memcached in MB-u. The default value is 11211-c. The maximum number of concurrent connections is running, the default value is 1024-P (uppercase). The pid file for saving Memcache is followed by the path