{"id":7149,"date":"2017-11-28T08:44:35","date_gmt":"2017-11-28T00:44:35","guid":{"rendered":"http:\/\/rmohan.com\/?p=7149"},"modified":"2017-11-28T08:44:35","modified_gmt":"2017-11-28T00:44:35","slug":"redis-2","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7149","title":{"rendered":"Redis"},"content":{"rendered":"<p>what is Redis<\/p>\n<p>Redis is a key-value storage system. Similar to Memcached, it supports storing relatively many value types, including string, list, set, and zset.<br \/>\nThese data types support push \/ pop, add \/ remove, and intersection and union and difference sets and richer operations, all of which are atomic.<br \/>\nOn this basis, Redis supports a variety of different sorts. Like memcached, data is cached in memory for efficiency.<br \/>\nThe difference is that Redis periodically writes updated data to disk or writes modifications to additional log files and implements master-slave synchronization based on this. Redis is a high-performance key-value database.<br \/>\nThe emergence of Redis, a large extent, to compensate for such lack of keyvalue memcached storage, in some cases can play a good complement to the relational database.<\/p>\n<p>&nbsp;<\/p>\n<p>1, Redis installation<\/p>\n<p>1.1 Pre-installation environment description<\/p>\n<p>Using a CentOS 7 version of Linux system with<br \/>\nmaster ip of 192.168.1.110<br \/>\nslave ip of 192.168.1.111 The<\/p>\n<p>1.2 Download Redis<\/p>\n<p>Redis can go to the official website to download: https:\/\/redis.io\/download , now the latest stable version has reached 4.0.<br \/>\nUsed here is redis-4.0.1.tar.gz .<\/p>\n<p>1.3 installation steps<\/p>\n<p>$ wget http:\/\/download.redis.io\/releases\/redis-4.0.1.tar.gz<br \/>\n$ tar xzf redis-4.0.1.tar.gz -C \/usr\/local\/<br \/>\n$ cd \/usr\/local\/redis-4.0.1<br \/>\n$ make &amp; make test<br \/>\nmake Possible exceptions<\/p>\n<p>make[1]: Leaving directory `\/usr\/local\/redis-4.0.1\/src&#8217; make[1]: Entering directory `\/usr\/local\/redis-4.0.1\/src&#8217;<br \/>\nYou need tcl 8.5 or newer in order to run the Redis test<br \/>\nmake[1]: *** [test] Error 1<br \/>\nmake[1]: Leaving directory `\/usr\/local\/redis-4.0.1\/src&#8217;<br \/>\nmake: *** [test] Error 2<br \/>\nsolution<\/p>\n<p>yum install -y tcl<\/p>\n<p>2, Redis simple configuration<\/p>\n<p>All configuration changes are in this configuration file<\/p>\n<p>\/usr\/local\/redis-4.0.1\/redis.conf<\/p>\n<p>&nbsp;<\/p>\n<p>2.2 bound host address<\/p>\n<p>Bind after the host to add ip,from behind Redis need to connect through the IP.<\/p>\n<p>bind 127.0.0.1 192.168.1.110<\/p>\n<p>2.3 Set Redis password<\/p>\n<p>The password is set herejaven<\/p>\n<p># requirepass foobared<br \/>\nrequirepass mohan<\/p>\n<p>2.4 Set the Redis port number<\/p>\n<p>The default port is6379<\/p>\n<p>port 6379<\/p>\n<p>3, test Redis<\/p>\n<p>start up<br \/>\n\/usr\/local\/redis-4.0.1\/redis.conf<br \/>\nsrc\/redis-server<\/p>\n<p>src\/redis-server redis.conf<br \/>\nClient connection<\/p>\n<p>src\/redis-cli<br \/>\nsrc\/redis-cli -a mohan<\/p>\n<p>\/usr\/local\/redis-4.0.1\/redis.conf<br \/>\nsrc\/redis-cli shutdown<br \/>\nsrc\/redis-cli -p 6666 shutdown<\/p>\n<p>&nbsp;<\/p>\n<p>4, Redis master-slave replication configuration<\/p>\n<p>Redis master-slave replication is very powerful, a master can have multiple slaves, and a slave can have multiple slaves, so go on, forming a powerful multi-level server cluster architecture. The following simple configuration.<\/p>\n<p>Modify the slave&#8217;s redis configuration file<\/p>\n<p>Master&#8217;s redis configuration file bindcan be set as long as<\/p>\n<p>Slave redis modify the slave configuration file slaveof 10.211.55.3 6379 (mapped to the main server, 6379the port number)<br \/>\ncan also be dynamically set:<br \/>\nRedis-cli connected to the slave node server, execute the following command.<br \/>\nslaveof 10.211.55.3 6379<\/p>\n<p>If master sets the authentication password, you also need to configure masterauth. Here I set the master authentication password javen, so configure masterauth javen.<\/p>\n<p>After configuring the slave start the Redis service, OK, master-slave configuration is completed (is not very simple).<br \/>\nThe following test:<br \/>\nIn the master and slave, respectively, the info command to view the results are as follows:<\/p>\n<p>slave:<\/p>\n<p>[root@centos-linux-2 redis-4.0.1]# src\/redis-cli<br \/>\n127.0.0.1:6379&gt; info<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>5, Redis remote connection<\/p>\n<p>Usage: redis-cli [OPTIONS] [cmd [arg [arg &#8230;]]]<\/p>\n<p>-h &lt;host ip&gt;, the default is 127.0.0.1<\/p>\n<p>-p &lt;port&gt;, the default is 6379<\/p>\n<p>-a &lt;password&gt;, redis lock, you need to pass the password<\/p>\n<p>-help, Show help information<\/p>\n<p>redis-cli -h 10.211.55.4 -p 6379 -a javen<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>what is Redis<\/p>\n<p>Redis is a key-value storage system. Similar to Memcached, it supports storing relatively many value types, including string, list, set, and zset. These data types support push \/ pop, add \/ remove, and intersection and union and difference sets and richer operations, all of which are atomic. On this basis, Redis supports [&#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\/7149"}],"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=7149"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7149\/revisions"}],"predecessor-version":[{"id":7150,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7149\/revisions\/7150"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}