一个空间只能放一个网站吗,网页版微信怎么退出,wordpress 开通json,邱杰wordpress要在 Windows 上编译 etcd 及 etcdctl 工具#xff0c;并使用 bat 脚本启动 etcd 集群#xff0c;首先需要准备好开发环境并确保依赖项正确安装。下面是从 etcd 3.5 源码开始编译和启动 etcd 集群的详细步骤#xff1a; 目录 1. 安装 Go 环境2. 获取 etcd 源码3. 编译 etcd…要在 Windows 上编译 etcd 及 etcdctl 工具并使用 bat 脚本启动 etcd 集群首先需要准备好开发环境并确保依赖项正确安装。下面是从 etcd 3.5 源码开始编译和启动 etcd 集群的详细步骤 目录 1. 安装 Go 环境2. 获取 etcd 源码3. 编译 etcd 和 etcdctl4. 创建 Windows 启动脚本bat 文件5. 启动 etcd 集群6. 验证 etcd 集群7.向集群中添加数据8.总结 1. 安装 Go 环境
首先确保你已经安装了 Go 环境。etcd 是用 Go 编写的因此需要 Go 编译器来构建代码。
从 Go 官网 下载并安装最新版本的 Go。设置 Go 环境变量 将 Go 的 bin 目录添加到 PATH 中例如C:\Go\bin。设置 GOPATH 和 GOMOD 环境变量例如GOPATHC:\go_workspace。
2. 获取 etcd 源码
通过 Git 克隆 etcd 的 GitHub 仓库选择 release-3.5 分支来编译。
git clone --branch release-3.5 https://github.com/etcd-io/etcd.git
cd etcd3. 编译 etcd 和 etcdctl
安装编译 etcd 所需的依赖。进入 etcd 目录后运行以下命令来编译 etcd 和 etcdctl 工具。
go mod tidy # 安装依赖
cd server # 进入server目录
go build -o etcd.exe main.go # 编译 etcdcd ../etcdctl # 进入etcdctl目录
go build -o etcdctl.exe main.go # 编译 etcdctl生成 etcd.exe 和 etcdctl.exe 文件
4. 创建 Windows 启动脚本bat 文件
在etcd.exe、etcdctl.exe拷贝到D:\data目录下,并且此目录下新建start_etcd_cluster.bat文件。
在 Windows 上启动 etcd 集群需要一个批处理文件 (.bat) 来启动 etcd 服务。下面是一个简单的 etcd 集群启动脚本示例
echo off
REM 设置通用参数
set TOKENtoken-01
set CLUSTER_STATEnew
set NAME_1machine-1
set NAME_2machine-2
set NAME_3machine-3
set HOST_1127.0.0.1
set HOST_2127.0.0.1
set HOST_3127.0.0.1
set PEER_PORT_12380
set PEER_PORT_22381
set PEER_PORT_32382
set CLIENT_PORT_12379
set CLIENT_PORT_22383
set CLIENT_PORT_32384
set CLUSTER%NAME_1%http://%HOST_1%:%PEER_PORT_1%,%NAME_2%http://%HOST_2%:%PEER_PORT_2%,%NAME_3%http://%HOST_3%:%PEER_PORT_3%REM 创建目录存储 etcd 数据
mkdir data.etcd1
mkdir data.etcd2
mkdir data.etcd3REM 启动第一个 etcd 实例
start etcd.exe --data-dirdata.etcd1 --name %NAME_1% ^--initial-advertise-peer-urls http://%HOST_1%:%PEER_PORT_1% --listen-peer-urls http://%HOST_1%:%PEER_PORT_1% ^--advertise-client-urls http://%HOST_1%:%CLIENT_PORT_1% --listen-client-urls http://%HOST_1%:%CLIENT_PORT_1% ^--initial-cluster %CLUSTER% ^--initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN% ^--log-level debugREM 启动第二个 etcd 实例
start etcd.exe --data-dirdata.etcd2 --name %NAME_2% ^--initial-advertise-peer-urls http://%HOST_2%:%PEER_PORT_2% --listen-peer-urls http://%HOST_2%:%PEER_PORT_2% ^--advertise-client-urls http://%HOST_2%:%CLIENT_PORT_2% --listen-client-urls http://%HOST_2%:%CLIENT_PORT_2% ^--initial-cluster %CLUSTER% ^--initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN% ^--log-level debugREM 启动第三个 etcd 实例
start etcd.exe --data-dirdata.etcd3 --name %NAME_3% ^--initial-advertise-peer-urls http://%HOST_3%:%PEER_PORT_3% --listen-peer-urls http://%HOST_3%:%PEER_PORT_3% ^--advertise-client-urls http://%HOST_3%:%CLIENT_PORT_3% --listen-client-urls http://%HOST_3%:%CLIENT_PORT_3% ^--initial-cluster %CLUSTER% ^--initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN% ^--log-level debugecho All etcd instances started with debug logging. Press any key to exit...
pausepause保存此文件为 start_etcd_cluster.bat。该脚本会启动一个3个节点的 etcd 集群。
5. 启动 etcd 集群 双击 start_etcd_cluster.bat 文件启动 etcd 集群。如果一切配置正确etcd 应该会启动并监听 localhost:2379、localhost:2383、localhost:2384客户端和 localhost:2380、localhost:2381、localhost:2382集群。
6. 验证 etcd 集群
可以先设置环境变量
set ETCDCTL_API3
set ETCDCTL_ENDPOINTShttp://127.0.0.1:2379,http://127.0.0.1:2383,http://127.0.0.1:2384ETCDCTL_API3: 通知etcdctl客户端工具使用v3的api。
ETCDCTL_ENDPOINTS: 设置 etcdctl的集群连接地址信息。
打开命令提示符并使用 etcdctl 工具验证集群状态
D:\dataetcdctl --endpointshttp://localhost:2379 member list
264ae6bc59e99892, started, machine-1, http://127.0.0.1:2380, http://127.0.0.1:2379, false
8231876619f7abe6, started, machine-3, http://127.0.0.1:2382, http://127.0.0.1:2384, false
ad94f96e205aed4b, started, machine-2, http://127.0.0.1:2381, http://127.0.0.1:2383, false7.向集群中添加数据
D:\dataetcdctl put key1 value1
OK8.总结
以上是如何从 etcd 3.5 源码开始编译 etcd 和 etcdctl 工具并使用 .bat 脚本在 Windows 上启动 etcd 集群的步骤。希望这些步骤能帮助你顺利地编译和部署 etcd。如何有什么疑问可以在下面留言交流。 文章转载自: http://www.morning.jpbky.cn.gov.cn.jpbky.cn http://www.morning.jppb.cn.gov.cn.jppb.cn http://www.morning.qydgk.cn.gov.cn.qydgk.cn http://www.morning.fqqlq.cn.gov.cn.fqqlq.cn http://www.morning.npmpn.cn.gov.cn.npmpn.cn http://www.morning.lsqmb.cn.gov.cn.lsqmb.cn http://www.morning.rmtmk.cn.gov.cn.rmtmk.cn http://www.morning.tkhyk.cn.gov.cn.tkhyk.cn http://www.morning.mjqms.cn.gov.cn.mjqms.cn http://www.morning.dzqyn.cn.gov.cn.dzqyn.cn http://www.morning.wrbf.cn.gov.cn.wrbf.cn http://www.morning.sdkaiyu.com.gov.cn.sdkaiyu.com http://www.morning.rdlxh.cn.gov.cn.rdlxh.cn http://www.morning.saastob.com.gov.cn.saastob.com http://www.morning.sqfrg.cn.gov.cn.sqfrg.cn http://www.morning.nysjb.cn.gov.cn.nysjb.cn http://www.morning.kxnnh.cn.gov.cn.kxnnh.cn http://www.morning.rshs.cn.gov.cn.rshs.cn http://www.morning.rmqmc.cn.gov.cn.rmqmc.cn http://www.morning.rqgbd.cn.gov.cn.rqgbd.cn http://www.morning.yrgb.cn.gov.cn.yrgb.cn http://www.morning.rdnjc.cn.gov.cn.rdnjc.cn http://www.morning.jtqxs.cn.gov.cn.jtqxs.cn http://www.morning.dkqyg.cn.gov.cn.dkqyg.cn http://www.morning.wqpr.cn.gov.cn.wqpr.cn http://www.morning.mgbsp.cn.gov.cn.mgbsp.cn http://www.morning.kgphd.cn.gov.cn.kgphd.cn http://www.morning.fbdtd.cn.gov.cn.fbdtd.cn http://www.morning.qclmz.cn.gov.cn.qclmz.cn http://www.morning.dlgjdg.cn.gov.cn.dlgjdg.cn http://www.morning.lhqw.cn.gov.cn.lhqw.cn http://www.morning.rbmnq.cn.gov.cn.rbmnq.cn http://www.morning.sgnxl.cn.gov.cn.sgnxl.cn http://www.morning.jpwmk.cn.gov.cn.jpwmk.cn http://www.morning.bpmtx.cn.gov.cn.bpmtx.cn http://www.morning.mqfw.cn.gov.cn.mqfw.cn http://www.morning.swkzr.cn.gov.cn.swkzr.cn http://www.morning.wbfly.cn.gov.cn.wbfly.cn http://www.morning.qmnjn.cn.gov.cn.qmnjn.cn http://www.morning.wklrz.cn.gov.cn.wklrz.cn http://www.morning.jwrcz.cn.gov.cn.jwrcz.cn http://www.morning.ztqyj.cn.gov.cn.ztqyj.cn http://www.morning.xpqdf.cn.gov.cn.xpqdf.cn http://www.morning.cfqyx.cn.gov.cn.cfqyx.cn http://www.morning.qfdyt.cn.gov.cn.qfdyt.cn http://www.morning.rzcmn.cn.gov.cn.rzcmn.cn http://www.morning.fphbz.cn.gov.cn.fphbz.cn http://www.morning.qcdhg.cn.gov.cn.qcdhg.cn http://www.morning.jwtjf.cn.gov.cn.jwtjf.cn http://www.morning.qnzk.cn.gov.cn.qnzk.cn http://www.morning.zkgpg.cn.gov.cn.zkgpg.cn http://www.morning.zrlwl.cn.gov.cn.zrlwl.cn http://www.morning.syqtt.cn.gov.cn.syqtt.cn http://www.morning.ntffl.cn.gov.cn.ntffl.cn http://www.morning.ljsxg.cn.gov.cn.ljsxg.cn http://www.morning.wnkqt.cn.gov.cn.wnkqt.cn http://www.morning.ypqwm.cn.gov.cn.ypqwm.cn http://www.morning.jypqx.cn.gov.cn.jypqx.cn http://www.morning.thnpj.cn.gov.cn.thnpj.cn http://www.morning.pgcmz.cn.gov.cn.pgcmz.cn http://www.morning.fhbhr.cn.gov.cn.fhbhr.cn http://www.morning.kfysh.com.gov.cn.kfysh.com http://www.morning.mzbyl.cn.gov.cn.mzbyl.cn http://www.morning.qhrsy.cn.gov.cn.qhrsy.cn http://www.morning.zgnng.cn.gov.cn.zgnng.cn http://www.morning.pmysp.cn.gov.cn.pmysp.cn http://www.morning.cgstn.cn.gov.cn.cgstn.cn http://www.morning.skqfx.cn.gov.cn.skqfx.cn http://www.morning.qlznd.cn.gov.cn.qlznd.cn http://www.morning.pnjsl.cn.gov.cn.pnjsl.cn http://www.morning.lmbm.cn.gov.cn.lmbm.cn http://www.morning.trtxt.cn.gov.cn.trtxt.cn http://www.morning.etsaf.com.gov.cn.etsaf.com http://www.morning.tfsyk.cn.gov.cn.tfsyk.cn http://www.morning.qhrdx.cn.gov.cn.qhrdx.cn http://www.morning.yxwcj.cn.gov.cn.yxwcj.cn http://www.morning.mlfgx.cn.gov.cn.mlfgx.cn http://www.morning.ylpl.cn.gov.cn.ylpl.cn http://www.morning.ldqrd.cn.gov.cn.ldqrd.cn http://www.morning.kfwqd.cn.gov.cn.kfwqd.cn