1. 程式人生 > >Consul的安裝與試用

Consul的安裝與試用

Consul的安裝與試用

2016-5-23

一)安裝在RedHat7.2

1. [email protected] info

[[email protected]]# uname -a

Linuxip-172-30-0-43.ec2.internal 3.10.0-327.el7.x86_64 #1 SMP Thu Oct 2917:29:29 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

[[email protected]]# cat /etc/redhat-release

RedHat Enterprise Linux Server release 7.2 (Maipo)

2. 安裝

主頁https://www.consul.io/

當然 版本

https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip

下載, 然後unzip 解壓, 得到唯一個可執行檔案

wgethttps://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip

unzipconsul_0.6.4_linux_amd64.zip

檢查一下版本

[[email protected]]# ./consul version

Consulv0.6.4

ConsulProtocol: 3 (Understands back to: 1)

[[email protected]]#

3. Bootstrap Server 模式 啟動

./consulagent -server -bootstrap-expect=1 -data-dir /tmp/consul

./consulagent -server -bootstrap -data-dir /tmp/consul

輸出如下:

[[email protected]]# ./consul agent -server -bootstrap-expect=1 -data-dir/tmp/consul

==>WARNING: BootstrapExpect Mode is specified as 1; this is the same asBootstrap mode.

==>WARNING: Bootstrap mode enabled! Do not enable unless necessary

==>Starting Consul agent...

==>Starting Consul agent RPC...

==>Consul agent running!

Nodename: 'ip-172-30-0-43.ec2.internal'

Datacenter:'dc1'

Server:true (bootstrap: true)

ClientAddr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400)

ClusterAddr: 172.30.0.43 (LAN: 8301, WAN: 8302)

Gossipencrypt: false, RPC-TLS: false, TLS-Incoming: false

Atlas:<disabled>

......(省略)......

4. 檢視,成員info

[[email protected]]# ./consul members

Node Address Status Type Build Protocol DC

ip-172-30-0-43.ec2.internal 172.30.0.43:8301 alive server 0.6.4 2 dc1

[[email protected]]# ./consul members -detailed

Node Address Status Tags

ip-172-30-0-43.ec2.internal 172.30.0.43:8301 alive bootstrap=1,build=0.6.4:26a0ef8c,dc=dc1,port=8300,role=consul,vsn=2,vsn_max=3,vsn_min=1

[[email protected]]# ./consul info

agent:

check_monitors= 0

check_ttls= 0

checks= 0

services= 1

build:

......(省略)......

二)服務的註冊與發現

1. 節點的基本情況

兩臺Node

ip-172-30-0-43 RedHat7.2 172.30.0.43Server

ip-172-30-0-89 Amazon(4.1.10)172.30.0.89 Server

2. 執行的主要命令

引數-bootstrap-expect=2指明 是兩臺server

/home/consul/consulagent -server -bootstrap-expect=2 -data-dir /tmp/consul-node=ip-172-30-0-43 -bind=172.30.0.43 -dc=dc1

/home/consul/consulagent -server -bootstrap-expect=2 -data-dir /tmp/consul-node=ip-172-30-0-89 -bind=172.30.0.89 -dc=dc1

/home/consul/consuljoin 172.30.0.89

3. 控制檯輸出

[[email protected]]# /home/consul/consul agent -server -bootstrap-expect=2 -data-dir/tmp/consul -node=ip-172-30-0-43 -bind=172.30.0.43 -dc=dc1

==>WARNING: Expect Mode enabled, expecting 2 servers

==>Starting Consul agent...

==>Starting Consul agent RPC...

==>Consul agent running!

Nodename: 'ip-172-30-0-43'

Datacenter:'dc1'

Server:true (bootstrap: false)

ClientAddr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400)

ClusterAddr: 172.30.0.43 (LAN: 8301, WAN: 8302)

Gossipencrypt: false, RPC-TLS: false, TLS-Incoming: false

Atlas:<disabled>

==>Log data will now stream in as it occurs:

2016/05/1601:48:46 [INFO] serf: EventMemberJoin: ip-172-30-0-43 172.30.0.43

2016/05/1601:48:46 [INFO] serf: EventMemberJoin: ip-172-30-0-43.dc1 172.30.0.43

2016/05/1601:48:46 [INFO] raft: Node at 172.30.0.43:8300 [Follower] enteringFollower state

2016/05/1601:48:46 [INFO] consul: adding LAN server ip-172-30-0-43 (Addr:172.30.0.43:8300) (DC: dc1)

2016/05/1601:48:46 [INFO] consul: adding WAN server ip-172-30-0-43.dc1 (Addr:172.30.0.43:8300) (DC: dc1)

2016/05/1601:48:46 [ERR] agent: failed to sync remote state: No cluster leader

2016/05/1601:48:47 [WARN] raft: EnableSingleNode disabled, and no known peers.Aborting election.

2016/05/1601:48:56 [INFO] agent.rpc: Accepted client: 127.0.0.1:41616

2016/05/1601:48:56 [INFO] agent: (LAN) joining: [172.30.0.89]

2016/05/1601:48:56 [INFO] serf: EventMemberJoin: ip-172-30-0-89 172.30.0.89

2016/05/1601:48:56 [INFO] agent: (LAN) joined: 1 Err: <nil>

2016/05/1601:48:56 [INFO] consul: adding LAN server ip-172-30-0-89 (Addr:172.30.0.89:8300) (DC: dc1)

2016/05/1601:48:56 [INFO] consul: Attempting bootstrap with nodes:[172.30.0.43:8300 172.30.0.89:8300]

2016/05/1601:48:57 [INFO] consul: New leader elected: ip-172-30-0-89

2016/05/1601:49:00 [INFO] agent: Synced service 'consul'

[[email protected]]# /home/consul/consul agent -server -bootstrap-expect=2 -data-dir/tmp/consul -node=ip-172-30-0-89 -bind=172.30.0.89 -dc=dc1

==>WARNING: Expect Mode enabled, expecting 2 servers

==>Starting Consul agent...

==>Starting Consul agent RPC...

==>Consul agent running!

Nodename: 'ip-172-30-0-89'

Datacenter:'dc1'

Server:true (bootstrap: false)

ClientAddr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400)

ClusterAddr: 172.30.0.89 (LAN: 8301, WAN: 8302)

Gossipencrypt: false, RPC-TLS: false, TLS-Incoming: false

Atlas:<disabled>

==>Log data will now stream in as it occurs:

2016/05/1605:48:50 [INFO] serf: EventMemberJoin: ip-172-30-0-89 172.30.0.89

2016/05/1605:48:50 [INFO] serf: EventMemberJoin: ip-172-30-0-89.dc1 172.30.0.89

2016/05/1605:48:50 [INFO] raft: Node at 172.30.0.89:8300 [Follower] enteringFollower state

2016/05/1605:48:50 [INFO] consul: adding LAN server ip-172-30-0-89 (Addr:172.30.0.89:8300) (DC: dc1)

2016/05/1605:48:50 [INFO] consul: adding WAN server ip-172-30-0-89.dc1 (Addr:172.30.0.89:8300) (DC: dc1)

2016/05/1605:48:50 [ERR] agent: failed to sync remote state: No cluster leader

2016/05/1605:48:51 [WARN] raft: EnableSingleNode disabled, and no known peers.Aborting election.

2016/05/1605:48:56 [INFO] serf: EventMemberJoin: ip-172-30-0-43 172.30.0.43

2016/05/1605:48:56 [INFO] consul: adding LAN server ip-172-30-0-43 (Addr:172.30.0.43:8300) (DC: dc1)

2016/05/1605:48:56 [INFO] consul: Attempting bootstrap with nodes:[172.30.0.89:8300 172.30.0.43:8300]

2016/05/1605:48:57 [WARN] raft: Heartbeat timeout reached, starting election

2016/05/1605:48:57 [INFO] raft: Node at 172.30.0.89:8300 [Candidate] enteringCandidate state

2016/05/1605:48:57 [INFO] raft: Election won. Tally: 2

2016/05/1605:48:57 [INFO] raft: Node at 172.30.0.89:8300 [Leader] enteringLeader state

2016/05/1605:48:57 [INFO] consul: cluster leadership acquired

2016/05/1605:48:57 [INFO] consul: New leader elected: ip-172-30-0-89

2016/05/1605:48:57 [INFO] raft: pipelining replication to peer 172.30.0.43:8300

2016/05/1605:48:57 [INFO] consul: member 'ip-172-30-0-89' joined, markinghealth alive

2016/05/1605:48:57 [INFO] consul: member 'ip-172-30-0-43' joined, markinghealth alive

2016/05/1605:48:59 [INFO] agent: Synced service 'consul'

[[email protected]~]# /home/consul/consul join 172.30.0.89

Successfullyjoined cluster by contacting 1 nodes.

[[email protected]~]# /home/consul/consul members

Node Address Status Type Build Protocol DC

ip-172-30-0-43 172.30.0.43:8301 alive server 0.6.4 2 dc1

ip-172-30-0-89 172.30.0.89:8301 alive server 0.6.4 2 dc1

[[email protected]~]# tree /tmp/consul/

/tmp/consul/

├── checkpoint-signature

├── raft

│   ├── peers.json

│   ├── raft.db

│   └── snapshots

└── serf

├── local.snapshot

└── remote.snapshot

3 directories, 5 files

輸入Ctrl+ C 後,停止服務, 輸出如下:

^C==>Caught signal: interrupt

==>Gracefully shutting down agent...

2016/05/1603:03:30 [INFO] consul: server starting leave

2016/05/1603:03:30 [INFO] serf: EventMemberLeave: ip-172-30-0-43.dc1172.30.0.43

2016/05/1603:03:30 [INFO] consul: removing WAN server ip-172-30-0-43.dc1 (Addr:172.30.0.43:8300) (DC: dc1)

2016/05/1603:03:31 [INFO] serf: EventMemberLeave: ip-172-30-0-43 172.30.0.43

2016/05/1603:03:31 [INFO] consul: removing LAN server ip-172-30-0-43 (Addr:172.30.0.43:8300) (DC: dc1)

2016/05/1603:03:31 [INFO] raft: Removed ourself, transitioning to follower

2016/05/1603:03:32 [INFO] agent: requesting shutdown

2016/05/1603:03:32 [INFO] consul: shutting down server

2016/05/1603:03:32 [ERR] dns: error starting tcp server: accept tcp127.0.0.1:8600: use of closed network connection

2016/05/1603:03:32 [INFO] agent: shutdown complete

4. 儲存值

利用開啟的8500http服務,儲存某些值。

[[email protected]]# curl -X PUT -d 'bar'http://localhost:8500/v1/kv/foo

true[[email protected]]#

[[email protected]]# curlhttp://localhost:8500/v1/kv/foo

[{"LockIndex":0,"Key":"foo","Flags":0,"Value":"YmFy","CreateIndex":144,"ModifyIndex":144}][[email protected]]#

[[email protected]]# echo "YmFy" | base64 --decode

bar[[email protected]]#

5. 其他

重啟,但加上-rejoin命令:

如:

/home/consul/consulagent -server -bootstrap-expect=2 -data-dir /tmp/consul-node=ip-172-30-0-43 -bind=172.30.0.43 -dc=dc1 -rejoin

退出, 使用consul leave 命令

三)進一步的思考與問題

1. 幾種一致性演算法或者相關概念

GOSSIPCONSENSUS, SERF

2. 相關的產品

ZooKeeper, doozerd, etcd

Chef, Puppet, etc.

Nagios, Sensu

SkyDNS

SmartStack

Serf

3. 多資料中心,

延遲? 配置?

如何寫入資料?指令碼 (curl http請求?)

分裂?一個數據中心, 分裂成兩個或多個

4. 某一個server退出(leave命令)重新加入, 有問題,

不能正確選舉leader

5. 發現IBM的一些資料如:

藉助ConsulDocker支援即插即用的服務發現(servicediscovery)

準備進一步學習....

相關推薦

Consul安裝試用

Consul的安裝與試用 2016-5-23 一)安裝在RedHat7.2上 1. [email protected] info [[email protected]]# uname -a Linuxip-172-30-0-43.ec2.i

Opencv在mac系統的安裝試用

網上 tin pty group name bsp -s setting -h 1.在mac終端內,使用brew安裝opencv3,這時我的opencv被安裝到/usr/local/Cellar/opencv3/3.2.0內。 2.新建xcode 項目,選擇command

試用vSphere 6(三):安裝vCenter 6(獨立資料庫)之:vCenter安裝配置

—————————————————————————————————————————- 一、VMware vSphere 6(RC版)安裝配置系列文章: 三、整個實驗環境如下: 資料中心名稱:DataCenter  ESXi叢集名稱:Cluster  域:vsp

Nginx安裝使用

表示 cli 3.1 replace 需要 網站 pop emp 文字 Nginx安裝與使用 Nginx是一款輕量級的Web 服務器/反向代理服務器及電子郵件(IMAP/POP3)代理服務器,並在一個BSD-like 協議下發行。由俄羅斯的程序設計師Igor Sysoev所

3.1 Java以及Lucene的安裝配置

clas font style edi 面向對象 上進 net ref ips Lucene是Java開發的一套用於全文檢索和搜索的開源程序庫,它面向對象多層封裝,提供了一個低耦合、與平臺無關的、可進行二次開發的全文檢索引擎架構,是這幾年最受歡迎的信息檢索程序庫[1]。對L

Linux下svn的安裝部署

myeclipse span .com 服務 點擊 svn服務器 。。 hook idt     最近工作碰到一個問題,我和一個同夥負責開發一個管理系統,基於原來的代碼上進行修改,每當他修改之後,我要再修改都要和他確定是不是最新的文件,才能進行修改。非常影響工作的效率,所以

Tomcat、mysql在Linux上的安裝配置

jre -s mkdir acl .html pat etc rac pac 1.下載JDK與Tomcat. jdk下載地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downlo

nrm是什麽?以及nrm的安裝命令

color tar targe 原本 如果 align ima strong -a nrm的作用與安裝使用 一、nrm是什麽? 這是官方的原話:   開發的npm registry 管理工具 nrm, 能夠查看和切換當前使用的registry, 最近NPM經常 down 掉

【Redis】2、CentOS 7 上安裝 redis3.2.3安裝配置

sync 倉庫 ace /var/ 發現 wan sudo base str 一、redis源碼安裝 【更正】現在最新穩定的版本已經到了3.2.8 截至到2016.8.11,redis最新穩定版本為3.2.3.本篇文章我們就以此版本為基礎,進行相關的講解。 下載redis源

linux應用之vim的安裝配置(centos)

utf8 power scroll pbo gb2312 nco pla red vma 1.vim的安裝 #yum search vim //查看vim相關軟件信息 #yum install -y vim* //在線安裝vim 2.vim的配置 (1)~/.vimi

ubuntu下nvm,node以及npm的安裝使用

詳細 manage tag 不知道 https desc .org 原因 使用方法 一:安裝nvm 首先下載nvm。這裏我們須要使用git,假設沒有安裝git,能夠使用 sudo apt-get install git來安裝 git clone https://g

LDAP簡介及LDAP服務器的安裝配置

默認 access 目的 ani pro sta 目錄服務 unit onf 一、LDAP簡介 全稱:Lightweight Directory Access Protocol,目錄服務是一種特殊的數據庫系統,其專門針對讀取。 LDAP目錄中的信息是按照樹型結構組織,具體信

[大數據]-Elasticsearch5.3.1+Kibana5.3.1從單機到分布式的安裝使用<2>

amp fault hang 終端 bject pre 定義 地理 類型 前言:上篇[大數據]-Elasticsearch5.3.1+Kibana5.3.1從單機到分布式的安裝與使用<1>中介紹了ES ,Kibana的單機到分布式的安裝,這裏主要是介紹Elast

paramiko的安裝使用

roo ace .cn 密碼 oot 通過 技術分享 sha img paramiko是用python語言寫的一個模塊,遵循SSH2協議,支持以加密和認證的方式,進行遠程服務器的連接,支持在遠程登錄服務器執行命令和上傳下載文件的功能。 安裝 pycrypto下載地址:

Hyperledger fablic 0.6 在centos7環境下的安裝部署

maker ber gin sudo 管理 lease nts eve blank 原文:http://blog.csdn.net/zhaoliang1131/article/details/54617274 Hyperledger Fabric超級賬本 項目約定共同遵守

Redis 3.2.8 安裝配置

blog 裝包 ase dir edi useradd nging 執行文件 make 在本章中,您將了解和學習Redis的環境安裝設置。 一、RedHat 6.0 自定義安裝 1、創建redis用戶 Redis 默認的安裝路徑是/usr/local/redis,並且

ActiveMQ在Windows下的安裝啟動(懶人專屬)

最新 lin 管理 star 新的 tro 安裝目錄 min 1.5 其實這些ActiveMQ官網都有,但是如果你懶得看官網,那就直接看這吧! 1. 官網下載最新的ActiveMQ安裝包 apache-activemq-x.x.x-bin.zip並解壓 2.進入安

Eclipse的安裝配置

卸載 exe 分享 技術分享 .org src 技術 修改 刪除 1.下載 http://www.eclipse.org/ 2.安裝 解壓後就能使用(解壓目錄不要出現中文) 雙擊解壓後的exe文件,首次啟動會出現 修改工作空間 3.卸載 將文件夾刪除即可 Eclipse

菜鳥運維筆記:安裝配置Apacheserver

str .cn apach tps 官網 壓縮 ron entos 本地 前幾天在在阿裏花了49.5買了一個月的主機。試著好用再續費吧。 地域:青島可用區:青島可用區ACPU:1核內存:512MB帶寬:1Mbps操作系統:CentOS 6.5 64位雲盾:是

Tomcat 8安裝配置

tomcat##Tomcat 8官方文檔:http://tomcat.apache.org/tomcat-8.0-doc/setup.html#Tomcat 8 下載地址:http://tomcat.apache.org/download-80.cgi# Tomcat 運行需要JDK的支持#JDK 下載地址: