image xiufu
This commit is contained in:
parent
f935f57b02
commit
cb8f117cfb
7
.obsidian/app.json
vendored
7
.obsidian/app.json
vendored
@ -1,7 +0,0 @@
|
||||
{
|
||||
"legacyEditor": false,
|
||||
"attachmentFolderPath": "./assets",
|
||||
"newLinkFormat": "relative",
|
||||
"useMarkdownLinks": true,
|
||||
"newFileLocation": "current"
|
||||
}
|
3
.obsidian/appearance.json
vendored
3
.obsidian/appearance.json
vendored
@ -1,3 +0,0 @@
|
||||
{
|
||||
"baseFontSize": 24
|
||||
}
|
15
.obsidian/core-plugins.json
vendored
15
.obsidian/core-plugins.json
vendored
@ -1,15 +0,0 @@
|
||||
[
|
||||
"file-explorer",
|
||||
"global-search",
|
||||
"switcher",
|
||||
"graph",
|
||||
"backlink",
|
||||
"page-preview",
|
||||
"note-composer",
|
||||
"command-palette",
|
||||
"editor-status",
|
||||
"markdown-importer",
|
||||
"word-count",
|
||||
"open-with-default-app",
|
||||
"file-recovery"
|
||||
]
|
1
.obsidian/hotkeys.json
vendored
1
.obsidian/hotkeys.json
vendored
@ -1 +0,0 @@
|
||||
{}
|
103
.obsidian/workspace
vendored
103
.obsidian/workspace
vendored
@ -1,103 +0,0 @@
|
||||
{
|
||||
"main": {
|
||||
"id": "1c78de9b842f3d85",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "0a8ca340a6b98c99",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "git/45 个 Git 操作场景,专治不会合代码.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
},
|
||||
"left": {
|
||||
"id": "b7f9cb940e0033b7",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "02f1ba640fab0859",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "3c2f1e60391ce1aa",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "file-explorer",
|
||||
"state": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "1841eb746b6d7625",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "search",
|
||||
"state": {
|
||||
"query": "",
|
||||
"matchingCase": false,
|
||||
"explainSearch": false,
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 455
|
||||
},
|
||||
"right": {
|
||||
"id": "beb34dc5a95aa22e",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "f4afd477ae75ace8",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "e29520e33bb22368",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "git/45 个 Git 操作场景,专治不会合代码.md",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
"showSearch": false,
|
||||
"searchQuery": "",
|
||||
"backlinkCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 300,
|
||||
"collapsed": true
|
||||
},
|
||||
"active": "0a8ca340a6b98c99",
|
||||
"lastOpenFiles": [
|
||||
"git/45 个 Git 操作场景,专治不会合代码.md",
|
||||
"git/GIt push失败.pdf",
|
||||
"web/docker-compose一键部署蘑菇博客设置SSL证书.md",
|
||||
"web/蘑菇博客设置SSL证书.md",
|
||||
"web/assets/image-20220709181337201.png",
|
||||
"web/assets/image-20220709181251481.png",
|
||||
"web/assets/image-20220709183408851.png",
|
||||
"web/assets/image-20220709183124753.png",
|
||||
"未命名.assets/image-20220506232148429.png.md",
|
||||
"spring-cloud/eureka/Eureka 自我保护机制、健康检查的作用、actuator 模块监控.md"
|
||||
]
|
||||
}
|
0
assets/Pasted.md
Normal file
0
assets/Pasted.md
Normal file
@ -4,9 +4,9 @@
|
||||
|
||||
接着以上篇文章建立的三个工程为基础(eureka-server,uerreg,myweb), 默认 Eureka 是开启自我保护的。我们来做个测试,我们先启动三个工程,我们访问注册中心 [http://localhost:8761/](http://localhost:8761/),
|
||||
|
||||
![[Pasted image 20220406220855.png]]
|
||||
![](assets/Pasted image 20220406220855.png)
|
||||
可以看到,实例是成功注册到中心的。此时我们将 uerreg 服务关闭,刷新注册中心,我们会发现如下界面
|
||||
![[Pasted image 20220406220914.png]]
|
||||
![](assets/Pasted image 20220406220914.png)
|
||||
我们除了看到了一行红色的警告信息,还发现了一件神奇的事情,就是我们的服务实例虽然被 kill 了,但是在服务注册中心他还是存在的。这就是 Eureka 自我保护机制,他不会剔除已经挂掉的服务,他会认为这个服务是在尝试重新连接的。
|
||||
我们在开发过程中肯定是不希望这样的,不利于开发。我们可以关闭 Eureka 的自我保护机制(实际生产环境不建议关闭)。
|
||||
|
||||
@ -34,7 +34,7 @@ eureka.instance.lease-expiration-duration-in-seconds=20
|
||||
```
|
||||
|
||||
我们重新启动服务,然后关闭 userreg 客户端进行测试。
|
||||
![[Pasted image 20220406220933.png]]
|
||||
![](assets/Pasted image 20220406220933.png)
|
||||
此时我们发现,红色警告变成了自我保护被关闭的警告,且实例被注册中心剔除,表明此时自我保护机制被关闭。
|
||||
|
||||
* #### 健康检查
|
||||
@ -80,7 +80,7 @@ ok, 其他的什么都不变,我们来访问一下这个接口 [http://localho
|
||||
|
||||
此时我们访问 / beans 敏感信息时,弹出如下信息,需要我们进行身份认证
|
||||
|
||||
![[Pasted image 20220406220957.png]]
|
||||
![](assets/Pasted image 20220406220957.png)
|
||||
|
||||
仅仅引入依赖其实是有问题的,因为我们请求正常的业务接口他也会要求进行认证,解决办法可以在 userreg 工程的配置文件中添加如下设置:
|
||||
|
||||
@ -96,7 +96,7 @@ security.basic.path=/admin
|
||||
重启服务,我们访问 [http://localhost:9001/admin/beans](http://localhost:9001/admin/beans),注意哦,我们在配置文件中添加了相对路径,只对 admin 进行验证,此时我们输入正确的用户名和密码(已在配置文件中配置)会显示我们需要的信息。
|
||||
|
||||
* #### 实战健康检查
|
||||
|
||||
|
||||
|
||||
健康检查在实际应用场景中有哪些呢?举个例子,我们配置 userreg 工程数据源
|
||||
在 pom 文件中引入以下依赖
|
||||
@ -132,12 +132,12 @@ public class Myconfig {
|
||||
```
|
||||
|
||||
这个在 springboot 中已经学习过,后续我会把 springboot 学习过程以博客的方式记录下来,配置完成数据源之后,我们启动服务,访问 [http://localhost:9001/admin/health](http://localhost:9001/admin/health) 查看健康情况
|
||||
![[Pasted image 20220406221207.png]]
|
||||
![](assets/Pasted image 20220406221207.png)
|
||||
|
||||
我们可以看到 db 的健康情况。假如此时我们的 mysql 服务挂掉,会怎样呢?
|
||||
![[Pasted image 20220406221107.png]]
|
||||
|
||||
![](assets/Pasted image 20220406221107.png)
|
||||
|
||||
我们手动停止 mysql 服务,然后再看健康情况
|
||||
|
||||
![[Pasted image 20220406221125.png]]
|
||||
|
||||
![](assets/Pasted image 20220406221125.png)
|
||||
发现 db 状态已经由 “UP” 变成了 “DOWN” 并显示了错误信息,这样就很方便我们查看服务的健康情况了。
|
||||
|
@ -16,15 +16,15 @@
|
||||
|
||||
在cloud-demo父工程下,创建一个子模块:
|
||||
|
||||
![[Pasted image 20220405222734.png]]
|
||||
![](assets/Pasted image 20220405222734.png)
|
||||
|
||||
填写模块信息:
|
||||
|
||||
![[Pasted image 20220405223018.png]]
|
||||
![](assets/Pasted image 20220405223018.png)
|
||||
|
||||
然后填写服务信息:
|
||||
|
||||
![[Pasted image 20220405223056.png]]
|
||||
![](assets/Pasted image 20220405223056.png)
|
||||
|
||||
## 2.2.引入eureka依赖
|
||||
|
||||
@ -79,7 +79,7 @@ eureka:
|
||||
|
||||
看到下面结果应该是成功了:
|
||||
|
||||
![[Pasted image 20220405224233.png]]
|
||||
![](assets/Pasted image 20220405224233.png)
|
||||
|
||||
# 3.服务注册
|
||||
## 3.1 引入依赖
|
||||
@ -108,25 +108,25 @@ eureka:
|
||||
## 3.3启动多个userservice实例
|
||||
为了演示一个服务有多个实例的场景,我们添加一个SpringBoot的启动配置,再启动一个user-service。
|
||||
|
||||
|
||||
|
||||
首先,复制原来的user-service启动配置:
|
||||
|
||||
![[Pasted image 20220405224152.png]]
|
||||
![](assets/Pasted image 20220405224152.png)
|
||||
|
||||
然后,在弹出的窗口中,填写信息:
|
||||
|
||||
![[Pasted image 20220405224314.png]]
|
||||
![](assets/Pasted image 20220405224314.png)
|
||||
|
||||
现在,SpringBoot窗口会出现两个user-service启动配置:
|
||||
|
||||
![[Pasted image 20220405224333.png]]
|
||||
![](assets/Pasted image 20220405224333.png)
|
||||
|
||||
不过,第一个是8081端口,第二个是8082端口。
|
||||
|
||||
启动两个user-service实例:
|
||||
|
||||
![[Pasted image 20220405224355.png]]
|
||||
![](assets/Pasted image 20220405224355.png)
|
||||
|
||||
查看eureka-server管理页面:
|
||||
|
||||
![[Pasted image 20220405224406.png]]
|
||||
![](assets/Pasted image 20220405224406.png)
|
||||
|
@ -11,96 +11,96 @@
|
||||
## 开始搭建
|
||||
### 新建虚拟电脑
|
||||
选择工具点击新建
|
||||
![[Pasted image 20220419003859.png]]
|
||||
![](assets/Pasted image 20220419003859.png)
|
||||
|
||||
设置内存大小
|
||||
![[Pasted image 20220419003957.png]]
|
||||
![](assets/Pasted image 20220419003957.png)
|
||||
|
||||
默认
|
||||
![[Pasted image 20220419004014.png]]
|
||||
![](assets/Pasted image 20220419004014.png)
|
||||
默认
|
||||
![[Pasted image 20220419004022.png]]
|
||||
![](assets/Pasted image 20220419004022.png)
|
||||
|
||||
这里我为了演示节省时间选择的是动态大小 硬盘空间充足的话建议选择固定大小
|
||||
![[Pasted image 20220419004030.png]]
|
||||
![](assets/Pasted image 20220419004030.png)
|
||||
|
||||
设置硬盘大小
|
||||
![[Pasted image 20220419004037.png]]
|
||||
![](assets/Pasted image 20220419004037.png)
|
||||
|
||||
### 设置虚拟网卡
|
||||
ctrl+h 打开网络管理器 选中已有的网卡或新建网卡进行配置 点击属性配置网卡的信息 我这里改的是10.0.0 的网段
|
||||
不懂网络的同学可以按照我的去做
|
||||
![[Pasted image 20220419005241.png]]
|
||||
![](assets/Pasted image 20220419005241.png)
|
||||
|
||||
![[Pasted image 20220419005247.png]]
|
||||
![](assets/Pasted image 20220419005247.png)
|
||||
|
||||
### 修改虚拟机配置
|
||||
选中我们创建的虚拟机点击设置 打开虚拟机的配置页面
|
||||
![[Pasted image 20220419010011.png]]
|
||||
![](assets/Pasted image 20220419010011.png)
|
||||
|
||||
设置内存大小 建议不超过宿主机内存的百分之五十
|
||||
![[Pasted image 20220419010034.png]]
|
||||
![](assets/Pasted image 20220419010034.png)
|
||||
|
||||
设置处理器数量 建议不超过宿主机的百分之五十
|
||||
![[Pasted image 20220419010045.png]]
|
||||
![](assets/Pasted image 20220419010045.png)
|
||||
|
||||
显存可以设置小一点
|
||||
![[Pasted image 20220419010054.png]]
|
||||
![](assets/Pasted image 20220419010054.png)
|
||||
|
||||
根据步骤添加我们下载的镜像为虚拟光盘
|
||||
![[Pasted image 20220419010455.png]]
|
||||
![](assets/Pasted image 20220419010455.png)
|
||||
|
||||
设置好的样子
|
||||
![[Pasted image 20220419010110.png]]
|
||||
![](assets/Pasted image 20220419010110.png)
|
||||
|
||||
配置网络
|
||||
网卡一连接方式选择Host-Only 可以在这个网络下和宿主机以及其他虚拟机组成一个局域网
|
||||
![[Pasted image 20220419010116.png]]
|
||||
![](assets/Pasted image 20220419010116.png)
|
||||
|
||||
网卡二 连接方式选中桥接网卡 界面名称选择你电脑上可以链接到公网的网卡 网卡二可以让我们的虚拟机上公网
|
||||
![[Pasted image 20220419010124.png]]
|
||||
![](assets/Pasted image 20220419010124.png)
|
||||
|
||||
### 开始安装
|
||||
双击启动 默认选择英文不需要改动 直接回车进入下一步
|
||||
![[Pasted image 20220419010926.png]]
|
||||
![](assets/Pasted image 20220419010926.png)
|
||||
|
||||
配置键盘布局 选择“Done” 回车
|
||||
![[Pasted image 20220419010935.png]]
|
||||
![](assets/Pasted image 20220419010935.png)
|
||||
|
||||
网络配置 不需要动,以防修改错误后续操作无法进行 继续Done
|
||||
![[Pasted image 20220419010944.png]]
|
||||
![](assets/Pasted image 20220419010944.png)
|
||||
|
||||
不需要填 选中Done回车
|
||||
![[Pasted image 20220419010951.png]]
|
||||
![](assets/Pasted image 20220419010951.png)
|
||||
|
||||
这里可以改为阿里云软件源的镜像地址 https://mirrors.aliyun.com/ubuntu/
|
||||
![[Pasted image 20220419010958.png]]
|
||||
![](assets/Pasted image 20220419010958.png)
|
||||
|
||||
后面的的配置默认不需要修改 选择Done 和 continue 知道自定义用户账号信息
|
||||
|
||||
自定义用户账号信息,输入完成之后,选择“Done”,按Enter键
|
||||
![[Pasted image 20220419011004.png]]
|
||||
![](assets/Pasted image 20220419011004.png)
|
||||
|
||||
中间页面默认不需要修改
|
||||
|
||||
安装ssh远程连接 建议在进入系统后手动安装
|
||||
![[Pasted image 20220419011015.png]]
|
||||
![](assets/Pasted image 20220419011015.png)
|
||||
|
||||
默认选中Done 下一步至此页面 等待漫长的安装过程
|
||||
|
||||
![[Pasted image 20220419011022.png]]
|
||||
![](assets/Pasted image 20220419011022.png)
|
||||
|
||||
安装完成后会出现Reboot Now选项 选择此选项回车进行重启
|
||||
![[Pasted image 20220419012839.png]]
|
||||
![](assets/Pasted image 20220419012839.png)
|
||||
|
||||
等待重启过程中,如果卡住,多按几次Enter键即可
|
||||
![[Pasted image 20220419012853.png]]
|
||||
![](assets/Pasted image 20220419012853.png)
|
||||
|
||||
在登陆页面 如果卡住 同时按alt+f2 切换一个控制台进行登录 不出现的话多按几次
|
||||
![[Pasted image 20220419012859.png]]
|
||||
![](assets/Pasted image 20220419012859.png)
|
||||
|
||||
输入账号密码进入系统
|
||||
![[Pasted image 20220419012906.png]]
|
||||
![](assets/Pasted image 20220419012906.png)
|
||||
|
||||
执行以下命令解决Used fallback datasource问题 [修复此问题原文地址](https://askubuntu.com/questions/1321968/ubuntu-server-20-04-2-lts-hangs-after-bootup-cloud-init-1781-yyyy-mm-dd-h)
|
||||
```shell
|
||||
@ -118,12 +118,12 @@ ifconfig
|
||||
|
||||
```
|
||||
|
||||
![[Pasted image 20220419013832.png]]
|
||||
![](assets/Pasted image 20220419013832.png)
|
||||
|
||||
设置固定ip地址
|
||||
编辑/etc/netplan/ 下的yaml文件
|
||||
`sudo vim /etc/netplan/***.yaml`
|
||||
![[Pasted image 20220419015105.png]]
|
||||
![](assets/Pasted image 20220419015105.png)
|
||||
|
||||
```shell
|
||||
#使刚才设置网卡的配置生效
|
||||
@ -134,6 +134,6 @@ ifconfig
|
||||
ping www.baidu.com
|
||||
```
|
||||
|
||||
![[Pasted image 20220419014308.png]]
|
||||
![](assets/Pasted image 20220419014308.png)
|
||||
|
||||
到此位置你的Ubuntu已经搭建完毕.
|
Loading…
Reference in New Issue
Block a user