수요일, 5월 22, 2024
HomeLinuxmemcached replication failover test

memcached replication failover test

memcached replication failover 구현에 대한 포스팅입니다.

memcached #1, memcached #2 각 set 후 memcached #2 replication failover

1.memcache #1 server start

/usr/local/memcached_rep/bin/memcached -U 0 -p 11211 -d -v -m 30720 -u root -l 0.0.0.0 -P /usr/local/memcached_rep/memcachedrep.pid -c 32767 -x 192.168.56.41
replication: connect (peer=192.168.56.41:11212)
replication: marugoto copying
replication: close
replication: listen
replication: accept

2.telnet 192.168.56.40 11211

Trying 192.168.56.40...
Connected to 192.168.56.40.
Escape character is '^]'.
stats
STAT pid 3213
STAT uptime 6
STAT time 1423123557
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 0.000294
STAT rusage_system 0.000483
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 3
STAT total_connections 7
STAT connection_structures 4
STAT cmd_flush 0
STAT cmd_get 0
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 7
STAT bytes_written 0
STAT limit_maxbytes 32212254720
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2.1
STAT repcached_qi_free 8192
STAT repcached_wdata 0
STAT repcached_wsize 0
END

3.memcache #2 server start

/usr/local/memcached_rep/bin/memcached -U 0 -p 11211 -d -v -m 30720 -u root -l 0.0.0.0 -P /usr/local/memcached_rep/memcachedrep.pid -c 32767 -x 192.168.56.40
replication: connect (peer=192.168.56.40:11212)
replication: marugoto copying
replication: start

telnet 192.168.56.41 11211

Trying 192.168.56.41...
Connected to 192.168.56.41.
Escape character is '^]'.
stats
STAT pid 3256
STAT uptime 6
STAT time 1423123567
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 0.000370
STAT rusage_system 0.000474
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 5
STAT total_connections 6
STAT connection_structures 6
STAT cmd_flush 0
STAT cmd_get 0
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 21
STAT bytes_written 0
STAT limit_maxbytes 32212254720
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2.1
STAT repcached_qi_free 8192
STAT repcached_wdata 0
STAT repcached_wsize 2048
END

4.set get php sample
vi mt.php


telnet 192.168.56.41 11211
Trying 192.168.56.41...
Connected to 192.168.56.41.
Escape character is '^]'.
stats
STAT pid 3390
STAT uptime 30
STAT time 1423124181
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 0.171504
STAT rusage_system 1.626436
STAT curr_items 30000
STAT total_items 30000
STAT bytes 3900000
STAT curr_connections 5
STAT total_connections 6
STAT connection_structures 6
STAT cmd_flush 0
STAT cmd_get 0
STAT cmd_set 30000
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 2797809
STAT bytes_written 0
STAT limit_maxbytes 32212254720
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2.1
STAT repcached_qi_free 8192
STAT repcached_wdata 0
STAT repcached_wsize 2048
END

memcache #2 down시 memcache #1에서 set 에 대한 테스트

10. memcache #2 kill

ps -elf|grep memcache
1 S webadm    3390     1  1  80   0 -  3896 ep_pol 17:15 ?        00:00:01 /usr/local/memcached_rep/bin/memcached -U 0 -p 11211 -d -v -m 30720 -u root -l 0.0.0.0 -P /usr/local/memcached_rep/memcachedrep.pid -c 32767 -x 192.168.56.40
0 S webadm    3414  3203  0  80   0 -  2616 pipe_w 17:17 pts/3    00:00:00 grep --color=auto memcache
webadm@ubuntu:~$ kill -9 3390

11. memcache #1 set

php set.php -h 127.0.0.1 -p 11211 -op set -c 20000
string(12) "{key : 20000"
Memcached set END 

12. memcache #1 stats

stats
STAT pid 3213
STAT uptime 757
STAT time 1423124308
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 0.540510
STAT rusage_system 2.861457
STAT curr_items 50000
STAT total_items 50000
STAT bytes 6500000
STAT curr_connections 3
STAT total_connections 17
STAT connection_structures 7
STAT cmd_flush 0
STAT cmd_get 0
STAT cmd_set 50000
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 4508922
STAT bytes_written 242068
STAT limit_maxbytes 32212254720
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2.1
STAT repcached_qi_free 8154
STAT repcached_wdata 0
STAT repcached_wsize 0
END

13. memcache #2 start

/usr/local/memcached_rep/bin/memcached -U 0 -p 11211 -d -v -m 30720 -u root -l 0.0.0.0 -P /usr/local/memcached_rep/memcachedrep.pid -c 32767 -x 192.168.56.40
webadm@ubuntu:~$ Could not open the pid file /usr/local/memcached_rep/memcachedrep.pid for writing
replication: connect (peer=192.168.56.40:11212)
replication: marugoto copying
replication: start

14. memcache #2 stats
telnet 192.168.56.41 11211

Trying 192.168.56.41...
Connected to 192.168.56.41.
Escape character is '^]'.
stats
STAT pid 3440
STAT uptime 15
STAT time 1423124382
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 0.111554
STAT rusage_system 1.067313
STAT curr_items 20000       ### mamcache #2 down시 memcache#1에서 set한 20000건은???
STAT total_items 20000      ### 
STAT bytes 2600000
STAT curr_connections 5
STAT total_connections 6
STAT connection_structures 6
STAT cmd_flush 0
STAT cmd_get 0
STAT cmd_set 20000
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 1880021
STAT bytes_written 0
STAT limit_maxbytes 32212254720
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2.1
STAT repcached_qi_free 8192
STAT repcached_wdata 0
STAT repcached_wsize 2048
END

15. memcache #1 stats

stats
STAT pid 3213
STAT uptime 891
STAT time 1423124442
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 0.721090
STAT rusage_system 4.069219
STAT curr_items 20000       ### mamcache #2 down시 memcache#1에서 set한 20000건은???
STAT total_items 50000      ### 
STAT bytes 2600000
STAT curr_connections 5
STAT total_connections 20
STAT connection_structures 7
STAT cmd_flush 0
STAT cmd_get 0
STAT cmd_set 50000
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 4508929
STAT bytes_written 242767
STAT limit_maxbytes 32212254720
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2.1
STAT repcached_qi_free 8154
STAT repcached_wdata 0
STAT repcached_wsize 2048
END

위의 상태에서 memcache #1 down시 에 대한 테스트

16. memcache #1 down

ps -elf|grep memcache
1 S webadm    3213     1  0  80   0 -  4757 ep_pol 17:05 ?        00:00:04 /usr/local/memcached_rep/bin/memcached -U 0 -p 11211 -d -v -m 30720 -u root -l 0.0.0.0 -P /usr/local/memcached_rep/memcachedrep.pid -c 32767 -x 192.168.56.41
0 S webadm    3523  1290  0  80   0 -  2616 pipe_w 17:29 pts/0    00:00:00 grep --color=auto memcache
webadm@ubuntu:~$ kill -9 3213
webadm@ubuntu:~$ /usr/local/memcached_rep/bin/memcached -U 0 -p 11211 -d -v -m 30720 -u root -l 0.0.0.0 -P /usr/local/memcached_rep/memcachedrep.pid -c 32767 -x 192.168.56.41
webadm@ubuntu:~$ Could not open the pid file /usr/local/memcached_rep/memcachedrep.pid for writing
replication: connect (peer=192.168.56.41:11212)
replication: marugoto copying
replication: start

17. memcache #2 stats

stats
STAT pid 3440
STAT uptime 639
STAT time 1423125006
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 0.124990
STAT rusage_system 1.096932
STAT curr_items 0            ### memcache #1 down시 모든 data 초기화됨
STAT total_items 20000
STAT bytes 0
STAT curr_connections 5
STAT total_connections 10
STAT connection_structures 6
STAT cmd_flush 0
STAT cmd_get 0
STAT cmd_set 20000
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 1880063
STAT bytes_written 4184
STAT limit_maxbytes 32212254720
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2.1
STAT repcached_qi_free 8191
STAT repcached_wdata 0
STAT repcached_wsize 2048
END

18. memcache #2 stats

stats
STAT pid 3529
STAT uptime 11
STAT time 1423124998
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 0.000476
STAT rusage_system 0.000583
STAT curr_items 0           ### memcache #1 down시 모든 data 초기화됨
STAT total_items 0
STAT bytes 0
STAT curr_connections 5
STAT total_connections 6
STAT connection_structures 6
STAT cmd_flush 0
STAT cmd_get 0
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 21
STAT bytes_written 0
STAT limit_maxbytes 32212254720
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2.1
STAT repcached_qi_free 8192
STAT repcached_wdata 0
STAT repcached_wsize 2048
END
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Time limit exceeded. Please complete the captcha once again.

Most Popular