做个笔记下

--

前言

部分内容有参考网友的,但是地址不记得了!

安装内容基本参考官网的和上一个网友的

官网地址:

https://www.consul.io/downloads

以下是使用root方式安装的。

如果是consul,则建议先创建consul用户,再以consul登录

安装

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install consul
注意:root用户,省略sudu

配置

启动服务配置-修改启动文件consul.service
[Unit]
Description="HashiCorp Consul - A service mesh solution"
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/etc/consul.d/consul.hcl

[Service]
EnvironmentFile=/etc/consul.d/consul.env
User=root
Group=root
ExecStart=/usr/bin/consul agent -config-dir=/etc/consul.d/
#不持久化 -dev
#ExecStart=/usr/bin/consul agent -dev  -config-dir=/etc/consul.d/
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

--

consul参数配置

具体可以看 https://www.consul.io/docs/agent/options

可以命令行,可以是json,hcl之类的,主要是为了兼容老习惯

添加额外的参数文件(在/etc/consul.d/下添加sever.json,注意只要是json结尾即可,叫啥无所谓)
{
  "datacenter": "dc1",
  "data_dir": "/data/data/consul",
  "log_level": "INFO",
  "node_name": "foobar",
  "server": true,
  "ports": {
        "http": 8500,
        "https": -1,
        "dns": 8600,
        "grpc": -1,
        "serf_lan": 8001,
        "serf_wan": 8002,
        "server": 8003
    }  
}

另外,这个版本中,有个默认的 /etc/consul.d/consul.hcl
修改几个参数:

# 任意客户端都可以链接--2021
client_addr = "0.0.0.0"
# 启动内置ui-web管理--2021dd
ui_config{
  enabled = true
}
bind_addr = "0.0.0.0"
advertise_addr = "127.0.0.1"

# 指定只有一个节点,否则总是会提示 No cluster leader
bootstrap_expect=1

这些配置的大体意思就是 使用server模式(单节点)启动,web端口为8500,任意客户端可以连接!

最后看下启动后的界面

看下管理界面

最后,能不能用,还得通过springboot来验证:https://www.cnblogs.com/MrSi/p/13961890.html

--- 根据以上的提示

Springboot工程验证

1.使用sts创建一个springboot工程,pom配置如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.lzf</groupId>
<artifactId>vehicle-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>consul-test</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2021.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<!-- 添加热部署 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<!-- 引入 Spring Boot Actuator 组件,因为需要通过它提供健康检查的接口给 Consul -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

2.创建一个application.properties

#开发-热部署
spring.devtools.restart.enabled=true
server.port=8762
# Spring
spring.application.name=customer-service #actuator监控信息
info.app.name=应用服务器-8762
info.company.name=org.lzf
info.build.artifactId=cloud-customer
info.build.version=1.0-SNAPSHOT
#其余省略

3.创建一个boostrap.yml

spring:
cloud:
consul:
config:
enabled: true
format: YAML
data-key: data
watch:
enabled: true
prefix: config
discovery:
enabled: true
heartbeat:
enabled: true
health-check-interval: 5s
health-check-path: /actuator/health
instance-id: customer-service.8762
prefer-ip-address: true
enabled: true
host: 114.67.246.199
port: 8500

4.启动类记得加注解 @EnableDiscoveryClient

最后检测是ok的:

京东云上centos8.2 安装 consul1.11.1的更多相关文章

  1. 阿里云服务器 centos 7 安装postgresql 11

    Postgresql简介 官方网站:https://www.postgresql.org/ 简介参考zhihu文章 https://www.zhihu.com/question/20010554 关于 ...

  2. 矩池云上nvidia opencl安装及测试教程

    本教程租用的是2080ti,3.7多框架镜像. 添加nvidia-cuda的阿里源 curl -fsSL https://mirrors.aliyun.com/nvidia-cuda/ubuntu18 ...

  3. 矩池云上如何快速安装tensorRT

    国内镜像 https://mirrors.cloud.tencent.com/nvidia-machine-learning/ubuntu1804/x86_64/ 检查系统版本 source /etc ...

  4. 矩池云上如何快速安装nvcc

    若您想要使用 nvcc,但是所选的镜像中没有预装 nvcc,可按照如下操作自行安装. 1.检查系统版本 source /etc/os-release && echo $VERSION_ ...

  5. JAE京东云引擎Git上传管理代码教程和京东云数据库导入导出管理

    文章目录 Git管理准备工作 Git工具上传代码 发布代码装程序 mywebsql管理 京东云引擎小结   JAE京东云引擎是京东推出的支持Java.Ruby.Python.PHP.Node.js多语 ...

  6. 干货 | 利用京东云Web应用防火墙实现Web入侵防护

    摘要 本指南描述如何利用京东云Web应用防火墙(简称WAF),对一个简单的网站(无论运行在京东云.其它公有云或者IDC)进行Web完全防护的全过程.该指南包括如下内容: 准备环境 在京东云上准备Web ...

  7. 干货 | 运维福音——Terraform自动化管理京东云

    干货 | 运维福音--Terraform自动化管理京东云 原创: 张宏伟 京东云开发者社区  昨天 Terraform是一个高度可扩展的IT基础架构自动化编排工具,主张基础设施即代码,可通过代码集中管 ...

  8. 干货 | 京东云Kubernetes集群+Traefik实战

    摘要 Traefik支持丰富的annotations配置,可配置众多出色的特性,例如:自动熔断.负载均衡策略.黑名单.白名单.所以Traefik对于微服务来说简直就是一神器. 利用Traefik,并结 ...

  9. Developer Friendly | 基础设施即代码的事实标准Terraform已支持京东云!

    Developer Friendly | 基础设施即代码的事实标准Terraform已支持京东云! Chef.Puppet.Ansible.SaltStack 都可以称为配置管理工具,这些工具的主要目 ...

  10. 京东云数据库 RDS助力企业便捷运维

    iPhone6发布那年,京东在国贸等商圈送货最快速度数分钟,包括从下单到送达.这是一个极端的富含营销因素例子.即便如此,常态来看,隔天到货的这种业务模式,也是基于同样的支撑:营销业务.物流业务,大数据 ...

随机推荐

  1. [FAQ] Vue iframe 的 src 是链接地址却加载了相对路径 ?

    iframe 的 src 是链接, 但是加载的实际链接是相对路径,只有一种可能:链接地址不正确. 检查链接有没有少符号,常见错误:http//,http:/ Refer:Vue的iframe错误 Li ...

  2. 扎克伯格说,Llama3-8B还是太大了,量化、剪枝、蒸馏准备上!

    扎克伯格说,Llama3-8B还是太大了,不适合放到手机中,有什么办法? 量化.剪枝.蒸馏,如果你经常关注大语言模型,一定会看到这几个词,单看这几个字,我们很难理解它们都干了些什么,但是这几个词对于现 ...

  3. dotnet C# 基础 为什么 GetHashCode 推荐只取只读属性或字段做哈希值

    在 C# 里面,所有的对象都继承 Object 类型,此类型有开放 GetHashCode 用于给开发者重写.此 GetHashCode 方法推荐是在重写 Equals 方法时也同时进行重写,要求两个 ...

  4. 2019-3-15-uwp-ScrollViewer-content-out-of-panel-when-set-the-long-width

    title author date CreateTime categories uwp ScrollViewer content out of panel when set the long widt ...

  5. vue中vant-list组件实现下拉刷新,上滑加载

    后端返回的数据是一股脑的情况(不是按pageSize,pageNum一组一组的发送)时,前端使用vant-list实现懒加载需要再写一点js,记录一下 main.js: Vue.use(List); ...

  6. vue+vant+js实现购物车原理小demo(高级版选择与反选)

    新增反选功能.上图(这个系列系利用前端框架的原创): main.js: Vue.use(Stepper); Vue.use(Checkbox); Vue.use(CheckboxGroup); .vu ...

  7. linux用户与用户组管理

    linux用户与用户组管理 目录 linux用户与用户组管理 1.linux用户管理 1.1 用户基础 1.2 /etc/passwd:用户信息文件 1.3 /etc/shadow:用户密码信息文件 ...

  8. xlwings模块详解

    中文文档:https://www.kancloud.cn/gnefnuy/xlwings-docs/1127454 import xlwings#查找包路径print(xlwings.__path__ ...

  9. Istio(六):Istio弹性(超时&重试)和故障注入

    目录 一.模块概览 二.系统环境 三.弹性(超时&重试) 3.1 弹性 四.故障注入 4.1 故障注入 五.实战:观察错误注入 5.1 在 Grafana.Zipkin 和 Kiali 中观察 ...

  10. WebView2在WPF中的应用

    开发环境 运行环境:.Net 6 开发环境:Visual Studio 2022 17.1.3 框架语言:WPF 安装WebView2 通过Package Manager控制台安装 Install-P ...