2278 Chess source Control win or lose, Redis Sentinel h5 room card bull chess Platform Rental high-availability Service architecture construction

Source: Internet
Author: User
Tags benchmark failover install redis redis server

Tag: HTML return IP) indicates offline product Note Port cluster

A few days ago, saw a H5 room card bullfighting platform, H5 Room card bull platform leasing, the idea is very good, but no construction process, this document records the Redis Sentinel high-AV service system construction process.
According to the author's fourth plan,

1. Redis is a fully open source, free, BSD-compliant, high-performance key-value database.
Redis and other key-valued cache products have the following three characteristics:
Redis supports data persistence, saves the in-memory data to disk, and loads it again on reboot. Redis supports not only simple key-value data, but also lists, collections, Zset, hashes, and other data structures. Redis supports data backup, which is data backup in master-slave mode. Advantages of Redis:
Very high performance--redis reads 110,000/s and writes 81,000 times/S. The rich data type--redis supports binary case string, list, hash, set, and sort set data type operations. E. An operation is atomic. Multiple operations also support transactions that are wrapped by multi and exec directives, that is, atomicity. Rich feature-redis also supports features such as publish subscriptions, notifications, key expiration, and so on. Runoob.com/reidis/redis-ion.html
2. The concept of Reiss Sentinel, Reisis Sentinel, is a highly available solution Reids is officially recommended. When using Redis as the primary-from a high availability solution, if the primary server fails, the Redis itself (including many of its clients) does not automatically switch between the host and the standby, Redis-sentinel will do the same. When the master drops, cluster and switch.
The Redis Stavenele system is used to manage multiple Redis servers (instances) performing the following three tasks:
Monitoring: Sentinel constantly checks whether the primary server and slave server are working properly. Notification: Sentinel can send notifications to administrators or other applications through the API when there is a problem with the monitored RDIs server. Automatic failover: When a problem occurs on the primary server, Sentinel initiates an automatic failover operation, upgrades one secondary server of the failed primary server to the new primary server, and replaces the other secondary servers of the failed master with the new primary service. When connecting to a failed primary server, the cluster also returns the address of the new primary server to the client, allowing the cluster to use the new primary server instead of the failed server. Even if you use the gossip protocol to receive information about whether the primary server is offline, and use the Protocol protocol to decide whether to perform an automatic failover. Move and select which server is the new primary server.
A sentinel process can be connected to several other sentinel processes, each of which can check the availability of each other and exchange information.
The above content is extracted from Http:/rdedoc. com/stutial/stavenel.html.
Three. To build a Redis server (Master), we will follow the architecture diagram above, with approximately three servers (firewall off):
10.9.10.154 main Redis-server redis-.nel10.9.10.152 from Redis-server Redis-.nel10.9.10.215redis-.nel first download the latest version of Redis from Redis.ioreleases.
http
TER-RUNTER$CC makefile.dep INSTALL redis-sentinel cc REDIS-CLI.O link redis-cli cc REDIS-BENCHMARK.O link Redis-benchmark Install Redis-check-rdb tip: It's a good idea to run make test; install installation installed install installation install install installation installing installed installs Setup will be REDIS-4.0.8/SRC header record, generate redis-server and Reiss Sentinel executable file.
Then, on the Master node (10.9.10.154), we create a redis-4.0.8/redis-master.conf configuration file with the following example configuration:
#使用守护进程yes #unprotected mode, external access protected mode No#port 6379#bound IP, local IP bind 10.9.10.154# Learn and develop, use maximum log level, can see log information up to log level debug # Specify the log file path, no file to do this, create the log file Home/ubuntu/redis/redis-4.0.8/reis-server. Log-x client access, require pass 123456 to require a password connection, and then start the host:
Src/redis-server redis-master.config $cat redis-server.config $cat redis-server.log 8517:8517:c 06:06:10:10:38.345#### Ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 8517:c 06:10:10:10:10:38.345ation loaded 8518:m 28FEB 06:10:10* increase the maximum number of open files to 10032 (initially set to 1024). 8518: February 28 06:10:38.352* Run mode = standalone operation, port =6379.8518:m 6379.8518:m282 month 28th February 28 February 2282 Month 206:10:10:38.352# Warning: 511 TCP Backlog setting 511 cannot force procproc2 month 06:10:38.352 warning you that transparent Jumbo page (THP) support is enabled in the kernel. This will result in Redis latency and memory usage issues. To fix this problem, run echo.gtsyskernelmm.t_hugepageenabled as the root and add it to ETCRC local to preserve the Setti. After THP is disabled, Redis must be restarted. 8518:m 06:10:38.352* ready to accept the connection 8518:m 06:10:38.352-0 (slave), 765776 bytes used to view the status of Redis:
$redis-cli-h 10.9.10.154-p 6379-a 123456 10.9.10.154:6379gt;info Copy # Replication role: Primary Connection _ Slave: 0master_replid:0master_ replid:7f90fb4ba0c450b184a348f31d9c40b010d master_replid2:0000000000000000000000000000000000000000000000000000_ . _offset:0_replreplreplreplreplreplrepley:-log-1_activ_replid 1e:0repl_backlog_log_size:01048576 primebealogyfixstybyteoffoffice:0 realposixrelogystudilen:0:10.97.154:6399gt; Table tennis add and get key value test:
7.154:637 9GT; set test Hello OK 107.10154:637 9GT; get test helereles is a common command:
Start Service: Service Redis start stop service: Service Redis Stop restarting service: If service Redis x is not configured as a service service, you can turn off Redis with the following command:
Setting up a Redis Server (slave) from a node is similar to building a master node, except that the redis-slave.conf configuration file is different:
With guard is unprotected mode, Protected mode does not have a 6379 port bound IP that is accessed from the external network. The local IP binding 10.9.10.152# specifies the primary IP address and port from which to learn and develop 10.9.10.154 6379#. With the maximum log level, you can see the most logs. Log level debug g Specifies the path to the log file. If there are no files, create the logfile/home/ubuntu/redis/redis-4.0.8/reis-server. log-* set the password master auth 123456 to access the host and boot from the machine:
    srcredis-server redis-from server redis-from. conf$ $cat redis-server $cat$cat redis-server. Log 7307.log 7307#7307.# 7307. #7307. $cat #737373737307$cat$cat. $cat $206$2 Month 20606 06 06 06 06 06 06:11:11:11:11:11:11:11:11 : 11:11:11:00.11:00.987.987# #Redis版本 =4 4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8,bits=64,commit=00000,.=0:.=0,start= 7307,just 7307:just 7307:oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooofiguration loaded in 7308S 28, February 28, 06:11:00.989* increases the maximum number of open files to 10032 (initially set to 1024). 7308:S2282 month 28th 06:11:00.989* Run mode = standalone, Port =6379.7308:s26379.7308:s2282 month 2282 month 2282 month 206:06:11:00.990# Warning: 511 of TCP backlog settings cannot be enforced proc08:s 28 February 28 06:11:00.990 warns you that transparent giant page (THP) support is enabled in the kernel. This will result in Redis latency and memory usage issues. To fix this problem, run the command echo, never gt; S/kernelmm.t_hugepageenabled a s root and add it to the etc/rc.local in order to retain S. Restart after reboot. After THP is disabled, you must restart Redis. 7308:s 28 February 28 06:11.990* ready to accept 7308:s 28 February 28 connection (slave) 06:11:00.990-0,76572 month 06:00.990-0 connection 36 bytes, using 7308:s 28:s 28 February 28 06 : 11:00.990* connected to master 10.9.15 4:6379 7308:s 28:s 28 February 28 06:11:00.990*-gt; The non-blocking connection triggering event from the beginning of synchronization 7308:s 06:11.990*sync. 7308:s 06:s 06:s 28:s 06:11:00.991* Host response Ping, replication can continue 7308:s 06:11.993* partial resynchronization impossible (no cache host) 7308:s b 06:s 28:11.993*995x from master: redis,b929,9ff66f9610687ce95ddfbdecb986:0 Check the full state:
Redis-cli-h 10.9.10.152-p 6379-a 123456 10.9.10.154:6379gt;info Copy # Copy role: Slave master_host:10.9.10.154master_ Port:6379master_link_status:up_last_io_seconds_s:10_sync_.:0slave_repl_offset:280ve_.:100:1_connected_read_.:1 _slave_read_host:10.9.10. 154master_port:6379master_link_status:up_last_io_seconds_master_.:0 Slave_repl_offset:es:0master_replid:55b29a9f06ffb89f961087ce95ddfbdeccb986master_replid 2:0000000000000000000000000master_repl_offset:280._repl_offset: -1repl_backlog_active:1repl_backlog_size : 1048576repl_backlog_first_byte_offset:1repl_backlog_offset:1repl_ Histlen:280.10.9.152:pong, but; then, we will check the status of the primary server (update. _slaves information):
$redis-cli-h 10.9.10.154-p 6379-a 123456 10.9.10.154:6379gt;info Copy # Copy role: Main. _slaves:1000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 0 00 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 0 billion Billions billion billion billion billion billion billion billion billion billion billion billion billion billion billion billion billion billion billion billion billion Offset:28._repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_ Backlog_histlen:28 In addition, you can test by adding the encryption key and value to the primary server, and then get v_backlog_active_size:1048576 repl_backlog_first_byte_offset:28. The corresponding key is sold.
5. Build Redis Sentinel, then configure Redis Sentinel on three servers, create redis-4.0.8/.nel-my.conf configuration files, sample configurations (remember to change different binding IPs):
Port 26379 Binding 10.9.10.154 Daemon is a log file Home%ubuntu/redis/redis-4.0.8redis-.nel.log Sentinel Monitor Manager 1 10.9.10.154 6379 2 Sentinel Authentication Manager 1 123456yncs ManagER1 1 1 is configured as a set of four rows, because we have only one master node, so only one master node can be configured to configure multiple master nodes without configuring the slave node information, since the node can be automatically detected (the master node will have messages about the slave node)
The first line of configuration instructs Sentinel to monitor the master server named Manager 1. The server has an IP address of 10.9.10.154, a port number of 6379, and requires at least two sentinel consent failures (automatic failover will not succeed as long as the number of Sentinel does not meet the standard). ).
The basic format for the other options is as follows:
Sentinel lt; The name of the option is gt;lt; the name of the primary server is gt;lt; the value of the option is GT; Option Description:
Auth-pass: option specifies the password for the primary connection. Down-.-. seconds: option specifies the milliseconds that Sentinel requires the server to disconnect. Failover-timeout: If the failover operation does not complete within that time (MS), consider failover A. Parallel-syncs: This option specifies the maximum number of times a failover can be synchronized from the server to the new primary server, and the smaller the amount, the longer it will take to complete the failover. Next, start Redis Sentinel (default port 26379):
$SRC/redis-server sentinel-my.conf--sentinelor $src/redis-sentinel-my.conf-Sentinelor or $SRC/ redis-sentinel-my.conf $cat Redis-sentinel.log 5716:x 03:04:04:17.407## # # # # # # # # # # # # # # # # # # # # Ooooooooooooooooooooooooo Ooooooo 57OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOjust Start 5716:x 03:04:04:04:04:17.407#configuration load 5716:x 03:04:04:04:04:17.408* The maximum number of open files is increased to 10032 (initially set to 1024). "" "" "" ""-u.-"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "". " "" "" "" "" "" "" "" "" "" "" "" "" "." "" "" "" "-...-' __...-'." "" "" "" "" "" "" "" '-._ ' _.-port:26379 '-._ '. _/_.-pid:5716 '-._ '-._ '-./_.-_.-'-._ '-._ '-.__.-_.-_.-'-._ '-._ _.-_.-http://redis.io '-._ '-._ '-.__.-_.-_.- '-._ '-._ '-.__.-_.-_.-'-._ '-._ _.-_.-'-._ '-._ '-.__.-_.-_.-'-._ '-.__.-_.-'-._ _.-'-.__.-5716:x 03:04:17. The TCP backlog setting for 410 # WA511 cannot be enforced because procprocsys/procsys/net
Et
ET core/somaxaxaxaxaxaxaxconn/proc
Et
Et
Et
Et
Et
Et
ET when the server starts the Reiss Sentinel, there is such a log (Radis Sentinel communicates with each other):
5716:x28 Feb 03:18:46.404# tilt mode exit 5716:x 03:19:43.959*+ Sentinel 55ebce153ac69c908800 bc14 beff24725fc5a721 10.9.10.152 [ Email protected] 1 10.9.10.154 6379 connection test (test three servers):
Redis-redis-cli-10.9.10.154-p 26379 10.9.10.10.154-p 26379 10.9.10.10.154-p 26379 10.10.10.10.154-p 26379 10.10.10.10.154-p 26379 10.9 10.10.10.154-p 26379 10.10.10.10.154-2679gt; pingpong $redirediredis$redis$ redis-redis-cli-redi-cli-Reset-cli-cli-cli-10.10.10.9-10.9.9.10.10.10.10.10.152-10.152-p 26379-10.10.10.10 s:
ping-This command returns only Pone.sentinel hosts-displays a list of monitoring hosts and their status. Sentinel Host {host name} displays the status and information for the specified host. Sentinel Slave {host name} displays the slave list and the host status it sends. Inels{master name}-Displays a list of the Master Sentinel instances and their status. SENTINEL get-master-addr-by-name{master name}-returns the IP and master ports. If the failover is processed or successfully terminated, the promoted slave IP and port are returned. Sentinel Reset {.} The-this command resets all matching host names. The parameter is a blog style. The reset process empties all States of the host and removes all dependents and sentinels that have been found and associated with the host. Sentinel Failover {hostname}-If the host cannot be accessed, the Sentinels is executed without the consent of the other lover. Sentinel ckquorum{Master Name}-checks whether the current sentinel configuration is capable of meeting the quorum required for failover and requires most failover authorization. This command should be used to monitor the system to check whether it is expanded. The yment is correct. Sentinel Refresh Configuration-forces Sentinel to rewrite the configuration on the disk, including the current Sentinel state. In general, Sentinel changes its state each time the configuration is rewritten. However, sometimes the configuration file may be lost due to an operational error, a hard disk failure ures, a package upgrade script, or a configuration manager. In this scenario, the mandatory sentinel rewrite configuration file is received. You can use this command even if the above configuration file is completely lost. Read Sentry failure test our plan is to stop the guru's reisis service and see how the Read sentry works.
First, let's look at the current master node information (remember IP):
$redis-cli-h 10.9.10.154-p 6379 10.9.10.154:26379gt;sentinel get-master-addr by-name Manager 1 1) 10.9.10.154 2) 6379 and execute the following command (Force Redis server to sleep for 120 seconds):
Redis-cy-h 107.10154-p 637 9A A 123456 Debug Hibernation 120, then we look at the master node information:
$redis-cli-h 10.9.10.154-p 6379 10.9.10.154:26379gt;sentinel get-master-addr-by-name Manager 1) 10.9.10.152) 6379 Discovery IP has become the previous salt node, that is, 10.9.10.152 has become the primary node, and then view the current master information:
$redis-cli-cli-10.9.10.10.10.10.152-p 6379-p 6379-a 12345616110.9.9.10.10.10.10.10.10.10.152-p634579-a 123456 10.10.10.10.10.10.10.10.152-p 6379-p 6379-p63797979797979a 1234561456 10.10.10.9.10.10.10.10.10.10.10.10.10.10.10.10.10.10.152-p 6379-p 6379-p 6379-p 6379-p 6379-p 6379- p63797979797979797979797979797979a 12345a 123451 12345b033 De604be41707070707070707070707070707070707070707070707070707b2727b27b52bcc2981_master_master_replc2981_repl REPLREPLREPLREPLREPLF1D4B24C9499C4A Master_repl_ offset:12707070707070707070707070707070707070707070707070707b277b27272727b2727b2727b27b27b27b2727b2727b27b27b22b Main REPL _offset:1270535._repl_offset:1208143repl_backlog_active:1repl_backlog_size:1repl_backlog_ size:1048576replen:1048 6slave0:ip=10. 9 10154, the port =6379 indicates that the previous host has become solve.
Throughout the process, we can view the logs of the Read Sentinel:
20153:x 20153: February 28, 2010 February 28 0909:13:13:51.023############# #eeee228282828282828120151 : 3:28:2829:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:13:52.102#### #新经理1 #+ new manager Manager 1#+ New manager 1#+ new manager 1 1 1 1 1 20151 1 1 1 1 1 1 1 1 1 1 1 20153 20153 20153 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 20153 1 20153 1 1 1 1 20153 Quorum 2 1 1 20153 1 1 1 20153 1 1 1 1 20153 quorum 1 1 1 1 1 1 [email protected] [email protected] 10.154 6379:x 1 10.154 6379:x2010 February 28 09:[email protected] [email protected] 10.10.9.154 6379:10.154 6379:x 10.154 637676767676767676764:X2 Month 28th 0909:13.365.6516161616167* Switch -19-19.19.154161616161616161616161616161616161616161616161616161616161616161515151515151515151515151515151515151579.
Each Sentinel discovers that the primary node is closed and has a +sdown event that is later upgraded to +odown, which means that most Sentinel has agreed that the primary node is inaccessible. Sentinel starts voting for Sentinel to start and tries failover failover. Also, note that Redis Sentinel is not an address for external services, it is just a monitoring tool to manage Redis primary standby switching, so the address provided by the external client is still the address of the Redis server (including, of course, salve, which can also provide a uniform address). Access a similar load balancing (SLB) or virtual IP (virtual IP,VIP).

2278 Chess source Control win or lose, Redis Sentinel h5 room card bull chess Platform Rental high-availability Service architecture construction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.