{"id":6879,"date":"2017-07-21T16:51:39","date_gmt":"2017-07-21T08:51:39","guid":{"rendered":"http:\/\/rmohan.com\/?p=6879"},"modified":"2017-07-21T16:51:39","modified_gmt":"2017-07-21T08:51:39","slug":"how-to-configure-a-redis-cluster-on-centos-7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6879","title":{"rendered":"How To Configure a Redis Cluster on CentOS 7"},"content":{"rendered":"<pre><code>yum install gcc make\r\ncd ~\r\nmkdir init\r\nwget http:\/\/download.redis.io\/releases\/redis-3.2.3.tar.gz\r\ntar -zxvf redis-3.2.3.tar.gz \r\ncd redis-3.2.3\r\nmake \r\nmake install\r\n\r\n#cd utils\r\n#.\/install_server.sh\r\n\r\ncd src\/\r\ncp redis-server redis-cli \/usr\/local\/bin\r\ncp redis-sentinel redis-benchmark redis-check-aof redis-check-dump \/usr\/local\/bin\r\n\r\nmkdir \/etc\/redis\r\nmkdir -p \/var\/lib\/redis\/6379\r\n<\/code><\/pre>\n<p>Set the vm.overcommit_memory to 1, which means always, this will avoid data to be truncated, take a look here for more.<\/p>\n<pre><code>sysctl -w vm.overcommit_memory=1\r\n<\/code><\/pre>\n<p>Change the maximum of backlog connections some value higher than the value on tcp-backlog option of redis.conf, which defaults to 511. You can find more on sysctl based ip networking \u201ctunning\u201d on kernel.org website.<\/p>\n<pre><code>sysctl -w net.core.somaxconn=512\r\n<\/code><\/pre>\n<p>Disable transparent huge pages support, that is known to cause latency and memory access issues with Redis.<\/p>\n<pre><code>echo never &gt; \/sys\/kernel\/mm\/transparent_hugepage\/enabled\r\n<\/code><\/pre>\n<p>Redis.conf is the Redis configuration file, however you will see the file named as 6379.conf here, where the number is the same as the network port is listening to. This name is recommended if you are going to run more than one Redis instance.<\/p>\n<pre><code>cp redis.conf \/etc\/redis\/6379.conf\r\nvim \/etc\/redis\/6379.conf\r\n\r\ndaemonize yes #note\r\npidfile \/var\/run\/redis_6379.pid\r\nport 6379\r\nloglevel notice\r\nlogfile \/var\/log\/redis_6379.log\r\ndir \/var\/lib\/redis\/6379\r\n<\/code><\/pre>\n<h1 id=\"starting-at-boot\">Starting at boot<\/h1>\n<pre><code>cp utils\/redis_init_script \/etc\/init.d\/redis_6379\r\nvim \/etc\/systemd\/system\/redis_6379.service\r\n\r\n[Unit]\r\nDescription=Redis on port 6379\r\n\r\n[Service]\r\nType=forking\r\nExecStart=\/etc\/init.d\/redis_6379 start\r\nExecStop=\/etc\/init.d\/redis_6379 stop\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n\r\nvim \/etc\/sysctl.conf\r\n\r\nvm.overcommit_memory = 1\r\nnet.core.somaxconn=512\r\n<\/code><\/pre>\n<p>For the transparent huge pages support there is no sysctl directive, so you can put the command at the end of \/etc\/rc.local<\/p>\n<pre><code>echo never &gt; \/sys\/kernel\/mm\/transparent_hugepage\/enabled\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h1 id=\"configure-redis-master\">Configure Redis Master<\/h1>\n<pre><code>vi \/etc\/redis.conf\r\n\r\ndaemonize yes #note\r\ntcp-keepalive 60\r\n#bind 127.0.0.1\r\nrequirepass your_redis_master_password\r\nmaxmemory-policy noeviction\r\nappendonly yes\r\nappendfilename \"appendonly.aof\"\r\n<\/code><\/pre>\n<p>restart if makeinstall<br \/>\nredis-server \/etc\/redis\/6379.conf<\/p>\n<h1 id=\"configure-redis-slave\">Configure Redis Slave<\/h1>\n<pre><code>daemonize yes #note\r\n#bind 127.0.0.1\r\nrequirepass your_redis_slave_password\r\nslaveof your_redis_master_ip 6379\r\nmasterauth your_redis_master_password<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>yum install gcc make cd ~ mkdir init wget http:\/\/download.redis.io\/releases\/redis-3.2.3.tar.gz tar -zxvf redis-3.2.3.tar.gz cd redis-3.2.3 make make install #cd utils #.\/install_server.sh cd src\/ cp redis-server redis-cli \/usr\/local\/bin cp redis-sentinel redis-benchmark redis-check-aof redis-check-dump \/usr\/local\/bin mkdir \/etc\/redis mkdir -p \/var\/lib\/redis\/6379 <\/p>\n<p>Set the vm.overcommit_memory to 1, which means always, this will avoid data to be truncated, take a [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6879"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6879"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6879\/revisions"}],"predecessor-version":[{"id":6880,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6879\/revisions\/6880"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}