Skip to content

Quick Start

downgoon edited this page Jan 11, 2018 · 1 revision

Quick Start for memcloud-0.1.0 automan

how to install memcloud

[root@10.213.42.153 memcloud]#./memcloud-install.sh

install success if you see

memcloud installed ok: /usr/local/bin/memcached

on the bottom lines.

Requirement

before you use it please open and edit some variables according to your environment. the script has been tested on centos 6. please make sure the three packages named ibevent-2.0.19-stable.tar.gz, memcached-1.4.5.tar.gz and repcached-2.3-1.4.5.patch.gz can be downloaded from outside web sites or already placed in the specific local path such as /opt/memcloud/ written in the script by default.

  1. install path created /opt/memcloud/
  2. web accessing or the three packages mentioned above found in the install path

by the way, official package memcached-1.4.5.tar.gz is located on http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz, but *.googlecode.com cann't be accessed in some regions.

how to start memcloud

# ./memcloud.sh
Usage: memcloud.sh [local_ip:]<local_port> <peer_ip:repc_port> example: memcloud.sh 11211 10.213.57.166:11212

NOTE

the value of <local_port> MUST be different from <repc_port> because the <repc_port> can listen on <local_ip> or <peer_ip> when failover occurs.

a bad case like this

[root@10.213.42.153 memcloud]# memcloud.sh 11211 10.213.42.154:11211
local addr is 10.213.42.153:11211 and remote addr is 10.213.42.154:11211
/usr/local/bin/memcached -d -p 11211 -m 1024 -x 10.213.42.153 -X 11211 -u root -l 10.213.42.154  -c 256 -P /tmp/memcloud_11211_10.213.42.154_11211.pid -v >> ./memcloud.log  2>&1

[root@10.213.42.153 memcloud]# cat ./memcloud.log
replication: connect (peer=10.213.42.153:11211)
replication: marugoto copying
replication: close
replication: listen
failed to listen on TCP port 11211: Address already in use

Suggestion

the value of <local_ip> SHOULD be different from <peer_ip> otherwise replication will take no effects when the host fails down.

a good case

run the command as follows on 10.213.42.153

[root@10.213.42.153 memcloud]# memcloud.sh 11211 10.213.57.166:11212

on 10.213.57.166

[root@10.213.57.166 memcloud]# memcloud.sh 11211 10.213.42.153:11212

the graph of deployment

replica between memcloud peers

replication testing

for easy communication, let's tag 10.213.42.153 as A, and 10.213.57.166 as B.

  • set hello=world in A, then world got from B
  • set name=memcloud in B, then memcloud got from A

execute the command set hello 0 0 5 in A

~ telnet 10.213.42.153 11211
Trying 10.213.42.153...
Connected to CDCS-213042153.
Escape character is '^]'.
set hello 0 0 5
world
STORED
gets hello
VALUE hello 0 5 3
world
END

then get gets hello from B

~ telnet 10.213.57.166 11211
Trying 10.213.57.166...
Connected to 10.213.57.166.
Escape character is '^]'.
gets hello
VALUE hello 0 5 3
world
END

then set name 0 0 8 in B and gets name in A demonstrated as follows

bi-directional replication

replication demo

by the way, command syntaxes of memcache protocol

<command name> <key> <flags> <exptime> <bytes>/r/n

<data block>/r/n

Clone this wiki locally