MongoDB Replica Set with Arbiter

1. HAproxy
listen mongodb_cluster
 bind 0.0.0.0:27017
 option tcp-check
 option tcpka
 option tcplog
 # 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 mongodb1 10.0.0.11:27017 check inter 2000
 server mongodb2 10.0.0.12:27017 check inter 2000
2. Mongodb
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

# /etc/mongod.conf
net:
  port: 27017
  bindIp: 0.0.0.0
replication:
  replSetName: rs0

3. On MASTER node
mongo
rs.initiate()
rs.add("mongodb2:27017")
rs.addArb("mongodb-arb:27017")

# check on all nodes
rs.conf()

Backup
#!/bin/bash

mongodump --host mongodb-vip --port 27017 --gzip --archive=/var/backups_mongo/`date +"%m-%d-%y"`.gz

Other
# movePrimary primary
db.adminCommand( { movePrimary: , to:  } )
db.adminCommand( { movePrimary : "test", to : "shard0001" } )