CentOS7 Install Consul
Centos7 Install Consul
原文链接:http://www.cnblogs.com/caoguo/p/5959962.html
1) 环境
192.168.217.158 consul-
192.168.217.159 consul-
192.168.217.160 consul-
192.168.217.161 agent-
2) 安装
# yum install -y unzip
# wget https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_linux_amd64.zip # unzip consul_0..0_linux_amd64.zip
# mv consul /usr/local/bin/
3)配置
# consul-1配置
# consul agent -server -bootstrap-expect -data-dir /tmp/consul -node=n1 -bind=192.168.217.158 -dc=bj1 # consul-2配置
# consul agent -server -bootstrap-expect -data-dir /tmp/consul -node=n2 -bind=192.168.217.159 -dc=bj1 # consul-3配置
# consul agent -server -bootstrap-expect -data-dir /tmp/consul -node=n3 -bind=192.168.217.160 -dc=bj1 # 将consul- consul-3加入集群
[root@consul- ~]# consul join 192.168.217.159 192.168.217.160
Successfully joined cluster by contacting nodes. # 配置服务注册文件(也可以从consul api 接口添加服务注册,他会自动持久化)
[root@localhost ~]# vi /etc/consul.d/web3.json
{
"service": {
"name": "web3",
"tags": ["master"],
"address": "127.0.0.1",
"port": ,
"checks": [
{
"http": "http://localhost:10000/health",
"interval": "10s"
}
]
} # wget https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_web_ui.zip #启动客户端agent-
# consul agent -data-dir /tmp/consul -node=n4 -bind=192.168.217.161 -join=192.168.217.158 -dc=bj1 -config-dir=/etc/consul.d -ui-dir /tmp/ui -client=192.168.217.161
4) 测试
# 开一个端口10000的服务
[root@localhost ~]# vi web3.go
package main import (
"fmt"
"net/http"
) func handler(w http.ResponseWriter, r *http.Request) {
fmt.Println("hello Web3! This is n3")
fmt.Fprintf(w, "Hello Web3! This is n3")
} func healthHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println("health check!")
} func main() {
http.HandleFunc("/", handler)
http.HandleFunc("/health", healthHandler)
http.ListenAndServe(":10000", nil)
}
# 运行服务
# go run web3.go
[root@consul- ~]# consul members
Node Address Status Type Build Protocol DC
n1 192.168.217.158: alive server 0.7. bj1
n2 192.168.217.159: alive server 0.7. bj1
n3 192.168.217.160: alive server 0.7. bj1
n4 192.168.217.161: alive client 0.7. bj1 # consul members -detailed
# curl localhost:/v1/catalog/nodes
# curl localhost:/v1/status/leader
# curl localhost:/v1/status/peers
# 服务发现
# curl -s http://192.168.217.161:8500/v1/catalog/service/web3|python -m json.tool
[
{
"Address": "192.168.217.161",
"CreateIndex": ,
"ModifyIndex": ,
"Node": "n4",
"ServiceAddress": "127.0.0.1",
"ServiceEnableTagOverride": false,
"ServiceID": "web3",
"ServiceName": "web3",
"ServicePort": ,
"ServiceTags": [
"master"
],
"TaggedAddresses": {
"lan": "192.168.217.161",
"wan": "192.168.217.161"
}
}
] [root@localhost ~]# dig @127.0.0.1 -p web3.service.consul SRV ; <<>> DiG 9.9.-RedHat-9.9.-.el7_2. <<>> @127.0.0.1 -p web3.service.consul SRV
; ( server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id:
;; flags: qr aa rd; QUERY: , ANSWER: , AUTHORITY: , ADDITIONAL:
;; WARNING: recursion requested but not available ;; QUESTION SECTION:
;web3.service.consul. IN SRV ;; ANSWER SECTION:
web3.service.consul. IN SRV n4.node.bj1.consul. ;; ADDITIONAL SECTION:
n4.node.bj1.consul. IN A 127.0.0.1 ;; Query time: msec
;; SERVER: 127.0.0.1#(127.0.0.1)
;; WHEN: Thu Oct :: EDT
;; MSG SIZE rcvd: # 浏览器访问
http://192.168.217.161:8500/



CentOS7 Install Consul的更多相关文章
- centos7上consul的集群安装
centos7上consul的安装 ###一 下载 下载文件 wget https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_a ...
- Centos7 install Openstack - (第四节)添加计算服务(Nova)
Centos7 install Openstack - (第四节)添加计算服务(Nova) 我的blog地址:http://www.cnblogs.com/caoguo 该文根据openstack官方 ...
- Centos7 install Openstack - (第三节)添加镜像服务(Glance)
Centos7 install Openstack - (第三节)添加镜像服务(Glance) 我的blog地址:http://www.cnblogs.com/caoguo 该文根据openstack ...
- (dev mode) install CONSUL on ubuntu
WSL: V18.04.1 1. install $sudo apt-get update$sudo apt-get install consul wsl1017@DESKTOP-14G6K9S:~$ ...
- centos7 install vim8
centos7 install vim8 Git and dependency Git: https://github.com/vim/vim # yum install -y perl-devel ...
- CentOS7 Install Shipyard
# 采集木jj 原文:http://www.cnblogs.com/caoguo/p/5735189.html # CentOS7 Install Shipyard# yum install dock ...
- CentOS7 install vsftpd
#mkdir -p /var/ftp/xcl/ #yum install -y vsftpd#useradd -g ftp -M -d /var/ftp/xcl -s /sbin/nologin xc ...
- centos7 install nginx+fastdfs
说明:centos7单机部署 nginx fastdfs ## 创建一下目录作为存储数据图片的路径 可以自己定义 mkdir -pv /data/application/{storage,tracke ...
- docker centos7创建consul镜像以及用docker-compose启动镜像
直接贴代码了: Dockfile: # Version 0.1 FROM kuba_centos7 MAINTAINER kuba si812cn@163.com # This is the rele ...
随机推荐
- String StringBuffer StringBuilder 对比
1.StringBuffer是线程安全的,StringBuilder是非线程安全的 2.对String的修改其实是new了一个StringBuilder并调用append方法,然后调用toSt ...
- camera闪光灯校准
1. adb shell 2. setprop z.flash_ratio 1 3. 全黑环境下,请将手机固定,对着白墙10cm,固定. 4. 点击拍照,然后手机会自动打闪2(Duty num)次(其 ...
- ISA总线
ISA总线: (Industry Standard Architecture:工业标准体系结构)是为PC/AT电脑而制定的总线标准,为16位体系结构,只能支持16位的I/O设备,数据传输率大约是16M ...
- Iterator 使用
Configuration cfg = new Configuration().configure(); SessionFactory factory = cfg.buildSessionFactor ...
- 将多个jar合并为一个jar
有时候,我们需要将多个jar合并为一个jar,ant提供了这样的一个功能 build.xml文件如下 执行以上任务会将 当前目录下的 mysql.jar,commons-io.jar合并为一个 all ...
- Oracle sql执行计划解析
Oracle sql执行计划解析 https://blog.csdn.net/xybelieve1990/article/details/50562963 Oracle优化器 Oracle的优化器共有 ...
- vue 随笔 vue 的属性和方法
新建的项目中main.js是项目的入口文件 npm run dev 运行文件 npm run bulid 编译 属性与方法 每个Vue实例都会代理其 data 对象里所有的属性: var data= ...
- window下 node.js 的安装
下载安装文件 Node.js安装包及源码下载地址为:https://nodejs.org/en/download/. 32 位安装包下载地址 : https://nodejs.org/dist/v4. ...
- 解决IE和firefox 下flash盖住div的问题(转载)
原文地址:http://www.oschina.net/question/171410_26563 做的企业站 顶部是flash的滚动图片. 右侧是在线客户,但是flash盖住了在线客户的div 网上 ...
- javascript使用正则表达式,从字符串提取内容,多数组解析
JavaScript有两种方式创建一个正则表达式: 第一种方式是直接通过/正则表达式/写出来,第二种方式是通过new RegExp('正则表达式')创建一个RegExp对象. 如: var re1 = ...