Go环境下编译运行etcd与goreman管理

近几年了Go在比特币、区块链、云服务等相关重要领域贡献突出,作为IT行业的传承“活到老、学到光头”,保持学习心态。

周末放假,补充一二

主题:在Go环境下首试传闻已久的etcd与goreman, 开源高性能KV集群服务,并提供共享配置、服务的注册和发现,在当前微服务流行的年代,充当着中间存储与代理服务的重要角色,除了与redis相对比功能相似外,etcd更贴近于微服务集成,得益于它的共享配置、服务的注册和发现。

SO,试行一把并作记录~~

1.安装Golang

下载地址: https://studygolang.com/dl 各平台版本按需自助,

此处for MAC: https://studygolang.com/dl/golang/go1.12.1.darwin-amd64.pkg

2.获取etcd与goreman源码

go get github.com/etcd-io/etcd
go get github.com/mattn/goreman

3.编译,并生成exe到$GOPATH/bin目录,( go build编译输出到main文件同目录,go install编译输出到$GOPATH/bin )

go install github.com/etcd-io/etcd          #KV服务
go install github.com/etcd-io/etcd/etcdctl   #读写控件
go install github.com/mattn/goreman        #KV集群管理

4.启动执行,启动goreman需要一个集群配置来启动和管理集群的etcd,并选中其中一个作为Master其余作为Slave

创建 $GOPATH/bin/Procfile文件

# Use goreman to run `go get github.com/mattn/goreman`
etcd1: etcd --name infra1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:12380 --initial-advertise-peer-urls http://127.0.0.1:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr
etcd2: etcd --name infra2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls http://127.0.0.1:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr
etcd3: etcd --name infra3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls http://127.0.0.1:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr
#proxy: etcd grpc-proxy start --endpoints=127.0.0.1:,127.0.0.1:,127.0.0.1: --listen-addr=127.0.0.1: --advertise-client-url=127.0.0.1: --enable-pprof

执行命令

PS:~/go/bin goreman start 

附:更多转阅 https://frank6866.gitbooks.io/linux/content/chapters/db/db-etcd-etcdctl.html

5.验证结果

当前启动集群:

http://127.0.0.1:2379
http://127.0.0.1:22379
http://127.0.0.1:32379

往其中一个服务添加一个key,然后在另外两个服务读取

# 添加一个Key,默认缺省endpoints服务为端口2379,可以不用写
etcdctl put mykey "this is a hello world" # 在2379上读取
etcdctl get mykey # 在22379上读取
etcdctl --endpoints=http://localhost:22379 get mykey # 在33379上读
etcdctl --endpoints=http://localhost:32379 get mykey

Bingo~

Go环境下,编译运行etcd与goreman集群管理(1)的更多相关文章

  1. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:3.安装Oracle RAC-3.6.集群管理命令

    3.6. 集群管理命令 3.6.1. RAC的启动与关闭 oracle rac默认会开机自启动,如需维护时可使用以下命令: 关闭: crsctl stop cluster 停止本节点集群服务 crsc ...

  2. 在linux环境下编译运行OpenCV程序的两种方法

    原来以为在Ubuntu下安装好了OpenCV之后,自己写个简单的程序应该很容易吧,但是呢,就是为了编译一个简单的显示图片的程序我都快被弄崩溃了. 在谷歌和上StackOverFlow查看相关问题解答之 ...

  3. Linux环境下配置及启动Hadoop(伪集群)

    1.下载tag软件包后,我习惯放到software文件夹下,并建立app文件夹2.通过tar -zxvf hadoop-2.6.0-cdh5.7.0.tar.gz -C ~/app/ 命令解压到app ...

  4. linux环境下redis安装(redis伪集群搭建)

    redis在linux环境下搭建 1.创建目录 [root@192 local]# mkdir /usr/local/redis 2.下载redis,并解压 [root@192 local]# wge ...

  5. Centos6.9下RocketMQ3.4.6高可用集群部署记录(双主双从+Nameserver+Console)

    之前的文章已对RocketMQ做了详细介绍,这里就不再赘述了,下面是本人在测试和生产环境下RocketMQ3.4.6高可用集群的部署手册,在此分享下: 1) 基础环境 ip地址 主机名 角色 192. ...

  6. Redhat环境下编译安装Google Bazel

    Redhat环境下编译安装bazel 作者:Jack47 目前Google Bazel没有提供各个操作系统下的二进制安装包,只提供源代码,需要我们自己编译安装,详情可以见我翻译的中文版Google B ...

  7. Android 环境下编译FFmpeg

    Android 环境下编译FFmpeg 开发环境:Ubuntu 12.04.2 LTS , android-sdk-linux, android-ndk-r8e 一 .X264 编译 1.    X2 ...

  8. Boost学习总结(一)VS2010环境下编译STLport和Boost

    Boost学习总结(一)VS2010环境下编译STLport和Boost Boost简介 Boost库是一个功能强大.构造精巧.跨平台.开源并且完全免费的C++程序库.1998年,Beman G.Da ...

  9. libCURL开源库在VS2010环境下编译安装,配置详解

    libCURL开源库在VS2010环境下编译安装,配置详解 转自:http://my.oschina.net/u/1420791/blog/198247 http://blog.csdn.net/su ...

随机推荐

  1. 2017最新整理移动Web开发遇到的坑

    随着前端的热度不断升温,行业对前端的要求越来越高:精准无误的实现UI设计,已成为前端职业更加精细化的一种表现:随着移动互联网的发展.WebApp似乎一种不可逾越的鸿沟:越来越多的企业开始趋势于轻量级的 ...

  2. 第四章 栈与队列(a)栈接口与实现

  3. c# 键值对的方式post提交

    DataContractJsonSerializer jsQcData = new DataContractJsonSerializer(typeof(DATA<data>));//DAT ...

  4. 我的图片爬虫demo

    本来是根据scrapy教程写了一个下载图片的简易爬虫,但是搞了一天,死活下载不了图片. 然后换了一个网站,用原生的库写了一个图片爬虫. import urllib.requestimport osde ...

  5. 浅谈CSRF

    CSRF是什么? (Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,它在 2007 年曾被列为互联网 20 大安全隐患之一,也被称为“One Click ...

  6. The following packages have unmet dependencies错误

    当出现类似这类错误: The following packages have unmet dependencies: python-dev : Depends: python (= 2.7.5-5ub ...

  7. Python数据分析--Pandas知识点(二)

    本文主要是总结学习pandas过程中用到的函数和方法, 在此记录, 防止遗忘. Python数据分析--Pandas知识点(一) 下面将是在知识点一的基础上继续总结. 13. 简单计算 新建一个数据表 ...

  8. 产品密钥无法激活成功,最后使用visio2013激活软件激活成功。

    装了visio2013,使用网上搜索的产品密钥,没有一个能够激活成功.最后发现了visio的一个激活软件KMSpico,成功激活. 破解工具 KMSpico_setup.exe 下载地址: http: ...

  9. Java并发-volatile的原理及用法

    Java并发-volatile的原理及用法 volatile属性:可见性.保证有序性.不保证原子性.一.volatile可见性 在Java的内存中所有的变量都存在主内存中,每个线程有单独CPU缓存内存 ...

  10. The 10 Best Choices On The Market Review 2018

    Looking to buy a scan tool or considering one of Autel Scanner impressive product line?. The company ...