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 ...
随机推荐
- Mac Mysql [ERR] 2006 - MySQL server has gone away
Mac mysql 安装后,导入sql数据,出现这个错误: 处理方式,是因为sql文件太大,需要修改mysql的配置.如果没有my.cnf就自己建一个. cd /etc sudo vim my.cnf ...
- Android 6.0 RK3288 ROM编译详解+命令详解【转】
本文转载自:http://blog.csdn.net/MLQ8087/article/details/58607692 Android 6.0 RK3288 ROM编译详解+命令详解 原创 2017年 ...
- MkDocs -- Project documentation with Markdown
/************************************************************************ * MkDocs -- Project docume ...
- gevent 协程 使用
Python通过yield提供了对协程的基本支持,但是不完全.而第三方的gevent为Python提供了比较完善的协程支持. gevent是第三方库,通过greenlet实现协程,其基本思想是: 当一 ...
- zip压缩文件测试
http://tech.it168.com/a2009/0604/583/000000583382_5.shtml ]; MessageBox.Show(string.F ...
- sum=1+2+3+…+100
sum = 1 for i in range(0,101): # sum = sum + i sum += i print(sum) sum +=i 等于 sum = sum + i
- robotframework 随机选中下拉框中的值
示例脚本: click element id=provinceName #点击地区 省 wait until element is enabled xpath=.//*[@id='provinceNa ...
- cmath函数整理
double a= pow(double x, double y)://返回x的y次方. double a= sqrt(double x)://返回x的平方根. double a=ceil(doubl ...
- maven配置文件注意事项
1:安装完成后在C:\Users\Administrator\.m2有一个文件settings.xml需要修改一下配置 2:设置maven从网上下载的jar包.(时间长会很大).我设置它保存我的电脑位 ...
- 洛谷 P2763 试题库问题【最大流】
s向所有类别属性连流量为当前类别属性需要的个数的边,所有题目向t连流量为1的边(表示只能选一次),所有属性向含有它的题连容量为1的边.跑一变dinic,结果小于m则无解,否则看每一个类别属性连出去的题 ...