Monday, October 24, 2016

How to test pacemaker to create a Virtual IP for LB purpose for 3 nodes

sometimes, you need have more than one LBs for HA purpose.  and we always want to have one floatip virual IP cross all LB nodes. and we can use pacepaker/corosyncd to do this very easily.  for the testing purpose, I will use Vagrant to create 3 nodes (node1, node2, node3). once booted up , all 3 machine are well figured for hostname.

nodeone= 'node1'
nodetwo= 'node2'
nodethree= 'node3'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
####  node 1###########
                 config.vm.define :"node1" do |node1|
                        node1.vm.box = BOX
                        node1.vm.box_url = BOX_URL
                        node1.vm.network :private_network, ip: "192.168.2.101"
                        node1.vm.hostname = nodeone
                        node1.vm.synced_folder ".", "/vagrant", disabled: true
               node1.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
                        node1.vm.provision "shell", path: "post-deploy.sh" ,run: "always"
                        node1.vm.provider "virtualbox" do |v|
                                v.customize ["modifyvm", :id, "--memory", "1300"]
                                v.name = nodeone
                    v.gui = true
                        end
                end

and post-deploy.sh
#!/bin/bash
value=$( grep -ic "entry" /etc/hosts )
if [ $value -eq 0 ]
then
echo "
################ hosts entry ############
192.168.2.101 node1
192.168.2.102 node2
192.168.2.103 node3
######################################################
" >> /etc/hosts
fi

once done, you can call vagrant up node1 node2 node3 to have 3 VMs ready.

now vagran ssh all nodes  to install the dependencies.

yum install -y pcsd pacemaker corosync

after done, enable all daemon to start automatically.
systemctl enable pcsd
systemctl enable pacemaker
systemctl enable corosync
//disable firewalld
systemctl disable firewalld

Now time to configure the corosync for nodes topology.

you can just copy the /etc/corosync/corosync.conf.example to /etc/corosync/corosync.conf
just change your ip and quorum settings (by dfault it use mcast to maintain the cluster membership)


then create a user named haclusteruser among 3 nodes

echo you_special_compliceted_password|passwd --stdin haclusteruser

once done, you can call pcs cluster auth to authorize eacy host using the shared credential
pcs cluster auth node1

after this. start the corosync and pacemaker on all nodes.

run crm_mon to see all the nodes

now we can create a floating vip to HA purpose.
pcs  resource create VIP2 IPaddr2 ip=192.168.2.100 cidr_netmask=32 nic=enp0s8 op monitor interval=30s

after that, you might see the status is always stopped. we need to disable the stonith
pcs  property set stonith-enabled=false

try the check again for the status, the VIP is bound to one node (node1 here)



to test the HA, shutdown node1. and run crm_mon again, the VIP was assigned on node2

10 comments:

Sathya said...

Excellent article.This is really very useful to students who are in the software field.Keep going..Thank you for your sharing.

Smith John Live said...

HP LaserJet Pro MFP M428fdn Setup - If you would like to know more about the features of HP laserjet Pro MFP 428fdn, setup, we have a team certified to answer your queries and help you to execute the device setup. Among the most preferred HP Printer models available, HP Color LaserJet Pro MFP M479fdn is opted by customers as it delivers excellent print results. Features and specifications are many and suggest you to check out the reviews to get an idea

Rachel Bilson said...

It’s always my passion to write creative articles. Have worked on a lot of innovative and interesting topics. Read it and it’s informative. Recommend you to provide your feedback & suggestions to work on more titles. Contact me or reach me if you would like to know more about my profile.
My work:Pureflix on Roku

Unknown said...

In the hysteria of social networks, free e-mail service remains the cornerstone of corporate internet communication. Therefore, it is only important to evaluate the best available email services and make the right choice for your needs. Many people are satisfied with the provider of email services they now use.
Additionally, for further queries about the best email service, feel free to interact with active customer care.

Be Tvastra | Digital Marketing Company in Chennai said...

Hi this is SaiVijay, I'am from Chennai. I'am a technical writer for a digital marketing company in Chennai for more than five years. And its my own passion to choose this field. I have to write a creative articles, novels, documents. My hobbies are drawing, playing foot ball and playing cricket also. My most favorite one is "Be Tvastra" which one is the most memorable one in my works. I have suggest you to read the articles.
Digital Marketing Company in Chennai
Digital Marketing Agency in Chennai
SEO services in Chennai
SEO company in Chennai
Web Design Company in Chennai
Web Development Company in Chennai
top 10 digital marketing companies in chennai
digital marketing companies in chennai
best digital marketing agency in chennai
digital marketing companies in anna nagar
seo services company in chennai
Best SEO Companies In Chennai
cheap seo in chennai

Alex said...

Grunt is a remarkable and free creative one page website template for agencies and freelancers. Download it now at TemplateMonster.

Kuma Herbals said...

Thanks for this great information...
Unani Treatment in Bangalore

Elliana Taylor said...

Thank you for sharing valuable information. Nice post. I enjoyed reading this post. The whole blog is very nice found some good stuff and good information here Thanks.
Software Testing Services
Independent Software Testing Services
Functional Testing Services
QA Automation Testing Services
eCommerce Testing Services
Performance Testing Services
Security Testing Services
API Testing Company
Regression Testing Services
Mobile App Testing Services

periyannan said...

I am very thankfull to you for sharing this fantastic article
internship request letter | Internship completion letter | internship companies | internship resume objective | internship application letter | Internship with training | internship email | internship experience | What internship means | Internship acknowledgement

MaksimMB said...

Are you in a long search for bpo services providers? Then I have good news for you! This site is for you! With the help of this company, you can access highly qualified and educated professionals who will become part of your dream remote team, all you need to do is to leave a small vacancy on the site, and get interviewed! Good luck!

 
Locations of visitors to this page