{"id":3331,"date":"2025-03-24T08:46:26","date_gmt":"2025-03-23T23:46:26","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=3331"},"modified":"2025-03-24T08:46:56","modified_gmt":"2025-03-23T23:46:56","slug":"%e3%80%90%e4%bf%9d%e5%ad%98%e7%89%88%e3%80%91redis-sentinel%e3%81%a7%e5%ae%9f%e7%8f%be%e3%81%99%e3%82%8b%e9%ab%98%e5%8f%af%e7%94%a8%e6%80%a7redis%e7%92%b0%e5%a2%83%e3%81%ae%e6%a7%8b%e7%af%89%e3%81%a8","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=3331","title":{"rendered":"\u3010\u4fdd\u5b58\u7248\u3011Redis Sentinel\u3067\u5b9f\u73fe\u3059\u308b\u9ad8\u53ef\u7528\u6027Redis\u74b0\u5883\u306e\u69cb\u7bc9\u3068\u904b\u7528 &#8211; 7\u3064\u306e\u5b9f\u8df5\u30dd\u30a4\u30f3\u30c8"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">Redis Sentinel\u3068\u306f\uff1f\u30b7\u30b9\u30c6\u30e0\u5b89\u5b9a\u6027\u3092\u652f\u3048\u308b\u91cd\u8981\u6a5f\u80fd\u3092\u89e3\u8aac<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">Redis Sentinel\u304c\u89e3\u6c7a\u3059\u308b3\u3064\u306e\u8ab2\u984c<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-2\">\u5f93\u6765\u306eRedis\u69cb\u6210\u3068\u306e\u6bd4\u8f03\u3067\u308f\u304b\u308b\u30e1\u30ea\u30c3\u30c8<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-3\">Redis Sentinel\u306e\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u8a73\u89e3<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-4\">\u30de\u30b9\u30bf\u30fc\u30fb\u30b9\u30ec\u30fc\u30d6\u69cb\u6210\u306e\u4ed5\u7d44\u307f<\/a>      <\/li>      <li>        <a href=\"#i-5\">\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306e\u52d5\u4f5c\u30d7\u30ed\u30bb\u30b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-6\">Sentinel\u30ce\u30fc\u30c9\u306e\u5f79\u5272\u3068\u5fc5\u8981\u6570<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-7\">Redis Sentinel\u74b0\u5883\u306e\u69cb\u7bc9\u624b\u9806<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-8\">\u57fa\u672c\u7684\u306a\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u624b\u9806\u3068\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/a>      <\/li>      <li>        <a href=\"#i-9\">PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u306e\u63a5\u7d9a\u8a2d\u5b9a<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-10\">\u52d5\u4f5c\u78ba\u8a8d\u3068\u30c6\u30b9\u30c8\u65b9\u6cd5<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-11\">Redis Sentinel\u306e\u904b\u7528\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-12\">\u52b9\u679c\u7684\u306a\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-13\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306e\u30dd\u30a4\u30f3\u30c8<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-14\">\u969c\u5bb3\u691c\u77e5\u306e\u95be\u5024\u8a2d\u5b9a<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-15\">PHP\u3067\u306eRedis Sentinel\u6d3b\u7528\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-16\">Predis\u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\u4f8b<\/a>      <\/li>      <li>        <a href=\"#i-17\">PhpRedis\u3067\u306e\u63a5\u7d9a\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-18\">\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-19\">Redis Sentinel\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-20\">\u3088\u304f\u3042\u308b\u969c\u5bb3\u30d1\u30bf\u30fc\u30f3\u3068\u5bfe\u51e6\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-21\">\u30ed\u30b0\u89e3\u6790\u306e\u30dd\u30a4\u30f3\u30c8<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-22\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u4f4e\u4e0b\u6642\u306e\u6539\u5584\u624b\u9806<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-23\">Redis Sentinel\u306e\u767a\u5c55\u7684\u306a\u4f7f\u3044\u65b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-24\">\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u3067\u306e\u69cb\u6210\u4f8b<\/a>      <\/li>      <li>        <a href=\"#i-25\">\u30af\u30e9\u30a6\u30c9\u74b0\u5883\u3067\u306e\u69cb\u7bc9\u30dd\u30a4\u30f3\u30c8<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-26\">\u76e3\u8996\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u9023\u643a\u65b9\u6cd5<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">Redis Sentinel\u3068\u306f\uff1f\u30b7\u30b9\u30c6\u30e0\u5b89\u5b9a\u6027\u3092\u652f\u3048\u308b\u91cd\u8981\u6a5f\u80fd\u3092\u89e3\u8aac<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">Redis Sentinel\u304c\u89e3\u6c7a\u3059\u308b3\u3064\u306e\u8ab2\u984c<\/h3>\n\n\n\n<p>Redis Sentinel\u306f\u3001Redis\u30af\u30e9\u30b9\u30bf\u30fc\u74b0\u5883\u306b\u304a\u3051\u308b\u9ad8\u53ef\u7528\u6027\uff08HA\uff09\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306e\u76e3\u8996\u30fb\u5236\u5fa1\u30b7\u30b9\u30c6\u30e0\u3067\u3059\u3002\u4e3b\u306b\u4ee5\u4e0b\u306e3\u3064\u306e\u91cd\u8981\u306a\u8ab2\u984c\u3092\u89e3\u6c7a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u81ea\u52d5\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306e\u5b9f\u73fe<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30de\u30b9\u30bf\u30fc\u30ce\u30fc\u30c9\u306e\u969c\u5bb3\u3092\u5373\u6642\u306b\u691c\u77e5<\/li>\n\n\n\n<li>\u30b9\u30ec\u30fc\u30d6\u30ce\u30fc\u30c9\u304b\u3089\u6700\u9069\u306a\u65b0\u30de\u30b9\u30bf\u30fc\u3092\u81ea\u52d5\u9078\u51fa<\/li>\n\n\n\n<li>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u63a5\u7d9a\u5148\u3092\u81ea\u52d5\u5207\u308a\u66ff\u3048<\/li>\n\n\n\n<li>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u5b8c\u4e86\u307e\u3067\u306e\u6642\u9593\u3092\u6700\u5c0f\u5316\uff08\u901a\u5e38\u6570\u79d2\u301c\u6570\u5341\u79d2\uff09<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7d99\u7d9a\u7684\u306a\u76e3\u8996\u3068\u30a2\u30e9\u30fc\u30c8<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5404Redis\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u6b7b\u6d3b\u76e3\u8996<\/li>\n\n\n\n<li>\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u72b6\u614b\u306e\u76e3\u8996<\/li>\n\n\n\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5206\u65ad\u306e\u691c\u77e5<\/li>\n\n\n\n<li>\u7570\u5e38\u691c\u77e5\u6642\u306e\u901a\u77e5\u6a5f\u80fd<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30af\u30e9\u30b9\u30bf\u30fc\u69cb\u6210\u306e\u81ea\u52d5\u7ba1\u7406<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30de\u30b9\u30bf\u30fc\/\u30b9\u30ec\u30fc\u30d6\u95a2\u4fc2\u306e\u52d5\u7684\u7ba1\u7406<\/li>\n\n\n\n<li>\u8a2d\u5b9a\u5909\u66f4\u306e\u81ea\u52d5\u540c\u671f<\/li>\n\n\n\n<li>\u30af\u30e9\u30b9\u30bf\u30fc\u30c8\u30dd\u30ed\u30b8\u30fc\u306e\u7dad\u6301\u3068\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u65b0\u898f\u30ce\u30fc\u30c9\u306e\u81ea\u52d5\u691c\u51fa\u3068\u7d71\u5408<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">\u5f93\u6765\u306eRedis\u69cb\u6210\u3068\u306e\u6bd4\u8f03\u3067\u308f\u304b\u308b\u30e1\u30ea\u30c3\u30c8<\/h3>\n\n\n\n<p>\u5f93\u6765\u306eRedis\u69cb\u6210\u3068\u6bd4\u8f03\u3057\u3066\u3001Sentinel\u3092\u5c0e\u5165\u3059\u308b\u3053\u3068\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u660e\u78ba\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u5f97\u3089\u308c\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b7\u30b9\u30c6\u30e0\u53ef\u7528\u6027\u306e\u5927\u5e45\u306a\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n<div id=\"id-41ef7176-3dea-4196-a4f6-a8376aa3892d\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u8a55\u4fa1\u9805\u76ee<\/th><th>\u5f93\u6765\u306e\u69cb\u6210<\/th><th>Sentinel\u69cb\u6210<\/th><\/tr><\/thead><tbody><tr><td>\u969c\u5bb3\u691c\u77e5<\/td><td>\u624b\u52d5\u307e\u305f\u306f\u5916\u90e8\u76e3\u8996\u30c4\u30fc\u30eb<\/td><td>\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u81ea\u52d5\u691c\u77e5<\/td><\/tr><tr><td>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc<\/td><td>\u624b\u52d5\u5207\u308a\u66ff\u3048\u5fc5\u8981<\/td><td>\u5b8c\u5168\u81ea\u52d5\u5316<\/td><\/tr><tr><td>\u30c0\u30a6\u30f3\u30bf\u30a4\u30e0<\/td><td>\u691c\u77e5\u301c\u5fa9\u65e7\u307e\u3067\u9577\u6642\u9593<\/td><td>\u6570\u79d2\u301c\u6570\u5341\u79d2\u306b\u77ed\u7e2e<\/td><\/tr><tr><td>24\u6642\u9593\u904b\u7528<\/td><td>\u904b\u7528\u30c1\u30fc\u30e0\u306e\u5e38\u6642\u5f85\u6a5f\u304c\u5fc5\u8981<\/td><td>\u81ea\u52d5\u5316\u306b\u3088\u308b\u7701\u4eba\u5316<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u904b\u7528\u7ba1\u7406\u306e\u52b9\u7387\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u76e3\u8996\u4f5c\u696d\u306e\u81ea\u52d5\u5316\u306b\u3088\u308b\u904b\u7528\u8ca0\u8377\u306e\u8efd\u6e1b<\/li>\n\n\n\n<li>\u969c\u5bb3\u5bfe\u5fdc\u306e\u6a19\u6e96\u5316\u3068\u81ea\u52d5\u5316<\/li>\n\n\n\n<li>\u69cb\u6210\u5909\u66f4\u4f5c\u696d\u306e\u7c21\u7d20\u5316<\/li>\n\n\n\n<li>\u904b\u7528\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u7c21\u7565\u5316<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b7\u30b9\u30c6\u30e0\u306e\u4fe1\u983c\u6027\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5358\u4e00\u969c\u5bb3\u70b9\u306e\u6392\u9664<\/li>\n\n\n\n<li>\u5206\u6563\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306b\u3088\u308b\u8010\u969c\u5bb3\u6027\u306e\u5411\u4e0a<\/li>\n\n\n\n<li>\u30c7\u30fc\u30bf\u6574\u5408\u6027\u306e\u81ea\u52d5\u691c\u8a3c<\/li>\n\n\n\n<li>\u969c\u5bb3\u5fa9\u65e7\u6642\u9593\u306e\u4e88\u6e2c\u53ef\u80fd\u6027<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u306e\u78ba\u4fdd<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8aad\u307f\u53d6\u308a\u30b9\u30b1\u30fc\u30eb\u30a2\u30a6\u30c8\u306e\u5bb9\u6613\u306a\u5b9f\u73fe<\/li>\n\n\n\n<li>\u30ce\u30fc\u30c9\u306e\u52d5\u7684\u8ffd\u52a0\u30fb\u524a\u9664\u306e\u30b5\u30dd\u30fc\u30c8<\/li>\n\n\n\n<li>\u5730\u7406\u5206\u6563\u69cb\u6210\u3078\u306e\u5bfe\u5fdc<\/li>\n\n\n\n<li>\u6bb5\u968e\u7684\u306a\u6027\u80fd\u62e1\u5f35\u306e\u5b9f\u73fe<\/li>\n<\/ul>\n\n\n\n<p>Sentinel\u30ce\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5206\u6563\u69cb\u6210\u3092\u53d6\u308b\u3053\u3068\u3067\u3001\u76e3\u8996\u30b7\u30b9\u30c6\u30e0\u81ea\u4f53\u306e\u4fe1\u983c\u6027\u3082\u78ba\u4fdd\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">         +----------------+\n         | Sentinel Node 1|\n         +----------------+\n                |\n+----------+    |    +----------+\n|  Redis   |----+----+  Redis   |\n|  Master  |    |    |  Slave   |\n+----------+    |    +----------+\n                |\n         +----------------+\n         | Sentinel Node 2|\n         +----------------+<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001Redis Sentinel\u306f\u5358\u306a\u308b\u76e3\u8996\u30c4\u30fc\u30eb\u3067\u306f\u306a\u304f\u3001Redis\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u81ea\u5f8b\u7684\u306a\u904b\u7528\u3092\u5b9f\u73fe\u3059\u308b\u7d71\u5408\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002\u7279\u306b\u91cd\u8981\u306a\u696d\u52d9\u30b7\u30b9\u30c6\u30e0\u3084\u30b5\u30fc\u30d3\u30b9\u30ec\u30d9\u30eb\u30a2\u30b0\u30ea\u30fc\u30e1\u30f3\u30c8\uff08SLA\uff09\u306e\u53b3\u3057\u3044\u74b0\u5883\u306b\u304a\u3044\u3066\u3001\u305d\u306e\u4fa1\u5024\u3092\u6700\u5927\u9650\u306b\u767a\u63ee\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-3\">Redis Sentinel\u306e\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u8a73\u89e3<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">\u30de\u30b9\u30bf\u30fc\u30fb\u30b9\u30ec\u30fc\u30d6\u69cb\u6210\u306e\u4ed5\u7d44\u307f<\/h3>\n\n\n\n<p>Redis Sentinel\u306b\u304a\u3051\u308b\u30de\u30b9\u30bf\u30fc\u30fb\u30b9\u30ec\u30fc\u30d6\u69cb\u6210\u306f\u3001\u4ee5\u4e0b\u306e\u8981\u7d20\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u57fa\u672c\u69cb\u6210\u8981\u7d20<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30de\u30b9\u30bf\u30fc\u30ce\u30fc\u30c9\uff1a\u66f8\u304d\u8fbc\u307f\/\u8aad\u307f\u53d6\u308a\u53ef\u80fd\u306a\u4e3b\u30ce\u30fc\u30c9<\/li>\n\n\n\n<li>\u30b9\u30ec\u30fc\u30d6\u30ce\u30fc\u30c9\uff1a\u8aad\u307f\u53d6\u308a\u5c02\u7528\u306e\u8907\u88fd\u30ce\u30fc\u30c9<\/li>\n\n\n\n<li>Sentinel\u30ce\u30fc\u30c9\uff1a\u76e3\u8996\u30fb\u5236\u5fa1\u3092\u884c\u3046\u7ba1\u7406\u30ce\u30fc\u30c9<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c7\u30fc\u30bf\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u6d41\u308c<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   [\u30af\u30e9\u30a4\u30a2\u30f3\u30c8] \u2192 [\u30de\u30b9\u30bf\u30fc\u30ce\u30fc\u30c9] \n                    \u2193 \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\n                 [\u30b9\u30ec\u30fc\u30d6\u30ce\u30fc\u30c91]\n                 [\u30b9\u30ec\u30fc\u30d6\u30ce\u30fc\u30c92]<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u540c\u671f\u306e\u4ed5\u7d44\u307f<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u521d\u671f\u540c\u671f\uff1a\u30b9\u30ec\u30fc\u30d6\u8ffd\u52a0\u6642\u306e\u30d5\u30eb\u30c7\u30fc\u30bf\u540c\u671f<\/li>\n\n\n\n<li>\u5dee\u5206\u540c\u671f\uff1a\u901a\u5e38\u904b\u7528\u6642\u306e\u5909\u66f4\u30c7\u30fc\u30bf\u306e\u307f\u540c\u671f<\/li>\n\n\n\n<li>\u30d0\u30c3\u30af\u30ed\u30b0\u7ba1\u7406\uff1a\u5207\u65ad\u6642\u306e\u518d\u540c\u671f\u7528\u30c7\u30fc\u30bf\u4fdd\u6301<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306e\u52d5\u4f5c\u30d7\u30ed\u30bb\u30b9<\/h3>\n\n\n\n<p>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306f\u4ee5\u4e0b\u306e5\u3064\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u969c\u5bb3\u691c\u77e5\u30d5\u30a7\u30fc\u30ba<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Sentinel\u306b\u3088\u308b\u5b9a\u671f\u7684\u306a\u30d8\u30eb\u30b9\u30c1\u30a7\u30c3\u30af<\/li>\n\n\n\n<li>PING\u5fdc\u7b54\u306e\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u76e3\u8996<\/li>\n\n\n\n<li>\u4e3b\u89b3\u7684\u30c0\u30a6\u30f3\uff08SDOWN\uff09\u72b6\u614b\u306e\u5224\u5b9a<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5408\u610f\u5f62\u6210\u30d5\u30a7\u30fc\u30ba<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8907\u6570\u306eSentinel\u306b\u3088\u308b\u72b6\u614b\u78ba\u8a8d<\/li>\n\n\n\n<li>\u5ba2\u89b3\u7684\u30c0\u30a6\u30f3\uff08ODOWN\uff09\u72b6\u614b\u306e\u5224\u5b9a<\/li>\n\n\n\n<li>\u30af\u30a9\u30fc\u30e9\u30e0\u9054\u6210\u306e\u78ba\u8a8d<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30ea\u30fc\u30c0\u30fc\u9078\u51fa\u30d5\u30a7\u30fc\u30ba<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Raft\u5408\u610f\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u3088\u308b\u30ea\u30fc\u30c0\u30fcSentinel\u9078\u51fa<\/li>\n\n\n\n<li>\u9078\u51fa\u3055\u308c\u305fSentinel\u304c\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u3092\u4e3b\u5c0e<\/li>\n\n\n\n<li>\u4e8c\u91cd\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306e\u9632\u6b62<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u65b0\u30de\u30b9\u30bf\u30fc\u9078\u51fa\u30d5\u30a7\u30fc\u30ba<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   \u9078\u51fa\u57fa\u6e96\uff1a\n   1. \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u9045\u5ef6\u304c\u6700\u5c0f\n   2. \u512a\u5148\u5ea6\u304c\u6700\u9ad8\n   3. \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3ID\u304c\u6700\u65b0\n   4. \u30e9\u30f3\u30bf\u30a4\u30e0ID\uff08\u6570\u5024\u7684\u306b\u5c0f\u3055\u3044\u65b9\uff09<\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><strong>\u69cb\u6210\u5909\u66f4\u30d5\u30a7\u30fc\u30ba<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u65b0\u30de\u30b9\u30bf\u30fc\u306e\u6607\u683c\u51e6\u7406<\/li>\n\n\n\n<li>\u4ed6\u30b9\u30ec\u30fc\u30d6\u306e\u518d\u63a5\u7d9a<\/li>\n\n\n\n<li>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u63a5\u7d9a\u306e\u5207\u308a\u66ff\u3048<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">Sentinel\u30ce\u30fc\u30c9\u306e\u5f79\u5272\u3068\u5fc5\u8981\u6570<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4e3b\u8981\u306a\u5f79\u5272<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u76e3\u8996\uff1a\u5404Redis\u30ce\u30fc\u30c9\u306e\u72b6\u614b\u76e3\u8996<\/li>\n\n\n\n<li>\u901a\u77e5\uff1a\u7ba1\u7406\u8005\u3078\u306e\u969c\u5bb3\u901a\u77e5<\/li>\n\n\n\n<li>\u81ea\u52d5\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\uff1a\u969c\u5bb3\u6642\u306e\u81ea\u52d5\u5fa9\u65e7<\/li>\n\n\n\n<li>\u69cb\u6210\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\uff1a\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3078\u306e\u63a5\u7d9a\u60c5\u5831\u63d0\u4f9b<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u63a8\u5968\u3055\u308c\u308b\u30ce\u30fc\u30c9\u6570<\/strong> \u30c7\u30d7\u30ed\u30a4\u30e1\u30f3\u30c8\u898f\u6a21 \u63a8\u5968Sentinel\u6570 \u30af\u30a9\u30fc\u30e9\u30e0\u5024 \u958b\u767a\u74b0\u5883 3 2 \u5c0f\u898f\u6a21\u672c\u756a\u74b0\u5883 3\u301c5 2\u301c3 \u5927\u898f\u6a21\u672c\u756a\u74b0\u5883 5\u301c7 3\u301c4 \u5730\u7406\u5206\u6563\u74b0\u5883 7\u4ee5\u4e0a 4\u4ee5\u4e0a<\/li>\n\n\n\n<li><strong>\u914d\u7f6e\u306e\u8003\u616e\u70b9<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7570\u306a\u308b\u7269\u7406\u30b5\u30fc\u30d0\u30fc\u3078\u306e\u5206\u6563\u914d\u7f6e<\/li>\n\n\n\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30b0\u30e1\u30f3\u30c8\u306e\u5206\u6563<\/li>\n\n\n\n<li>\u96fb\u6e90\u7cfb\u7d71\u306e\u5206\u6563<\/li>\n\n\n\n<li>\u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u3092\u307e\u305f\u3050\u914d\u7f6e<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u5f71\u97ff<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   \u76e3\u8996\u9593\u9694\uff1a1\u79d2\n   \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\uff1a30\u79d2\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\uff09\n   \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5e2f\u57df\uff1a\u7d041KB\/\u79d2\/\u30ce\u30fc\u30c9\n   CPU\u4f7f\u7528\u7387\uff1a1%\u672a\u6e80\uff08\u901a\u5e38\u6642\uff09<\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><strong>\u9ad8\u5ea6\u306a\u8a2d\u5b9a\u30aa\u30d7\u30b7\u30e7\u30f3<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30c0\u30a6\u30f3\u691c\u77e5\u306e\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8abf\u6574<\/li>\n\n\n\n<li>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u5b9f\u884c\u306e\u6761\u4ef6\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u3088\u308b\u5916\u90e8\u9023\u643a<\/li>\n\n\n\n<li>\u30ab\u30b9\u30bf\u30e0\u901a\u77e5\u306e\u8a2d\u5b9a<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306b\u3088\u308a\u3001Redis Sentinel\u306f\u9ad8\u3044\u4fe1\u983c\u6027\u3068\u53ef\u7528\u6027\u3092\u5b9f\u73fe\u3057\u3066\u3044\u307e\u3059\u3002\u9069\u5207\u306a\u69cb\u6210\u3068\u30d1\u30e9\u30e1\u30fc\u30bf\u8a2d\u5b9a\u306b\u3088\u308a\u3001\u3055\u307e\u3056\u307e\u306a\u904b\u7528\u8981\u4ef6\u306b\u5bfe\u5fdc\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-7\">Redis Sentinel\u74b0\u5883\u306e\u69cb\u7bc9\u624b\u9806<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u57fa\u672c\u7684\u306a\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u624b\u9806\u3068\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Redis\u672c\u4f53\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Ubuntu\u306e\u5834\u5408\nsudo apt-get update\nsudo apt-get install redis-server\n\n# CentOS\u306e\u5834\u5408\nsudo yum install epel-release\nsudo yum install redis<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30de\u30b9\u30bf\u30fc\u30ce\u30fc\u30c9\u306e\u8a2d\u5b9a\uff08redis.conf\uff09<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u57fa\u672c\u8a2d\u5b9a\nbind 0.0.0.0\nport 6379\ndaemonize yes\npidfile \/var\/run\/redis\/redis-server.pid\n\n# \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u95a2\u9023\nrequirepass \"master_password\"\nmasterauth \"master_password\"\n\n# \u6c38\u7d9a\u5316\u8a2d\u5b9a\nappendonly yes\nappendfilename \"appendonly.aof\"<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30b9\u30ec\u30fc\u30d6\u30ce\u30fc\u30c9\u306e\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u57fa\u672c\u8a2d\u5b9a\uff08redis.conf\uff09\nport 6380\ndaemonize yes\npidfile \/var\/run\/redis\/redis-server.pid\n\n# \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u8a2d\u5b9a\nreplicaof 192.168.1.100 6379\nmasterauth \"master_password\"<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Sentinel\u306e\u8a2d\u5b9a\uff08sentinel.conf\uff09<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Sentinel\u306e\u57fa\u672c\u8a2d\u5b9a\nport 26379\ndaemonize yes\nsentinel monitor mymaster 192.168.1.100 6379 2\nsentinel auth-pass mymaster master_password\n\n# \u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u95a2\u9023\u8a2d\u5b9a\nsentinel down-after-milliseconds mymaster 5000\nsentinel failover-timeout mymaster 60000\nsentinel parallel-syncs mymaster 1<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-9\">PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u306e\u63a5\u7d9a\u8a2d\u5b9a<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Predis\u3092\u4f7f\u7528\u3057\u305f\u63a5\u7d9a\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ Composer\u3067\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n\/\/ composer require predis\/predis\n\n\/\/ Sentinel\u3092\u4f7f\u7528\u3057\u305f\u63a5\u7d9a\u8a2d\u5b9a\n$sentinels = [\n    'tcp:\/\/192.168.1.100:26379',\n    'tcp:\/\/192.168.1.101:26379',\n    'tcp:\/\/192.168.1.102:26379'\n];\n\n$options = [\n    'replication' =&gt; 'sentinel',\n    'service' =&gt; 'mymaster',\n    'parameters' =&gt; [\n        'password' =&gt; 'master_password'\n    ]\n];\n\ntry {\n    $client = new Predis\\Client($sentinels, $options);\n    \/\/ \u63a5\u7d9a\u30c6\u30b9\u30c8\n    $client-&gt;ping();\n} catch (Exception $e) {\n    \/\/ \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n    error_log('Redis\u63a5\u7d9a\u30a8\u30e9\u30fc: ' . $e-&gt;getMessage());\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>PhpRedis\u3092\u4f7f\u7528\u3057\u305f\u63a5\u7d9a\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ PhpRedis\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n\/\/ pecl install redis\n\n\/\/ Sentinel\u3092\u4f7f\u7528\u3057\u305f\u63a5\u7d9a\n$redis = new Redis();\n$sentinel = new RedisSentinel('192.168.1.100', 26379);\n\ntry {\n    \/\/ \u30de\u30b9\u30bf\u30fc\u306e\u53d6\u5f97\n    $master = $sentinel-&gt;getMasterAddrByName('mymaster');\n\n    \/\/ \u30de\u30b9\u30bf\u30fc\u3078\u306e\u63a5\u7d9a\n    $redis-&gt;connect($master[0], $master[1]);\n    $redis-&gt;auth('master_password');\n} catch (RedisException $e) {\n    error_log('Sentinel\u63a5\u7d9a\u30a8\u30e9\u30fc: ' . $e-&gt;getMessage());\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u52d5\u4f5c\u78ba\u8a8d\u3068\u30c6\u30b9\u30c8\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u57fa\u672c\u7684\u306a\u52d5\u4f5c\u78ba\u8a8d<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Sentinel\u306e\u72b6\u614b\u78ba\u8a8d\nredis-cli -p 26379\nsentinel master mymaster\n\n# \u30de\u30b9\u30bf\u30fc\u306e\u72b6\u614b\u78ba\u8a8d\nredis-cli -h 192.168.1.100 -p 6379 info replication\n\n# \u30b9\u30ec\u30fc\u30d6\u306e\u72b6\u614b\u78ba\u8a8d\nredis-cli -h 192.168.1.101 -p 6380 info replication<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u30c6\u30b9\u30c8<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ PHP\u3067\u306e\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8\n&lt;?php\n$redis = new Redis();\n$sentinel = new RedisSentinel('192.168.1.100', 26379);\n\n\/\/ \u63a5\u7d9a\u7dad\u6301\u30eb\u30fc\u30d7\nwhile (true) {\n    try {\n        $master = $sentinel-&gt;getMasterAddrByName('mymaster');\n        $redis-&gt;connect($master[0], $master[1]);\n        $redis-&gt;auth('master_password');\n\n        \/\/ \u30c7\u30fc\u30bf\u66f8\u304d\u8fbc\u307f\u30c6\u30b9\u30c8\n        $redis-&gt;set('test_key', date('Y-m-d H:i:s'));\n        echo \"\u66f8\u304d\u8fbc\u307f\u6210\u529f: \" . $redis-&gt;get('test_key') . \"\\n\";\n\n        sleep(1);\n    } catch (Exception $e) {\n        echo \"\u30a8\u30e9\u30fc\u767a\u751f: \" . $e-&gt;getMessage() . \"\\n\";\n        echo \"\u518d\u63a5\u7d9a\u3092\u8a66\u307f\u307e\u3059...\\n\";\n        sleep(1);\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8<\/strong><\/li>\n<\/ol>\n\n\n<div id=\"id-083e1f6f-8c86-4059-9921-f86dd32428ca\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u78ba\u8a8d\u9805\u76ee<\/th><th>\u78ba\u8a8d\u65b9\u6cd5<\/th><th>\u671f\u5f85\u5024<\/th><\/tr><\/thead><tbody><tr><td>\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u72b6\u614b<\/td><td>info replication<\/td><td>role:master\/slave<\/td><\/tr><tr><td>Sentinel\u76e3\u8996\u72b6\u614b<\/td><td>sentinel master mymaster<\/td><td>flags:master<\/td><\/tr><tr><td>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u52d5\u4f5c<\/td><td>\u30de\u30b9\u30bf\u30fc\u505c\u6b62\u30c6\u30b9\u30c8<\/td><td>\u81ea\u52d5\u5207\u308a\u66ff\u3048<\/td><\/tr><tr><td>\u30c7\u30fc\u30bf\u6574\u5408\u6027<\/td><td>\u30ad\u30fc\u5024\u306e\u6bd4\u8f03<\/td><td>\u5168\u30ce\u30fc\u30c9\u3067\u4e00\u81f4<\/td><\/tr><tr><td>\u6027\u80fd<\/td><td>\u30ec\u30a4\u30c6\u30f3\u30b7\u30c1\u30a7\u30c3\u30af<\/td><td>1ms\u4ee5\u4e0b<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u76e3\u8996\u9805\u76ee\u306e\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Sentinel\u306e\u8a73\u7d30\u306a\u76e3\u8996\u8a2d\u5b9a\nsentinel notification-script mymaster \/etc\/redis\/notify.sh\nsentinel client-reconfig-script mymaster \/etc\/redis\/reconfig.sh\nsentinel down-after-milliseconds mymaster 5000<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u69cb\u6210\u3067\u3001\u9ad8\u53ef\u7528\u6027\u3092\u5099\u3048\u305fRedis Sentinel\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5b9f\u904b\u7528\u3067\u306f\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u5206\u96e2\u3084\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a2d\u5b9a\u306a\u3069\u3082\u8003\u616e\u306b\u5165\u308c\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-11\">Redis Sentinel\u306e\u904b\u7528\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u52b9\u679c\u7684\u306a\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b7\u30b9\u30c6\u30e0\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u76e3\u8996<\/strong><\/li>\n<\/ol>\n\n\n<div id=\"id-3282c2e8-d07c-422f-9e05-bfbcd5b3e415\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30e1\u30c8\u30ea\u30af\u30b9<\/th><th>\u76e3\u8996\u9805\u76ee<\/th><th>\u8b66\u544a\u95be\u5024<\/th><th>\u5371\u967a\u95be\u5024<\/th><\/tr><\/thead><tbody><tr><td>\u30e1\u30e2\u30ea\u4f7f\u7528\u7387<\/td><td>used_memory_rss<\/td><td>80%<\/td><td>90%<\/td><\/tr><tr><td>CPU\u4f7f\u7528\u7387<\/td><td>cpu_sys<\/td><td>70%<\/td><td>85%<\/td><\/tr><tr><td>\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u9045\u5ef6<\/td><td>master_repl_offset<\/td><td>1000<\/td><td>5000<\/td><\/tr><tr><td>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u63a5\u7d9a\u6570<\/td><td>connected_clients<\/td><td>5000<\/td><td>8000<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Prometheus\u306b\u3088\u308b\u76e3\u8996\u8a2d\u5b9a\u4f8b<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># prometheus.yml\nscrape_configs:\n  - job_name: 'redis_exporter'\n    static_configs:\n      - targets: ['localhost:9121']\n    metrics_path: \/metrics\n    relabel_configs:\n      - source_labels: [__address__]\n        target_label: instance<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Grafana\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306e\u63a8\u5968\u30d1\u30cd\u30eb<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30de\u30b9\u30bf\u30fc\/\u30b9\u30ec\u30fc\u30d6\u306e\u72b6\u614b<\/li>\n\n\n\n<li>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306e\u767a\u751f\u56de\u6570<\/li>\n\n\n\n<li>\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u30ec\u30a4\u30c6\u30f3\u30b7<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u72b6\u6cc1<\/li>\n\n\n\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30afI\/O<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306e\u30dd\u30a4\u30f3\u30c8<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u7ba1\u7406\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># redis.conf\nmaxmemory 8gb\nmaxmemory-policy allkeys-lru\nmaxmemory-samples 10\n\n# \u30b7\u30b9\u30c6\u30e0\u8a2d\u5b9a\nvm.overcommit_memory = 1\nvm.swappiness = 0<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u8a2d\u5b9a\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30b7\u30b9\u30c6\u30e0\u8a2d\u5b9a\nnet.core.somaxconn = 65535\nnet.ipv4.tcp_max_syn_backlog = 65535\nnet.ipv4.tcp_keepalive_time = 300\n\n# redis.conf\ntcp-keepalive 300\ntcp-backlog 65535<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u6c38\u7d9a\u5316\u8a2d\u5b9a\u306e\u8abf\u6574<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># AOF\u8a2d\u5b9a\nappendonly yes\nappendfsync everysec\nno-appendfsync-on-rewrite yes\nauto-aof-rewrite-percentage 100\nauto-aof-rewrite-min-size 64mb\n\n# RDB\u8a2d\u5b9a\nsave 900 1\nsave 300 10\nsave 60 10000<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u969c\u5bb3\u691c\u77e5\u306e\u95be\u5024\u8a2d\u5b9a<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Sentinel\u57fa\u672c\u8a2d\u5b9a\u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># sentinel.conf\n\n# \u30c0\u30a6\u30f3\u691c\u77e5\u306e\u57fa\u672c\u8a2d\u5b9a\nsentinel down-after-milliseconds mymaster 5000\nsentinel failover-timeout mymaster 60000\n\n# \u30af\u30a9\u30fc\u30e9\u30e0\u8a2d\u5b9a\nsentinel monitor mymaster 192.168.1.100 6379 2\n\n# \u4e26\u5217\u540c\u671f\u6570\nsentinel parallel-syncs mymaster 1\n\n# \u901a\u77e5\u30b9\u30af\u30ea\u30d7\u30c8\nsentinel notification-script mymaster \/etc\/redis\/notify.sh<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u74b0\u5883\u5225\u306e\u63a8\u5968\u95be\u5024<\/strong><\/li>\n<\/ol>\n\n\n<div id=\"id-5dc935b8-76f6-44a6-87d0-fa7d8883acfd\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u74b0\u5883<\/th><th>down-after-milliseconds<\/th><th>failover-timeout<\/th><th>parallel-syncs<\/th><\/tr><\/thead><tbody><tr><td>\u958b\u767a<\/td><td>5000<\/td><td>60000<\/td><td>1<\/td><\/tr><tr><td>\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0<\/td><td>10000<\/td><td>180000<\/td><td>1<\/td><\/tr><tr><td>\u672c\u756a\uff08\u6a19\u6e96\uff09<\/td><td>15000<\/td><td>300000<\/td><td>1<\/td><\/tr><tr><td>\u672c\u756a\uff08\u5927\u898f\u6a21\uff09<\/td><td>30000<\/td><td>600000<\/td><td>2<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30ab\u30b9\u30bf\u30e0\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u88c5\u4f8b<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n# \/etc\/redis\/notify.sh\n\n# \u969c\u5bb3\u901a\u77e5\u30b9\u30af\u30ea\u30d7\u30c8\nEVENT_TYPE=$1\nEVENT_DESC=$2\nMASTER_NAME=$3\nMASTER_IP=$4\nMASTER_PORT=$5\n\n# Slack\u901a\u77e5\ncurl -X POST -H 'Content-type: application\/json' \\\n--data \"{\\\"text\\\":\\\"Redis Sentinel Event\\nType: $EVENT_TYPE\\nDesc: $EVENT_DESC\\nMaster: $MASTER_NAME ($MASTER_IP:$MASTER_PORT)\\\"}\" \\\nhttps:\/\/hooks.slack.com\/services\/YOUR\/WEBHOOK\/URL\n\n# \u30e1\u30fc\u30eb\u901a\u77e5\necho \"Redis Sentinel Event\\nType: $EVENT_TYPE\\nDesc: $EVENT_DESC\\nMaster: $MASTER_NAME ($MASTER_IP:$MASTER_PORT)\" | \\\nmail -s \"Redis Sentinel Alert\" admin@example.com<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u7570\u5e38\u691c\u77e5\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8907\u6570\u306eSentinel\u30ce\u30fc\u30c9\u3067\u306e\u5408\u610f\u5f62\u6210\u3092\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5206\u65ad\u3092\u8003\u616e\u3057\u305f\u95be\u5024\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u8aa4\u691c\u77e5\u3092\u9632\u3050\u305f\u3081\u306e\u9069\u5207\u306a\u9045\u5ef6\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u74b0\u5883\u306b\u5fdc\u3058\u305f\u6bb5\u968e\u7684\u306a\u95be\u5024\u8abf\u6574<\/li>\n<\/ul>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u76e3\u8996\u8a2d\u5b9a\u306e\u4f8b\uff08Zabbix\uff09<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Zabbix\u30c8\u30ea\u30ac\u30fc\u8a2d\u5b9a\n- \u540d\u524d: Redis Sentinel\u30de\u30b9\u30bf\u30fc\u30c0\u30a6\u30f3\n  \u6761\u4ef6: {redis.sentinel.master.status} = 0\n  \u91cd\u8981\u5ea6: \u9ad8\n\n- \u540d\u524d: Redis Sentinel\u30af\u30a9\u30fc\u30e9\u30e0\u672a\u9054\n  \u6761\u4ef6: {redis.sentinel.quorum.status} &lt; {$MIN_QUORUM}\n  \u91cd\u8981\u5ea6: \u8b66\u544a\n\n- \u540d\u524d: Redis\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u9045\u5ef6\n  \u6761\u4ef6: {redis.replication.delay} &gt; 1000\n  \u91cd\u8981\u5ea6: \u8b66\u544a<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u8a2d\u5b9a\u3068\u76e3\u8996\u306b\u3088\u308a\u3001Redis Sentinel\u306e\u5b89\u5b9a\u904b\u7528\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002\u5b9f\u969b\u306e\u904b\u7528\u3067\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u898f\u6a21\u3084\u8981\u4ef6\u306b\u5fdc\u3058\u3066\u9069\u5207\u306b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-15\">PHP\u3067\u306eRedis Sentinel\u6d3b\u7528\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">Predis\u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\u4f8b<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u57fa\u672c\u7684\u306a\u63a5\u7d9a\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nrequire 'vendor\/autoload.php';\n\nclass RedisSentinelConnection {\n    private $client;\n    private $sentinels = [\n        'tcp:\/\/192.168.1.100:26379',\n        'tcp:\/\/192.168.1.101:26379',\n        'tcp:\/\/192.168.1.102:26379'\n    ];\n\n    private $options = [\n        'replication' =&gt; 'sentinel',\n        'service' =&gt; 'mymaster',\n        'parameters' =&gt; [\n            'password' =&gt; 'master_password',\n            'database' =&gt; 0\n        ],\n        'prefix' =&gt; 'app:',\n    ];\n\n    public function __construct() {\n        try {\n            $this-&gt;client = new Predis\\Client($this-&gt;sentinels, $this-&gt;options);\n        } catch (Exception $e) {\n            $this-&gt;handleConnectionError($e);\n        }\n    }\n\n    private function handleConnectionError($e) {\n        error_log(\"Redis\u63a5\u7d9a\u30a8\u30e9\u30fc: \" . $e-&gt;getMessage());\n        \/\/ \u30ea\u30c8\u30e9\u30a4\u30ed\u30b8\u30c3\u30af\u3084\u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\u51e6\u7406\u3092\u5b9f\u88c5\n    }\n\n    public function getClient() {\n        return $this-&gt;client;\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30bb\u30c3\u30b7\u30e7\u30f3\u7ba1\u7406\u3067\u306e\u6d3b\u7528\u4f8b<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nclass RedisSessionHandler implements SessionHandlerInterface {\n    private $redis;\n    private $ttl;\n\n    public function __construct(RedisSentinelConnection $connection, $ttl = 3600) {\n        $this-&gt;redis = $connection-&gt;getClient();\n        $this-&gt;ttl = $ttl;\n    }\n\n    public function open($path, $name): bool {\n        return true;\n    }\n\n    public function close(): bool {\n        return true;\n    }\n\n    public function read($id): string {\n        $data = $this-&gt;redis-&gt;get(\"session:$id\");\n        return $data ?: '';\n    }\n\n    public function write($id, $data): bool {\n        return $this-&gt;redis-&gt;setex(\"session:$id\", $this-&gt;ttl, $data);\n    }\n\n    public function destroy($id): bool {\n        $this-&gt;redis-&gt;del(\"session:$id\");\n        return true;\n    }\n\n    public function gc($max_lifetime): bool {\n        return true; \/\/ Redis\u306e\u6709\u52b9\u671f\u9650\u6a5f\u80fd\u306b\u3088\u308a\u81ea\u52d5\u7684\u306b\u51e6\u7406\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$connection = new RedisSentinelConnection();\n$handler = new RedisSessionHandler($connection);\nsession_set_save_handler($handler, true);\nsession_start();<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30ad\u30e3\u30c3\u30b7\u30e5\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\u4f8b<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nclass RedisCache {\n    private $redis;\n    private $defaultTtl;\n\n    public function __construct(RedisSentinelConnection $connection, $defaultTtl = 3600) {\n        $this-&gt;redis = $connection-&gt;getClient();\n        $this-&gt;defaultTtl = $defaultTtl;\n    }\n\n    public function get($key) {\n        try {\n            $value = $this-&gt;redis-&gt;get($key);\n            return $value ? json_decode($value, true) : null;\n        } catch (Exception $e) {\n            error_log(\"\u30ad\u30e3\u30c3\u30b7\u30e5\u53d6\u5f97\u30a8\u30e9\u30fc: \" . $e-&gt;getMessage());\n            return null;\n        }\n    }\n\n    public function set($key, $value, $ttl = null) {\n        try {\n            $ttl = $ttl ?: $this-&gt;defaultTtl;\n            $serialized = json_encode($value);\n            return $this-&gt;redis-&gt;setex($key, $ttl, $serialized);\n        } catch (Exception $e) {\n            error_log(\"\u30ad\u30e3\u30c3\u30b7\u30e5\u8a2d\u5b9a\u30a8\u30e9\u30fc: \" . $e-&gt;getMessage());\n            return false;\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">PhpRedis\u3067\u306e\u63a5\u7d9a\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u57fa\u672c\u7684\u306a\u63a5\u7d9a\u51e6\u7406<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nclass RedisSentinelManager {\n    private $sentinels = [\n        ['host' =&gt; '192.168.1.100', 'port' =&gt; 26379],\n        ['host' =&gt; '192.168.1.101', 'port' =&gt; 26379],\n        ['host' =&gt; '192.168.1.102', 'port' =&gt; 26379]\n    ];\n\n    private $masterName = 'mymaster';\n    private $password = 'master_password';\n\n    public function getMasterConnection(): Redis {\n        $redis = new Redis();\n\n        foreach ($this-&gt;sentinels as $sentinel) {\n            try {\n                $sentinel = new RedisSentinel($sentinel['host'], $sentinel['port']);\n                $master = $sentinel-&gt;getMasterAddrByName($this-&gt;masterName);\n\n                if ($master) {\n                    $redis-&gt;connect($master[0], $master[1]);\n                    $redis-&gt;auth($this-&gt;password);\n                    return $redis;\n                }\n            } catch (RedisException $e) {\n                continue;\n            }\n        }\n\n        throw new Exception('\u5229\u7528\u53ef\u80fd\u306a\u30de\u30b9\u30bf\u30fc\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093');\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30ea\u30c8\u30e9\u30a4\u30e1\u30ab\u30cb\u30ba\u30e0\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nclass RedisRetryWrapper {\n    private $connection;\n    private $maxRetries;\n    private $retryDelay;\n\n    public function __construct($connection, $maxRetries = 3, $retryDelay = 100) {\n        $this-&gt;connection = $connection;\n        $this-&gt;maxRetries = $maxRetries;\n        $this-&gt;retryDelay = $retryDelay;\n    }\n\n    public function executeWithRetry(callable $operation) {\n        $attempts = 0;\n        $lastException = null;\n\n        while ($attempts &lt; $this-&gt;maxRetries) {\n            try {\n                return $operation($this-&gt;connection);\n            } catch (Exception $e) {\n                $lastException = $e;\n                $attempts++;\n\n                if ($attempts &lt; $this-&gt;maxRetries) {\n                    usleep($this-&gt;retryDelay * 1000 * $attempts);\n                    $this-&gt;reconnect();\n                }\n            }\n        }\n\n        throw new Exception(\n            \"\u64cd\u4f5c\u304c\u5931\u6557\u3057\u307e\u3057\u305f\u3002\u8a66\u884c\u56de\u6570: $attempts, \" .\n            \"\u6700\u5f8c\u306e\u30a8\u30e9\u30fc: \" . $lastException-&gt;getMessage()\n        );\n    }\n\n    private function reconnect() {\n        \/\/ \u518d\u63a5\u7d9a\u30ed\u30b8\u30c3\u30af\u306e\u5b9f\u88c5\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$wrapper = new RedisRetryWrapper($redisConnection);\n$result = $wrapper-&gt;executeWithRetry(function($redis) {\n    return $redis-&gt;get('important_key');\n});<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b5\u30fc\u30ad\u30c3\u30c8\u30d6\u30ec\u30fc\u30ab\u30fc\u30d1\u30bf\u30fc\u30f3\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nclass RedisCircuitBreaker {\n    private $failureThreshold;\n    private $resetTimeout;\n    private $failures = 0;\n    private $lastFailureTime = 0;\n    private $state = 'CLOSED';\n\n    public function __construct($failureThreshold = 5, $resetTimeout = 60) {\n        $this-&gt;failureThreshold = $failureThreshold;\n        $this-&gt;resetTimeout = $resetTimeout;\n    }\n\n    public function execute(callable $operation) {\n        $this-&gt;checkState();\n\n        if ($this-&gt;state === 'OPEN') {\n            throw new Exception('Circuit Breaker is OPEN');\n        }\n\n        try {\n            $result = $operation();\n            $this-&gt;recordSuccess();\n            return $result;\n        } catch (Exception $e) {\n            $this-&gt;recordFailure();\n            throw $e;\n        }\n    }\n\n    private function checkState() {\n        if ($this-&gt;state === 'OPEN' &amp;&amp; \n            time() - $this-&gt;lastFailureTime &gt;= $this-&gt;resetTimeout) {\n            $this-&gt;state = 'HALF-OPEN';\n        }\n    }\n\n    private function recordSuccess() {\n        if ($this-&gt;state === 'HALF-OPEN') {\n            $this-&gt;state = 'CLOSED';\n            $this-&gt;failures = 0;\n        }\n    }\n\n    private function recordFailure() {\n        $this-&gt;failures++;\n        $this-&gt;lastFailureTime = time();\n\n        if ($this-&gt;failures &gt;= $this-&gt;failureThreshold) {\n            $this-&gt;state = 'OPEN';\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306b\u3088\u308a\u3001PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067Redis Sentinel\u3092\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5b9f\u969b\u306e\u904b\u7528\u3067\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u8981\u4ef6\u306b\u5fdc\u3058\u3066\u9069\u5207\u306b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-19\">Redis Sentinel\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">\u3088\u304f\u3042\u308b\u969c\u5bb3\u30d1\u30bf\u30fc\u30f3\u3068\u5bfe\u51e6\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306e\u5931\u6557<\/strong><\/li>\n<\/ol>\n\n\n<div id=\"id-e79c71b9-f47c-4bfe-81ad-18270d9c6da8\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u75c7\u72b6<\/th><th>\u8003\u3048\u3089\u308c\u308b\u539f\u56e0<\/th><th>\u5bfe\u51e6\u65b9\u6cd5<\/th><\/tr><\/thead><tbody><tr><td>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u304c\u958b\u59cb\u3055\u308c\u306a\u3044<\/td><td>\u30af\u30a9\u30fc\u30e9\u30e0\u4e0d\u8db3<\/td><td>Sentinel\u306e\u7a3c\u50cd\u6570\u78ba\u8a8d\u3068\u5fa9\u65e7<\/td><\/tr><tr><td>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u304c\u9014\u4e2d\u3067\u505c\u6b62<\/td><td>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5206\u65ad<\/td><td>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u72b6\u614b\u306e\u78ba\u8a8d\u3068\u4fee\u5fa9<\/td><\/tr><tr><td>\u8aa4\u3063\u305f\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u767a\u751f<\/td><td>\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u304c\u53b3\u3057\u3059\u304e\u308b<\/td><td>down-after-milliseconds\u306e\u8abf\u6574<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306e\u72b6\u614b\u78ba\u8a8d\nredis-cli -p 26379\nsentinel masters    # \u30de\u30b9\u30bf\u30fc\u306e\u72b6\u614b\u78ba\u8a8d\nsentinel slaves mymaster    # \u30b9\u30ec\u30fc\u30d6\u306e\u72b6\u614b\u78ba\u8a8d\n\n# \u30af\u30a9\u30fc\u30e9\u30e0\u306e\u78ba\u8a8d\nredis-cli -p 26379 sentinel ckquorum mymaster<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u9045\u5ef6<\/strong><\/li>\n<\/ol>\n\n\n\n<p>\u78ba\u8a8d\u30b3\u30de\u30f3\u30c9\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30de\u30b9\u30bf\u30fc\u3067\u306e\u78ba\u8a8d\nredis-cli -h master_host info replication\n\n# \u30b9\u30ec\u30fc\u30d6\u3067\u306e\u78ba\u8a8d\nredis-cli -h slave_host info replication | grep -E \"master_repl_offset|slave_repl_offset\"<\/pre>\n\n\n\n<p>\u5bfe\u51e6\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># redis.conf\uff08\u30b9\u30ec\u30fc\u30d6\u5074\uff09\nclient-output-buffer-limit slave 256mb 64mb 60\nrepl-backlog-size 512mb<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u95a2\u9023\u306e\u554f\u984c<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30e1\u30e2\u30ea\u4f7f\u7528\u72b6\u6cc1\u306e\u78ba\u8a8d\nredis-cli info memory\n\n# \u30e1\u30e2\u30ea\u30dd\u30ea\u30b7\u30fc\u306e\u78ba\u8a8d\u3068\u8a2d\u5b9a\nredis-cli config get maxmemory-policy\nredis-cli config set maxmemory-policy allkeys-lru<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">\u30ed\u30b0\u89e3\u6790\u306e\u30dd\u30a4\u30f3\u30c8<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u91cd\u8981\u306a\u30ed\u30b0\u30d1\u30bf\u30fc\u30f3<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Sentinel\u30ed\u30b0\n+sdown    # \u4e3b\u89b3\u7684\u30c0\u30a6\u30f3\u306e\u691c\u77e5\n+odown    # \u5ba2\u89b3\u7684\u30c0\u30a6\u30f3\u306e\u691c\u77e5\n+try-failover    # \u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u8a66\u884c\n+failover-state    # \u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u72b6\u614b\u306e\u5909\u66f4\n+switch-master    # \u30de\u30b9\u30bf\u30fc\u5207\u308a\u66ff\u3048\u306e\u5b9f\u884c<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30ed\u30b0\u53ce\u96c6\u3068\u5206\u6790\u30c4\u30fc\u30eb\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># fluent.conf\n&lt;source&gt;\n  @type tail\n  path \/var\/log\/redis\/sentinel.log\n  tag redis.sentinel\n  &lt;parse&gt;\n    @type regexp\n    expression \/(?&lt;time&gt;\\d{1,2}:\\d{1,2}:\\d{1,2}) (?&lt;pid&gt;\\d+):(?&lt;role&gt;[X,C,S]) (?&lt;message&gt;.*)\/\n  &lt;\/parse&gt;\n&lt;\/source&gt;\n\n&lt;match redis.sentinel&gt;\n  @type elasticsearch\n  host elasticsearch.example.com\n  port 9200\n  index_name redis-sentinel-logs\n  type_name redis_log\n&lt;\/match&gt;<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u76e3\u8996\u3059\u3079\u304d\u30ed\u30b0\u30e1\u30c3\u30bb\u30fc\u30b8<\/strong><\/li>\n<\/ol>\n\n\n<div id=\"id-66b40df5-8d67-4d32-9b71-866897dbe457\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30ed\u30b0\u30d1\u30bf\u30fc\u30f3<\/th><th>\u91cd\u8981\u5ea6<\/th><th>\u5bfe\u5fdc\u65b9\u6cd5<\/th><\/tr><\/thead><tbody><tr><td>+sdown<\/td><td>\u8b66\u544a<\/td><td>\u5bfe\u8c61\u30ce\u30fc\u30c9\u306e\u72b6\u614b\u78ba\u8a8d<\/td><\/tr><tr><td>+odown<\/td><td>\u91cd\u8981<\/td><td>\u5373\u6642\u5bfe\u5fdc\u304c\u5fc5\u8981<\/td><\/tr><tr><td>-sdown<\/td><td>\u60c5\u5831<\/td><td>\u5fa9\u65e7\u306e\u78ba\u8a8d<\/td><\/tr><tr><td>+switch-master<\/td><td>\u91cd\u8981<\/td><td>\u30d5\u30a7\u30a4\u30eb\u30aa\u30fc\u30d0\u30fc\u306e\u691c\u8a3c<\/td><\/tr><tr><td>+tilt<\/td><td>\u7dca\u6025<\/td><td>Sentinel\u306e\u72b6\u614b\u78ba\u8a8d<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"i-22\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u4f4e\u4e0b\u6642\u306e\u6539\u5584\u624b\u9806<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6027\u80fd\u8a3a\u65ad\u624b\u9806<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30ec\u30a4\u30c6\u30f3\u30b7\u306e\u78ba\u8a8d\nredis-cli --latency-history\n\n# \u30b9\u30ed\u30fc\u30af\u30a8\u30ea\u306e\u7279\u5b9a\nredis-cli slowlog get 10\n\n# \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u63a5\u7d9a\u72b6\u6cc1\nredis-cli info clients\n\n# \u30e1\u30e2\u30ea\u65ad\u7247\u5316\u306e\u78ba\u8a8d\nredis-cli info memory | grep fragmentation<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6539\u5584\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># redis.conf\n# \u30e1\u30e2\u30ea\u6700\u9069\u5316\nmaxmemory-policy allkeys-lru\nmaxmemory-samples 10\n\n# \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u6700\u9069\u5316\nrepl-backlog-size 512mb\nrepl-backlog-ttl 3600\n\n# \u6c38\u7d9a\u5316\u8a2d\u5b9a\u306e\u8abf\u6574\nappendfsync everysec\nno-appendfsync-on-rewrite yes<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30b7\u30b9\u30c6\u30e0\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30b7\u30b9\u30c6\u30e0\u8a2d\u5b9a\u306e\u6700\u9069\u5316\necho never &gt; \/sys\/kernel\/mm\/transparent_hugepage\/enabled\necho 1 &gt; \/proc\/sys\/vm\/overcommit_memory\necho 512 &gt; \/proc\/sys\/net\/core\/somaxconn\n\n# \u30c7\u30a3\u30b9\u30afI\/O\u8a2d\u5b9a\necho deadline &gt; \/sys\/block\/sda\/queue\/scheduler<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u30b9\u30af\u30ea\u30d7\u30c8\u4f8b<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\/\/ \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u30b9\u30af\u30ea\u30d7\u30c8\nfunction checkRedisPerformance($host, $port) {\n    $redis = new Redis();\n    $redis-&gt;connect($host, $port);\n\n    $metrics = [\n        'latency' =&gt; microtime(true),\n        'memory' =&gt; $redis-&gt;info('memory'),\n        'clients' =&gt; $redis-&gt;info('clients'),\n        'stats' =&gt; $redis-&gt;info('stats')\n    ];\n\n    \/\/ \u30ec\u30a4\u30c6\u30f3\u30b7\u30c1\u30a7\u30c3\u30af\n    $redis-&gt;ping();\n    $metrics['latency'] = (microtime(true) - $metrics['latency']) * 1000;\n\n    \/\/ \u7d50\u679c\u306e\u89e3\u6790\u3068\u5831\u544a\n    if ($metrics['latency'] &gt; 100) {\n        error_log(\"High latency detected: {$metrics['latency']}ms\");\n    }\n\n    if ($metrics['memory']['used_memory_rss'] &gt; 8589934592) { \/\/ 8GB\n        error_log(\"High memory usage detected\");\n    }\n\n    return $metrics;\n}<\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6539\u5584\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>[ ] \u30e1\u30e2\u30ea\u4f7f\u7528\u7387\u306e\u78ba\u8a8d\u3068\u6700\u9069\u5316<\/li>\n\n\n\n<li>[ ] \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30ec\u30a4\u30c6\u30f3\u30b7\u306e\u6e2c\u5b9a<\/li>\n\n\n\n<li>[ ] \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u63a5\u7d9a\u6570\u306e\u9069\u6b63\u5316<\/li>\n\n\n\n<li>[ ] \u30b9\u30ed\u30fc\u30af\u30a8\u30ea\u306e\u7279\u5b9a\u3068\u6539\u5584<\/li>\n\n\n\n<li>[ ] \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u9045\u5ef6\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>[ ] \u30b7\u30b9\u30c6\u30e0\u30ea\u30bd\u30fc\u30b9\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>[ ] \u30c7\u30a3\u30b9\u30afI\/O\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>[ ] \u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u51e6\u7406\u306e\u5f71\u97ff\u78ba\u8a8d<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u624b\u6cd5\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001Redis Sentinel\u306e\u5b89\u5b9a\u904b\u7528\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002\u5b9a\u671f\u7684\u306a\u30ed\u30b0\u89e3\u6790\u3068\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3092\u884c\u3044\u3001\u554f\u984c\u306e\u65e9\u671f\u767a\u898b\u3068\u5bfe\u5fdc\u3092\u5fc3\u304c\u3051\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-23\">Redis Sentinel\u306e\u767a\u5c55\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-24\">\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u3067\u306e\u69cb\u6210\u4f8b<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30de\u30eb\u30c1\u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u69cb\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[\u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fcA]\n    Master Redis\n    \u2514\u2500\u2500 Slave Redis\n    \u2514\u2500\u2500 Sentinel (3\u53f0)\n\n[\u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fcB]\n    Slave Redis\n    \u2514\u2500\u2500 Sentinel (3\u53f0)\n\n[\u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fcC]\n    Slave Redis\n    \u2514\u2500\u2500 Sentinel (3\u53f0)<\/pre>\n\n\n\n<p>\u8a2d\u5b9a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># sentinel.conf (DC-A)\nsentinel monitor mymaster 10.0.1.100 6379 5\nsentinel known-sentinel mymaster 10.0.2.100 26379 dc2\nsentinel known-sentinel mymaster 10.0.3.100 26379 dc3\n\n# \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u9593\u306e\u901a\u4fe1\u8a2d\u5b9a\nsentinel announce-ip 10.0.1.100\nsentinel announce-port 26379<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b7\u30e3\u30fc\u30c7\u30a3\u30f3\u30b0\u69cb\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\/\/ \u30b7\u30e3\u30fc\u30c7\u30a3\u30f3\u30b0\u5b9f\u88c5\u4f8b\nclass RedisShardedSentinel {\n    private $shards;\n    private $totalShards;\n\n    public function __construct($shardConfigs) {\n        $this-&gt;totalShards = count($shardConfigs);\n        foreach ($shardConfigs as $shardId =&gt; $config) {\n            $this-&gt;shards[$shardId] = new RedisSentinelConnection(\n                $config['sentinels'],\n                $config['master_name']\n            );\n        }\n    }\n\n    public function get($key) {\n        $shardId = $this-&gt;getShardId($key);\n        return $this-&gt;shards[$shardId]-&gt;get($key);\n    }\n\n    private function getShardId($key) {\n        return crc32($key) % $this-&gt;totalShards;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-25\">\u30af\u30e9\u30a6\u30c9\u74b0\u5883\u3067\u306e\u69cb\u7bc9\u30dd\u30a4\u30f3\u30c8<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>AWS\u74b0\u5883\u3067\u306e\u69cb\u6210\u4f8b<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Terraform\u8a2d\u5b9a\u4f8b\nresource \"aws_elasticache_replication_group\" \"redis_cluster\" {\n  replication_group_id          = \"redis-sentinel-cluster\"\n  replication_group_description = \"Redis with Sentinel\"\n  node_type                    = \"cache.r5.large\"\n  number_cache_clusters        = 3\n  automatic_failover_enabled   = true\n\n  cluster_mode {\n    replicas_per_node_group = 2\n    num_node_groups         = 1\n  }\n}\n\nresource \"aws_security_group\" \"redis_security_group\" {\n  name        = \"redis-sentinel-sg\"\n  description = \"Security group for Redis Sentinel\"\n\n  ingress {\n    from_port   = 6379\n    to_port     = 6379\n    protocol    = \"tcp\"\n    cidr_blocks = [\"10.0.0.0\/16\"]\n  }\n\n  ingress {\n    from_port   = 26379\n    to_port     = 26379\n    protocol    = \"tcp\"\n    cidr_blocks = [\"10.0.0.0\/16\"]\n  }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Kubernetes\u74b0\u5883\u3067\u306e\u69cb\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># redis-sentinel-statefulset.yaml\napiVersion: apps\/v1\nkind: StatefulSet\nmetadata:\n  name: redis-sentinel\nspec:\n  serviceName: redis-sentinel\n  replicas: 3\n  selector:\n    matchLabels:\n      app: redis-sentinel\n  template:\n    metadata:\n      labels:\n        app: redis-sentinel\n    spec:\n      containers:\n      - name: redis\n        image: redis:6.2\n        ports:\n        - containerPort: 6379\n        volumeMounts:\n        - name: redis-data\n          mountPath: \/data\n      - name: sentinel\n        image: redis:6.2\n        command: [\"redis-sentinel\", \"\/etc\/redis\/sentinel.conf\"]\n        volumeMounts:\n        - name: sentinel-config\n          mountPath: \/etc\/redis\n  volumeClaimTemplates:\n  - metadata:\n      name: redis-data\n    spec:\n      accessModes: [ \"ReadWriteOnce\" ]\n      resources:\n        requests:\n          storage: 10Gi<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-26\">\u76e3\u8996\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u9023\u643a\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Prometheus\u3068\u306e\u9023\u643a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># prometheus.yml\nscrape_configs:\n  - job_name: 'redis_exporter'\n    static_configs:\n      - targets:\n        - 'redis-exporter:9121'\n    metrics_path: \/metrics\n    relabel_configs:\n      - source_labels: [__address__]\n        target_label: instance\n\n# Grafana\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u8a2d\u5b9a\n{\n  \"panels\": [\n    {\n      \"title\": \"Redis Sentinel Status\",\n      \"type\": \"stat\",\n      \"targets\": [\n        {\n          \"expr\": \"redis_sentinel_masters\",\n          \"legendFormat\": \"Masters\"\n        }\n      ]\n    },\n    {\n      \"title\": \"Failover Events\",\n      \"type\": \"graph\",\n      \"targets\": [\n        {\n          \"expr\": \"rate(redis_sentinel_failover_total[5m])\",\n          \"legendFormat\": \"Failovers\/min\"\n        }\n      ]\n    }\n  ]\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30a2\u30e9\u30fc\u30c8\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># alertmanager.yml\ngroups:\n- name: redis_sentinel_alerts\n  rules:\n  - alert: RedisSentinelQuorumLost\n    expr: redis_sentinel_quorum &lt; 2\n    for: 1m\n    labels:\n      severity: critical\n    annotations:\n      summary: \"Sentinel quorum lost\"\n      description: \"Redis Sentinel quorum is below minimum threshold\"\n\n  - alert: RedisSentinelNoMaster\n    expr: redis_sentinel_masters == 0\n    for: 1m\n    labels:\n      severity: critical\n    annotations:\n      summary: \"No Redis master available\"<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30ab\u30b9\u30bf\u30e0\u76e3\u8996\u30b9\u30af\u30ea\u30d7\u30c8<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\/\/ Sentinel\u30d8\u30eb\u30b9\u30c1\u30a7\u30c3\u30af\u30b9\u30af\u30ea\u30d7\u30c8\nclass SentinelHealthCheck {\n    private $sentinels;\n    private $masterName;\n\n    public function __construct($sentinels, $masterName) {\n        $this-&gt;sentinels = $sentinels;\n        $this-&gt;masterName = $masterName;\n    }\n\n    public function check() {\n        $health = [\n            'quorum' =&gt; 0,\n            'master_status' =&gt; false,\n            'slaves_count' =&gt; 0\n        ];\n\n        foreach ($this-&gt;sentinels as $sentinel) {\n            try {\n                $redis = new RedisSentinel(\n                    $sentinel['host'],\n                    $sentinel['port']\n                );\n\n                $master = $redis-&gt;master($this-&gt;masterName);\n                if ($master) {\n                    $health['quorum']++;\n                    $health['master_status'] = true;\n                    $health['slaves_count'] = count(\n                        $redis-&gt;slaves($this-&gt;masterName)\n                    );\n                }\n            } catch (Exception $e) {\n                error_log(\"Sentinel health check error: \" . $e-&gt;getMessage());\n            }\n        }\n\n        return $health;\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$checker = new SentinelHealthCheck([\n    ['host' =&gt; '10.0.1.100', 'port' =&gt; 26379],\n    ['host' =&gt; '10.0.1.101', 'port' =&gt; 26379],\n    ['host' =&gt; '10.0.1.102', 'port' =&gt; 26379]\n], 'mymaster');\n\n$health = $checker-&gt;check();<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u767a\u5c55\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u306b\u3088\u308a\u3001Redis Sentinel\u3092\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u3084\u30af\u30e9\u30a6\u30c9\u74b0\u5883\u3067\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5b9f\u969b\u306e\u5c0e\u5165\u6642\u306b\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u8981\u4ef6\u3084\u898f\u6a21\u306b\u5fdc\u3058\u3066\u9069\u5207\u306a\u69cb\u6210\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":{"0":"post-3331","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-php","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3331"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3331\/revisions"}],"predecessor-version":[{"id":3333,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/3331\/revisions\/3333"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}