This commit is contained in:
parent
f72c440587
commit
45077006af
|
@ -0,0 +1,37 @@
|
||||||
|
# JVM配置
|
||||||
|
|
||||||
|
**日志配置文件**:
|
||||||
|
|
||||||
|
- `-Djava.util.logging.config.file=/datal/weibo/conf/logging.properties`:指定Java日志配置文件的位置。
|
||||||
|
|
||||||
|
**日志管理器**:
|
||||||
|
|
||||||
|
- `-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager`:指定Java日志管理器的实现类。
|
||||||
|
|
||||||
|
**TLS/SSL临时密钥位数**:
|
||||||
|
|
||||||
|
- `-Djdk.tls.ephemeralDHkeySize=2048`:设置TLS/SSL协议中临时Diffie-Hellman密钥交换的位数为2048位。
|
||||||
|
|
||||||
|
**URL协议处理包**:
|
||||||
|
|
||||||
|
- `-Djava.protocol.handler.pkgs=org.apache.catalina.webresources`:指定处理URL协议的Java包。
|
||||||
|
|
||||||
|
**Tomcat安全监听器UMASK**:
|
||||||
|
|
||||||
|
- `-Dorg.apache.catalina.security.SecurityListener.UMASK=0022`:设置Apache Tomcat的安全监听器的UMASK值。
|
||||||
|
|
||||||
|
**名称服务提供者**:
|
||||||
|
|
||||||
|
- `-Dsun.net.spi.nameservice.provider.1=dns,dnsjava`:指定第一个名称服务提供者。
|
||||||
|
- `-Dsun.net.spi.nameservice.provider.2=dns,dnsjava`:指定第二个名称服务提供者。
|
||||||
|
|
||||||
|
**偏向锁**:
|
||||||
|
|
||||||
|
- `-XX:-UseBiasedLocking`:禁用偏向锁,偏向锁在高并发时可能带来消耗,故禁用。
|
||||||
|
|
||||||
|
**JVM内存设置**:
|
||||||
|
|
||||||
|
- `-Xmx8g`:设置JVM的最大堆内存为8GB。
|
||||||
|
- `-Xms8g`:设置JVM的初始堆内存为8GB。
|
||||||
|
- `-Xmn4g`:设置JVM的年轻代堆内存为4GB。
|
||||||
|
- `-Xss1m`:设置每个线程的堆栈大小为1MB。
|
|
@ -0,0 +1,43 @@
|
||||||
|
# 开发完接口之后:
|
||||||
|
|
||||||
|
**入参校验**:长度校验、判空、逻辑校验
|
||||||
|
|
||||||
|
**分页处理**:是否实现分页功能
|
||||||
|
|
||||||
|
**逻辑删除**:避免物理删除,使用逻辑删除
|
||||||
|
|
||||||
|
**查询加缓存**:提高查询效率,减少数据库压力
|
||||||
|
|
||||||
|
**逻辑漏洞**:检查逻辑是否存在漏洞
|
||||||
|
|
||||||
|
**重点接口加验签**:防止流量劫持和数据篡改
|
||||||
|
|
||||||
|
**异常情况提示语**:清晰明确的异常提示信息
|
||||||
|
|
||||||
|
**外部接口错误处理**:是否需要重试还是直接返回错误,对方是否有幂等性
|
||||||
|
|
||||||
|
**接口访问量**:评估接口的访问量
|
||||||
|
|
||||||
|
**中间件压力**:考虑中间件的负载能力
|
||||||
|
|
||||||
|
**时间复杂度**:优化时间复杂度,例如map的查找操作为O(1)
|
||||||
|
|
||||||
|
**代码细化**:每个操作步骤细化明确,思考每个方法是否可以控制在10行以内,抽取通用代码便于维护
|
||||||
|
|
||||||
|
**Redis数据结构选择**:合理选择Redis数据结构
|
||||||
|
|
||||||
|
**设计模式**:是否考虑设计模式
|
||||||
|
|
||||||
|
**外部接口调用日志**:记录入参、返回值,尤其是不满足预期和报错的时候
|
||||||
|
|
||||||
|
**国际通用返回值**:`code`, `msg`, `data`, `extMap`, `requestId`
|
||||||
|
|
||||||
|
**@Value默认值**:`@Value = "$(aaa:defaultValue)"`,带一个默认值,增强健壮性
|
||||||
|
|
||||||
|
**参数配置文件化**:所有参数放入配置文件,便于将来动态刷新
|
||||||
|
|
||||||
|
**临界值测试**:调用方获取的永远是`baseResponse`,不能把Java异常返回出去,业务代码明确,见名知意
|
||||||
|
|
||||||
|
**日志记录**:多打日志,入口、出口,尤其是调用第三方接口时,记录入参、出参
|
||||||
|
|
||||||
|
**全局意识**:在项目开发中,即使自己只是整个流程的一部分,也要有全局意识,替对方着想,这样开发起来更加顺畅
|
|
@ -0,0 +1,209 @@
|
||||||
|
### 常用
|
||||||
|
|
||||||
|
```
|
||||||
|
[abc] - 单个字符: a 或 b 或 c
|
||||||
|
[^abc] - a, b, c 以外的单个字符
|
||||||
|
[a-zA-Z0-9] - 字符范围: 字母或数字
|
||||||
|
. - 任意字符
|
||||||
|
\s - 空字符
|
||||||
|
\S - 非空字符
|
||||||
|
\d - 数字字符
|
||||||
|
\D - 非数字字符
|
||||||
|
\w - 单词(字母,数字,下划线)
|
||||||
|
\W - 非单词
|
||||||
|
\b - 单词边界
|
||||||
|
\B - 非单词边界
|
||||||
|
^ - 开头
|
||||||
|
$ - 结尾
|
||||||
|
(a|b) - a 或 b
|
||||||
|
a* - 重复 0 次或多次
|
||||||
|
a? - 重复 0 次或 1 次
|
||||||
|
a+ - 重复 1 次或多次
|
||||||
|
a{3} - 重复 3 次
|
||||||
|
a{3,} - 重复 3 次或多次
|
||||||
|
a{3,5} - 重复 3 到 5 次
|
||||||
|
? - 非贪婪匹配
|
||||||
|
(...) - 分组
|
||||||
|
(?:a) - 非捕获分组
|
||||||
|
a(?=b) - 正向断言
|
||||||
|
a(?!b) - 正向否定断言
|
||||||
|
(?<=b)a - 反向断言
|
||||||
|
(?<!b)a - 反向否定断言
|
||||||
|
(?<name>a) - 命名分组
|
||||||
|
\k<name> - 命名反向引用
|
||||||
|
\n - 反向引用,n 为 99 以内的十进制数字
|
||||||
|
\xhh - 十六进制 hh 字符
|
||||||
|
\uhhhh - 十六进制 hhhh 字符
|
||||||
|
\u{hhhh} - (设置了 u 标志时) 十六进制 hhhh 字符
|
||||||
|
\cX - 控制字符
|
||||||
|
\0 - 空字符
|
||||||
|
\a - alert 字符
|
||||||
|
\t - 制表符
|
||||||
|
\n - 换行符
|
||||||
|
\v - 垂直制表符
|
||||||
|
\f - 换页符
|
||||||
|
\r - 回车符
|
||||||
|
\e - escape 字符
|
||||||
|
[\b] - 退格符
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### 用户名和密码
|
||||||
|
|
||||||
|
1. 用户名和密码格式验证:
|
||||||
|
- 正则表达式: `^[a-zA-Z]\w{5,15}$`
|
||||||
|
- 正确格式: 字母开头,6~16位包含字母、数字、下划线
|
||||||
|
|
||||||
|
### 电话号码
|
||||||
|
|
||||||
|
1. 电话号码格式验证:
|
||||||
|
- 正则表达式: `^(\d{3,4}-)\d{7,8}$`
|
||||||
|
- 正确格式: 区号-号码 或 区号号码
|
||||||
|
|
||||||
|
### 手机号码
|
||||||
|
|
||||||
|
1. 手机号码格式验证:
|
||||||
|
- 正则表达式: `^1[3|4|5|7|8][0-9]\d{8}$`
|
||||||
|
|
||||||
|
### 身份证号
|
||||||
|
|
||||||
|
1. 身份证号格式验证:
|
||||||
|
- 正则表达式: `\d{14}[[0-9],0-9xX]`
|
||||||
|
|
||||||
|
### Email地址
|
||||||
|
|
||||||
|
1. Email地址格式验证:
|
||||||
|
- 正则表达式: `^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$`
|
||||||
|
|
||||||
|
### 字符串组成
|
||||||
|
|
||||||
|
1. 数字和字母组成的字符串:
|
||||||
|
- 正则表达式: `^[A-Za-z0-9]+$`
|
||||||
|
|
||||||
|
### 数字
|
||||||
|
|
||||||
|
1. **整数或小数:**
|
||||||
|
- 正则表达式: `^[0-9]+([.][0-9]+){0,1}$`
|
||||||
|
2. **只能输入数字:**
|
||||||
|
- 正则表达式: `^[0-9]*$`
|
||||||
|
3. **n位数字:**
|
||||||
|
- 正则表达式: `^\d{n}$`
|
||||||
|
4. **至少n位数字:**
|
||||||
|
- 正则表达式: `^\d{n,}$`
|
||||||
|
5. **m~n位数字:**
|
||||||
|
- 正则表达式: `^\d{m,n}$`
|
||||||
|
6. **零和非零开头的数字:**
|
||||||
|
- 正则表达式: `^(0|[1-9][0-9]*)$`
|
||||||
|
7. **有两位小数的正实数:**
|
||||||
|
- 正则表达式: `^[0-9]+(\.[0-9]{2})?$`
|
||||||
|
8. **1~3位小数的正实数:**
|
||||||
|
- 正则表达式: `^[0-9]+(\.[0-9]{1,3})?$`
|
||||||
|
9. **非零的正整数:**
|
||||||
|
- 正则表达式: `^\+?[1-9][0-9]*$`
|
||||||
|
10. **非零的负整数:**
|
||||||
|
- 正则表达式: `^\-[1-9][0-9]*$`
|
||||||
|
|
||||||
|
### 字符串长度
|
||||||
|
|
||||||
|
1. **长度为3的字符:**
|
||||||
|
- 正则表达式: `^.{3}$`
|
||||||
|
2. **由26个英文字母组成的字符串:**
|
||||||
|
- 正则表达式: `^[A-Za-z]+$`
|
||||||
|
3. **由26个大写英文字母组成的字符串:**
|
||||||
|
- 正则表达式: `^[A-Z]+$`
|
||||||
|
4. **由26个小写英文字母组成的字符串:**
|
||||||
|
- 正则表达式: `^[a-z]+$`
|
||||||
|
|
||||||
|
### 特殊字符
|
||||||
|
|
||||||
|
1. 验证是否含有特殊字符:
|
||||||
|
- 正则表达式: `[%&',;=?$\\^]+`
|
||||||
|
|
||||||
|
### 汉字
|
||||||
|
|
||||||
|
1. 只能输入汉字:
|
||||||
|
- 正则表达式: `^[\u4e00-\u9fa5]{0,}$`
|
||||||
|
|
||||||
|
### URL
|
||||||
|
|
||||||
|
1. 验证URL:
|
||||||
|
- 正则表达式: `^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$`
|
||||||
|
|
||||||
|
### 月份和日期
|
||||||
|
|
||||||
|
1. **一年的12个月:**
|
||||||
|
- 正则表达式: `^(0?[1-9]|1[0-2])$`
|
||||||
|
2. **一个月的31天:**
|
||||||
|
- 正则表达式: `^((0?[1-9])|((1|2)[0-9])|30|31)$`
|
||||||
|
3. **日期格式:**
|
||||||
|
- 正则表达式: `\d{4}[年|\-|\.]\d{\1-\12}[月|\-|\.]\d{\1-\31}日?`
|
||||||
|
|
||||||
|
### 其他
|
||||||
|
|
||||||
|
1. **匹配双字节字符:**
|
||||||
|
- 正则表达式: `[^\x00-\xff]`
|
||||||
|
2. **匹配空白行:**
|
||||||
|
- 正则表达式: `\n\s*\r`
|
||||||
|
3. **匹配HTML标记:**
|
||||||
|
- 正则表达式: `<(\S*?)[^>]*>.*?</>|<.*? />`
|
||||||
|
4. **匹配首尾空白字符:**
|
||||||
|
- 正则表达式: `^\s*|\s*$`
|
||||||
|
5. **匹配网址URL:**
|
||||||
|
- 正则表达式: `[a-zA-z]+://[^\s]*`
|
||||||
|
6. **帐号是否合法:**
|
||||||
|
- 正则表达式: `^[a-zA-Z][a-zA-Z0-9_]{4,15}$`
|
||||||
|
7. **腾讯QQ号:**
|
||||||
|
- 正则表达式: `[1-9][0-9]{4,}`
|
||||||
|
8. **中国邮政编码:**
|
||||||
|
- 正则表达式: `[1-9]\d{5}(?!\d)`
|
||||||
|
9. **IP地址:**
|
||||||
|
- 正则表达式: `([1-9]{1,3}\.){3}[1-9]`
|
||||||
|
10. **MAC地址:**
|
||||||
|
- 正则表达式: `([A-Fa-f0-9]{2}\:){5}[A-Fa-f0-9]`
|
||||||
|
|
||||||
|
### 函数
|
||||||
|
|
||||||
|
1. **正则表达式校验函数 (IsRegu):**
|
||||||
|
|
||||||
|
```vbscript
|
||||||
|
Function IsRegu(Regu, s)
|
||||||
|
' 正则表达式校验
|
||||||
|
If Regu = "" Then
|
||||||
|
Exit Function
|
||||||
|
End If
|
||||||
|
Dim Re, Sre
|
||||||
|
Set Re = New RegExp
|
||||||
|
Re.Pattern = Regu
|
||||||
|
Sre = Re.Test(s)
|
||||||
|
If Sre = True Then
|
||||||
|
IsRegu = True
|
||||||
|
Else
|
||||||
|
IsRegu = False
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
2. **验证URL:**
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
function IsValidUrl(str) {
|
||||||
|
var regu = "^(https?://)"
|
||||||
|
+ "?(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?"
|
||||||
|
+ "(([0-9]{1,3}\.){3}[0-9]{1,3}"
|
||||||
|
+ "|"
|
||||||
|
+ "([0-9a-z_!~*'()-]+\.)*"
|
||||||
|
+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\."
|
||||||
|
+ "[a-z]{2,6})"
|
||||||
|
+ "(:[0-9]{1,4})?"
|
||||||
|
+ "((/?)|"
|
||||||
|
+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
|
||||||
|
var re = new RegExp(regu);
|
||||||
|
if (!re.test(str)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
|
@ -1,25 +0,0 @@
|
||||||
# aaPanel-宝塔面板国际版安装教程(宝塔海外版)
|
|
||||||
|
|
||||||
## 一、SSH登录至VPS
|
|
||||||
|
|
||||||
## 二、执行以下命令安装aaPanel
|
|
||||||
|
|
||||||
### CentOS:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
yum install -y wget && wget -O install.sh http://www.aapanel.com/script/install_6.0_en.sh && bash install.sh aapanel
|
|
||||||
```
|
|
||||||
|
|
||||||
### Ubuntu/Deepin:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
wget -O install.sh http://www.aapanel.com/script/install-ubuntu_6.0_en.sh && sudo bash install.sh aapanel
|
|
||||||
```
|
|
||||||
|
|
||||||
### Debian:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
wget -O install.sh http://www.aapanel.com/script/install-ubuntu_6.0_en.sh && bash install.sh aapanel
|
|
||||||
```
|
|
||||||
|
|
||||||
## 三、使用外网面板
|
|
|
@ -1,9 +1,21 @@
|
||||||
CentOS 配置国内 yum 源
|
## 图形化安装设置
|
||||||
|
|
||||||
## CentOS 7 x86-64
|
我们将安装源(软件源)配置为阿里的:
|
||||||
|
|
||||||
|
协议选择为`http://`
|
||||||
|
|
||||||
|
路径是`mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/`
|
||||||
|
|
||||||
|
URL类型是:`软件库URL`
|
||||||
|
|
||||||
|
注意上面的阿里路径最后要记得加上一个斜杠`/`
|
||||||
|
|
||||||
|
https://mirrors.aliyun.com/centos/7/os/x86_64/
|
||||||
|
|
||||||
|
## CentOS 7 x86_64
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
CentOS 7 x86-64
|
CentOS 7 x86_64
|
||||||
|
|
||||||
//进入root,切换至yum.repos.d目录
|
//进入root,切换至yum.repos.d目录
|
||||||
cd /etc/yum.repos.d/
|
cd /etc/yum.repos.d/
|
||||||
|
@ -21,10 +33,10 @@ wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos
|
||||||
yum clean all && yum makecache
|
yum clean all && yum makecache
|
||||||
```
|
```
|
||||||
|
|
||||||
## CentOS Stream 8 x86-64
|
## CentOS Stream 8 x86_64
|
||||||
|
|
||||||
````shell
|
````shell
|
||||||
CentOS Stream 8 x86-64
|
CentOS Stream 8 x86_64
|
||||||
|
|
||||||
//进入root,切换至yum.repos.d目录
|
//进入root,切换至yum.repos.d目录
|
||||||
cd /etc/yum.repos.d/
|
cd /etc/yum.repos.d/
|
||||||
|
@ -43,10 +55,10 @@ sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-*
|
||||||
yum clean all && yum makecache
|
yum clean all && yum makecache
|
||||||
````
|
````
|
||||||
|
|
||||||
## CentOS Stream 9 x86-64
|
## CentOS Stream 9 x86_64
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
CentOS Stream 9 x86-64
|
CentOS Stream 9 x86_64
|
||||||
|
|
||||||
//进入root,切换至yum.repos.d目录
|
//进入root,切换至yum.repos.d目录
|
||||||
cd /etc/yum.repos.d/
|
cd /etc/yum.repos.d/
|
||||||
|
@ -69,3 +81,12 @@ yum clean all && yum makecache
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 时间设置
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# 在设置中国时区使用亚洲/上海(+8)
|
||||||
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
|
||||||
|
# 查看时间和日期
|
||||||
|
date
|
||||||
|
```
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[TOC]
|
[TOC]
|
||||||
|
|
||||||
首先说一下什么使用centos 7 ,因为我的mac PD虚拟机安装不上包括centos Stream 8,为此只能换到centos Stream 9 了,我的云服务上跑的都是Centos 7,暂时用不惯 Ubuntu 。KubeSphere最新版本中部分组件不支持arm64,在后面的启动可查包组件中会提到如何解决。
|
首先说一下为什么不使用centos 7 ,因为我的mac PD虚拟机安装不上包括centos Stream 8,为此只能换到centos Stream 9 了,我的云服务上跑的都是Centos 7,暂时用不惯 Ubuntu 。KubeSphere最新版本中部分组件不支持arm64,在后面的启动可查包组件中会提到如何解决。
|
||||||
|
|
||||||
下面是我搭建版本以及环境版本
|
下面是我搭建版本以及环境版本
|
||||||
|
|
|
@ -135,6 +135,11 @@ timedatectl
|
||||||
|
|
||||||
### 配置时间同步
|
### 配置时间同步
|
||||||
|
|
||||||
|
|
||||||
|
```shell
|
||||||
|
ntpdate time.windows.com
|
||||||
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
#安装 chrony 作为时间同步软件
|
#安装 chrony 作为时间同步软件
|
||||||
yum install chrony -y
|
yum install chrony -y
|
||||||
|
@ -305,7 +310,7 @@ grubby --default-kernel
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
#修改系统默认内核为新内核
|
#修改系统默认内核为新内核
|
||||||
grubby --set-default "/boot/vmlinuz-5.4.258-1.el7.elrepo.x86_64"
|
grubby --set-default "/boot/vmlinuz-5.4.268-1.el7.elrepo.x86_64"
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -402,7 +407,7 @@ chmod +x kk
|
||||||
如果不改名称,那么将创建默认文件 `config-sample.yaml`。
|
如果不改名称,那么将创建默认文件 `config-sample.yaml`。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
vi config-sample.yaml
|
vim config-sample.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
### 主机
|
### 主机
|
|
@ -0,0 +1,232 @@
|
||||||
|
# PVE装机记录
|
||||||
|
|
||||||
|
## 硬件配置
|
||||||
|
|
||||||
|
| 硬件 | 配置 | 数量 | 参考单价 |
|
||||||
|
| ---- | ---------------------------- | ---- | ----------------- |
|
||||||
|
| CPU | E5 2673v3 | 2 | 56 |
|
||||||
|
| 主板 | 华南金牌 x99-8D3 双路 | 1 | 580 |
|
||||||
|
| 内存 | 三星 32G DDR3 ECC 4R*4 1866L | 2 | 88 |
|
||||||
|
| 机箱 | 金河田 凌霜Pro 黑色 | 1 | 148 |
|
||||||
|
| 电源 | 鑫谷 GN650 650W 金牌 | 1 | 299 |
|
||||||
|
| 风扇 | A500 风扇 | 2 | 40 |
|
||||||
|
| 显卡 | 亮机卡 | 1 | 20 |
|
||||||
|
| 硬盘 | 三星 970EVO 512G | 1 | 600(笔记本拆机) |
|
||||||
|
| 硬盘 | 希捷 紫盘 4T | 1 | 439 |
|
||||||
|
| | | 总价 | 2454 |
|
||||||
|
|
||||||
|
## 系统选择
|
||||||
|
|
||||||
|
### [PVE](https://www.proxmox.com/en/)
|
||||||
|
|
||||||
|
全称 Proxmox Virtual Environment,是基于 Debian 的 Linux 系统,虚拟机内核为 KVM。硬件兼容性优秀。Web UI 的界面功能不强,但是如果通过命令行去操作的话,扩展定制能力几乎是无限的。
|
||||||
|
|
||||||
|
![image-20240131103027227](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706668227.png)
|
||||||
|
|
||||||
|
我选择使用的是7.4的版本
|
||||||
|
|
||||||
|
## BIOS设置
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 系统安装
|
||||||
|
|
||||||
|
制作启动盘推荐使用 [balenaEthcher](https://www.balena.io/etcher/)
|
||||||
|
|
||||||
|
![image-20240131103233515](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706668353.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 系统优化
|
||||||
|
|
||||||
|
参考https://bbs.x86pi.cn/thread?topicId=20
|
||||||
|
|
||||||
|
快速脚本
|
||||||
|
|
||||||
|
```shell
|
||||||
|
wget -q -O /root/pve_source.tar.gz 'https://bbs.x86pi.cn/file/topic/2023-11-28/file/01ac88d7d2b840cb88c15cb5e19d4305b2.gz' && tar zxvf /root/pve_source.tar.gz && /root/./pve_source
|
||||||
|
```
|
||||||
|
|
||||||
|
## 挂载硬盘
|
||||||
|
|
||||||
|
### 2T以下的硬盘
|
||||||
|
|
||||||
|
查看目前的硬盘分区
|
||||||
|
|
||||||
|
```shell
|
||||||
|
df -h
|
||||||
|
```
|
||||||
|
|
||||||
|
选择硬盘
|
||||||
|
|
||||||
|
```shell
|
||||||
|
fdisk /dev/sda
|
||||||
|
```
|
||||||
|
|
||||||
|
输入 n 创建新的分区,一只回车显示创建成功后输入 w 保存
|
||||||
|
|
||||||
|
格式化为ext4格式
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkfs -t ext4 /dev/sda1
|
||||||
|
```
|
||||||
|
|
||||||
|
创建目录
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkdir -p /mnt/sda1
|
||||||
|
```
|
||||||
|
|
||||||
|
将/dev/sda分区挂载在/mnt/sda上
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mount -t ext4 /dev/sda1 /mnt/sda1
|
||||||
|
```
|
||||||
|
|
||||||
|
将/mnt/sda挂载写入到系统启动项
|
||||||
|
|
||||||
|
```shell
|
||||||
|
echo /dev/sda1 /mnt/sda1 ext4 defaults 12>> /etc/fstab
|
||||||
|
```
|
||||||
|
|
||||||
|
最后添加在PVE设置中
|
||||||
|
|
||||||
|
![image-20240131091718419](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706663839.png)
|
||||||
|
|
||||||
|
### 4T及以上使用parted工具
|
||||||
|
|
||||||
|
首先安装工具 parted
|
||||||
|
|
||||||
|
```shell
|
||||||
|
apt install parted
|
||||||
|
```
|
||||||
|
|
||||||
|
![image-20240131100739790](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706666860.png)
|
||||||
|
|
||||||
|
查看目前的硬盘分区
|
||||||
|
|
||||||
|
```shell
|
||||||
|
df -h
|
||||||
|
```
|
||||||
|
|
||||||
|
选择硬盘
|
||||||
|
|
||||||
|
```shell
|
||||||
|
parted /dev/sda
|
||||||
|
```
|
||||||
|
|
||||||
|
查看分区
|
||||||
|
|
||||||
|
```shell
|
||||||
|
print
|
||||||
|
```
|
||||||
|
|
||||||
|
![image-20240131100810896](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706666891.png)
|
||||||
|
|
||||||
|
- 如果无法识别该硬盘,需要输入以下命令先建立gpt表
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mklabel gpt
|
||||||
|
```
|
||||||
|
|
||||||
|
求一个指定容量为4001GB的分区
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkpart primary 0GB 4001GB
|
||||||
|
```
|
||||||
|
|
||||||
|
![image-20240131100929879](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706666970.png)
|
||||||
|
|
||||||
|
查看分区是否完成
|
||||||
|
|
||||||
|
```shell
|
||||||
|
print
|
||||||
|
```
|
||||||
|
|
||||||
|
最后退出
|
||||||
|
|
||||||
|
```shell
|
||||||
|
quit
|
||||||
|
```
|
||||||
|
|
||||||
|
挂载到指定目录
|
||||||
|
|
||||||
|
查看一下是否有硬盘
|
||||||
|
|
||||||
|
```shell
|
||||||
|
fdisk -l
|
||||||
|
```
|
||||||
|
|
||||||
|
将/dev/sda分区挂载在/mnt/sda上
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mount -t ext4 /dev/sda1 /mnt/sda1
|
||||||
|
```
|
||||||
|
|
||||||
|
将/mnt/sda挂载写入到系统启动项
|
||||||
|
|
||||||
|
```shell
|
||||||
|
echo /dev/sda1 /mnt/sda1 ext4 defaults 12>> /etc/fstab
|
||||||
|
```
|
||||||
|
|
||||||
|
最后添加在PVE设置中
|
||||||
|
|
||||||
|
![image-20240131091718419](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706663839.png)
|
||||||
|
|
||||||
|
## 扩展硬盘
|
||||||
|
|
||||||
|
https://blog.csdn.net/u011414736/article/details/131207861
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 功耗节约
|
||||||
|
|
||||||
|
查看当前功耗
|
||||||
|
|
||||||
|
```shell
|
||||||
|
lscpu | grep MHz
|
||||||
|
```
|
||||||
|
|
||||||
|
![image-20240131104925895](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706669366.png)
|
||||||
|
|
||||||
|
### 省电优化
|
||||||
|
|
||||||
|
### 调整 CPU 模式
|
||||||
|
|
||||||
|
首先得安装 cpupower:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
apt install linux-cpupower
|
||||||
|
```
|
||||||
|
|
||||||
|
下面是 cpupower 的一些常用命令:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# CPU实时频率查看
|
||||||
|
watch -n 1 cpupower monitor
|
||||||
|
|
||||||
|
# 查看当前所有CPU的信息
|
||||||
|
cpupower -c all frequency-info
|
||||||
|
|
||||||
|
# 设置所有CPU为节能模式
|
||||||
|
cpupower -c all frequency-set -g powersave
|
||||||
|
|
||||||
|
# 设置所有CPU为性能模式
|
||||||
|
cpupower -c all frequency-set -g performance
|
||||||
|
```
|
||||||
|
|
||||||
|
![image-20240131105139420](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706669499.png)
|
||||||
|
|
||||||
|
因为 PVE 下默认的 CPU 电源策略就是 performance 性能模式了,所以我们这里将其设置为保守一点的 conservative 模式:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cpupower -c all frequency-set -g conservative
|
||||||
|
```
|
||||||
|
|
||||||
|
此时检测频率发现所有的 CPU 频率都已经下来了
|
||||||
|
|
||||||
|
![image-20240131105257937](https://lsky.hhdxw.top/imghub/2024/01/image-202401311706669578.png)
|
||||||
|
|
||||||
|
## [[内网穿透]]
|
|
@ -0,0 +1,116 @@
|
||||||
|
## 时间同步
|
||||||
|
|
||||||
|
查看日期时间、时区、以及NTP状态
|
||||||
|
|
||||||
|
```shell
|
||||||
|
timedatectl
|
||||||
|
```
|
||||||
|
|
||||||
|
展示如下
|
||||||
|
|
||||||
|
```shell
|
||||||
|
[root@localhost ~]# timedatectl
|
||||||
|
Local time: 四 2024-01-25 21:30:41 EST
|
||||||
|
Universal time: 五 2024-01-26 02:30:41 UTC
|
||||||
|
RTC time: 五 2024-01-26 02:30:40
|
||||||
|
Time zone: America/New_York (EST, -0500)
|
||||||
|
System clock synchronized: yes
|
||||||
|
NTP service: active
|
||||||
|
RTC in local TZ: no
|
||||||
|
```
|
||||||
|
|
||||||
|
### Centos 7
|
||||||
|
|
||||||
|
打开终端,以root用户身份登录。
|
||||||
|
|
||||||
|
安装NTP(Network Time Protocol)软件包。运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
yum install ntp
|
||||||
|
```
|
||||||
|
|
||||||
|
安装完成后,编辑NTP配置文件。运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
vi /etc/ntp.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
在打开的文件中,找到或添加以下行,将其注释解除并设置NTP服务器:
|
||||||
|
|
||||||
|
```
|
||||||
|
server pool.ntp.org
|
||||||
|
```
|
||||||
|
|
||||||
|
或者你可以使用其他可靠的NTP服务器,例如:
|
||||||
|
|
||||||
|
```
|
||||||
|
server ntp1.aliyun.com
|
||||||
|
server ntp2.aliyun.com
|
||||||
|
server ntp3.aliyun.com
|
||||||
|
```
|
||||||
|
|
||||||
|
保存并关闭文件。
|
||||||
|
|
||||||
|
启动NTP服务并设置为开机自启。运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
systemctl start ntpd
|
||||||
|
systemctl enable ntpd
|
||||||
|
```
|
||||||
|
|
||||||
|
等待一段时间,系统将与NTP服务器同步时间。
|
||||||
|
|
||||||
|
完成上述步骤后,CentOS 8的时间将会与NTP服务器同步。你可以使用以下命令检查系统时间是否已经同步:
|
||||||
|
|
||||||
|
```
|
||||||
|
date
|
||||||
|
```
|
||||||
|
|
||||||
|
### Centos 8 Stream
|
||||||
|
|
||||||
|
查看同步源
|
||||||
|
|
||||||
|
```shell
|
||||||
|
chronyc sources -v
|
||||||
|
```
|
||||||
|
|
||||||
|
打开终端,以root用户身份登录。
|
||||||
|
|
||||||
|
安装chrony软件包。运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
yum install chrony
|
||||||
|
```
|
||||||
|
|
||||||
|
安装完成后,编辑chrony配置文件。运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
vi /etc/chrony.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
在打开的文件中,找到或添加以下行,将其注释解除并设置NTP服务器:
|
||||||
|
|
||||||
|
```
|
||||||
|
server pool.ntp.org
|
||||||
|
```
|
||||||
|
|
||||||
|
或者你可以使用其他可靠的NTP服务器,例如:
|
||||||
|
|
||||||
|
```
|
||||||
|
server ntp1.aliyun.com
|
||||||
|
server ntp2.aliyun.com
|
||||||
|
server ntp3.aliyun.com
|
||||||
|
```
|
||||||
|
|
||||||
|
保存并关闭文件。
|
||||||
|
|
||||||
|
启动chronyd服务并设置为开机自启。运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
systemctl start chronyd
|
||||||
|
systemctl enable chronyd
|
||||||
|
```
|
||||||
|
|
||||||
|
等待一段时间,系统将与NTP服务器同步时间。
|
||||||
|
|
||||||
|
完成上述步骤后,CentOS 8的时间将会与NTP服务器同步。你可以使用以下命令检查系统时间是否已经同步:
|
|
@ -57,13 +57,19 @@ sudo vim /etc/docker/daemon.json
|
||||||
|
|
||||||
镜像源
|
镜像源
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"registry-mirrors": ["https://hub-mirror.c.163.com"]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```json
|
||||||
{
|
{
|
||||||
"registry-mirrors": [
|
"registry-mirrors": [
|
||||||
"https://9kkc1zdn.mirror.aliyuncs.com",
|
"https://9kkc1zdn.mirror.aliyuncs.com",
|
||||||
"https://hub-mirror.c.163.com/",
|
"https://hub-mirror.c.163.com",
|
||||||
"https://docker.mirrors.ustc.edu.cn/",
|
"https://docker.mirrors.ustc.edu.cn",
|
||||||
"https://registry.docker-cn.com"
|
"https://registry.docker-cn.com",
|
||||||
"https://hub.docker.com"
|
"https://hub.docker.com"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,10 @@ sudo vim /etc/systemd/system/multi-user.target.wants/docker.service
|
||||||
-H tcp://0.0.0.0
|
-H tcp://0.0.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0 --containerd=/run/containerd/containerd.sock
|
||||||
|
```
|
||||||
|
|
||||||
![image-20230901170301087](https://lsky.hhdxw.top/imghub/2023/09/iamge-202309011693558981.png)
|
![image-20230901170301087](https://lsky.hhdxw.top/imghub/2023/09/iamge-202309011693558981.png)
|
||||||
|
|
||||||
esc :wq保存退出
|
esc :wq保存退出
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
docker run -p 9200:9200 -p 9300:9300 --name elasticsearch \
|
docker run -p 9200:9200 -p 9300:9300 --name elasticsearch \
|
||||||
-e "discovery.type=single-node" \
|
-e "discovery.type=single-node" \
|
||||||
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
|
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
|
||||||
-d elasticsearch:7.8.0
|
-d elasticsearch:7.17.7
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -10,7 +10,7 @@ docker exec -it elasticsearch /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.5/elasticsearch-analysis-ik-7.17.5.zip
|
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -18,5 +18,18 @@ docker restart elasticsearch
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run -d --name kibana --link elasticsearch:elasticsearch -p 5601:5601 kibana:7.8.0
|
docker run -d --name kibana --link elasticsearch:elasticsearch -p 5601:5601 kibana:7.17.7
|
||||||
|
```
|
||||||
|
|
||||||
|
其中服务器可能因为网络原因下载不下来 ik 分词器,我们下载后本地导入安装
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# ik 分词器在服务器中的位置 /root/elasticsearch-analysis-ik-7.17.7.zip# 导入 docker 中
|
||||||
|
docker cp /root/elasticsearch-analysis-ik-7.17.7.zip elasticsearch:/tmp/elasticsearch-analysis-ik-7.17.7.zip
|
||||||
|
|
||||||
|
# 进入容器
|
||||||
|
docker exec -it elasticsearch /bin/bash
|
||||||
|
|
||||||
|
# 安装
|
||||||
|
./bin/elasticsearch-plugin install file:///tmp/elasticsearch-analysis-ik-7.17.7.zip
|
||||||
```
|
```
|
|
@ -0,0 +1,209 @@
|
||||||
|
|
||||||
|
|
||||||
|
在GitHub上下载对应版本的frp程序,然后上传frps到服务器
|
||||||
|
|
||||||
|
下载地址https://github.com/fatedier/frp/releases
|
||||||
|
|
||||||
|
文档地址
|
||||||
|
|
||||||
|
```shell
|
||||||
|
#直接下载指定版本
|
||||||
|
wget https://github.com/fatedier/frp/releases/download/v0.53.2/frp_0.53.2_linux_amd64.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 解压
|
||||||
|
|
||||||
|
```shell
|
||||||
|
tar -xzvf frp_0.53.2_linux_amd64.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 复制
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cp -R /root/frp_0.53.2_linux_amd64/* /root/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 服务端
|
||||||
|
|
||||||
|
#### 测试运行
|
||||||
|
|
||||||
|
```shell
|
||||||
|
chmod +x frps
|
||||||
|
./frps
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 运行配置
|
||||||
|
|
||||||
|
```shell
|
||||||
|
vim frps.toml
|
||||||
|
```
|
||||||
|
|
||||||
|
配置文件如下
|
||||||
|
|
||||||
|
```properties
|
||||||
|
bindPort = 7000 #注册服务端口
|
||||||
|
auth.method = "token" #验证方式
|
||||||
|
auth.token = "token" #token秘钥
|
||||||
|
|
||||||
|
webServer.port = 7500 #管理面板端口
|
||||||
|
webServer.addr = "0.0.0.0" #绑定到所有网络上,外网访问
|
||||||
|
webServer.user = "admin" #管理员名称
|
||||||
|
webServer.password = "admin" #管理员密码
|
||||||
|
```
|
||||||
|
|
||||||
|
上面是带有备注(运行时好像不能带有备注,后面两个的均为该行为)
|
||||||
|
|
||||||
|
```properties
|
||||||
|
bindPort = 7000
|
||||||
|
auth.method = "token"
|
||||||
|
auth.token = "token"
|
||||||
|
|
||||||
|
webServer.port = 7500
|
||||||
|
webServer.addr = "0.0.0.0"
|
||||||
|
webServer.user = "admin"
|
||||||
|
webServer.password = "admin"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 启动
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./frps -c frps.toml
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 配置为Linux服务的形式运行
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo vim /etc/systemd/system/frps.service
|
||||||
|
```
|
||||||
|
|
||||||
|
配置文件如下
|
||||||
|
|
||||||
|
```properties
|
||||||
|
[Unit]
|
||||||
|
Description = frp server
|
||||||
|
After = network.target syslog.target
|
||||||
|
Wants = network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type = simple
|
||||||
|
ExecStart = /root/frps -c /root/frps.toml
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy = multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 启动
|
||||||
|
|
||||||
|
```shell
|
||||||
|
systemctl enable frps
|
||||||
|
systemctl start frps
|
||||||
|
```
|
||||||
|
|
||||||
|
## 客户端
|
||||||
|
|
||||||
|
#### 测试运行
|
||||||
|
|
||||||
|
```shell
|
||||||
|
chmod +x frpc
|
||||||
|
./frpc
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 运行配置
|
||||||
|
|
||||||
|
```shell
|
||||||
|
vim frpc.toml
|
||||||
|
```
|
||||||
|
|
||||||
|
配置文件如下
|
||||||
|
|
||||||
|
```properties
|
||||||
|
serverAddr = "1.1.1.1" //之前搭建好的内网穿透服务器地址
|
||||||
|
serverPort = 7000 //内网穿透服务器注册端口
|
||||||
|
auth.method = "token" //使用token验证
|
||||||
|
auth.token = "123456" //使用密码
|
||||||
|
|
||||||
|
[[proxies]]
|
||||||
|
name = "nginx" //配置需要代理的本地服务
|
||||||
|
type = "tcp" //类型选择tcp即可(大部分都是)
|
||||||
|
localIP = "127.0.0.1" //本地服务的IP地址,因为是直接部署在本地,所以说直接127.0.0.1
|
||||||
|
localPort = 80 //本地服务端口
|
||||||
|
remotePort = 80 //远程代理端口
|
||||||
|
```
|
||||||
|
|
||||||
|
```properties
|
||||||
|
serverAddr = "1.1.1.1"
|
||||||
|
serverPort = 7000
|
||||||
|
auth.method = "token"
|
||||||
|
auth.token = "123456"
|
||||||
|
|
||||||
|
[[proxies]]
|
||||||
|
name = "nginx"
|
||||||
|
type = "tcp"
|
||||||
|
localIP = "127.0.0.1"
|
||||||
|
localPort = 80
|
||||||
|
remotePort = 80
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 启动
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./frpc -c frpc.toml
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 配置为Linux服务的形式运行
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo vim /etc/systemd/system/frpc.service
|
||||||
|
```
|
||||||
|
|
||||||
|
配置文件如下
|
||||||
|
|
||||||
|
```properties
|
||||||
|
[Unit]
|
||||||
|
Description = frp client
|
||||||
|
After = network.target syslog.target
|
||||||
|
Wants = network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type = simple
|
||||||
|
ExecStart = /root/frpc -c /root/frpc.toml
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy = multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 启动
|
||||||
|
|
||||||
|
```shell
|
||||||
|
systemctl enable frpc
|
||||||
|
systemctl start frpc
|
||||||
|
```
|
||||||
|
|
||||||
|
## 其他设置
|
||||||
|
|
||||||
|
#### 进程放到后台运行
|
||||||
|
|
||||||
|
通过下面命令启动
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nohup ./frpc -c frpc.toml >/dev/null 2>&1 &
|
||||||
|
```
|
||||||
|
|
||||||
|
查看运行进程
|
||||||
|
|
||||||
|
```shell
|
||||||
|
ps aux | grep frpc
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
root@pve:~# ps aux | grep frpc
|
||||||
|
root 17856 0.0 0.0 724104 12160 pts/0 Sl 10:17 0:00 ./frpc -c frpc.toml
|
||||||
|
root 17903 0.0 0.0 6332 2048 pts/1 S+ 10:17 0:00 grep frpc
|
||||||
|
```
|
||||||
|
|
||||||
|
清除进程
|
||||||
|
|
||||||
|
```shell
|
||||||
|
kill 17856
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue