Fourth Chapter Consul Cluster

Source: Internet
Author: User

1, vagrant

To simulate cluster effects, use vagrant.

1.1, first download vagrant

Https://www.vagrantup.com/downloads.html

Description: Browser download may be slow, can be downloaded through thunder.

1.2. After download, install vagrant

Mac, the next step in the end can.

Note: Although vagrant needs to rely on VirtualBox, we do not need to install it beforehand because VirtualBox is installed automatically when the vagrant is installed.

1.3. Open terminal, start vagrant

1.3.1, Initialize:

Description: The above is installed 64bit Linux system (Ubuntu), 32bit of the number to 32.

Reference: https://liuzhichao.com/p/1940.html

1.3.2, modify Vagrantfile file

Description: Ruby wrote the content to read as follows:

1 #-*-Mode:ruby-*-2 #vi:set Ft=ruby:3$script = <<SCRIPT4 echo Installing dependencies ...5sudo apt-Get update6sudo apt-get install-y Unzip Curl7 echo fetching Consul ...8cd/tmp/9wget Https://releases.hashicorp.com/consul/0.6.1/consul_0.6.1_linux_amd64.zip-O Consul.zipTen echo Installing Consul ... One Unzip Consul.zip Asudo chmod +x Consul -sudo mv consul/usr/bin/Consul -sudo mkdir/etc/CONSUL.D thesudo chmod a+w/etc/CONSUL.D - SCRIPT -  - #vagrantfile api/syntax version. Don ' t touch unless you know ' re doing! +Vagrantfile_api_version ="2" -  +Vagrant.configure (vagrantfile_api_version) do |config| AConfig.vm.box ="debian/wheezy64" at  -Config.vm.provision"Shell", inline: $script -  -Config.vm.define"N1"Do |n1| -N1.vm.hostname ="N1" -N1.vm.network"private_network"Ip:"172.20.20.10" in End -  toConfig.vm.define"N2"Do |n2| +N2.vm.hostname ="N2" -N2.vm.network"private_network"Ip:"172.20.20.11" the End *End
View Code

The contents of this document are Consul's official recommended demo. This content can be modified according to the actual situation. (I assigned the node's IP itself, try not to be the same as their own native IP, otherwise may affect some features), the following is my configuration.

1 #-*-Mode:ruby-*-2 #vi:set Ft=ruby:3$script = <<SCRIPT4 echo Installing dependencies ...5sudo apt-Get update6sudo apt-get install-y Unzip Curl7 echo fetching Consul ...8cd/tmp/9wget Https://releases.hashicorp.com/consul/0.6.1/consul_0.6.1_linux_amd64.zip-O Consul.zipTen echo Installing Consul ... One Unzip Consul.zip Asudo chmod +x Consul -sudo mv consul/usr/bin/Consul -sudo mkdir/etc/CONSUL.D thesudo chmod a+w/etc/CONSUL.D - SCRIPT -  - #vagrantfile api/syntax version. Don ' t touch unless you know ' re doing! +Vagrantfile_api_version ="2" -  +Vagrant.configure (vagrantfile_api_version) do |config| AConfig.vm.box ="debian/wheezy64" at  -Config.vm.provision"Shell", inline: $script -  -Config.vm.define"n110"Do |n1| -N1.vm.hostname ="n110" -N1.vm.network"private_network"Ip:"192.168.21.110" in End -  toConfig.vm.define"n111"Do |n2| +N2.vm.hostname ="n111" -N2.vm.network"private_network"Ip:"192.168.21.111" the End *End
View Code

Just modify the node location, in fact, the above script did not let him to execute, can be removed.

1.3.3, start

Description: When you see the log output to

can be "CTRL + C" exit (may sometimes need "CTRL + C" two times), otherwise it will be the contents of the local ~/to n110 this node, may n110 this node space will not be enough, resulting in late work can not be done.

At this point a node starts up, but the second one doesn't get up, and it needs to perform the top operation again.

Finally, the third time the start command is executed.

That's good.

The software is then installed for n110 and n111 two nodes respectively.

2. Install the Software

Go to/tmp/and download the Consul software.

After decompression (provided that the "unzip" command is installed, if not installed, execute)

A binary file "Consul" appears after decompression, as follows:

This binary file is then moved or copied to/usr/bin

Note: The above steps are performed once for n110 and n111 two nodes, respectively.

3. n110 start the service in server mode

4. n111 start service in client mode

5. Join

Starting the above two services respectively, found that in fact, n110 and n111 two of each other who do not know who (can be used to verify by switching the screen), at this time must one of the nodes join to another node, this time to each other to form a cluster.

Note: The above command adds the N110 node to the n111 cluster (which in turn is not a problem), and then by looking at n110 and n111, each is a cluster of two member.

Note: Suppose a cluster has 2 nodes (N1,N2), this time there is a node N3 want to join the cluster, do not need to join two times, only need to join N1 or N2 is good. In this case, the cluster communicates with each other through the gossip protocol, and N3 joins the cluster.

6. Node leaves the cluster

"Ctrl + C"

Fill: The above join is a manual join, there is a node added to the cluster after the automatic join to the cluster to see:

Https://www.consul.io/intro/getting-started/join.html

Reference:

Https://www.consul.io/intro/getting-started/join.html

http://www.jianshu.com/p/d483db36ec9a

Https://liuzhichao.com/p/1940.html

Fourth Chapter Consul Cluster

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.