dockerÔõô¸´ÖÆredis
ÔÚ docker Öи´ÖÆ redis ÐèÒªÉèÖÃÖ÷´Ó¸´ÖÆ¡£Ïêϸ°ì·¨°üÀ¨£º1. ½¨ÉèÖ÷ redis ÈÝÆ÷£»2. Æô¶¯¸±±¾ÈÝÆ÷²¢ÅþÁ¬µ½Ö÷ÈÝÆ÷£»3. ÑéÖ¤¸´ÖÆ£»4. Ö´ÐйÊÕÏתÒÆ£¨ÈôÊÇÐèÒª£©£»5. À©Õ¹¸±±¾£¨¿ÉÑ¡£©¡£
ÔõÑùÔÚ Docker Öи´ÖÆ Redis
ÔÚ Docker Öи´ÖÆ Redis Éæ¼°½¨ÉèÖ÷´Ó¸´ÖÆÉèÖá£ÒÔÏ°취½«Ö¸µ¼ÄãÍê³É´ËÀú³Ì£º
1. ½¨ÉèÖ÷ Redis ÈÝÆ÷
docker run -d --name redis-master redis:latest
µÇ¼ºó¸´ÖÆ
2. Æô¶¯¸±±¾ÈÝÆ÷²¢ÅþÁ¬µ½Ö÷ÈÝÆ÷
docker run --rm -it --link redis-master:redis redis:latest \ redis-cli --slaveof redis-master 6379
µÇ¼ºó¸´ÖÆ
3. ÑéÖ¤¸´ÖÆ
docker exec redis-master redis-cli info replication
µÇ¼ºó¸´ÖÆ
´ËÏÂÁÔÚÖ÷ÈÝÆ÷ÖÐÊä³öÒÔÏÂÐÅÏ¢£º
connected_slaves:1 slave0:ip=172.17.0.2,port=6379,state=online,offset=14467,lag=0
µÇ¼ºó¸´ÖÆ
4. ¹ÊÕÏתÒÆ
ÈôÊÇÖ÷ÈÝÆ÷±¬·¢¹ÊÕÏ£¬½«×Ô¶¯´¥·¢¹ÊÕÏתÒÆ£¬²¢Ñ¡ÔñÒ»¸ö¸±±¾×÷ΪÐÂÖ÷¡£Äã¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÊÖ¶¯´¥·¢¹ÊÕÏתÒÆ£º
docker exec redis-master redis-cli SLAVEOF NO ONE
µÇ¼ºó¸´ÖÆ
5. À©Õ¹¸±±¾
ÒªÀ©Õ¹¸±±¾ÊýÄ¿£¬ÇëÖظ´°ì·¨ 2¡£Ã¿¸ö¸±±¾½«×Ô¶¯ÅþÁ¬µ½Ö÷ÈÝÆ÷¡£
ÌáÐÑ£º
ʹÓà –net=host ²ÎÊýÔÊÐíÈÝÆ÷Ö±½ÓʹÓÃÖ÷»úµÄÍøÂç¿ÍÕ»£¬´Ó¶ø¼ò»¯ÈÝÆ÷Ö®¼äµÄͨѶ¡£
ΪÈÝÆ÷·ÖÅɳ¤ÆÚÐÔ´æ´¢£¬ÒÔ±£´æÊý¾Ý£¬×ÝÈ»ÈÝÖØÊÓÐÂÆô¶¯»ò±¬·¢¹ÊÕÏ¡£
¼à¿Ø¸´ÖÆÉèÖã¬È·±£ËùÓи±±¾¶¼Õý³£ÔËÐС£
ÒÔÉϾÍÊÇdockerÔõô¸´ÖÆredisµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡