{"id":67594,"date":"2025-05-10T08:39:42","date_gmt":"2025-05-10T00:39:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/67594\/"},"modified":"2025-05-10T08:39:42","modified_gmt":"2025-05-10T00:39:42","slug":"centos7-redis%e4%b8%bb%e4%bb%8e%e6%90%ad%e5%bb%ba%e9%85%8d%e7%bd%ae%e7%9a%84%e5%ae%9e%e7%8e%b0-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/67594\/","title":{"rendered":"Centos7 Redis\u4e3b\u4ece\u642d\u5efa\u914d\u7f6e\u7684\u5b9e\u73b0"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>Centos7 Redis\u4e3b\u4ece\u642d\u5efa\u914d\u7f6e\u7684\u5b9e\u73b0<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u600e\u4e48\u5165\u95e8\u6570\u636e\u5e93\u7f16\u7a0b\uff1f\u9700\u8981\u5b66\u4e60\u54ea\u4e9b\u77e5\u8bc6\u70b9\uff1f\u8fd9\u662f\u65b0\u624b\u4eec\u521a\u63a5\u89e6\u7f16\u7a0b\u65f6\u5e38\u89c1\u7684\u95ee\u9898\uff1b\u4e0b\u9762golang\u5b66\u4e60\u7f51\u5c31\u6765\u7ed9\u5927\u5bb6\u6574\u7406\u5206\u4eab\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u591f\u7ed9\u521d\u5b66\u8005\u4e00\u4e9b\u5e2e\u52a9\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u4ecb\u7ecd\u300aCentos7 Redis\u4e3b\u4ece\u642d\u5efa\u914d\u7f6e\u7684\u5b9e\u73b0\u300b\uff0c\u6d89\u53ca\u5230Centos7Redis\u3001\u4e3b\u4ece\u642d\u5efa\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u6536\u85cf\u4e00\u4e0b<\/p>\n<p><span style=\"color: #ff0000\"><strong>\u4e00\u3001\u73af\u5883\u4ecb\u7ecd<\/strong><\/span><\/p>\n<p>Redis\u2014master&nbsp;&nbsp; 172.18.8.19<br \/> Redis\u2014slave&nbsp;&nbsp; 172.18.8.20<\/p>\n<p><span style=\"color: #ff0000\"><strong>\u4e8c\u3001redis\u4e3b\u7684\u914d\u7f6e<\/strong><\/span><\/p>\n<pre>\n#\u521b\u5efaredis\u6570\u636e\u76ee\u5f55\nmkdir -p \/data0\/redis_trade\n\n#redis\u4e3b\u914d\u7f6e\u6587\u4ef6\nroot&gt;# cat redis_6379.conf |grep -Ev \"^$|^#\"\nbind 172.18.8.19\nprotected-mode yes\nport 6379\ntcp-backlog 511\ntimeout 0\ntcp-keepalive 300\ndaemonize yes\nsupervised no\npidfile \/var\/run\/redis_6379.pid\nloglevel notice\nlogfile \"\/var\/log\/redis_6379.log\"\ndatabases 16\nsave 900 1\nsave 300 10\nsave 60 10000\nstop-writes-on-bgsave-error yes\nrdbcompression yes\nrdbchecksum yes\ndbfilename dump_6379.rdb\ndir \/data0\/redis_trade\nslave-serve-stale-data yes\nslave-read-only yes\nrepl-diskless-sync no\nrepl-diskless-sync-delay 5\nrepl-disable-tcp-nodelay no\nslave-priority 100\nrequirepass Allwelltokok\nappendonly yes\nappendfilename \"appendonly_6379.aof\"\nappendfsync everysec\nno-appendfsync-on-rewrite no\nauto-aof-rewrite-percentage 100\nauto-aof-rewrite-min-size 64mb\naof-load-truncated yes\nlua-time-limit 5000\nslowlog-log-slower-than 10000\nslowlog-max-len 128\nlatency-monitor-threshold 0\nnotify-keyspace-events \"\"\nhash-max-ziplist-entries 512\nhash-max-ziplist-value 64\nlist-max-ziplist-size -2\nlist-compress-depth 0\nset-max-intset-entries 512\nzset-max-ziplist-entries 128\nzset-max-ziplist-value 64\nhll-sparse-max-bytes 3000\nactiverehashing yes\nrename-command FLUSHALL ZYzv6FOBdwflW2nX\nrename-command EVAL S9UHPKEpSvUJMM\nrename-command FLUSHDB D60FPVDJuip7gy6l\nclient-output-buffer-limit normal 0 0 0\nclient-output-buffer-limit slave 256mb 64mb 60\nclient-output-buffer-limit pubsub 32mb 8mb 60\nhz 10\naof-rewrite-incremental-fsync yes\n<\/pre>\n<p><span style=\"color: #ff0000\"><strong>\u4e09\u3001redis\u4ece\u914d\u7f6e<\/strong><\/span><\/p>\n<pre>\nroot&gt;# cat redis_6379.conf |grep -Ev \"^$|^#\"\nbind 172.18.8.20\nprotected-mode yes\nport 6379\ntcp-backlog 511\ntimeout 0\ntcp-keepalive 300\ndaemonize yes\nsupervised no\npidfile \/var\/run\/redis_6379.pid\nloglevel notice\nlogfile \"\/var\/log\/redis_6379.log\"\ndatabases 16\nsave 900 1\nsave 300 10\nsave 60 10000\nstop-writes-on-bgsave-error yes\nrdbcompression yes\nrdbchecksum yes\ndbfilename dump_6379.rdb\ndir \/data0\/redis_trade\nslaveof 172.18.8.19 6379   -----\u4ece\u5e93\u6bd4\u4e3b\u5e93\u591a\u8fd92\u884c\u914d\u7f6e\u53c2\u6570\nmasterauth Allwelltokok   -----\u4ece\u5e93\u6bd4\u4e3b\u5e93\u591a\u8fd92\u884c\u914d\u7f6e\u53c2\u6570\nslave-serve-stale-data yes\nslave-read-only yes\nrepl-diskless-sync no\nrepl-diskless-sync-delay 5\nrepl-disable-tcp-nodelay no\nslave-priority 100\nrequirepass Allwelltokok\nappendonly yes\nappendfilename \"appendonly_6379.aof\"\nappendfsync everysec\nno-appendfsync-on-rewrite no\nauto-aof-rewrite-percentage 100\nauto-aof-rewrite-min-size 64mb\naof-load-truncated yes\nlua-time-limit 5000\nslowlog-log-slower-than 10000\nslowlog-max-len 128\nlatency-monitor-threshold 0\nnotify-keyspace-events \"\"\nhash-max-ziplist-entries 512\nhash-max-ziplist-value 64\nlist-max-ziplist-size -2\nlist-compress-depth 0\nset-max-intset-entries 512\nzset-max-ziplist-entries 128\nzset-max-ziplist-value 64\nhll-sparse-max-bytes 3000\nactiverehashing yes\nrename-command FLUSHALL ZYzv6FOBdwflW2nX\nrename-command EVAL S9UHPKEpSvUJMM\nrename-command FLUSHDB D60FPVDJuip7gy6l\nclient-output-buffer-limit normal 0 0 0\nclient-output-buffer-limit slave 256mb 64mb 60\nclient-output-buffer-limit pubsub 32mb 8mb 60\nhz 10\naof-rewrite-incremental-fsync yes\n<\/pre>\n<p><span style=\"color: #ff0000\"><strong>\u56db\u3001redis\u542f\u52a8\u811a\u672c<\/strong><\/span><\/p>\n<pre>\nroot&gt;# cat \/etc\/init.d\/redis_6379 \n#!\/bin\/sh\n#\n# Simple Redis init.d script conceived to work on Linux systems\n# as it does use of the \/proc filesystem.\n# chkconfig:  2345 90 10\n\nsource \/etc\/init.d\/functions\nREDISPORT=6379\nEXEC=\/usr\/local\/bin\/redis-server\nCLIEXEC=\/usr\/local\/bin\/redis-cli\n \nPIDFILE=\/var\/run\/redis_${REDISPORT}.pid\nCONF=\"\/usr\/local\/redis\/etc\/redis_${REDISPORT}.conf\"\nAUTH=\"Allwelltokok\"\nBIND_IP='172.18.8.19'\n \nstart(){\n   \n  if [ -f $PIDFILE ]\n  then\n    echo \"$PIDFILE exists, process is already running or crashed\"\n  else\n    echo \"Starting Redis server...\"\n    $EXEC $CONF\n  fi\n  if [ \"$?\"=\"0\" ] \n  then \n    echo \"Redis is running...\" \n  fi \n \n \n}\n \nstop(){\n \n  if [ ! -f $PIDFILE ]\n  then\n    echo \"$PIDFILE does not exist, process is not running\"\n  else\n    PID=$(cat $PIDFILE)\n    echo \"Stopping ...\"\n    $CLIEXEC -h $BIND_IP -a $AUTH -p $REDISPORT SHUTDOWN \n    sleep 1\n    while [ -x \/proc\/${PID} ]\n    do\n      echo \"Waiting for Redis to shutdown ...\"\n      sleep 1\n    done\n      echo \"Redis stopped\"\n  fi\n}\n \nrestart(){\n  stop\n  start\n \n}\nstatus(){\n \n  ps -ef|grep redis-server|grep -v grep &gt;\/dev\/null 2&gt;&amp;1\n \n  if [ $? -eq 0 ];then\n \n    echo \"redis server is running\"\n \n  else\n    echo \"redis server is stopped\"\n \n  fi\n   \n \n}\n \n \ncase \"$1\" in\n  start)\n    start\n    ;;\n  stop)\n    stop\n    ;;\n     \n  restart)\n    restart\n    ;;\n     \n  status)\n    status\n    ;;   \n  *)\n   \n   echo \"Usage: \/etc\/init.d\/redis {start|stop|status|start}\" &gt;&amp;2 \n   exit 1 \nesac\n\n<\/pre>\n<p><span style=\"color: #ff0000\"><strong>\u4e94\u3001\u542f\u52a8\u670d\u52a1<\/strong><\/span><\/p>\n<pre>\nroot&gt;# \/etc\/init.d\/redis_6379 start  \n\n<\/pre>\n<p>\u67e5\u770b\u65e5\u5fd7<\/p>\n<pre>\nroot&gt;# tail -100f \/var\/log\/redis_6379.log\n5563:S 29 Jun 22:14:23.236 * Increased maximum number of open files to 10032 (it was originally set to 1024).\n        _._                         \n      _.-``__ ''-._                       \n   _.-``  `. `_. ''-._      Redis 3.2.12 (00000000\/0) 64 bit\n .-`` .-```. ```\\\/  _.,_ ''-._                  \n (  '   ,    .-` | `,  )   Running in standalone mode\n |`-._`-...-` __...-.``-._|'` _.-'|   Port: 6379\n |  `-._  `._  \/   _.-'  |   PID: 5563\n `-._  `-._ `-.\/ _.-'  _.-'                  \n |`-._`-._  `-.__.-'  _.-'_.-'|                 \n |  `-._`-._    _.-'_.-'  |      http:\/\/redis.io    \n `-._  `-._`-.__.-'_.-'  _.-'                  \n |`-._`-._  `-.__.-'  _.-'_.-'|                 \n |  `-._`-._    _.-'_.-'  |                 \n `-._  `-._`-.__.-'_.-'  _.-'                  \n   `-._  `-.__.-'  _.-'                    \n     `-._    _.-'                      \n       `-.__.-'                        \n\n5563:S 29 Jun 22:14:23.237 # Server started, Redis version 3.2.12\n5563:S 29 Jun 22:14:23.237 * The server is now ready to accept connections on port 6379\n5563:S 29 Jun 22:14:23.237 * Connecting to MASTER 172.18.8.19:6379\n5563:S 29 Jun 22:14:23.237 * MASTER  SLAVE sync started\n5563:S 29 Jun 22:14:23.237 * Non blocking connect for SYNC fired the event.\n5563:S 29 Jun 22:14:23.238 * Master replied to PING, replication can continue...\n5563:S 29 Jun 22:14:23.238 * Partial resynchronization not possible (no cached master)\n5563:S 29 Jun 22:14:23.239 * Full resync from master: c9f303069f87253011bf39369366732a2e88b389:1\n5563:S 29 Jun 22:14:23.304 * MASTER  SLAVE sync: receiving 77 bytes from master\n5563:S 29 Jun 22:14:23.305 * MASTER  SLAVE sync: Flushing old data\n5563:S 29 Jun 22:14:23.305 * MASTER  SLAVE sync: Loading DB in memory\n5563:S 29 Jun 22:14:23.305 * MASTER  SLAVE sync: Finished with success\n5563:S 29 Jun 22:14:23.305 * Background append only file rewriting started by pid 5567\n5563:S 29 Jun 22:14:23.329 * AOF rewrite child asks to stop sending diffs.\n5567:C 29 Jun 22:14:23.329 * Parent agreed to stop sending diffs. Finalizing AOF...\n5567:C 29 Jun 22:14:23.329 * Concatenating 0.00 MB of AOF diff received from parent.\n5567:C 29 Jun 22:14:23.329 * SYNC append only file rewrite performed\n5567:C 29 Jun 22:14:23.330 * AOF rewrite: 0 MB of memory used by copy-on-write\n5563:S 29 Jun 22:14:23.337 * Background AOF rewrite terminated with success\n5563:S 29 Jun 22:14:23.337 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)\n5563:S 29 Jun 22:14:23.337 * Background AOF rewrite finished successfully  \n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Centos7 Redis\u4e3b\u4ece\u642d\u5efa\u914d\u7f6e\u7684\u5b9e\u73b0 \u6536\u85cf \u600e\u4e48\u5165\u95e8\u6570\u636e\u5e93\u7f16\u7a0b\uff1f\u9700\u8981\u5b66\u4e60\u54ea\u4e9b\u77e5\u8bc6\u70b9\uff1f\u8fd9\u662f\u65b0\u624b\u4eec\u521a\u63a5\u89e6\u7f16\u7a0b\u65f6\u5e38\u89c1\u7684\u95ee\u9898\uff1b\u4e0b\u9762golang\u5b66\u4e60\u7f51\u5c31\u6765\u7ed9\u5927\u5bb6\u6574\u7406\u5206\u4eab\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u591f\u7ed9\u521d\u5b66\u8005\u4e00\u4e9b\u5e2e\u52a9\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u4ecb\u7ecd\u300aCentos7 Redis\u4e3b\u4ece\u642d\u5efa\u914d\u7f6e\u7684\u5b9e\u73b0\u300b\uff0c\u6d89\u53ca\u5230Centos7Redis\u3001\u4e3b\u4ece\u642d\u5efa\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u6536\u85cf\u4e00\u4e0b \u4e00\u3001\u73af\u5883\u4ecb\u7ecd Redis\u2014master&nbsp;&nbsp; 172.18.8.19 Redis\u2014slave&nbsp;&nbsp; 172.18.8.20 \u4e8c\u3001redis\u4e3b\u7684\u914d\u7f6e #\u521b\u5efaredis\u6570\u636e\u76ee\u5f55 mkdir -p \/data0\/redis_trade #redis\u4e3b\u914d\u7f6e\u6587\u4ef6 root&gt;# cat redis_6379.conf |grep -Ev &#8220;^$|^#&#8221; bind 172.18.8.19 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile \/var\/run\/redis_6379.pid loglevel notice logfile &#8220;\/var\/log\/redis_6379.log&#8221; databases 16 save 900 1 save 300 10 save 60 10000 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-67594","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=67594"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67594\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=67594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=67594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=67594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}