In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use Visual Studio to remotely debug the Web App deployed on Azure. I hope you will get something after reading this article. Let's discuss it together.
Introduction
Redis Sentinel is a distributed system where you can run multiple Sentinel processes (progress) in a single architecture, which use the rumor protocol (gossip protocols) to receive information about whether the master server is offline, and use the voting protocol (agreement protocols) to decide whether to perform automatic failover and which slave server to choose as the new master server.
Although Redis Sentinel is released as a separate executable redis-sentinel, it is really just a Redis server running in a special mode, and you can start Redis Sentinel with the-- sentinel option when you start a normal Redis server.
The Sentinel system is used to manage multiple Redis servers (instance) and performs the following three tasks:
Monitoring (Monitoring): Sentinel will constantly check whether your master server and slave server are working properly.
Reminder (Notification): when there is a problem with a monitored Redis server, Sentinel can send notifications to administrators or other applications through API.
Automatic failover (Automatic failover): when a master server does not work properly, Sentinel starts an automatic failover operation, which upgrades one of the slaves of the failed master server to the new master server and allows the other slave servers of the failed master server to replicate the new master server When the client tries to connect to the failed primary server, the cluster also returns the address of the new primary server to the client, so that the cluster can use the new primary server instead of the failed server.
Redis version: 3.0.7
Master: 6379, sentinel:26379
From: 6380, sentinel:26380
Configuration
How to build an automatic failover reids cluster? when the master goes down, the master takes over as the new master, and after the master is started, it automatically becomes the slave. In fact, it is the same as the dual master mode of Mysql; the redis cluster needs redis-sentinel program and sentinel.conf configuration file.
Master configuration
Vim redis.conf
Daemonize yes pidfile / usr/local/redis-6379/run/redis.pid port 6379 tcp-backlog 128 timeout 0 tcp-keepalive 0 loglevel notice logfile "databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir" / usr/local/redis-6379 "masterauth" 123456 "requirepass" 123456 "slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp- Nodelay no slave-priority 100 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set-max-intset -entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 000000 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
Vim sentinel.conf
Cluster file configuration
Port 26379 dir "/ usr/local/redis-6379" # daemon mode daemonize yes # specifies the log file name logfile ". / sentinel.log" sentinel monitor mymaster 192.168.137.40 6379 1 sentinel down-after-milliseconds mymaster 5000 sentinel failover-timeout mymaster 18000 sentinel auth-pass mymaster 123456
From configuration
Vim redis.conf
Daemonize yes pidfile "/ usr/local/redis-6380/run/redis.pid" port 6380 tcp-backlog 128 timeout 0 tcp-keepalive 0 loglevel notice logfile "databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename" dump.rdb "dir" / usr/local/redis-6380 "masterauth" 123456 "requirepass" 123456 "slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 Repl-disable-tcp-nodelay no slave-priority 100 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 000 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
Vim sentinel.conf
# sentinel port port 26380 # working path, be careful not to repeat the master "/ usr/local/redis-6380" # daemon mode daemonize yes # indicates the log file name logfile ". / sentinel.log" # Sentinel monitored master, the master / slave configuration is the same. How long sentinel monitor mymaster 192.168.137.40 6379 1 # master or slave cannot be used (default is 30 seconds) and then marked as s_down status. Sentinel down-after-milliseconds mymaster 5000 # if the sentinel fails to complete the failover operation within the configuration value (that is, the master/slave automatically switches over in case of failure), the failover is considered to have failed. Sentinel failover-timeout mymaster 18000 # set master and slaves authentication password sentinel auth-pass mymaster 123456
Start redis
Both the master and the subordinate should be activated.
Src/redis-server redis.conf
Start cluster monitoring
Both the master and the subordinate should be activated.
Src/redis-sentinel sentinel.conf-sentinel
Start error processing
Error 1:
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory=1' to / etc/sysctl.conf and then reboot or run the command' sysctl vm.overcommit_memory=1' for this to take effect.
Two solutions (overcommit_memory) 1. Echo "vm.overcommit_memory=1" > / etc/sysctl.conf or vi / etcsysctl.conf, and then reboot restarts the machine 2. Echo 1 > / proc/sys/vm/overcommit_memory takes effect without starting the machine. Overcommit_memory parameters description: set memory allocation policy (optional, set according to the actual situation of the server) / proc/sys/vm/overcommit_memory optional values: 0, 1, 2. 0, which means that the kernel will check whether there is enough memory available for the application process; if there is enough memory available, the memory request is allowed; otherwise, the memory request fails and the error is returned to the application process. 1, which means that the kernel allows all physical memory to be allocated, regardless of the current memory state. 2, indicates that the kernel allows the allocation of memory that exceeds the sum of all physical memory and swap space. Note: when redis dump data, it will fork a child process. Theoretically, the memory occupied by the child process is the same as that of parent. For example, if the memory occupied by parent is 8 GB, 8 GB of memory should also be allocated to child. If the memory cannot afford it, it will often cause the downmachine or IO load of the redis server to be too high. The efficiency is declining. So the optimized memory allocation policy here should be set to 1 (meaning that the kernel allows all physical memory to be allocated, regardless of the current memory state). Overcommit and OOM are also involved here. What is Overcommit and OOM in Unix, when a user process requests memory using the malloc () function, if the return value is NULL, the process knows that there is no available memory space and will process it accordingly. Many processes print error messages and exit. Linux uses a different approach, replying "yes" to most requests for memory so that it can run more and larger programs. Because memory will not be used immediately after applying for memory. This technique is called Overcommit. OOM killer (OOM=out-of-memory) occurs when there is insufficient memory. It chooses to kill some processes (user-mode processes, not kernel threads) to free memory. The strategy of Overcommit overcommit has three strategies (Documentation/vm/overcommit-accounting) under Linux: 0. Heuristic strategy. Reasonable overcommit will be accepted, unreasonable overcommit will be rejected. 1. Any overcommit will be accepted. two。 Commit is rejected when the system allocates more memory than the swap+N%* physical RAM (N% is determined by vm.overcommit_ratio). The policy for overcommit is set through vm.overcommit_memory. The percentage of overcommit is set by vm.overcommit_ratio. # echo 2 > / proc/sys/vm/overcommit_memory # echo 80 > / proc/sys/vm/overcommit_ratio when oom-killer occurs, linux chooses which processes to kill. The function that selects the process is the oom_badness function (in mm/oom_kill.c), which calculates the number of points for each process (0,1000). The higher the points, the more likely the process is to be killed. The number of points for each process is related to oom_score_adj, and oom_score_adj can be set (- 1000 points).
Error 2:
WARNING: The TCP backlog setting of 511 cannot be enforced because / proc/sys/net/core/somaxconn is set to the lower value of 128.
Echo 511 > / proc/sys/net/core/somaxconn
Error 3:
16433 Jun X 12 it was originally set to 14 52 it was originally set to 37.734 * Increased maximum number of open files to 10032.
The newly installed linux is only 1024 by default. When the load is heavy, error: too many open files ulimit-a: use all the limit values vim / etc/security/limits.conf that can view the current system to add * soft nofile 65535 * hard nofile 65535 to the end of the file to execute su or re-close the connection to the user and then execute ulimit-a to view the modified results.
Failover mechanism
1. After starting the cluster, the cluster program defaults to adding the configuration of the connection master in the redis file of the slave library.
# Generated by CONFIG REWRITE slaveof 192.168.137.40 6379
two。 After starting the cluster, the cluster program defaults to adding the cluster information to the master-slave sentinel.conf file
Lord:
Port 26379 dir "/ usr/local/redis-6379" # daemon mode daemonize yes # specifies the log file name logfile ". / sentinel.log" sentinel monitor mymaster 192.168.137.40 6379 1 sentinel down-after-milliseconds mymaster 5000 sentinel failover-timeout mymaster 18000 sentinel auth-pass mymaster 123456 # Generated by CONFIG REWRITE sentinel config-epoch mymaster 0 sentinel leader-epoch mymaster 1 sentinel known-slave mymaster 192.168.137.40 6380 sentinel known-sentinel mymaster 192.168.137.40 26380 c77c5f64aaad0137a228875e531c7127ceeb5c3f sentinel current-epoch 1
From:
# sentinel port port 26380 # work path dir "/ usr/local/redis-6380" # daemon mode daemonize yes # indicates the log file name logfile ". / sentinel.log" # Sentinel monitored master, with the same master-slave configuration, 6379 will become the current master port when switching between master and slave Sentinel monitor mymaster 192.168.137.40 6379 1 # master or slave how long (default 30 seconds) cannot be used and marked as s_down status. Sentinel down-after-milliseconds mymaster 5000 # if the sentinel fails to complete the failover operation within the configuration value (that is, the master/slave automatically switches over in case of failure), the failover is considered to have failed. Sentinel failover-timeout mymaster 18000 # set master and slaves authentication passwords sentinel auth-pass mymaster 123456 # automatic addition of the Sentinel program # Generated by CONFIG REWRITE sentinel config-epoch mymaster 0 sentinel leader-epoch mymaster 1 # indicates the ip and port of the slave library of the current cluster This value will change sentinel known-slave mymaster 192.168.137.40 6380 # in addition to the current sentinel, what other monitored sentinel sentinel known-sentinel mymaster 192.168.137.40 26379 7a88891a6147e202a53601ca16a3d438e9d55c9d sentinel current-epoch 1
Simulate the main fault
[root@monitor redis-6380] # ps-ef | grep redis root 4171 10 14:20? 00:00:15 / usr/local/redis-6379/src/redis-server *: 6379 root 4175 10 14:20? 00:00:15 / usr/local/redis-6380/src/redis-server *: 6380 root 4305 10 15:28? 00:00:05 / usr/local/redis-6379/src/redis-sentinel *: 26379 [sentinel] root 4306 10 15:28? 00:00:05 / usr/local/redis-6380/src/redis-sentinel *: 26380 [sentinel] root 4337 4144 0 15:56 pts/1 00:00:00 grep redis [root@monitor redis-6380] # kill-9 4171 [root@monitor redis-6380] # ps-ef | grep redis root 4175 10 14:20? 00:00:15 / usr/local/redis-6380/src/redis-server *: 6380 root 4305 10 15:28? 00:00:05 / usr/local/redis-6379/src/ Redis-sentinel *: 26379 [sentinel] root 4306 1 0 15:28? 00:00:05 / usr/local/redis-6380/src/redis-sentinel *: 26380 [sentinel] root 4339 4144 0 15:56 pts/1 00:00:00 grep redis [root@monitor redis-6380] #
From the Sentinel configuration file, you can see that the current main library has changed.
From the log file, you can also see that the current master has been converted from 6379 to 6380.
After reading this article, I believe you have a certain understanding of "how to use Visual Studio to remotely debug Web App deployed on Azure". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.