In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The replication set mode adopted by the mongodb cluster has at least 3 nodes. There is a problem, when the mongodb master node down, how to let ceilometer automatically connect to the re-elected master node?
There are two solutions. As to which one to use, it depends on the demand.
1. Use vip to locate the mongodb master node.
Use keepalived to use vip. Here are two vip,vrrp_instance VI_1 for mongodb. Vip,vrrp_instance VI_2 is vip for OpenStack HA.
The vrrp script chk_mongo_primary script is designed to detect whether the node is a mongo master node, if so, the weight is + 2, and the vip of vrrp_instance VI_1 can be preempted.
When the mongodb master node is switched, the vip of the vrrp_instance VI_1 will also switch.
Keepalived.conf profile
! Configuration File for keepalivedvrrp_script chk_haproxy {script "killall-0 haproxy" interval 2 weight 2} # Define the script used to check if mongod is runningvrrp_script chk_mongod {script "killall-0 mongod" interval 2 # every two seconds weight 2} # Define the script to see if the local node is the primaryvrrp_script chk_mongo_primary {script "mongo-eval'(!! db.runCommand (" ismaster ") [" ismaster "])? quit (0): quit ( 1)'"interval 2 # every two seconds weight 2} # Configuation for the virtual interfacevrrp_instance VI_1 {interface br-ex state node MASTER # SLAVE on the other nodes priority 101 # 100 on other nodes virtual_router_id 55 authentication {auth_type PASS auth_pass secret # Set this to some secret phrase} # The virtual ipaddress shared between the two nodes virtual_ipaddress { 172.16.140.251/24} # Use the script above to check if we should fail over track_script {chk_mongod chk_mongo_primary}} vrrp_instance VI_2 {interface br-ex virtual_router_id 51 state BACKUP priority 200# if use it The openstack api do not response normally# use_vmac virtualmac# advert_int 1 dont_track_primary nopreempt authentication {auth_type PASS auth_pass password} virtual_ipaddress {172.16.140.250/24} track_script {chk_haproxy} notify / usr/local/bin/keepalivednotify.sh}
2. Use tcp-check of haproxy to detect
Haproyx mongodb configuration
Listen mongodb_cluster bind openstack_vip:27017 option tcpka option tcplog option tcp-check # MongoDB Wire Protocol tcp-check send-binary 3a000000 # Message Length (58) tcp-check send-binary EEEEEEEE # Request ID (random value) tcp-check send-binary 00000000 # Response To (nothing) tcp-check send-binary d4070000 # OpCode (Query) tcp-check send-binary 00000000 # Query Flags tcp-check send-binary 61646d696e2e # fullCollectionName (admin.$cmd) tcp-check send -binary 24636d6400 # continued tcp-check send-binary 00000000 # NumToSkip tcp-check send-binary FFFFFFFF # NumToReturn # Start of Document tcp-check send-binary 13000000 # Document Length (19) tcp-check send-binary 10 # Type (Int32) tcp-check send-binary 69736d617374657200 # ismaster: tcp-check send-binary 01000000 # Value: 1 tcp-check send-binary 00 # Term tcp-check expect binary 69736d61737465720001 # ismaster True server controller1 controller1:27017 check inter 2000 rise 2 fall 3 server controller2 controller2:27017 check inter 2000 rise 2 fall 3
There is a problem here. The non-master nodes seen on the haproxy monitoring page are all down because of tcp-check.
Why does send-binary write that on it? (grab the bag with tcpdum and get it for wireshark analysis)
For more information, please see https://blog.danman.eu/mongodb-haproxy/.
Http://serverfault.com/questions/625492/how-to-construct-a-mongodb-health-check-in-haproxy
Finally, it is found that the uri of mongodb supports multi host, such as mongodb://ceilometer:ceilometer@controller2,controller1,controller3/ceilometer?readPreference=primaryPreferred&replicaSet=rs0.
For more information, please refer to mongodb official: https://docs.mongodb.com/manual/reference/connection-string/
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.