首页 > 编程语言 >etcd——源码编译、学习

etcd——源码编译、学习

时间:2022-08-17 13:23:23浏览次数:44  
标签:http urls -- 192.168 编译 源码 etcd 1.32

借一张图

 

1、下载

https://github.com/etcd-io/etcd

git clone https://github.com/nats-io/nats-server.git

 

2、编译

进入etcd目录,

 

mac/linux下,   make clean  &&   make build

在etcd/bin目录下,生成 etcd  etcdctl   etcdutl 三个可执行文件

 

在win10下,不用make的前提下,

go build -o bin\etcd.exe server\main.go

go build -o bin\etcdctl.exe etcdctl\main.go

 

出现\etcd\client\v3 目录下诸多文件报错,这些文件都用的目录引用,

把真实目录 \etcd\tests\integration\clientv3\examples下对应的文件直接替换 D:\git\go\etcd\etcd\client\v3 目录下的,

重新编译即可。

 

3、单节点启动

命令行下: 

etcd -data-dir ~/data.etcd -advertise-client-urls  http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379

在 goland ide 下,加启动参数

--data-dir bin\in-ide.etcd --advertise-client-urls http://0.0.0.0:2379 --listen-client-urls http://0.0.0.0:2379  

 

4、测试

etcdctl member list
etcdctl --endpoints=10.60.80.11:2379 member list

etcdctl --endpoints=10.60.80.11:2379 put foo hihi
etcdctl --endpoints=10.60.80.11:2379 get foo

 

5、win10下集群部署与测试

1、win 10 环境
下载  https://github.com/etcd-io/etcd/releases
解压 etcd-v3.4.20-windows-amd64.zip

2、启动命令见
https://blog.51cto.com/u_10125763/3700481

3、依次启动 start1.bat   start2.bat  start3.bat

4、查看集群状态
etcdctl --endpoints=[192.168.1.32:2379,192.168.1.32:3379,192.168.1.32:4379]   member list

etcdctl --endpoints=[192.168.1.32:2379,192.168.1.32:3379,192.168.1.32:4379]   endpoint health --cluster=true

etcdctl --endpoints=10.60.80.11:2379 member list

5、查看服务发现
etcdctl --endpoints=[192.168.1.32:2379,192.168.1.32:3379,192.168.1.32:4379]   get /game/sanguo-test/server_state/gateway/1660642593870881200
/game/sanguo-test/server_state/gateway/1660642593870881200

start1.bat

.\etcd.exe --name etcd01 ^
--data-dir .\data\etcd01 ^
--advertise-client-urls http://192.168.1.32:2379 ^
--listen-client-urls http://192.168.1.32:2379 ^
--listen-peer-urls http://192.168.1.32:2380 ^
--initial-advertise-peer-urls http://192.168.1.32:2380 ^
--initial-cluster-token etcd-cluster-1 ^
--initial-cluster etcd01=http://192.168.1.32:2380,etcd02=http://192.168.1.32:2381,etcd03=http://192.168.1.32:2382 ^
--initial-cluster-state new

pause

start2.bat

.\etcd.exe --name etcd02 ^
--data-dir .\data\etcd02 ^
--advertise-client-urls http://192.168.1.32:3379 ^
--listen-client-urls http://192.168.1.32:3379 ^
--listen-peer-urls http://192.168.1.32:2381 ^
--initial-advertise-peer-urls http://192.168.1.32:2381 ^
--initial-cluster-token etcd-cluster-1 ^
--initial-cluster etcd01=http://192.168.1.32:2380,etcd02=http://192.168.1.32:2381,etcd03=http://192.168.1.32:2382 ^
--initial-cluster-state new

pause

start3.bat

.\etcd.exe --name etcd03 ^
--data-dir .\data\etcd03 ^
--advertise-client-urls http://192.168.1.32:4379 ^
--listen-client-urls http://192.168.1.32:4379 ^
--listen-peer-urls http://192.168.1.32:2382 ^
--initial-advertise-peer-urls http://192.168.1.32:2382 ^
--initial-cluster-token etcd-cluster-1 ^
--initial-cluster etcd01=http://192.168.1.32:2380,etcd02=http://192.168.1.32:2381,etcd03=http://192.168.1.32:2382 ^
--initial-cluster-state new

pause

 

6、mac/linux下集群部署

创建执行文件

touch etcd-static.sh

在每个etcd节点上,指定集群成员。

# 指定集群token
# 如果你所在的网络环境配置了多个etcd集群,为了避免意外发生,最好使用-initial-cluster-token参数为每个集群单独配置一个token认证。
# 这样就可以确保每个集群和集群的成员都拥有独特的ID。 TOKEN=token-01 CLUSTER_STATE=new NAME_1=machine-1 NAME_2=machine-2 NAME_3=machine-3 HOST_1=192.168.199.140 HOST_2=192.168.199.141 HOST_3=192.168.199.142 CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380

每个节点添加一下各节点对应启动命令行

THIS_NAME=${NAME_1}
THIS_IP=${HOST_1}
/opt/etcd-v3.2.32-linux-amd64/etcd --data-dir=data.etcd --name ${THIS_NAME} \
    --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
    --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
    --initial-cluster ${CLUSTER} \
    --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
    
THIS_NAME=${NAME_2}
THIS_IP=${HOST_2}
/opt/etcd-v3.2.32-linux-amd64/etcd --data-dir=data.etcd --name ${THIS_NAME} \
    --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
    --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
    --initial-cluster ${CLUSTER} \
    --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
    
THIS_NAME=${NAME_3}
THIS_IP=${HOST_3}
/opt/etcd-v3.2.32-linux-amd64/etcd --data-dir=data.etcd --name ${THIS_NAME} \
    --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 \
    --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 \
    --initial-cluster ${CLUSTER} \
    --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}

 

启动服务:sh etcd-static.sh

 

标签:http,urls,--,192.168,编译,源码,etcd,1.32
From: https://www.cnblogs.com/xingchong/p/16594799.html

相关文章

  • jar包反编译 idea
    java-cp"D:\quan\install_work\idea2019\plugins\java-decompiler\lib\java-decompiler.jar"org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler-dgs=t......
  • Ubuntu源码安装遇到的问题
    Ubuntu源码安装遇到的问题问题1.xml/apr_xml.c:35:10:fatalerror:expat.h:没有那个文件或目录35|#include<expat.h>|^~~~~~~~~原因:缺少ex......
  • vue源码阅读—13—扩展之transition
      <style>.fade-enter-active,.fade-leave-active{transition:opacity5s;}.fade-enter,.fade-leave-to{......
  • VS编译时提示“无法查找或打开 PDB 文件”的解决方法
     有时候,我们使用VS(VisualStudio)编译程序时会出现“无法查找或打开PDB文件”的提示,并且此时程序会生成失败,无法运行,如下图所示: 大家不要惊慌,出现这种提示并不是代码......
  • java线程池源码阅读
    说明简单理解和使用可以参考:https://www.cnblogs.com/LQBlog/p/8735356.html类图接口Executor接口publicinterfaceExecutor{/***代表提交了一个任......
  • idea中jar包关联源码
    1、问题描述idea中jar包关联源码,方便查看了解源码,记录下。2、问题说明springboot源码包,直接zip下载就好了。下载地址:https://github.com/spring-projects/spring-boot......
  • doris-flink-connect1.14.5编译及问题处理
    1前提条件编译源码来自https://github.com/apache/doris-flink-connector,日期2022-08-161.1版本dorisflinkJDK1.1.11.14.51.81.2是否独立编译没有......
  • can not find -lgl,记一次Qt Creator编译报错的解决
    某次在终端使用apt进行软维护时,提示某些软件包不再使用,可以使用autoremove进行清理。当时没多想,就依照提示使用autoremove进行了清理,具体清理了哪些地方的哪些软件包、链......
  • Dubbo源码(八) - 负载均衡
    前言本文基于Dubbo2.6.x版本,中文注释版源码已上传github:xiaoguyu/dubbo负载均衡,英文名称为LoadBalance,其含义就是指将负载(工作任务)进行平衡、分摊到多个操作单元上进行......
  • 编译适合CDH6.3.2的spark3.3.2
    1、版本对应编译环境:jdk:1.8.0_181maven:3.6.3scala2.12.0配置环境变量#jdkexportJAVA_HOME=/usr/java/jdk1.8.0_181-amd64exp......