This commit is contained in:
Shuaishuai Dai 2022-12-30 10:40:42 +08:00
commit 8a40f10d0a
14 changed files with 114 additions and 180 deletions

7
.obsidian/app.json vendored
View File

@ -1,7 +0,0 @@
{
"legacyEditor": false,
"attachmentFolderPath": "./assets",
"newLinkFormat": "relative",
"useMarkdownLinks": true,
"newFileLocation": "current"
}

View File

@ -1,3 +0,0 @@
{
"baseFontSize": 24
}

View File

@ -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"
]

View File

@ -1 +0,0 @@
{}

103
.obsidian/workspace vendored
View File

@ -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"
]
}

63
apps/openvpn/OpenVPN.md Normal file
View File

@ -0,0 +1,63 @@
openvpn-server
The git repository is available at: https://github.com/angristan/openvpn-install
##### 自定义openvpn网关
```bash
sudo vim /etc/openvpn/server.conf
#修改server.conf文件
server 10.0.11.0 255.255.255.0
```
##### 设置openvpn 客户端之间互通
```bash
sudo vim /etc/openvpn/server.conf
#在server.conf文件中添加
client-to-client
```
##### openvpn 客户端连接服务器后无法ping通内网服务
打开配置文件注释一下两行内容
```
#ignore-unknown-option block-outside-dns
#setenv opt block-outside-dns # Prevent Windows 10 DNS leak
```
添加下方配置行到配置文件底部
```
route-nopull
route 10.0.11.0 255.255.255.0 vpn_gateway
```
> 注意route后的 ip地址 需要填写你在服务器上配置的server地址默认是10.8.0.0
##### windows 客户端连接多个服务器
默认openvpn只会创建一个虚拟网卡所以同时只能连接一个服务器
打开此文件夹 `"C:\ProgramData\Microsoft\Windows\Start Menu\Program\OpenVPN\Utilities"` 双击击下方标记程序添加一个虚拟网卡然后就可以同时连接多个服务器了
![image-20221122235709604](assets/image-20221122235709604.png)
##### windows 设置openvpn gui 开机自启并且自动连接服务器
右击openvpn快捷方式图标点击属性然后在目标输入框的尾部添加 `--connect client.ovpn`
![image-20221122234949353](assets/image-20221122234949353.png)
win+R 输入`shell:startup`打开 自启文件夹
![image-20221122235136340](assets/image-20221122235136340.png)
然后将快捷方式复制到该文件夹下
![image-20221122235329742](assets/image-20221122235329742.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

0
assets/Pasted.md Normal file
View File

View 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” 并显示了错误信息,这样就很方便我们查看服务的健康情况了。

View File

@ -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)

View File

@ -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已经搭建完毕.