Memcached dapat kita gunakan sebagai cache untuk website atau juga dapat kita gunakan untuk menyimpan session PHP. Jika kita memiliki website yang diletakkan dibeda data center, untuk saling berbagi session agar tidak harus login lagi jika user mengakses site di data center yang berbeda.
Berikut langkah-langkahnya :
download & install repcached
1 2 |
# wget https://launchpad.net/~niedbalski/+archive/ubuntu/memcached-repcached/+files/memcached_1.4.14-0ubuntu10repcache3_amd64.deb # dpkg -i memcached_1.4.14-0ubuntu10repcache3_amd64.deb |
setelah diinstall memcached akan langsung berjalan, stop proses memcached yang sedang berjalan
1 |
# killall -9 memcached |
salin konfigurasi dasar memcached ke konfigurasi repcached pada server 1
1 |
# cp /etc/memcached.conf /etc/memcached_server1.conf |
edit konfigurasi repcached
1 |
# vi /etc/memcached_server1.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# Run as daemon -d # Logfile location logfile /var/log/memcached.log # Memory Amount -m 1024 # Connection Port TCP -p 11211 # User under which the daemon will run -u memcache # Bind on IP -l 117.53.44.101 # Connections Limit -c 4096 # Return error when memory is exhausted (rather than removing items) -M # Slave Memcached Server -x 117.53.44.102 |
start service repcached
1 |
# service memcached start |
salin konfigurasi dasar memcached ke konfigurasi repcached pada server 2
1 |
# cp /etc/memcached.conf /etc/memcached_server2.conf |
edit konfigurasi repcached
1 |
# vi /etc/memcached_server2.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# Run as daemon -d # Logfile location logfile /var/log/memcached.log # Memory Amount -m 1024 # Connection Port TCP -p 11211 # User under which the daemon will run -u memcache # Bind on IP -l 117.53.44.102 # Connections Limit -c 4096 # Return error when memory is exhausted (rather than removing items) -M # Slave Memcached Server -x 117.53.44.101 |
start service repcached
1 |
# service memcached start |
verifikasi pada server 1
1 2 3 4 5 6 7 8 9 10 11 |
# telnet 117.53.44.101 11211 Trying 117.53.44.101... Connected to 117.53.44.101. Escape character is '^]'. set rcn 0 0 10 routecloud STORED get rcn VALUE rcn 0 10 routecloud END |
verifikasi pada server 2
1 2 3 4 5 6 7 8 |
# telnet 117.53.44.102 11211 Trying 117.53.44.102... Connected to 117.53.44.102. Escape character is '^]'. get rcn VALUE rcn 0 10 routecloud END |
Komentar