In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the "lvs+ concurrency optimization method tutorial". In the daily operation, I believe that many people have doubts about the optimization method tutorial of lvs+ concurrency. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "lvs+ concurrency optimization method tutorial". Next, please follow the editor to study!
1 Origin
In an actual project, lvs can only carry very low capacity, so the kernel parameters of lvs and Linux need to be optimized.
2 Why use lvs+keepalived architecture
(1) LVS can achieve load balancing, but cannot perform health check. For example, if a RS fails, LVS will still forward the request to the failed RS server, which will lead to the invalidity of the request; keepalived software can perform health check.
(2) using keepalived can realize the high availability of LVS at the same time and solve the problem of LVS single point failure.
3 lvs+keepalived deployment 3.1 deployment diagram
Note: (1) lvs+keepalived requires at least 2 servers. (2) A VIP is required. (3) RS server cannot be reused with LVS and Keepalived.
4.2 lvs+keepalived deployment (2 DS servers)
Install ipvs and keepalived
Yum install ipvsadm keepalived-y
Keepalived configuration
Note: (1) whether the keepalived needs to compete for the master IP, if not, you need to change the state to BACKUP and configure nopreempt. (2) the function of persistence_timeout is to load all TCP requests from the same Client to the same RealServer within a certain period of time, and check ipvsadm-S-n.
Primary node
# Master node (MASTER) configuration file cat > / etc/keepalived/keepalived.conf / proc/sys/net/ipv4/conf/lo/arp_announce echo "1" > / proc/sys/net/ipv4/conf/all/arp_ignore echo "2" > / proc/sys/net/ipv4/conf/all/arp_announce sysctl-p > / dev/null 2 > & 1 echo "RealServer Start OK" Stop) ifconfig lo:0 down route del $SNS_VIP > / dev/null 2 > & 1 echo "0" > / proc/sys/net/ipv4/conf/lo/arp_ignore echo "0" > / proc/sys/net/ipv4/conf/lo/arp_announce echo "0" > / proc/sys/net/ipv4/conf/all/arp_ignore echo "0" > / proc/sys/net/ipv4/conf/all/ Arp_announce echo "RealServer Stoped" ; *) echo "Usage: $0 {start | stop}" exit 1 esac exit 0 execution takes effect # script is executed on all RS nodes: chmod + x lvs_dr_rs.sh. / lvs_dr_rs.sh start5 parameters optimize 5.1 LVS parameters
Increase the size of the ipvs module hash table
The default value of the ipvs module hash table is 2 ^ 12 = 4096, changed to 2 ^ 20 = 1048576. You can query the size of the current hash table with the ipvsadm-l command.
IP Virtual Server version 1.2.1 (size=4096)
Modify method:
Add the file ip_vs.conf in the / etc/modprobe.d/ directory as follows:
Options ip_vs conn_tab_bits=20
Reload the ipvs module.
IP Virtual Server version 1.2.1 (size=1048576)
Modify the timeout in the LVS table
Ipvsadm-- set 900 60 300 ipvsadm-ln-- timeout Timeout (tcp tcpfin udp): 900 60 3005.2 file handle and number of processes * soft nofile 1024000 * hard nofile 1024000 * soft nproc 1024000 * hard nproc 10240005.3 kernel parameter fs.file-max = 1048576 net.ipv4.ip_forward = 1 net.core.wmem_default = 8388608 net.core.wmem_max = 16777216 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.somaxconn = 65535 net. Core.optmem_max = 81920 net.core.netdev_max_backlog = 262144 net.ipv4.route.gc_timeout = 20 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_abort_on_overflow = 1 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_no_metrics_save = 1 net.ipv4.tcp_rmem = 32768 131072 16777216 net.ipv4.tcp_wmem = 8192 131072 16777216 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_fin_timeout = 10 net.ipv4.tcp_keepalive_time = 120 net.ipv4.tcp_keepalive_probes = 3 net.ipv4.tcp_keepalive_intvl = 15 net.ipv4.tcp_retries2 = 5 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 # modprobe ip_conntrack net.netfilter.nf_conntrack_tcp_timeout_established = 180 net.netfilter.nf_conntrack_max = 1048576 net.nf_conntrack_max = 1048576 kernel.sysrq = 0 kernel.core_uses_pid = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296
Note: net.ipv4.tcp_tw_recycle = 1 has holes, so use it cautiously in nat environment.
The greater the concurrency, the more important it is to note that the value of net.ipv4.tcp_max_tw_buckets should not be too large.
At this point, the study on the "lvs+ concurrency optimization method tutorial" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.