Compare commits
109 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0c4ff515b4 | ||
![]() |
4e45ae31d0 | ||
![]() |
1c92401de1 | ||
![]() |
e921e5a2f7 | ||
![]() |
f935311a57 | ||
![]() |
3d07153688 | ||
![]() |
a146bc2c7c | ||
![]() |
3f78f9d0d9 | ||
![]() |
617cbf506f | ||
![]() |
f57e34d2aa | ||
![]() |
341c8d1673 | ||
![]() |
8477fd5f7e | ||
![]() |
8c085cdb9a | ||
![]() |
39de3779f9 | ||
![]() |
f46aff8c20 | ||
![]() |
2a05e3e2f8 | ||
![]() |
e4842818d1 | ||
![]() |
e0fe3a5262 | ||
![]() |
762ab15ff7 | ||
![]() |
a8b42881bb | ||
![]() |
a327861eca | ||
![]() |
01ca790df2 | ||
![]() |
e9a2a836de | ||
![]() |
38eaf9e74b | ||
![]() |
7fdb83d25e | ||
![]() |
fd422bbbbb | ||
![]() |
8e362a1bc3 | ||
![]() |
4ef43d78c7 | ||
![]() |
a273e355fe | ||
![]() |
e514e3ae47 | ||
![]() |
00c44bcd00 | ||
![]() |
70b9778c4a | ||
![]() |
4f347a9288 | ||
![]() |
c86e1e8e82 | ||
![]() |
bfe16541b9 | ||
![]() |
ea6492d591 | ||
![]() |
e6ecaef094 | ||
![]() |
551e676e85 | ||
![]() |
409e785421 | ||
![]() |
18d217c3cb | ||
![]() |
2a4ceaeda9 | ||
![]() |
50e41af0d4 | ||
![]() |
4fccfcb947 | ||
![]() |
2b85736f53 | ||
![]() |
b26079b313 | ||
![]() |
6e8015a2cf | ||
![]() |
3d05bc7f8c | ||
![]() |
9cb4dedd8e | ||
![]() |
4878d90c1c | ||
![]() |
eabbc8c60b | ||
![]() |
f7f9ff37b6 | ||
![]() |
30a17ff30f | ||
![]() |
c85fb3f381 | ||
![]() |
91a8a7f708 | ||
![]() |
63ff416daf | ||
![]() |
91e9d0bb7d | ||
![]() |
5dbfe7b2da | ||
![]() |
e20a8534de | ||
![]() |
9dd2a6111e | ||
![]() |
4093ea559d | ||
![]() |
83cdbfcc78 | ||
![]() |
c02d21fc54 | ||
![]() |
589aace867 | ||
![]() |
666ae90129 | ||
![]() |
801bd56d44 | ||
![]() |
689177908b | ||
![]() |
df954b4c4d | ||
![]() |
4caecd979e | ||
![]() |
a698172e7f | ||
![]() |
a6bccc5347 | ||
![]() |
abe83ec6bb | ||
![]() |
8e95484615 | ||
![]() |
fa84a0a885 | ||
![]() |
c549c384a7 | ||
![]() |
bc68d63a8f | ||
![]() |
f66c487ccc | ||
![]() |
16ac79a58e | ||
![]() |
bf8df61b03 | ||
![]() |
3edf3f88fd | ||
![]() |
dd986a05f0 | ||
![]() |
292220fe34 | ||
![]() |
0d63a4429d | ||
![]() |
ac9799fab5 | ||
![]() |
9b3218c658 | ||
![]() |
85185daf6f | ||
![]() |
4b028c7948 | ||
![]() |
baa2b310e0 | ||
![]() |
187d994e6f | ||
![]() |
8a8347d508 | ||
![]() |
c59920d354 | ||
![]() |
7875814088 | ||
![]() |
dc3d152756 | ||
![]() |
3b24031a1f | ||
![]() |
804b64d90c | ||
![]() |
7a34633267 | ||
![]() |
880b7c2a57 | ||
![]() |
1fa6d81460 | ||
fa7e799eb8 | |||
de5e215b6e | |||
30775e4366 | |||
ab8978ba68 | |||
a64b8a4343 | |||
79b15b85f4 | |||
![]() |
a78a0db846 | ||
![]() |
438d859ba6 | ||
e0225c0b7f | |||
0ac3fe15a8 | |||
2be87e7a04 | |||
ab18b6d55c |
24
README.md
@ -27,12 +27,29 @@
|
|||||||
git push
|
git push
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 挂载 hugo 和 nginx 前端目录
|
||||||
|
- 下载 [hugo_extended_0.106.0](https://github.com/gohugoio/hugo/releases/download/v0.106.0/hugo_extended_0.106.0_linux-amd64.tar.gz)
|
||||||
|
- 解压获取可执行二进制文件 hugo
|
||||||
|
- 挂载 hugo 到 gitea 容器中
|
||||||
|
```yaml
|
||||||
|
- type: bind
|
||||||
|
source: ./gitea/hugo
|
||||||
|
target: /usr/bin/hugo
|
||||||
|
```
|
||||||
|
|
||||||
|
- 挂载 nginx 前端目录到 gitea 容器中
|
||||||
|
```yaml
|
||||||
|
- type: bind
|
||||||
|
source: ./nginx/html
|
||||||
|
target: /html
|
||||||
|
```
|
||||||
|
|
||||||
## 发布
|
## 发布
|
||||||
- 配置本仓库的 post-receive 钩子,内容如下
|
- 配置本仓库的 post-receive 钩子,内容如下
|
||||||
```bash
|
```bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
exec &> /var/log/gitea/post-receive.log
|
exec &> /opt/gitea/log/post-receive.log
|
||||||
date +'[%F %T] Update www.colben.cn ...'
|
date +'[%F %T] Update www.colben.cn ...'
|
||||||
cd /html/www.colben.cn
|
cd /html/www.colben.cn
|
||||||
env -i git pull origin master
|
env -i git pull origin master
|
||||||
@ -42,12 +59,11 @@
|
|||||||
- 克隆本仓库的前端目录
|
- 克隆本仓库的前端目录
|
||||||
```bash
|
```bash
|
||||||
docker exec -ti gitea /bin/bash # 进入 gitea 容器
|
docker exec -ti gitea /bin/bash # 进入 gitea 容器
|
||||||
apk update
|
chown gitea.gitea /html
|
||||||
apk add --no-cache hugo # 安装 hugo
|
|
||||||
chown gitea.www-data /html
|
|
||||||
su - gitea
|
su - gitea
|
||||||
cd /html
|
cd /html
|
||||||
git clone https://git.colben.cn/colben/www.colben.cn.git
|
git clone https://git.colben.cn/colben/www.colben.cn.git
|
||||||
|
cd www.colben.cn
|
||||||
hugo
|
hugo
|
||||||
exit # 退出容器
|
exit # 退出容器
|
||||||
```
|
```
|
||||||
|
11
config.toml
@ -2,6 +2,7 @@ baseURL = "https://colben.cn/"
|
|||||||
languageCode = "en"
|
languageCode = "en"
|
||||||
defaultContentLanguage = "zh-cn" # en / zh-cn / ... (This field determines which i18n file to use)
|
defaultContentLanguage = "zh-cn" # en / zh-cn / ... (This field determines which i18n file to use)
|
||||||
title = "Colben Notes"
|
title = "Colben Notes"
|
||||||
|
#title = "私人工作笔记"
|
||||||
preserveTaxonomyNames = true
|
preserveTaxonomyNames = true
|
||||||
enableRobotsTXT = true
|
enableRobotsTXT = true
|
||||||
enableEmoji = true
|
enableEmoji = true
|
||||||
@ -41,11 +42,11 @@ copyright = "" # default: author.name ↓ # 默认为下面配
|
|||||||
weight = 20
|
weight = 20
|
||||||
identifier = "archives"
|
identifier = "archives"
|
||||||
url = "/post/"
|
url = "/post/"
|
||||||
[[menu.main]]
|
#[[menu.main]]
|
||||||
name = "标签"
|
# name = "标签"
|
||||||
weight = 30
|
# weight = 30
|
||||||
identifier = "tags"
|
# identifier = "tags"
|
||||||
url = "/tags/"
|
# url = "/tags/"
|
||||||
[[menu.main]]
|
[[menu.main]]
|
||||||
name = "分类"
|
name = "分类"
|
||||||
weight = 40
|
weight = 40
|
||||||
|
45
content/ali.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
title: "阿里味儿"
|
||||||
|
date: 2019-10-30T13:43:55+08:00
|
||||||
|
lastmod: 2023-02-20T14:35:55+08:00
|
||||||
|
menu: "main"
|
||||||
|
weight: 60
|
||||||
|
---
|
||||||
|
|
||||||
|
1. 我不管你怎么做的,那是你的事情,如果你这点事情都做不到,那么你存在的价值是什么?
|
||||||
|
2. 你不要凡事都来问我,你自己的脑子呢?我怎么知道这个事怎么做?你自己看着办吧?
|
||||||
|
3. 这个事情你为什么不和我汇报?什么你汇报了?那你为什么不讲清楚利害关系?这个事是责任你要全部抗起来。
|
||||||
|
4. 没有发生的事情你不要设那么多的限制,做那么多不好的假设,要让业务先run起来。你不做怎么知道结果会不好呢?
|
||||||
|
5. 你开跑之前没想过风险吗?我说不care?你说不care你就可以不看了吗?这是你活还是我的活?今年3.25你没跑了。
|
||||||
|
6. 虽然你得了3.25,但也不意味着你没价值,外面的机会也不好呀,你再留一年吧,我今年保证给你3.75。
|
||||||
|
7. 你上年就是3.25,所以下半年肯定也要给你3.25啊,不是你没做错什么就可以了。你要有进步要有突破。某某某虽然也做错过事,但他很快调整了啊,已经基本弥补了之前的过错,所以我肯定要给他3.75啊。你不要总看别人,看看你自己。
|
||||||
|
8. 虽然你今年做的很好,值得375,但某某某比你更需要375,我要保他升8,所以这次只能给你3.5了。
|
||||||
|
9. 你是新人,你牺牲一下,今年3.25吧。
|
||||||
|
10. 她是新人,怎么能给一个新人3.25,你来吧。
|
||||||
|
11. 不要你认为,你要看看大家怎么想。
|
||||||
|
12. 大家的意见你就可以盲从吗?你的思考呢?
|
||||||
|
13. 遇到困难的时候,找我,我帮你协调。
|
||||||
|
14. 你怎么什么事都找我、你干嘛呢?
|
||||||
|
15. 这个事你自己去汇报就行,他p10怎么了,p10就不是人了嘛?就说我说的,你去。
|
||||||
|
16. 你为什么跨过我和p10汇报?你想干嘛?
|
||||||
|
17. 我们最终衡量绩效看得是业务价值,虽然你这一年做了很多事情,但是最终体现到业务上的东西我没有看到,只会埋头做事不是公司对p6的要求。慎重考虑决定给你年度3.25。
|
||||||
|
18. 你去年事情做的挺好,业务方也很认可,但是我觉得你在其它方面投入不够,对团队内其他组的项目了解不够,同时在全组的稳定性三板斧上投入太少,这些方面要多投入,所以给你一个你懂的,希望你明年努力争取375。
|
||||||
|
19. 你做的这个东西,它的业务价值是什么,在这个问题上你缺乏自己的思考和沉淀,近几年这些关键问题有改善吗?
|
||||||
|
20. 有没有拉通思维,有没有闭环形成?有没有赋能业务方?有没有沉淀?有没有来源于业务又高于业务看问题?
|
||||||
|
21. 你这说的是什么东西,毫无逻辑性和思考,能不能站在P9和P10的高度去看问题?
|
||||||
|
22. “我和xx一致认为,你的表现不如预期,在工作中没有看到你的价值,都是按领导布置的方向走,你的想法呢?你的创新呢?你主动开辟过什么项目?如果只是做老板定的项目,那你的价值和产出在哪里?你好好思考一下,把上半年的项目做个详细的复盘。我们xx团队原本是我们有力出击的拳头,但你没有让它发挥出来。” ——当年我接受阿里味洗礼的时候还只是是个小P6
|
||||||
|
23. 我是看中了你某公司背景才让你来的,结果你就这样?
|
||||||
|
24. 你作为一个高p(特么的一个7而已),不懂怎么做吗?你问我有什么用,得你自己想。
|
||||||
|
25. 你带的这个人,很聪明,我觉得放在你这浪费,等她转正我就让她做别的。
|
||||||
|
26. 你的不足太多了,所以我给你招个主管吧。
|
||||||
|
27. 虽然去年你做的不错,但是整个团队横向拉通对比,你排在最末尾。这次给你3.25是对你的激励,而不是找个机会欺负新人。
|
||||||
|
28. 你能提出来我觉得很好呀,符合阿里人真实不装的品格。但是在阿里,个人还是要服从组织的决定,要把团队的利益放在个人前面,团队成长了,你个人才能有所成长。
|
||||||
|
29. 快乐工作,认真生活。
|
||||||
|
30. 不扒自己一层皮,你怎么知道自己是谁。
|
||||||
|
31. 为过程鼓掌,为结果买单。
|
||||||
|
32. 要么忍,要么滚。
|
||||||
|
33. 排期上不要太紧,大家放宽。
|
||||||
|
34. 什么?这个事情排期要2个礼拜,1个礼拜给我完成。
|
||||||
|
35. 要有owner精神,敢于担当。
|
||||||
|
36. 你邮件里让谁确认了吗,出问题让我负责吗,让他明确邮件签字画押。
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
title: "其他"
|
|
||||||
date: 2019-10-30T13:43:55+08:00
|
|
||||||
lastmod: 2019-10-30T13:43:55+08:00
|
|
||||||
menu: "main"
|
|
||||||
weight: 60
|
|
||||||
---
|
|
||||||
|
|
||||||
# Linux
|
|
||||||
- [**Linux监控命令图文详述**](http://www.linuxidc.com/Linux/2015-01/111577.htm)
|
|
||||||
- [**Linux crontab 命令详细用法及示例**](http://www.linuxidc.com/Linux/2015-03/114339.htm)
|
|
||||||
- [**Linux下top命令详解**](http://www.linuxidc.com/Linux/2015-04/116101.htm)
|
|
||||||
- [**Ubuntu 通过 Live CD 更新Grub恢复引导Boot Menu**](http://www.linuxidc.com/Linux/2015-04/116451.htm)
|
|
||||||
- [**Kickstart配置文件超详细解析**](http://www.linuxidc.com/Linux/2017-08/146168.htm)
|
|
||||||
- [**PXE+Kickstart无人值守安装CentOS 7**](http://www.linuxidc.com/Linux/2017-08/146169.htm)
|
|
||||||
- [**PXE+Kickstart无人值守安装CentOS 6**](http://www.linuxidc.com/Linux/2017-08/146170.htm)
|
|
||||||
- [**Cobbler无人值守批量安装Linux系统**](http://www.linuxidc.com/Linux/2017-08/146171.htm)
|
|
||||||
- [**PXE+DHCP+TFTP+Cobbler 无人值守安装CentOS 7**](http://www.linuxidc.com/Linux/2017-09/146705.htm)
|
|
||||||
- [**Linux下搭建无人执守安装服务器**](http://www.linuxidc.com/Linux/2017-04/143182.htm)
|
|
||||||
|
|
||||||
# Network
|
|
||||||
- [**关于TCP连接建立与终止那点事**](http://www.linuxidc.com/Linux/2015-09/122777.htm)
|
|
||||||
|
|
||||||
# Database
|
|
||||||
- [**Oracle Linux 5.8安装Oracle 11g RAC**](http://www.linuxidc.com/Linux/2013-05/84251.htm)
|
|
||||||
- [**RAC环境数据库重启实例**](http://www.linuxidc.com/Linux/2013-08/88855.htm)
|
|
||||||
- [**使用Oracle 的 imp ,exp 命令实现数据的导入导出**](http://blog.csdn.net/studyvcmfc/article/details/5674290)
|
|
||||||
- [**ORACLE EXPDP命令使用详细**](http://blog.csdn.net/zftang/article/details/6387325)
|
|
||||||
- [**控制文件和控制文件的备份**](http://blog.csdn.net/seertan/article/details/8449050)
|
|
||||||
- [**MySQL如何通过EXPLAIN分析SQL的执行计划**](https://www.linuxidc.com/Linux/2018-08/153354.htm)
|
|
||||||
|
|
||||||
# Container
|
|
||||||
- [**Docker 终极指南**](http://www.linuxidc.com/Linux/2015-01/111631.htm)
|
|
||||||
|
|
||||||
# Python
|
|
||||||
- [**Python 的 OptionParser 模块**](http://www.it165.net/pro/html/201211/4140.html)
|
|
||||||
|
|
||||||
# Firewalld
|
|
||||||
- [**Iptables防火墙规则使用详解**](https://www.linuxidc.com/Linux/2018-08/153378.htm)
|
|
||||||
|
|
||||||
# Dev
|
|
||||||
- [**Make 命令教程详解**](http://www.linuxidc.com/Linux/2015-06/118278.htm)
|
|
||||||
- [**深入理解Java内存与垃圾回收调优**](https://www.linuxidc.com/Linux/2018-08/153457.htm)
|
|
||||||
|
|
@ -112,7 +112,7 @@ categories: ["network"]
|
|||||||
|
|
||||||
### 载入 bonding 模块,重启 network 服务
|
### 载入 bonding 模块,重启 network 服务
|
||||||
```bash
|
```bash
|
||||||
modprob bonding
|
modprobe bonding
|
||||||
systemctl restart network
|
systemctl restart network
|
||||||
```
|
```
|
||||||
|
|
||||||
|
40
content/post/disk-extend.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
title: "硬盘扩容"
|
||||||
|
date: 2024-07-10T19:49:00+08:00
|
||||||
|
lastmod: 2024-07-10T19:49:00+08:00
|
||||||
|
keywords: []
|
||||||
|
tags: ["扩容"]
|
||||||
|
categories: ["storage"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## 裸盘在线扩容
|
||||||
|
- 环境:/dev/sdb 直接挂载在 /data/ 下
|
||||||
|
- 直接更新文件系统
|
||||||
|
```
|
||||||
|
resize2fs /dev/sdb # ext4 文件系统,参数是设备
|
||||||
|
xfs_growfs /data # xfs 文件系统,参数是挂载点
|
||||||
|
```
|
||||||
|
|
||||||
|
## 分区在线扩容
|
||||||
|
- 环境:/dev/sdb1 直接挂载在 /data/ 下
|
||||||
|
- 安装 growpart
|
||||||
|
```
|
||||||
|
yum install cloud-utils-growpart # redhat 系 linux
|
||||||
|
apt install cloud-guest-utils # debian 系 linux
|
||||||
|
```
|
||||||
|
|
||||||
|
- 扩容分区
|
||||||
|
```
|
||||||
|
growpart /dev/sdb 1
|
||||||
|
# 第一个参数是设备,第二参数是分区编号
|
||||||
|
```
|
||||||
|
|
||||||
|
- 更新文件系统
|
||||||
|
```
|
||||||
|
resize2fs /dev/sdb1 # ext4 文件系统,参数是分区设备
|
||||||
|
xfs_growfs /data # xfs 文件系统,参数是挂载点
|
||||||
|
```
|
||||||
|
|
||||||
|
## lvm 逻辑卷在线扩容
|
||||||
|
- 参考[LV管理](https://www.colben.cn/post/lvm/#lv-%E7%AE%A1%E7%90%86)
|
||||||
|
|
@ -30,7 +30,7 @@ yum install vsftpd
|
|||||||
- 服务端从 20 端口连接客户端正在监听的端口,向客户端发送数据
|
- 服务端从 20 端口连接客户端正在监听的端口,向客户端发送数据
|
||||||
|
|
||||||
- 相关配置
|
- 相关配置
|
||||||
```ini
|
```
|
||||||
# 开启主动模式
|
# 开启主动模式
|
||||||
pasv_enable = no
|
pasv_enable = no
|
||||||
```
|
```
|
||||||
@ -44,17 +44,17 @@ yum install vsftpd
|
|||||||
- 客户端连接服务端新监听的端口,下载服务端数据
|
- 客户端连接服务端新监听的端口,下载服务端数据
|
||||||
|
|
||||||
- 相关配置
|
- 相关配置
|
||||||
```ini
|
```
|
||||||
# 开启被动模式
|
# 开启被动模式
|
||||||
pasv_enable = yes
|
pasv_enable = yes
|
||||||
# 数据连接可以使用的端口范围的最大端口,0 表示任意端口,默认值为0
|
# 数据连接可以使用的端口范围的最大端口,0 表示任意端口,默认值为0
|
||||||
pasv_min_port=30000
|
|
||||||
# 数据连接可以使用的端口范围的最小端口,0 表示任意端口,默认值为0
|
|
||||||
pasv_max_port=30999
|
pasv_max_port=30999
|
||||||
|
# 数据连接可以使用的端口范围的最小端口,0 表示任意端口,默认值为0
|
||||||
|
pasv_min_port=30000
|
||||||
```
|
```
|
||||||
|
|
||||||
## 匿名用户配置
|
## 匿名用户相关配置
|
||||||
```ini
|
```
|
||||||
# 控制是否允许匿名用户登入
|
# 控制是否允许匿名用户登入
|
||||||
# 匿名用户使用的登陆名为 ftp 或 anonymous,口令为空
|
# 匿名用户使用的登陆名为 ftp 或 anonymous,口令为空
|
||||||
# 匿名用户不能离开匿名用户家目录/var/ftp,且只能下载不能上传
|
# 匿名用户不能离开匿名用户家目录/var/ftp,且只能下载不能上传
|
||||||
@ -102,23 +102,7 @@ chown_username=username
|
|||||||
anon_umask=077
|
anon_umask=077
|
||||||
```
|
```
|
||||||
|
|
||||||
## 配置
|
## 匿名用户上传下载
|
||||||
### 常用配置
|
|
||||||
```ini
|
|
||||||
#允许匿名用户登陆
|
|
||||||
anonymous_enable=YES
|
|
||||||
#允许本地用户登陆
|
|
||||||
local_enable=YES
|
|
||||||
#允许登陆用户写可访问的目录或文件
|
|
||||||
write_enable=YES
|
|
||||||
#指定用户登陆后直接进入系统的/mnt目录
|
|
||||||
local_root=/mnt
|
|
||||||
chroot_list_enable=YES
|
|
||||||
#限定登陆用户可访问的目录只有自己的家目录或指定的local_root目录
|
|
||||||
chroot_list_file=/etc/vsftpd/chroot_list
|
|
||||||
```
|
|
||||||
|
|
||||||
### 允许 vsftpd 匿名用户上传和下载
|
|
||||||
- 创建匿名用户登陆目录
|
- 创建匿名用户登陆目录
|
||||||
```bash
|
```bash
|
||||||
mkdir -p /var/ftp/pub
|
mkdir -p /var/ftp/pub
|
||||||
@ -127,7 +111,7 @@ chroot_list_file=/etc/vsftpd/chroot_list
|
|||||||
```
|
```
|
||||||
|
|
||||||
- 修改 vsftpd.conf
|
- 修改 vsftpd.conf
|
||||||
```ini
|
```
|
||||||
#允许匿名用户登录FTP
|
#允许匿名用户登录FTP
|
||||||
anonymous_enable=YES
|
anonymous_enable=YES
|
||||||
#设置匿名用户的登录目录(如需要,需自己添加并修改)
|
#设置匿名用户的登录目录(如需要,需自己添加并修改)
|
||||||
@ -141,7 +125,18 @@ chroot_list_file=/etc/vsftpd/chroot_list
|
|||||||
anon_umask=022
|
anon_umask=022
|
||||||
```
|
```
|
||||||
|
|
||||||
### 本地用户登陆
|
## 单用户
|
||||||
|
- 创建用户及数据目录
|
||||||
|
```bash
|
||||||
|
cd /sbin
|
||||||
|
ln -s nologin ftplogin
|
||||||
|
echo '/sbin/ftplogin' >> /etc/shells
|
||||||
|
useradd -M -s /sbin/ftplogin user1
|
||||||
|
passwd user1
|
||||||
|
mkdir -p -m 0700 /path/to/ftpdata
|
||||||
|
chown user1:user1 /path/to/ftpdata
|
||||||
|
```
|
||||||
|
|
||||||
- 修改 vsftpd.conf
|
- 修改 vsftpd.conf
|
||||||
```
|
```
|
||||||
# 不允许匿名用户登入
|
# 不允许匿名用户登入
|
||||||
@ -150,35 +145,46 @@ chroot_list_file=/etc/vsftpd/chroot_list
|
|||||||
local_enable=YES
|
local_enable=YES
|
||||||
# 当本地用户登入时,将被更换到定义的目录下
|
# 当本地用户登入时,将被更换到定义的目录下
|
||||||
# 默认值为各用户的家目录
|
# 默认值为各用户的家目录
|
||||||
local_root=/home/username
|
local_root=/path/to/ftpdata
|
||||||
# 是否允许登陆用户有写权限
|
# 是否允许登陆用户有写权限
|
||||||
# 属于全局设置,默认值为YES。
|
# 属于全局设置,默认值为YES。
|
||||||
write_enable=YES/NO(YES)
|
write_enable=YES/NO(YES)
|
||||||
# 本地用户新增档案时的 umask 值,默认值为077
|
# 本地用户新增档案时的 umask 值,默认值为077
|
||||||
local_umask=022
|
local_umask=022
|
||||||
# 本地用户上传档案后的档案权限
|
# 指定 local_root 为根目录,不允许切换到上级目录
|
||||||
# 与chmod所使用的数值相同,默认值为0666
|
|
||||||
file_open_mode=0755
|
|
||||||
# 指定用户列表文件中的用户不允许切换到上级目录
|
|
||||||
chroot_local_user=YES
|
chroot_local_user=YES
|
||||||
|
# chroot 后可写
|
||||||
|
allow_writeable_chroot=YES
|
||||||
```
|
```
|
||||||
|
|
||||||
### 创建 ftp 专用账户
|
## 多用户
|
||||||
- 创建用户 ftpuser1
|
- 创建用户及数据目录
|
||||||
```bash
|
```bash
|
||||||
useradd -s /sbin/nologin ftpuser1
|
cd /sbin
|
||||||
passwd ftpuser1
|
ln -s nologin ftplogin
|
||||||
|
echo '/sbin/ftplogin' >> /etc/shells
|
||||||
|
useradd -d /ftp_disk/user1 -s /sbin/ftplogin user1
|
||||||
|
useradd -d /ftp_disk/user2 -s /sbin/ftplogin user2
|
||||||
|
passwd user1
|
||||||
|
passwd user2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
- 修改 vsftpd.conf
|
- 修改 vsftpd.conf
|
||||||
```ini
|
```
|
||||||
|
# 不允许匿名用户登入
|
||||||
anonymous_enable=no
|
anonymous_enable=no
|
||||||
|
# 允许本地用户登入
|
||||||
local_enable=YES
|
local_enable=YES
|
||||||
local_root=/home/ftpuser
|
# 是否允许登陆用户有写权限
|
||||||
write_enable=YES
|
# 属于全局设置,默认值为YES。
|
||||||
|
write_enable=YES/NO(YES)
|
||||||
|
# 本地用户新增档案时的 umask 值,默认值为077
|
||||||
local_umask=022
|
local_umask=022
|
||||||
file_open_mode=0755
|
# 指定家目录为根目录,不允许切换到上级目录
|
||||||
chroot_local_user=YES
|
chroot_local_user=YES
|
||||||
|
# chroot 后可写
|
||||||
|
allow_writeable_chroot=YES
|
||||||
```
|
```
|
||||||
|
|
||||||
## 参考
|
## 参考
|
||||||
|
@ -89,24 +89,32 @@ gsettings set org.gnome.desktop.wm.keybindings minimize "['<Primary><Super>Down'
|
|||||||
gsettings set org.gnome.desktop.wm.keybindings maximize "[]"
|
gsettings set org.gnome.desktop.wm.keybindings maximize "[]"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 在 CentOS6 下安装 gnome 桌面
|
## 安装 gnome 桌面
|
||||||
```bash
|
- CentOS6
|
||||||
yum groupinstall 'X Window System'
|
```bash
|
||||||
yum groupinstall Desktop
|
yum groupinstall 'X Window System'
|
||||||
sed -i '/^id/id:5:initdefault:' /etc/inittab
|
yum groupinstall Desktop
|
||||||
```
|
sed -i '/^id/id:5:initdefault:' /etc/inittab
|
||||||
|
```
|
||||||
|
|
||||||
## 在 CentOS7 下安装 gnome3 桌面
|
- CentOS7
|
||||||
```bash
|
```bash
|
||||||
yum groupinstall 'X Window System'
|
yum groupinstall 'X Window System'
|
||||||
yum groupinstall 'Gnome Desktop'
|
yum groupinstall 'Gnome Desktop'
|
||||||
systemctl set-default graphical.target
|
systemctl set-default graphical.target
|
||||||
systemctl enable gdm
|
systemctl enable gdm
|
||||||
# 创建一个可登陆的普通用户
|
# 创建一个可登陆的普通用户
|
||||||
```
|
```
|
||||||
|
|
||||||
## 在 gdm 中隐藏用户名
|
- Debian 安装 gnome 桌面
|
||||||
- 修改文件/etc/gdm/gdm.schemas,找到这一段:
|
```bash
|
||||||
|
apt install gdm3 gnome-terminal
|
||||||
|
# 创建一个可登陆的普通用户
|
||||||
|
```
|
||||||
|
|
||||||
|
## gdm 配置
|
||||||
|
### 隐藏用户名
|
||||||
|
- 修改文件 /etc/gdm/gdm.schemas,找到这一段:
|
||||||
```xml
|
```xml
|
||||||
<schema>
|
<schema>
|
||||||
<key>greeter/Exclude</key>
|
<key>greeter/Exclude</key>
|
||||||
@ -117,3 +125,12 @@ systemctl enable gdm
|
|||||||
```
|
```
|
||||||
- 将用户名添加在<default>与</default>之间即可,用逗号隔开,保存退出即可。
|
- 将用户名添加在<default>与</default>之间即可,用逗号隔开,保存退出即可。
|
||||||
|
|
||||||
|
### 用户自动登录
|
||||||
|
- 修改 gdm3 配置文件 /etc/gdm3/daemon.conf,配置用户(user1)自动登录
|
||||||
|
```
|
||||||
|
AutomaticLoginEnable = true
|
||||||
|
AutomaticLogin = user1
|
||||||
|
```
|
||||||
|
|
||||||
|
- 重启操作系统后,会自动登录 user1 用户
|
||||||
|
|
||||||
|
415
content/post/incus-install.md
Normal file
@ -0,0 +1,415 @@
|
|||||||
|
---
|
||||||
|
title: "Incus 安装"
|
||||||
|
date: 2025-01-05T11:09:00+08:00
|
||||||
|
lastmod: 2025-01-05T11:09:00+08:00
|
||||||
|
tags: ["kvm", "虚拟化", "容器"]
|
||||||
|
categories: ["kvm", "container"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## 单机环境
|
||||||
|
### 服务器
|
||||||
|
处理器 | 内存 | 系统盘 | 数据盘
|
||||||
|
---- | ---- | ---- | ----
|
||||||
|
4核 | 8GB | 30GB | 30GB
|
||||||
|
|
||||||
|
### 操作系统配置
|
||||||
|
- 在 /etc/security/limits.conf 中追加如下配置
|
||||||
|
```
|
||||||
|
* soft nofile 1048576
|
||||||
|
* hard nofile 1048576
|
||||||
|
root soft nofile 1048576
|
||||||
|
root hard nofile 1048576
|
||||||
|
* soft memlock unlimited
|
||||||
|
* hard memlock unlimited
|
||||||
|
root soft memlock unlimited
|
||||||
|
root hard memlock unlimited
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在 /etc/sysctl.conf 中追加如下配置
|
||||||
|
```
|
||||||
|
fs.aio-max-nr = 524288
|
||||||
|
fs.inotify.max_queued_events = 1048576
|
||||||
|
fs.inotify.max_user_instances = 1048576
|
||||||
|
fs.inotify.max_user_watches = 1048576
|
||||||
|
vm.max_map_count = 262144
|
||||||
|
```
|
||||||
|
|
||||||
|
- 安装 chrony,配置时间同步
|
||||||
|
|
||||||
|
#### debian
|
||||||
|
- 安装 curl 和 gpg
|
||||||
|
```BASH
|
||||||
|
apt install curl gpg
|
||||||
|
```
|
||||||
|
|
||||||
|
#### centos/rocky/fedora
|
||||||
|
- 禁用 selinux
|
||||||
|
- 关闭并禁用防火墙(firewalld)
|
||||||
|
- 安装 epel
|
||||||
|
```BASH
|
||||||
|
dnf install epel-release
|
||||||
|
dnf makecache
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置子用户
|
||||||
|
```BASH
|
||||||
|
echo root:1000000:1000000000 > /etc/subuid
|
||||||
|
echo root:1000000:1000000000 > /etc/subgid
|
||||||
|
```
|
||||||
|
|
||||||
|
- 重启操作系统
|
||||||
|
|
||||||
|
### 安装 incus 环境
|
||||||
|
#### debian
|
||||||
|
- 参考[zabbly/incus](https://github.com/zabbly/incus)
|
||||||
|
- 引入公钥,用于验证软件包的完整性
|
||||||
|
```BASH
|
||||||
|
curl -fsSL https://pkgs.zabbly.com/key.asc | gpg --show-keys --fingerprint
|
||||||
|
mkdir -p /etc/apt/keyrings/
|
||||||
|
curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置软件源,lts 版本太旧了,这里用的最新稳定版
|
||||||
|
```BASH
|
||||||
|
sh -c 'cat <<EOF > /etc/apt/sources.list.d/zabbly-incus-stable.sources
|
||||||
|
Enabled: yes
|
||||||
|
Types: deb
|
||||||
|
URIs: https://pkgs.zabbly.com/incus/stable
|
||||||
|
Suites: $(. /etc/os-release && echo ${VERSION_CODENAME})
|
||||||
|
Components: main
|
||||||
|
Architectures: $(dpkg --print-architecture)
|
||||||
|
Signed-By: /etc/apt/keyrings/zabbly.asc
|
||||||
|
|
||||||
|
EOF'
|
||||||
|
```
|
||||||
|
|
||||||
|
- 安装 incus 包
|
||||||
|
```BASH
|
||||||
|
apt update
|
||||||
|
apt install incus qemu-system
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置 incus
|
||||||
|
```BASH
|
||||||
|
echo 'INCUS_EDK2_PATH=/usr/share/ovmf' >> /etc/default/incus
|
||||||
|
```
|
||||||
|
|
||||||
|
- 重启 incus
|
||||||
|
```BASH
|
||||||
|
systemctl restart incus
|
||||||
|
```
|
||||||
|
|
||||||
|
#### centos/rocky
|
||||||
|
- 安装 incus 包,**目前测试 qemu 启动 vm 失败**
|
||||||
|
```BASH
|
||||||
|
dnf -y copr enable ligenix/enterprise-qemu-wider
|
||||||
|
dnf install lvm2 incus incus-tools
|
||||||
|
# 打算尝试虚拟机的可以安装 qemu-system 包
|
||||||
|
#dnf install qemu-system
|
||||||
|
```
|
||||||
|
|
||||||
|
- ~~修改 incus 服务文件~~
|
||||||
|
```BASH
|
||||||
|
sed -i 's/INCUS_OVMF_PATH/INCUS_EDK2_PATH/' /usr/lib/systemd/system/incus.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
```
|
||||||
|
|
||||||
|
- 启动 incus 服务
|
||||||
|
```BASH
|
||||||
|
systemctl start incus
|
||||||
|
```
|
||||||
|
|
||||||
|
#### fedora
|
||||||
|
- 安装 incus 包
|
||||||
|
```BASH
|
||||||
|
dnf install lvm2 incus incus-tools qemu-system
|
||||||
|
```
|
||||||
|
|
||||||
|
### 初始化 incus 单机环境
|
||||||
|
- 初始化 incus
|
||||||
|
```BASH
|
||||||
|
incus admin init
|
||||||
|
```
|
||||||
|
|
||||||
|
- 按提示回答初始化交互命令,大都直接回车就好了,大概回答内容如下
|
||||||
|
```
|
||||||
|
Would you like to use clustering? (yes/no) [default=no]:
|
||||||
|
Do you want to configure a new storage pool? (yes/no) [default=yes]:
|
||||||
|
Name of the new storage pool [default=default]:
|
||||||
|
Name of the storage backend to use (dir, lvm) [default=dir]:
|
||||||
|
Would you like to create a new local network bridge? (yes/no) [default=yes]:
|
||||||
|
What should the new bridge be called? [default=incusbr0]:
|
||||||
|
What IPv4 address should be used? (CIDR subnet notation, auto or none) [default=auto]:
|
||||||
|
What IPv6 address should be used? (CIDR subnet notation, auto or none) [default=auto]:
|
||||||
|
Would you like the server to be available over the network? (yes/no) [default=no]:
|
||||||
|
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: no
|
||||||
|
Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]:
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 集群环境
|
||||||
|
### 服务器
|
||||||
|
主机名 | 服务器网卡IP | 集群网卡IP | 数据盘 | /etc/hosts
|
||||||
|
---- | ---- | ---- | ---- | ----
|
||||||
|
incus1 | eth0: 192.168.1.1 | 10.10.10.1 | /dev/sdb | 10.10.10.1 incus1
|
||||||
|
incus2 | eth0: 192.168.1.2 | 10.10.10.2 | /dev/sdb | 10.10.10.2 incus2
|
||||||
|
incus3 | eth0: 192.168.1.3 | 10.10.10.3 | /dev/sdb | 10.10.10.3 incus3
|
||||||
|
|
||||||
|
### 操作系统配置
|
||||||
|
- [每台服务器的操作与单机环境完全一致](#操作系统配置)
|
||||||
|
|
||||||
|
### 安装 incus 环境
|
||||||
|
- [每台服务器的操作与单机环境完全一致](#安装-incus-环境)
|
||||||
|
|
||||||
|
### 创建网桥
|
||||||
|
#### debian
|
||||||
|
- **在每台服务器里执行下面操作**
|
||||||
|
- 创建网桥 incusbr
|
||||||
|
```BASH
|
||||||
|
apt install bridge-utils
|
||||||
|
brctl addbr incusbr
|
||||||
|
```
|
||||||
|
|
||||||
|
- 修改 /etc/network/interfaces,把 eth0 相关配置改成如下网桥配置
|
||||||
|
```
|
||||||
|
iface eth0 inet manual
|
||||||
|
auto incusbr
|
||||||
|
iface incusbr inet static
|
||||||
|
address ${eth0_ip}/24
|
||||||
|
gateway 192.168.1.254
|
||||||
|
bridge-ports eth0
|
||||||
|
bridge-stp off
|
||||||
|
bridge-fd 0
|
||||||
|
#dns-nameservers 223.5.5.5
|
||||||
|
# 把 ${eth0_ip} 替换成对应服务器的 eth0 网卡 ip
|
||||||
|
```
|
||||||
|
|
||||||
|
- 重启网络服务,**注意此操作可能会导致服务器断网**
|
||||||
|
```BASH
|
||||||
|
systemctl restart networking
|
||||||
|
```
|
||||||
|
|
||||||
|
#### centos/rocky/fedora
|
||||||
|
- **在每台服务器里执行下面操作**
|
||||||
|
- 创建网桥 incusbr,连接服务器网卡 eth0,**注意此操作可能会导致服务器断网**
|
||||||
|
```BASH
|
||||||
|
nmcli c add \
|
||||||
|
type bridge stp no \
|
||||||
|
ifname incusbr \
|
||||||
|
con-name incusbr \
|
||||||
|
autoconnect yes \
|
||||||
|
ipv4.addr ${eth0_ip}/24 \
|
||||||
|
ipv4.gateway 192.168.1.254 \
|
||||||
|
ipv4.method manual
|
||||||
|
# 把 ${eth0_ip} 替换成对应服务器的 eth0 网卡 ip
|
||||||
|
|
||||||
|
nmcli c add type bridge-slave con-name incusbr-eth0 ifname eth0 master incusbr
|
||||||
|
```
|
||||||
|
|
||||||
|
### 创建 lvm 卷组
|
||||||
|
- **在每台服务器里执行下面操作**
|
||||||
|
- 基于数据盘创建 lvm 卷组 incusvg
|
||||||
|
```BASH
|
||||||
|
pvcreate /dev/sdb
|
||||||
|
vgcreate incusvg /dev/sdb
|
||||||
|
```
|
||||||
|
|
||||||
|
### 创建集群
|
||||||
|
- **在 incus1 里执行下面操作**
|
||||||
|
- 初始化 incus
|
||||||
|
```BASH
|
||||||
|
incus admin init
|
||||||
|
```
|
||||||
|
|
||||||
|
- 按提示回答初始化交互命令,大概回答内容如下
|
||||||
|
```
|
||||||
|
Would you like to use clustering? (yes/no) [default=no]: yes # 使用集群模式
|
||||||
|
What IP address or DNS name should be used to reach this server? [default=10.10.10.1]: # 集群 ip
|
||||||
|
Are you joining an existing cluster? (yes/no) [default=no]: # 这里是创建新集群,不是加入已有集群
|
||||||
|
What member name should be used to identify this server in the cluster? [default=incus1]:
|
||||||
|
Do you want to configure a new local storage pool? (yes/no) [default=yes]: no # 不创建本地存储池
|
||||||
|
Do you want to configure a new remote storage pool? (yes/no) [default=no]: # 不创建远程存储池
|
||||||
|
Would you like to use an existing bridge or host interface? (yes/no) [default=no]: # 不创建网络
|
||||||
|
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: no
|
||||||
|
Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]:
|
||||||
|
```
|
||||||
|
|
||||||
|
- **经测试,需要手动创建存储池和受管网络,否则后面其他 incus 节点加入集群失败**
|
||||||
|
- 创建存储池 pool1
|
||||||
|
```BASH
|
||||||
|
incus storage create pool1 lvm source=incusvg
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建受管网络 incusbr99
|
||||||
|
```BASH
|
||||||
|
incus network create incusbr99
|
||||||
|
```
|
||||||
|
|
||||||
|
### 加入集群
|
||||||
|
- **在 incus2** 里初始化 incus
|
||||||
|
```BASH
|
||||||
|
incus admin init
|
||||||
|
```
|
||||||
|
|
||||||
|
- **在 incus1** 里生成加入 incus2 的令牌
|
||||||
|
```BASH
|
||||||
|
incus cluster add incus2
|
||||||
|
# 复制这里输出的令牌字符串,用于回答 incus2 加入集群的 token
|
||||||
|
```
|
||||||
|
|
||||||
|
- **返回 incus2**,按提示回答初始化交互命令,大概回答内容如下
|
||||||
|
```
|
||||||
|
Would you like to use clustering? (yes/no) [default=no]: yes
|
||||||
|
What IP address or DNS name should be used to reach this server? [default=10.10.10.2]:
|
||||||
|
Are you joining an existing cluster? (yes/no) [default=no]: yes # 加入已有的集群
|
||||||
|
Please provide join token: xxxxxxxx # 这里是 incus1 里生成的令牌
|
||||||
|
All existing data is lost when joining a cluster, continue? (yes/no) [default=no] yes
|
||||||
|
Choose "lvm.thinpool_name" property for storage pool "pool1": incusvg # 存储用 lvm 卷组 incusvg
|
||||||
|
Choose "lvm.vg_name" property for storage pool "pool1": incusvg # 存储用 lvm 卷组 incusvg
|
||||||
|
Choose "source" property for storage pool "pool1": incusvg # 存储用 lvm 卷组 incusvg
|
||||||
|
Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]:
|
||||||
|
```
|
||||||
|
|
||||||
|
- **在 incus3** 里初始化 incus
|
||||||
|
```BASH
|
||||||
|
incus admin init
|
||||||
|
```
|
||||||
|
|
||||||
|
- **在 incus1** 里生成加入 incus3 的令牌
|
||||||
|
```BASH
|
||||||
|
incus cluster add incus3
|
||||||
|
# 复制这里输出的令牌字符串,用于回答 incus3 加入集群的 token
|
||||||
|
```
|
||||||
|
|
||||||
|
- **返回 incus3**,按提示回答初始化交互命令,大概回答内容如下
|
||||||
|
```
|
||||||
|
Would you like to use clustering? (yes/no) [default=no]: yes
|
||||||
|
What IP address or DNS name should be used to reach this server? [default=10.10.10.3]:
|
||||||
|
Are you joining an existing cluster? (yes/no) [default=no]: yes # 加入已有的集群
|
||||||
|
Please provide join token: xxxxxxxx # 这里是 incus1 里生成的令牌
|
||||||
|
All existing data is lost when joining a cluster, continue? (yes/no) [default=no] yes
|
||||||
|
Choose "lvm.thinpool_name" property for storage pool "pool1": incusvg # 存储用 lvm 卷组 incusvg
|
||||||
|
Choose "lvm.vg_name" property for storage pool "pool1": incusvg # 存储用 lvm 卷组 incusvg
|
||||||
|
Choose "source" property for storage pool "pool1": incusvg # 存储用 lvm 卷组 incusvg
|
||||||
|
Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]:
|
||||||
|
```
|
||||||
|
|
||||||
|
- **之前创建的受管网络 incusbr99 虽然没用,但不建议删除,否则后面向该集群增加其他 incus 节点还会失败**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 简单使用
|
||||||
|
### 配置镜像源
|
||||||
|
- 增加清华镜像源
|
||||||
|
```BASH
|
||||||
|
incus remote add tuna https://mirrors.tuna.tsinghua.edu.cn/lxc-images/ \
|
||||||
|
--protocol=simplestreams --public
|
||||||
|
incus remote list # 查看镜像源
|
||||||
|
```
|
||||||
|
|
||||||
|
### lxc 容器
|
||||||
|
- 拉取 alpine lxc 镜像
|
||||||
|
```BASH
|
||||||
|
incus image list tuna: alpine amd64 # 查看清华源里存在的 alpine amd64 镜像
|
||||||
|
incus image copy tuna:alpine/3.21 local:
|
||||||
|
incus image alias create local:alpine-3.21 81f0ad86761e
|
||||||
|
```
|
||||||
|
|
||||||
|
- 启动一个系统级容器 alpine-lxc
|
||||||
|
```BASH
|
||||||
|
# 单机环境
|
||||||
|
incus launch local:alpine/3.21 alpine-lxc \
|
||||||
|
-c limits.cpu=2 -c limits.memory=4GiB -d root,size=5GiB
|
||||||
|
|
||||||
|
# 集群环境中的 incus2 节点
|
||||||
|
```BASH
|
||||||
|
incus launch local:alpine/3.21 alpine-lxc \
|
||||||
|
-c limits.cpu=2 -c limits.memory=4GiB -d root,size=5GiB \
|
||||||
|
--network incusbr --storage pool1 --target incus2
|
||||||
|
```
|
||||||
|
|
||||||
|
- 进入 alpine-lxc 容器
|
||||||
|
```BASH
|
||||||
|
incus shell alpine-lxc
|
||||||
|
|
||||||
|
# 单机环境的网络是 incus 管理的,此时会发现该虚拟机已有 ip,可以正常上网
|
||||||
|
# 集群环境的服务器网络中,如果有 dhcp 服务,该虚拟机也会分到 ip
|
||||||
|
# 如果没有 dhcp 服务,可以手动配置一个临时 ip
|
||||||
|
ip a add 192.168.1.123/24 dev eth0
|
||||||
|
ping 192.168.1.254 # 正常情况网关网络可达
|
||||||
|
```
|
||||||
|
|
||||||
|
### qemu 虚拟机
|
||||||
|
- 客户机安装 [virt-viewer](https://releases.pagure.org/virt-viewer/virt-viewer-x64-11.0-1.0.msi)
|
||||||
|
- 登录已安装 incus 的 debian 操作系统下
|
||||||
|
- 下载 RockyLinux8 操作系统镜像文件:Rocky-8.10-x86_64-minimal.iso
|
||||||
|
- 创建 iso 存储卷
|
||||||
|
```BASH
|
||||||
|
incus storage volume import pool1 \
|
||||||
|
/root/Rocky-8.7-x86_64-minimal.iso \
|
||||||
|
rocky8-iso-volume --type=iso
|
||||||
|
# pool1: 存储池
|
||||||
|
# /root/Rocky-8.7-x86_64-minimal.iso:本地 iso 镜像文件
|
||||||
|
# rocky8-iso-volume:创建的 iso 存储卷的名字
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建一个空的虚拟机,并设置 cpu、内存和系统盘大小和 boot 优先级
|
||||||
|
```BASH
|
||||||
|
incus create vm1 --empty --vm -c limits.cpu=2 -c limits.memory=4GiB -d root,size=6GiB -s pool1
|
||||||
|
# vm1:虚拟机名字
|
||||||
|
# limits.cpu=2:虚拟机占用 2 核
|
||||||
|
# limits.memory:虚拟机占用 4G 内存
|
||||||
|
# root,size=6GiB:虚拟机中的系统盘设备名是 root,大小是 6G
|
||||||
|
# pool1: 存储池
|
||||||
|
|
||||||
|
incus config device set vm1 root boot.priority=20
|
||||||
|
# boot.priority=20:boot 优先级,数字越大,优先级越高
|
||||||
|
|
||||||
|
# 修改虚拟机配置
|
||||||
|
#incus config set vm1 limits.cpu=4
|
||||||
|
#incus config edit vm1
|
||||||
|
```
|
||||||
|
|
||||||
|
- 为虚拟机增加 iso 存储卷,并设置 boot 优先级
|
||||||
|
```BASH
|
||||||
|
incus config device add vm1 iso-cd disk \
|
||||||
|
pool=pool1 source=rocky8-iso-volume boot.priority=10
|
||||||
|
# vm1:虚拟机名字
|
||||||
|
# iso-cd:虚拟机中的 iso 只读盘设备名
|
||||||
|
# pool1:存储池
|
||||||
|
# rocky8-iso-volume:创建的 iso 存储卷的名字
|
||||||
|
# boot.priority=10:boot 优先级,数字越大,优先级越高
|
||||||
|
```
|
||||||
|
|
||||||
|
- **在 aarch64 架构中,关闭虚拟机的安全引导**
|
||||||
|
```BASH
|
||||||
|
incus config set vm1 security.secureboot=false
|
||||||
|
```
|
||||||
|
|
||||||
|
- 启动虚拟机
|
||||||
|
```BASH
|
||||||
|
incus start vm1
|
||||||
|
```
|
||||||
|
|
||||||
|
- 打开已运行虚拟机的 console 终端
|
||||||
|
```BASH
|
||||||
|
incus console vm1 --type=vga
|
||||||
|
# 服务器中未安装 remote-viewer,因此该命令会输出下面 spice socket 信息:
|
||||||
|
The client automatically uses either spicy or remote-viewer when present.
|
||||||
|
As neither could be found, the raw SPICE socket can be found at:
|
||||||
|
spice+unix:///root/.config/incus/sockets/xxxx.spice
|
||||||
|
```
|
||||||
|
|
||||||
|
- 用 ssh 把 socket 文件转成 tcp 端口,[/etc/sshd_config 配置参考这里](/post/ssh)
|
||||||
|
```BASH
|
||||||
|
ssh -N -g -L 5555:/root/.config/incus/sockets/xxxx.spice 127.0.0.1
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在客户机中打开 virt-viewer,输入地址“spice://{debian 服务器 ip}:5555”,连接
|
||||||
|
- 在打开的窗口中开始安装 RockyLinux8
|
||||||
|
- 系统安装完成后,虚拟机不再需要 iso 只读盘设备,可以卸载
|
||||||
|
```BASH
|
||||||
|
incus config device remove vm1 iso-cd
|
||||||
|
```
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: "CentOS7 安装 K3S"
|
title: "RockyLinux 8.5 安装 K3S"
|
||||||
date: 2020-09-25T14:21:00+08:00
|
date: 2020-06-25T14:21:00+08:00
|
||||||
lastmod: 2020-09-25T14:21:00+08:00
|
lastmod: 2023-09-08T12:32:00+08:00
|
||||||
keywords: []
|
keywords: []
|
||||||
tags: ["rancher", "k3s"]
|
tags: ["rancher", "k3s"]
|
||||||
categories: ["container"]
|
categories: ["container"]
|
||||||
@ -9,151 +9,172 @@ categories: ["container"]
|
|||||||
|
|
||||||
## 环境
|
## 环境
|
||||||
|
|
||||||
角色 | 主机名 | 操作系统 | 软件
|
角色 | 主机名 | IP | 操作系统 | 软件
|
||||||
---- | ---- | ---- | ----
|
---- | ---- | ---- | ---- | ----
|
||||||
数据库 | - | - | docker-ce 19.03
|
镜像库 | k3s-170 | 10.0.4.170 | RockyLinux 8.5 | registry
|
||||||
k3s server | k3s-server0 | CentOS7.8 | docker-ce 19.03, k3s v1.18.9
|
数据库 | k3s-170 | 10.0.4.170 | RockyLinux 8.5 | mysql
|
||||||
k3s server | k3s-server1 | CentOS7.8 | docker-ce 19.03, k3s v1.18.9
|
负载均衡 | k3s-170 | 10.0.4.170 | RockyLinux 8.5 | nginx
|
||||||
k3s agent | k3s-agent0 | CentOS7.8 | docker-ce 19.03, k3s v1.18.9
|
k3s server | k3s-171 | 10.0.4.171 | RockyLinux 8.5 | k3s v1.27.4
|
||||||
k3s agent | k3s-agent1 | CentOS7.8 | docker-ce 19.03, k3s v1.18.9
|
k3s server | k3s-172 | 10.0.4.172 | RockyLinux 8.5 | k3s v1.27.4
|
||||||
|
k3s agent | k3s-173 | 10.0.4.173 | RockyLinux 8.5 | k3s v1.27.4
|
||||||
|
k3s agent | k3s-174 | 10.0.4.174 | RockyLinux 8.5 | k3s v1.27.4
|
||||||
|
k3s agent | k3s-175 | 10.0.4.175 | RockyLinux 8.5 | k3s v1.27.4
|
||||||
|
|
||||||
|
## 前期准备
|
||||||
- **全部服务器关闭 firewalld、selinux 和 swap,设置时间同步**
|
- **全部服务器关闭 firewalld、selinux 和 swap,设置时间同步**
|
||||||
- **全部 k3s 服务器(除了数据库)必须设置唯一主机名**
|
- **全部 k3s 服务器(除了k3s-170)必须设置唯一主机名**
|
||||||
|
- 在 k3s-170 上执行如下操作
|
||||||
|
- 安装 docker 环境,部署私有镜像库
|
||||||
|
- 安装 mysql,用来存储 k3s server 数据
|
||||||
|
- 安装 nginx,四层均衡负载两个 k3s server
|
||||||
|
- 下载 k3s 二进制文件和部署脚本
|
||||||
|
|
||||||
|
## 安装私有镜像库
|
||||||
|
- 在 k3s-170 上执行如下操作
|
||||||
|
- 修改 docker 配置,在 /etc/docker/daemon.json 中增加本机镜像库地址
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"insecure-registries": ["10.0.4.170:20080"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 安装私有镜像库 registry,监听 http 20080
|
||||||
|
- 下载镜像列表文件
|
||||||
|
```bash
|
||||||
|
curl -LO https://github.com/k3s-io/k3s/releases/download/v1.27.4%2Bk3s1/k3s-images.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
- 下载 k3s 系统镜像,推送到本机私有镜像库
|
||||||
|
```bash
|
||||||
|
for image in $(cat k3s-images.txt); do
|
||||||
|
docker pull $image
|
||||||
|
docker tag $image ${image/#docker.io/10.0.4.170:20080}
|
||||||
|
docker push ${image/#docker.io/10.0.4.170:20080}
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
## 安装数据库
|
## 安装数据库
|
||||||
- 在数据库服务器上执行如下操作
|
- 在 k3s-170 上执行如下操作
|
||||||
- 启动 docker 容器
|
- 安装 mysql
|
||||||
```bash
|
|
||||||
docker run -d \
|
|
||||||
--name mariadb \
|
|
||||||
-p 3306:3306 \
|
|
||||||
-v /data/mariadb/binlog:/var/lib/mysql-bin \
|
|
||||||
-v /data/mariadb/db:/var/lib/mysql \
|
|
||||||
-v /data/mariadb/log:/var/log/mysql \
|
|
||||||
harbor.colben.cn/general/alpine-mariadb
|
|
||||||
```
|
|
||||||
|
|
||||||
- 创建 k3s 数据库
|
- 创建 k3s 数据库
|
||||||
```bash
|
```bash
|
||||||
docker exec mariadb mysql -e "
|
CREATE DATABASE k3s DEFAULT CHARSET UTF8MB4;
|
||||||
CREATE DATABASE k3s DEFAULT CHARSET UTF8MB4;
|
CREATE USER k3s@'%' IDENTIFIED BY 'K3s_1234';
|
||||||
CREATE USER k3s@'%' IDENTIFIED BY 'Password_1234';
|
GRANT ALL ON k3s.* TO k3s@'%';
|
||||||
GRANT ALL ON k3s.* TO k3s@'%';
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- 生产环境建议配置 mysql 主从高可用,参考[MariaDB 主从复制](/post/mariadb-replication/)
|
## 安装负载均衡器
|
||||||
|
- 在 k3s-170 上执行如下操作
|
||||||
|
- 安装 nginx
|
||||||
|
- 配置 stream 四层转发
|
||||||
|
```
|
||||||
|
stream {
|
||||||
|
upstream k3s_servers {
|
||||||
|
server 10.0.4.171:6443;
|
||||||
|
server 10.0.4.172:6443;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 6443;
|
||||||
|
proxy_pass k3s_servers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 分发 k3s 部署文件
|
||||||
|
- 在 k3s-170 上执行如下操作
|
||||||
|
- 下载安装脚本(install-k3s.sh)和可执行文件(k3s)
|
||||||
|
```bash
|
||||||
|
curl -Lo install-k3s.sh get.k3s.io
|
||||||
|
curl -LO https://github.com/k3s-io/k3s/releases/download/v1.27.4%2Bk3s1/k3s
|
||||||
|
```
|
||||||
|
|
||||||
|
- 把安装脚本和二进制文件分发到每台 k3s server 和 k3s agent 服务器上
|
||||||
|
```bash
|
||||||
|
seq -f'10.0.4.%g' 171 175 | xargs -i scp k3s install-k3s.sh {}:/usr/local/bin
|
||||||
|
```
|
||||||
|
|
||||||
## 安装 k3s server
|
## 安装 k3s server
|
||||||
- 在每台 k3s server 服务器上执行如下操作
|
- 在每台 k3s server 上执行如下操作
|
||||||
- 下载并安装 k3s
|
- 增加可执行权限
|
||||||
```bash
|
```bash
|
||||||
cd /usr/local/bin/
|
cd /usr/local/bin
|
||||||
curl -LO https://github.com/rancher/k3s/releases/download/v1.18.9%2Bk3s1/k3s
|
chmod 0755 k3s install-k3s.sh
|
||||||
chmod 0755 k3s
|
|
||||||
ln -s k3s kubectl
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- 创建 systemd 服务文件 /etc/systemd/system/k3s-server.service,内容如下
|
- 创建私有镜像库配置文件
|
||||||
```ini
|
```bash
|
||||||
[Unit]
|
mkdir -p /etc/rancher/k3s
|
||||||
Description=Lightweight Kubernetes
|
cat >> /etc/rancher/k3s/registries.yaml <<-EOF
|
||||||
Documentation=https://k3s.io
|
mirrors:
|
||||||
Wants=network-online.target
|
docker.io:
|
||||||
|
endpoint:
|
||||||
[Install]
|
- "http://10.0.4.170:20080"
|
||||||
WantedBy=multi-user.target
|
EOF
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=notify
|
|
||||||
KillMode=process
|
|
||||||
Delegate=yes
|
|
||||||
LimitNOFILE=infinity
|
|
||||||
LimitNPROC=infinity
|
|
||||||
LimitCORE=infinity
|
|
||||||
TasksMax=infinity
|
|
||||||
TimeoutStartSec=0
|
|
||||||
Restart=always
|
|
||||||
RestartSec=5s
|
|
||||||
SuccessExitStatus=1
|
|
||||||
ExecStartPre=-/sbin/modprobe br_netfilter
|
|
||||||
ExecStartPre=-/sbin/modprobe overlay
|
|
||||||
ExecStart=/usr/local/bin/k3s \
|
|
||||||
server \
|
|
||||||
--docker \
|
|
||||||
--datastore-endpoint 'mysql://k3s:Password_1234@tcp({mysql 地址}:{mysql 端口})/k3s' \
|
|
||||||
--disable 'coredns,servicelb,traefik,local-storage,metrics-server' \
|
|
||||||
--pause-image 'harbor.colben.cn/k3s/pause:3.2'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- 重载 systemd 系统服务,启动 k3s-server 服务
|
- 执行安装脚本
|
||||||
|
```bash
|
||||||
|
INSTALL_K3S_EXEC='server --prefer-bundled-bin --disable "coredns,servicelb,traefik,local-storage,metrics-server" --datastore-endpoint="mysql://k3s:K3s_1234@tcp(10.0.4.170:3306)/k3s"' \
|
||||||
|
INSTALL_K3S_SKIP_DOWNLOAD=true \
|
||||||
|
INSTALL_K3S_SKIP_START=true \
|
||||||
|
K3S_TOKEN=123456 \
|
||||||
|
install-k3s.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- 修改 /etc/systemd/system/k3s.service,**把 mysql 一行中的反斜杠(\\)全部去掉**,重载
|
||||||
```bash
|
```bash
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl start k3s-server
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- 获取 token 信息(同一集群内各 server 上该文件完全一样),该信息用于 agent 连接
|
- 启动 k3s
|
||||||
```bash
|
```bash
|
||||||
cat /var/lib/rancher/k3s/server/token
|
systemctl start k3s
|
||||||
```
|
```
|
||||||
|
|
||||||
- 多个 k3s-server 服务可通过 keepalived 配置高可用,参考[keepalived 笔记](/post/keepalived/)
|
|
||||||
|
|
||||||
## 安装 k3s agent
|
## 安装 k3s agent
|
||||||
- 在每台 k3s agent 服务器上执行如下操作
|
- 在每台 k3s agent 上执行如下操作
|
||||||
- 下载并安装 k3s
|
- 增加可执行权限
|
||||||
```bash
|
```bash
|
||||||
cd /usr/local/bin/
|
cd /usr/local/bin
|
||||||
curl -LO https://github.com/rancher/k3s/releases/download/v1.18.9%2Bk3s1/k3s
|
chmod 0755 k3s install-k3s.sh
|
||||||
chmod 0755 k3s
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- 创建 systemd 服务文件 /etc/systemd/system/k3s-agent.service,内容如下
|
- 创建私有镜像库配置文件
|
||||||
```ini
|
|
||||||
[Unit]
|
|
||||||
Description=Lightweight Kubernetes
|
|
||||||
Documentation=https://k3s.io
|
|
||||||
Wants=network-online.target
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=notify
|
|
||||||
KillMode=process
|
|
||||||
Delegate=yes
|
|
||||||
LimitNOFILE=infinity
|
|
||||||
LimitNPROC=infinity
|
|
||||||
LimitCORE=infinity
|
|
||||||
TasksMax=infinity
|
|
||||||
TimeoutStartSec=0
|
|
||||||
Restart=always
|
|
||||||
RestartSec=5s
|
|
||||||
SuccessExitStatus=1
|
|
||||||
ExecStartPre=-/sbin/modprobe br_netfilter
|
|
||||||
ExecStartPre=-/sbin/modprobe overlay
|
|
||||||
ExecStart=/usr/local/bin/k3s \
|
|
||||||
agent \
|
|
||||||
--docker \
|
|
||||||
--server 'https://{任一 server 地址或 server 高可用地址}:6443' \
|
|
||||||
--pause-image 'harbor.boyachain.cn:20443/k3s/pause:3.2' \
|
|
||||||
--token '{server token 信息}'
|
|
||||||
```
|
|
||||||
|
|
||||||
- 重载 systemd 系统服务,启动 k3s-agent 服务
|
|
||||||
```bash
|
```bash
|
||||||
systemctl daemon-reload
|
mkdir -p /etc/rancher/k3s
|
||||||
systemctl start k3s-agent
|
cat >> /etc/rancher/k3s/registries.yaml <<-EOF
|
||||||
|
mirrors:
|
||||||
|
docker.io:
|
||||||
|
endpoint:
|
||||||
|
- "http://10.0.4.170:20080"
|
||||||
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
## 查看节点信息
|
- 执行安装脚本
|
||||||
- 在任一 k3s server 服务器上执行如下操作
|
```bash
|
||||||
- 查看节点信息
|
INSTALL_K3S_EXEC='agent --prefer-bundled-bin --server "https://10.0.4.170:6443"' \
|
||||||
|
INSTALL_K3S_SKIP_DOWNLOAD=true \
|
||||||
|
K3S_TOKEN=123456 \
|
||||||
|
install-k3s.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## 常用操作
|
||||||
|
- 在 k3s server 上查看节点信息
|
||||||
```bash
|
```bash
|
||||||
kubectl get nodes
|
kubectl get nodes
|
||||||
```
|
```
|
||||||
|
|
||||||
## 注意事项
|
- 在 k3s server 上标记 server 节点不可调度
|
||||||
- k3s 内部 ssl 证书有效期一年,可在到期前重启 k3s 集群轮换证书
|
```bash
|
||||||
|
kubectl cordon k3s-{171..172}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在 k3s server 上设置 agent 节点的角色为 worker
|
||||||
|
```bash
|
||||||
|
kubectl label nodes k3s-{173..175} kubernetes.io/role=worker --overwrite
|
||||||
|
```
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
- k3s 自签名 ca 证书有效期十年,客户端和服务器证书有效期一年
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ k8s-node | node124 | 10.0.4.124 | - | CentOS | docker flannel kubelet kube-proxy
|
|||||||
k8s-node | node125 | 10.0.4.125 | - | CentOS | docker flannel kubelet kube-proxy | /opt/kubernetes/
|
k8s-node | node125 | 10.0.4.125 | - | CentOS | docker flannel kubelet kube-proxy | /opt/kubernetes/
|
||||||
k8s-node | node126 | 10.0.4.126 | - | CentOS | docker flannel kubelet kube-proxy | /opt/kubernetes/
|
k8s-node | node126 | 10.0.4.126 | - | CentOS | docker flannel kubelet kube-proxy | /opt/kubernetes/
|
||||||
|
|
||||||
|
## 前期准备
|
||||||
- 全部服务器关闭 firewalld 和 selinux,禁用 swap,部署机(master120)可免密 ssh 登陆其他服务器
|
- 全部服务器关闭 firewalld 和 selinux,禁用 swap,部署机(master120)可免密 ssh 登陆其他服务器
|
||||||
- 软件版本
|
- 软件版本
|
||||||
- CentOS: 7.7
|
- CentOS: 7.7
|
||||||
|
@ -5,27 +5,34 @@ lastmod: 2019-10-30T11:22:03+08:00
|
|||||||
tags: ["keepalived", "高可用", "负载均衡"]
|
tags: ["keepalived", "高可用", "负载均衡"]
|
||||||
categories: ["ha/lb"]
|
categories: ["ha/lb"]
|
||||||
---
|
---
|
||||||
|
## keepalive 服务器
|
||||||
## 两个 haproxy 不抢占
|
|
||||||
- 环境
|
- 环境
|
||||||
- haproxy 服务器
|
- 应用服务器
|
||||||
- haproxy101: 10.1.1.101
|
- ka101: 10.1.1.101
|
||||||
- haproxy102: 10.1.1.102
|
- ka102: 10.1.1.102
|
||||||
- 虚拟地址
|
- 虚拟地址
|
||||||
- ip: 10.1.1.100
|
- ip: 10.1.1.100
|
||||||
- 在全部 haproxy 服务器上安装 keepalived
|
|
||||||
|
- 安装 keepalived
|
||||||
```bash
|
```bash
|
||||||
yum install keepalived
|
yum install keepalived
|
||||||
```
|
```
|
||||||
- 在全部 haproxy 服务器上配置 haproxy 和 keepalived 自启动
|
|
||||||
|
- 配置虚拟 ip
|
||||||
```bash
|
```bash
|
||||||
systemctl enable haproxy
|
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
|
||||||
systemctl enable keepalived
|
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
|
||||||
|
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
|
||||||
|
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
|
||||||
|
ip addr add 10.1.1.100/32 brd 10.1.1.100 dev lo
|
||||||
|
ip route add 10.1.1.100 dev lo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 两个 haproxy 不抢占
|
||||||
- MASTER/BACKUP 完整配置
|
- MASTER/BACKUP 完整配置
|
||||||
```
|
```
|
||||||
global_defs {
|
global_defs {
|
||||||
router_id haproxy101 #BACKUP 这里是 haproxy102
|
router_id ka101 #BACKUP 这里是 ka102
|
||||||
script_user root
|
script_user root
|
||||||
enable_script_security
|
enable_script_security
|
||||||
}
|
}
|
||||||
@ -58,11 +65,6 @@ categories: ["ha/lb"]
|
|||||||
|
|
||||||
## 两个 LVS-DR 调度器不抢占均衡后端 MySQL 和 Ceph 负载
|
## 两个 LVS-DR 调度器不抢占均衡后端 MySQL 和 Ceph 负载
|
||||||
- 环境
|
- 环境
|
||||||
- keepalived 服务器
|
|
||||||
- ka101: 10.1.1.101
|
|
||||||
- ka102: 10.1.1.102
|
|
||||||
- 虚拟地址
|
|
||||||
- ip: 10.1.1.100
|
|
||||||
- mysqld 服务器
|
- mysqld 服务器
|
||||||
- mysql103: 10.1.1.103
|
- mysql103: 10.1.1.103
|
||||||
- mysql104: 10.1.1.104
|
- mysql104: 10.1.1.104
|
||||||
@ -71,19 +73,12 @@ categories: ["ha/lb"]
|
|||||||
- ceph106: 10.1.1.106
|
- ceph106: 10.1.1.106
|
||||||
- ceph107: 10.1.1.107
|
- ceph107: 10.1.1.107
|
||||||
- ceph108: 10.1.1.108
|
- ceph108: 10.1.1.108
|
||||||
- 在全部 keepalived 服务器上安装 keepalived
|
|
||||||
```bash
|
|
||||||
yum install keepalived
|
|
||||||
```
|
|
||||||
- 在全部 keepalived 服务器上配置 keepalived 自启动
|
|
||||||
```bash
|
|
||||||
systemctl enable keepalived
|
|
||||||
```
|
|
||||||
- MASTER/BACKUP 完整配置
|
- MASTER/BACKUP 完整配置
|
||||||
- 全局和实例配置
|
- 全局和实例配置
|
||||||
```
|
```
|
||||||
global_defs {
|
global_defs {
|
||||||
router_id keepalive101 #BACKUP 配置 keepalive102
|
router_id ka101 #BACKUP 配置 ka102
|
||||||
}
|
}
|
||||||
vrrp_instance V1_1 {
|
vrrp_instance V1_1 {
|
||||||
state BACKUP #BACKUP 也配置 BACKUP
|
state BACKUP #BACKUP 也配置 BACKUP
|
||||||
@ -101,6 +96,7 @@ categories: ["ha/lb"]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- LVS 均衡 mysql galera cluser 负载
|
- LVS 均衡 mysql galera cluser 负载
|
||||||
```
|
```
|
||||||
virtual_server 10.1.1.100 3306 {
|
virtual_server 10.1.1.100 3306 {
|
||||||
@ -134,6 +130,7 @@ categories: ["ha/lb"]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- LVS 均衡 ceph radosgw 负载
|
- LVS 均衡 ceph radosgw 负载
|
||||||
```
|
```
|
||||||
virtual_server 10.1.1.100 7480 {
|
virtual_server 10.1.1.100 7480 {
|
||||||
@ -182,36 +179,12 @@ categories: ["ha/lb"]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
- 在全部 mysql 和 ceph-radosgw 服务器上配置虚拟 ip
|
|
||||||
```bash
|
|
||||||
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
|
|
||||||
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
|
|
||||||
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
|
|
||||||
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
|
|
||||||
ip addr add 10.1.1.100/32 brd 10.1.1.100 dev lo
|
|
||||||
ip route add 10.1.1.100 dev lo
|
|
||||||
```
|
|
||||||
|
|
||||||
## 不抢占自动切换两台 Redis 主从状态
|
## 不抢占自动切换两台 Redis 主从状态
|
||||||
- 环境
|
|
||||||
- Redis 服务器
|
|
||||||
- redis101: 10.1.1.101
|
|
||||||
- redis102: 10.1.1.102
|
|
||||||
- 虚拟地址
|
|
||||||
- ip: 10.1.1.100
|
|
||||||
- 在全部 redis 服务器上安装 keepalived
|
|
||||||
```bash
|
|
||||||
yum install keepalived
|
|
||||||
```
|
|
||||||
- 在全部 redis 服务器上配置 redis 和 keepalived 自启动
|
|
||||||
```bash
|
|
||||||
systemctl enable redis
|
|
||||||
systemctl enable keepalived
|
|
||||||
```
|
|
||||||
- MASTER/BACKUP 完整配置
|
- MASTER/BACKUP 完整配置
|
||||||
```
|
```
|
||||||
global_defs {
|
global_defs {
|
||||||
router_id redis101 #BACKUP 这里是 redis102
|
router_id ka101 #BACKUP 这里是 ka102
|
||||||
script_user root
|
script_user root
|
||||||
enable_script_security
|
enable_script_security
|
||||||
}
|
}
|
||||||
@ -243,6 +216,7 @@ categories: ["ha/lb"]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- 在全部 redis 服务器上创建 /etc/keepalived/scripts/master.sh 脚本,内容如下
|
- 在全部 redis 服务器上创建 /etc/keepalived/scripts/master.sh 脚本,内容如下
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
@ -250,7 +224,8 @@ categories: ["ha/lb"]
|
|||||||
/usr/bin/sed -i '/^slaveof/d' /etc/redis.conf
|
/usr/bin/sed -i '/^slaveof/d' /etc/redis.conf
|
||||||
/usr/bin/systemctl restart redis
|
/usr/bin/systemctl restart redis
|
||||||
```
|
```
|
||||||
- 在 redis101 上创建 /etc/keepalived/scripts/backup.sh 脚本,内容如下
|
|
||||||
|
- 在 ka101 上创建 /etc/keepalived/scripts/backup.sh 脚本,内容如下
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
@ -258,7 +233,8 @@ categories: ["ha/lb"]
|
|||||||
echo 'slaveof 10.1.1.102 6379' >> /etc/redis.conf
|
echo 'slaveof 10.1.1.102 6379' >> /etc/redis.conf
|
||||||
/usr/bin/systemctl restart redis
|
/usr/bin/systemctl restart redis
|
||||||
```
|
```
|
||||||
- 在 redis102 上创建 /etc/keepalived/scripts/backup.sh 脚本,内容如下
|
|
||||||
|
- 在 ka102 上创建 /etc/keepalived/scripts/backup.sh 脚本,内容如下
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
@ -266,10 +242,12 @@ categories: ["ha/lb"]
|
|||||||
echo 'slaveof 10.1.1.101 6379' >> /etc/redis.conf
|
echo 'slaveof 10.1.1.101 6379' >> /etc/redis.conf
|
||||||
/usr/bin/systemctl restart redis
|
/usr/bin/systemctl restart redis
|
||||||
```
|
```
|
||||||
|
|
||||||
- 在全部 redis 服务器上赋予脚本可执行权限
|
- 在全部 redis 服务器上赋予脚本可执行权限
|
||||||
```bash
|
```bash
|
||||||
chmod 0755 /etc/keepalived/scripts/*.sh
|
chmod 0755 /etc/keepalived/scripts/*.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
- 修改 redis 配置
|
- 修改 redis 配置
|
||||||
```
|
```
|
||||||
requirepass redis_password
|
requirepass redis_password
|
||||||
@ -277,9 +255,4 @@ categories: ["ha/lb"]
|
|||||||
maxmemory 4294967296
|
maxmemory 4294967296
|
||||||
maxmemory-policy volatile-lru
|
maxmemory-policy volatile-lru
|
||||||
```
|
```
|
||||||
- 在全部 redis 服务器上启动 redis 和 keepalived 服务
|
|
||||||
```bash
|
|
||||||
systemctl start redis
|
|
||||||
systemctl start keepalived
|
|
||||||
```
|
|
||||||
|
|
||||||
|
@ -1,208 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Kickstart 安装 CentOS7"
|
|
||||||
date: 2019-10-29T21:00:25+08:00
|
|
||||||
lastmod: 2019-10-29T21:00:25+08:00
|
|
||||||
keywords: []
|
|
||||||
tags: ["kickstart", "centos"]
|
|
||||||
categories: ["os"]
|
|
||||||
---
|
|
||||||
|
|
||||||
## 环境
|
|
||||||
- CentOS7.6
|
|
||||||
- genisoimage 1.1.11
|
|
||||||
- CentOS-7-x86_64-Minimal-1810.iso
|
|
||||||
|
|
||||||
## 复制 iso 内容到本地磁盘
|
|
||||||
```bash
|
|
||||||
mount -o loop CentOS-7-x86_64-Minimal-1810.iso /mnt/
|
|
||||||
mkdir -p /home/iso/centos7
|
|
||||||
cd /mnt && cp -af * .* /home/iso/centos7/
|
|
||||||
```
|
|
||||||
|
|
||||||
## 创建 isolinux/ks.cfg
|
|
||||||
- mbr 启动,/home/iso/centos7/isolinux/ks.cfg 内容如下
|
|
||||||
```
|
|
||||||
# Install OS instead of upgrade
|
|
||||||
install
|
|
||||||
# Reboot after installation
|
|
||||||
reboot
|
|
||||||
# System authorization information
|
|
||||||
auth --enableshadow --passalgo=sha512
|
|
||||||
# Use CDROM installation media
|
|
||||||
cdrom
|
|
||||||
# Use graphical install
|
|
||||||
graphical
|
|
||||||
# Run the Setup Agent on first boot
|
|
||||||
firstboot --enable
|
|
||||||
ignoredisk --only-use=sda
|
|
||||||
# Keyboard layouts
|
|
||||||
keyboard --vckeymap=cn --xlayouts='cn'
|
|
||||||
# System language
|
|
||||||
lang zh_CN.UTF-8
|
|
||||||
# Firewall configuration
|
|
||||||
firewall --disabled
|
|
||||||
# SELinux configuration
|
|
||||||
selinux --disabled
|
|
||||||
|
|
||||||
# Network information
|
|
||||||
#network --bootproto=dhcp --device=eth0 --onboot=off --ipv6=auto --no-activate
|
|
||||||
#network --hostname=localhost.localdomain
|
|
||||||
|
|
||||||
# Root password(111111)
|
|
||||||
rootpw --iscrypted $6$kD.hMvv5nCY8a/SM$Gnmb4zspkuyL75BP2Gj.1SGUaWBugXkd/zMFhoDndp9CSi8VP7R5JP7rfWzL4y7fy8crH3ryDT4PFkKCc7/xM.
|
|
||||||
# System services
|
|
||||||
services --enabled="chronyd"
|
|
||||||
# System timezone
|
|
||||||
timezone Asia/Shanghai --isUtc
|
|
||||||
# Clear the Master Boot Record
|
|
||||||
zerombr
|
|
||||||
# System bootloader configuration
|
|
||||||
bootloader --location=mbr --boot-drive=sda
|
|
||||||
# Partition clearing information
|
|
||||||
clearpart --none --initlabel
|
|
||||||
# Disk partitioning information
|
|
||||||
part /boot --fstype="xfs" --ondisk=sda --size=512
|
|
||||||
part / --fstype="xfs" --ondisk=sda --grow --size=1
|
|
||||||
|
|
||||||
%packages
|
|
||||||
@^minimal
|
|
||||||
@core
|
|
||||||
chrony
|
|
||||||
|
|
||||||
%end
|
|
||||||
|
|
||||||
%post
|
|
||||||
lsblk > /root/lsblk
|
|
||||||
%end
|
|
||||||
|
|
||||||
%addon com_redhat_kdump --disable --reserve-mb='auto'
|
|
||||||
|
|
||||||
%end
|
|
||||||
|
|
||||||
%anaconda
|
|
||||||
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
|
|
||||||
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
|
|
||||||
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
|
|
||||||
%end
|
|
||||||
```
|
|
||||||
- efi 启动,/home/iso/centos7/isolinux/ks.cfg 内容如下
|
|
||||||
```
|
|
||||||
# Install OS instead of upgrade
|
|
||||||
install
|
|
||||||
# Reboot after installation
|
|
||||||
reboot
|
|
||||||
# System authorization information
|
|
||||||
auth --enableshadow --passalgo=sha512
|
|
||||||
# Use CDROM installation media
|
|
||||||
cdrom
|
|
||||||
# Use graphical install
|
|
||||||
graphical
|
|
||||||
# Run the Setup Agent on first boot
|
|
||||||
firstboot --enable
|
|
||||||
ignoredisk --only-use=sda
|
|
||||||
# Keyboard layouts
|
|
||||||
keyboard --vckeymap=cn --xlayouts='cn'
|
|
||||||
# System language
|
|
||||||
lang zh_CN.UTF-8
|
|
||||||
# Firewall configuration
|
|
||||||
firewall --disabled
|
|
||||||
# SELinux configuration
|
|
||||||
selinux --disabled
|
|
||||||
|
|
||||||
# Network information
|
|
||||||
#network --bootproto=dhcp --device=eth0 --onboot=off --ipv6=auto --no-activate
|
|
||||||
#network --hostname=localhost.localdomain
|
|
||||||
|
|
||||||
# Root password(111111)
|
|
||||||
rootpw --iscrypted $6$kD.hMvv5nCY8a/SM$Gnmb4zspkuyL75BP2Gj.1SGUaWBugXkd/zMFhoDndp9CSi8VP7R5JP7rfWzL4y7fy8crH3ryDT4PFkKCc7/xM.
|
|
||||||
# System services
|
|
||||||
services --enabled="chronyd"
|
|
||||||
# System timezone
|
|
||||||
timezone Asia/Shanghai --isUtc
|
|
||||||
# Clear the Master Boot Record
|
|
||||||
zerombr
|
|
||||||
# System bootloader configuration
|
|
||||||
bootloader --location=mbr --boot-drive=sda
|
|
||||||
# Partition clearing information
|
|
||||||
clearpart --none --initlabel
|
|
||||||
# Disk partitioning information
|
|
||||||
part /boot --fstype="xfs" --ondisk=sda --size=512
|
|
||||||
part /boot/efi --fstype="xfs" --ondisk=sda --size=512
|
|
||||||
part / --fstype="xfs" --ondisk=sda --grow --size=1
|
|
||||||
|
|
||||||
%packages
|
|
||||||
@^minimal
|
|
||||||
@core
|
|
||||||
chrony
|
|
||||||
|
|
||||||
%end
|
|
||||||
|
|
||||||
%post
|
|
||||||
%end
|
|
||||||
|
|
||||||
%addon com_redhat_kdump --disable --reserve-mb='auto'
|
|
||||||
|
|
||||||
%end
|
|
||||||
|
|
||||||
%anaconda
|
|
||||||
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
|
|
||||||
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
|
|
||||||
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
|
|
||||||
%end
|
|
||||||
```
|
|
||||||
|
|
||||||
## 修改启动项文件
|
|
||||||
- mbr 启动,只需修改 isolinux/isolinux.cfg
|
|
||||||
- 删除 "label check" 下的 "menu default" 一行
|
|
||||||
- 在 "label linux" 一行上方添加如下内容
|
|
||||||
```
|
|
||||||
label auto
|
|
||||||
menu label ^Auto install CentOS 7
|
|
||||||
menu default
|
|
||||||
kernel vmlinuz
|
|
||||||
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS7 inst.ks=cdrom:/isolinux/ks.cfg quiet
|
|
||||||
```
|
|
||||||
- efi 启动,只需修改 EFI/BOOT/grub.cfg
|
|
||||||
- 修改第一行
|
|
||||||
```
|
|
||||||
set default="0"
|
|
||||||
```
|
|
||||||
- 在 "### BEGIN /etc/grub.d/10_linux ###" 一行下添加如下内容
|
|
||||||
```
|
|
||||||
menuentry 'Auto Install CentOS 7' --class fedora --class gnu-linux --class gnu --class os {
|
|
||||||
linuxefi /images/pxeboot/vmlinuz inst.ks=cdrom:/isolinux/ks.cfg inst.stage2=hd:LABEL=CentOS7 quiet
|
|
||||||
initrdefi /images/pxeboot/initrd.img
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 生成 ISO 镜像
|
|
||||||
- mbr 启动,执行如下命令
|
|
||||||
```bash
|
|
||||||
genisoimage -v -R -J -T -V CentOS7 \
|
|
||||||
-b isolinux/isolinux.bin \
|
|
||||||
-c isolinux/boot.cat \
|
|
||||||
-cache-inodes \
|
|
||||||
-joliet-long \
|
|
||||||
-no-emul-boot \
|
|
||||||
-boot-load-size 4 \
|
|
||||||
-boot-info-table \
|
|
||||||
-o /home/centos7.iso \
|
|
||||||
/home/iso/centos7
|
|
||||||
```
|
|
||||||
- efi 启动,执行如下命令
|
|
||||||
```bash
|
|
||||||
genisoimage -v -R -J -T -V CentOS7 \
|
|
||||||
-b images/efiboot.img \
|
|
||||||
-c isolinux/boot.cat \
|
|
||||||
-cache-inodes \
|
|
||||||
-joliet-long \
|
|
||||||
-no-emul-boot \
|
|
||||||
-boot-load-size 4 \
|
|
||||||
-boot-info-table \
|
|
||||||
-o /home/centos7-efi.iso \
|
|
||||||
/home/iso/centos7
|
|
||||||
```
|
|
||||||
|
|
||||||
## 参考
|
|
||||||
- [https://boke.wsfnk.com/archives/382.html](https://boke.wsfnk.com/archives/382.html)
|
|
||||||
|
|
@ -7,7 +7,8 @@ tags: ["letsencrypt", "certbot", "ssl"]
|
|||||||
categories: ["web"]
|
categories: ["web"]
|
||||||
---
|
---
|
||||||
|
|
||||||
## 安装 certbot
|
## 直接部署(不推荐)
|
||||||
|
### 安装 certbot
|
||||||
- 在 alpine linux 中安装 certbot
|
- 在 alpine linux 中安装 certbot
|
||||||
```bash
|
```bash
|
||||||
apk add --no-cache certbot openssl
|
apk add --no-cache certbot openssl
|
||||||
@ -18,7 +19,7 @@ categories: ["web"]
|
|||||||
certbot register --register-unsafely-without-email --agree-tos
|
certbot register --register-unsafely-without-email --agree-tos
|
||||||
```
|
```
|
||||||
|
|
||||||
## 普通域名证书
|
### 申请常规域名证书
|
||||||
- 申请 ssl 证书,有效期 90 天
|
- 申请 ssl 证书,有效期 90 天
|
||||||
```bash
|
```bash
|
||||||
certbot certonly -n -d x.x.com --standalone
|
certbot certonly -n -d x.x.com --standalone
|
||||||
@ -38,7 +39,7 @@ categories: ["web"]
|
|||||||
openssl dhparam -out /etc/letsencrypt/dhparam.pem 2048
|
openssl dhparam -out /etc/letsencrypt/dhparam.pem 2048
|
||||||
```
|
```
|
||||||
|
|
||||||
## 通配域名证书
|
### 申请通配域名证书
|
||||||
- 申请 ssl 证书,有效期 90 天
|
- 申请 ssl 证书,有效期 90 天
|
||||||
```bash
|
```bash
|
||||||
certbot certonly --manual -d '*.x.com' \
|
certbot certonly --manual -d '*.x.com' \
|
||||||
@ -64,21 +65,113 @@ categories: ["web"]
|
|||||||
openssl dhparam -out /etc/letsencrypt/dhparam.pem 2048
|
openssl dhparam -out /etc/letsencrypt/dhparam.pem 2048
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 容器部署
|
||||||
|
### 申请常规域名证书
|
||||||
|
- 为域名 x1.xx.com 和 x2.xx.com 申请 ssl 证书,创建 /letsencrypt/docker-compose.yml,内容如下
|
||||||
|
```yaml
|
||||||
|
version: "3.7"
|
||||||
|
services:
|
||||||
|
letsencrypt-common:
|
||||||
|
image: harbor.colben.cn/general/letsencrypt:latest
|
||||||
|
container_name: letsencrypt-common
|
||||||
|
restart: "no"
|
||||||
|
stop_grace_period: 4s
|
||||||
|
environment:
|
||||||
|
DOMAINS: x1.xx.com,x2.xx.com
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- type: bind
|
||||||
|
source: ./common/etc
|
||||||
|
target: /etc/letsencrypt
|
||||||
|
- type: bind
|
||||||
|
source: ./common/log
|
||||||
|
target: /var/log/letsencrypt
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建目录
|
||||||
|
```bash
|
||||||
|
mkdir -p /letsencrypt/common/{etc,log}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 手动启动,等待容器停止后,证书申请完成
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建定时任务,在每月的 31 号晚上十一点更新一次
|
||||||
|
```
|
||||||
|
0 23 31 * * docker-compose -f /letsencrypt/docker-compose.yml up letsencrypt-common
|
||||||
|
```
|
||||||
|
|
||||||
|
### 申请通配域名证书
|
||||||
|
- 为域名 \*.xxx.com 和 \*.yyy.com 申请 ssl 证书,创建 /letsencrypt/docker-compose.yml,内容如下
|
||||||
|
```yaml
|
||||||
|
version: "3.7"
|
||||||
|
services:
|
||||||
|
letsencrypt-wildcard:
|
||||||
|
image: harbor.colben.cn/general/letsencrypt
|
||||||
|
container_name: letsencrypt-wildcard
|
||||||
|
restart: "no"
|
||||||
|
stop_grace_period: 1m
|
||||||
|
environment:
|
||||||
|
DOMAINS: "*.xxx.com,*.yyy.com"
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- type: bind
|
||||||
|
source: ./wildcard/etc
|
||||||
|
target: /etc/letsencrypt
|
||||||
|
- type: bind
|
||||||
|
source: ./wildcard/log
|
||||||
|
target: /var/log/letsencrypt
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建目录
|
||||||
|
```bash
|
||||||
|
mkdir -p /letsencrypt/wildcard/{etc,log}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 获取通配域名的证书时,需要设置 TXT 解析记录,这里配合脚本实现自动添加和更新
|
||||||
|
- 调用腾讯云接口设置/更新 TXT 解析记录
|
||||||
|
```bash
|
||||||
|
cp tencent-api.sh /letsencrypt/wildcard/etc/manual-hook.sh
|
||||||
|
# 修改脚本,替换成自己的阿里云 access key 信息
|
||||||
|
#ACCESS_KEY_ID='aliyun access key id'
|
||||||
|
#ACCESS_KEY_SECRET='aliyun access key secret'
|
||||||
|
```
|
||||||
|
|
||||||
|
- 调用阿里云接口设置/更新 TXT 解析记录
|
||||||
|
```bash
|
||||||
|
cp aliyun-api.sh /letsencrypt/wildcard/etc/manual-hook.sh
|
||||||
|
# 修改脚本,替换成自己的腾讯云 secret 信息
|
||||||
|
#SECRET_ID='tencent secret id'
|
||||||
|
#SECRET_KEY='tencent secret key'
|
||||||
|
```
|
||||||
|
|
||||||
|
- 手动启动,等待容器停止后,证书申请完成
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建定时任务,并在每月的 31 号晚上十点更新一次
|
||||||
|
```
|
||||||
|
0 22 31 * * docker-compose -f /letsencrypt/docker-compose.yml up letsencrypt-wildcard
|
||||||
|
```
|
||||||
|
|
||||||
## 使用证书
|
## 使用证书
|
||||||
- nginx 配置 ssl
|
- nginx 配置 ssl
|
||||||
```
|
```
|
||||||
server {
|
server {
|
||||||
listen 443 ssl;
|
listen 443 ssl http2;
|
||||||
server_name x.x.x;
|
server_name x.x.x; # 替换成自己的域名
|
||||||
ssl_certificate /etc/letsencrypt/live/x.x.x/fullchain.pem;
|
ssl_certificate /letsencrypt/xxxx/etc/live/xxxx/fullchain.pem; # 替换实际目录
|
||||||
ssl_certificate_key /etc/letsencrypt/live/x.x.x/privkey.pem;
|
ssl_certificate_key /letsencrypt/xxxx/etc/live/xxxx/privkey.pem; # 替换实际目录
|
||||||
ssl_session_cache shared:le_nginx_SSL:10m;
|
ssl_session_cache shared:le_nginx_SSL:10m;
|
||||||
ssl_session_timeout 1440m;
|
ssl_session_timeout 1440m;
|
||||||
ssl_session_tickets off;
|
ssl_session_tickets off;
|
||||||
ssl_prefer_server_ciphers off;
|
ssl_prefer_server_ciphers off;
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";
|
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";
|
||||||
ssl_dhparam /etc/letsencrypt/dhparam.pem;
|
ssl_dhparam /letsencrypt/xxxx/etc/dhparam.pem; # 替换实际目录
|
||||||
location / {
|
location / {
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,11 @@ categories: ["storage"]
|
|||||||
```
|
```
|
||||||
- 删除 pv(需先踢出 vg)
|
- 删除 pv(需先踢出 vg)
|
||||||
```bash
|
```bash
|
||||||
pvremote /dev/sdb1
|
pvremove /dev/sdb1
|
||||||
|
```
|
||||||
|
- 同步物理卷容量
|
||||||
|
```bash
|
||||||
|
pvresize /dev/sdb1
|
||||||
```
|
```
|
||||||
|
|
||||||
## VG 管理
|
## VG 管理
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: "Minio 笔记"
|
title: "Minio 笔记"
|
||||||
date: 2021-10-17T00:48:00+08:00
|
date: 2021-10-17T00:48:00+08:00
|
||||||
lastmod: 2021-10-17T00:48:00+08:00
|
lastmod: 2024-04-17T20:08:00+08:00
|
||||||
keywords: []
|
keywords: []
|
||||||
tags: ["minio"]
|
tags: ["minio"]
|
||||||
categories: ["storage"]
|
categories: ["storage"]
|
||||||
@ -41,7 +41,8 @@ categories: ["storage"]
|
|||||||
Environment=MINIO_ROOT_USER=XXX
|
Environment=MINIO_ROOT_USER=XXX
|
||||||
Environment=MINIO_ROOT_PASSWORD=XXXXXXXX
|
Environment=MINIO_ROOT_PASSWORD=XXXXXXXX
|
||||||
ExecStart=/usr/local/bin/minio server \
|
ExecStart=/usr/local/bin/minio server \
|
||||||
--console-address ":9001" \
|
--address ":9000" \
|
||||||
|
--console-address ":9010" \
|
||||||
http://X.X.X:9000/minio/{1...4}
|
http://X.X.X:9000/minio/{1...4}
|
||||||
#Restart=on-failure
|
#Restart=on-failure
|
||||||
RestartSec=10s
|
RestartSec=10s
|
||||||
@ -64,38 +65,80 @@ categories: ["storage"]
|
|||||||
|
|
||||||
## 部署多节点分布式存储
|
## 部署多节点分布式存储
|
||||||
### 环境
|
### 环境
|
||||||
自定义域名 | 网卡 IP | 硬盘槽 | 数据分区
|
自定义域名 | 网卡 IP | 数据盘
|
||||||
---- | ---- | ---- | ----
|
---- | ---- | ----
|
||||||
X1.X.X | eth0: 192.168.1.11<br>eth1:10.0.0.11 | 8 个 | /dev/sdb1, /dev/sdc1<br>/dev/sdd1, /dev/sde1
|
X1.X.X | eth0: 192.168.1.11, eth1:10.0.0.11 | /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde
|
||||||
X2.X.X | eth0: 192.168.1.12<br>eth1:10.0.0.12 | 8 个 | /dev/sdb1, /dev/sdc1<br>/dev/sdd1, /dev/sde1
|
X2.X.X | eth0: 192.168.1.12, eth1:10.0.0.12 | /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde
|
||||||
X3.X.X | eth0: 192.168.1.13<br>eth1:10.0.0.13 | 8 个 | /dev/sdb1, /dev/sdc1<br>/dev/sdd1, /dev/sde1
|
X3.X.X | eth0: 192.168.1.13, eth1:10.0.0.13 | /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde
|
||||||
X4.X.X | eth0: 192.168.1.14<br>eth1:10.0.0.14 | 8 个 | /dev/sdb1, /dev/sdc1<br>/dev/sdd1, /dev/sde1
|
X4.X.X | eth0: 192.168.1.14, eth1:10.0.0.14 | /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde
|
||||||
|
|
||||||
- eth0 用于接收 api 请求
|
- eth0 用于接收 api 请求
|
||||||
- eth1 用于集群内部通信
|
- eth1 用于集群内部通信
|
||||||
- 每台服务器有 8 个硬盘槽,这里先各用 4 个组成 server pool,运行 minio 集群
|
- 操作系统:RockyLinux 9.3
|
||||||
- 每台服务器剩下的 4 个硬盘槽用于后面的扩容操作
|
|
||||||
|
|
||||||
### 挂载数据分区
|
### 挂载数据盘
|
||||||
- 在全部服务器上执行如下操作
|
- 在全部服务器上执行如下操作
|
||||||
- 挂载硬盘
|
- 格式化硬盘,设置卷标
|
||||||
```bash
|
```bash
|
||||||
mkdir -p /mnt/minio{1,2,3,4}
|
mkfs.xfs -f /dev/sdb -L MINIO1
|
||||||
mount /dev/sdb1 /mnt/minio1
|
mkfs.xfs -f /dev/sdc -L MINIO2
|
||||||
mount /dev/sdc1 /mnt/minio2
|
mkfs.xfs -f /dev/sdd -L MINIO3
|
||||||
mount /dev/sdd1 /mnt/minio3
|
mkfs.xfs -f /dev/sde -L MINIO4
|
||||||
mount /dev/sde1 /mnt/minio4
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- 建议在 fstab 中配置开机自动挂载
|
- 在 /etc/fstab 中增加挂载配置
|
||||||
|
```
|
||||||
|
LABEL=MINIO1 /mnt/minio1 xfs defaults,noatime 0 2
|
||||||
|
LABEL=MINIO2 /mnt/minio2 xfs defaults,noatime 0 2
|
||||||
|
LABEL=MINIO3 /mnt/minio3 xfs defaults,noatime 0 2
|
||||||
|
LABEL=MINIO4 /mnt/minio4 xfs defaults,noatime 0 2
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建挂载目录,挂载数据盘
|
||||||
|
```bash
|
||||||
|
systemctl daemon-reload
|
||||||
|
mkdir -p /mnt/minio{1,2,3,4}
|
||||||
|
mount -a
|
||||||
|
```
|
||||||
|
|
||||||
|
- 禁用 xfs 错误重试
|
||||||
|
```bash
|
||||||
|
for i in sdb sdc sdd sde; do
|
||||||
|
echo 0 > /sys/fs/xfs/$i/error/metadata/EIO/max_retries
|
||||||
|
echo 0 > /sys/fs/xfs/$i/error/metadata/ENOSPC/max_retries
|
||||||
|
echo 0 > /sys/fs/xfs/$i/error/metadata/default/max_retries
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
- 为 /etc/rc.d/rc.local 增加可执行权限
|
||||||
|
```bash
|
||||||
|
chmod 0755 /etc/rc.d/rc.local
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编辑 /etc/rc.d/rc.local,增加“禁用 xfs 错误重试”的脚本
|
||||||
|
```bash
|
||||||
|
for i in sdb sdc sdd sde; do
|
||||||
|
echo 0 > /sys/fs/xfs/$i/error/metadata/EIO/max_retries
|
||||||
|
echo 0 > /sys/fs/xfs/$i/error/metadata/ENOSPC/max_retries
|
||||||
|
echo 0 > /sys/fs/xfs/$i/error/metadata/default/max_retries
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
### 安装 minio
|
### 安装 minio
|
||||||
- 在全部服务器上执行如下操作
|
- 在全部服务器上执行如下操作
|
||||||
- 下载
|
- 下载 minio rpm 包,安装
|
||||||
|
```bash
|
||||||
|
curl -L -o minio.rpm https://dl.min.io/server/minio/release/linux-amd64/archive/minio-20240406052602.0.0-1.x86_64.rpm
|
||||||
|
rpm -Uvh minio.rpm
|
||||||
|
groupadd -r minio-user
|
||||||
|
useradd -r -g minio-user minio-user
|
||||||
|
chown minio-user:minio-user /mnt/minio{1..4}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 下载 minio 客户端工具 mc
|
||||||
```bash
|
```bash
|
||||||
curl -L -o /usr/local/bin/minio https://dl.min.io/server/minio/release/linux-amd64/minio
|
|
||||||
curl -L -o /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc
|
curl -L -o /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc
|
||||||
chmod 0755 /usr/local/bin/{minio,mc}
|
chmod 0755 /usr/local/bin/mc
|
||||||
```
|
```
|
||||||
|
|
||||||
- 修改 hosts,增加自定义域名解析,**注意这里是集群通信,要用 eth1 网卡 ip**
|
- 修改 hosts,增加自定义域名解析,**注意这里是集群通信,要用 eth1 网卡 ip**
|
||||||
@ -106,105 +149,41 @@ X4.X.X | eth0: 192.168.1.14<br>eth1:10.0.0.14 | 8 个 | /dev/sdb1, /dev/sd
|
|||||||
10.0.0.14 X4.X.X
|
10.0.0.14 X4.X.X
|
||||||
```
|
```
|
||||||
|
|
||||||
- 创建 /etc/systemd/system/minio.service,内容如下
|
- 创建 /etc/default/minio,内容如下
|
||||||
```ini
|
```ini
|
||||||
[Unit]
|
MINIO_VOLUMES="http://X{1...4}:9000/mnt/minio{1...4}"
|
||||||
Description=MinIO
|
MINIO_OPTS="--console-address :9001"
|
||||||
After=network.service
|
MINIO_ROOT_USER=minio-admin
|
||||||
Wants=network.service
|
MINIO_ROOT_PASSWORD=1234567890
|
||||||
|
|
||||||
[Service]
|
|
||||||
Environment=MINIO_ROOT_USER=XXX
|
|
||||||
Environment=MINIO_ROOT_PASSWORD=XXXXXXXX
|
|
||||||
ExecStart=/usr/local/bin/minio server \
|
|
||||||
--console-address ":9001" \
|
|
||||||
http://X{1...4}.X.X:9000/mnt/minio{1...4}
|
|
||||||
#Restart=on-failure
|
|
||||||
RestartSec=10s
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 启动 minio
|
### 启动 minio
|
||||||
- 在全部服务器上执行如下操作
|
- 在全部服务器上执行如下操作
|
||||||
- 配置开机自动启动
|
- 启动 minio,并配置开机自动启动
|
||||||
```bash
|
```bash
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable minio
|
|
||||||
```
|
|
||||||
|
|
||||||
- 启动 minio
|
|
||||||
```bash
|
|
||||||
systemctl start monio
|
systemctl start monio
|
||||||
```
|
systemctl enable minio
|
||||||
|
|
||||||
## 扩容多节点分布式存储
|
|
||||||
### 加装硬盘
|
|
||||||
- 在全部服务器上执行如下操作
|
|
||||||
- 在每台服务器上个增加四个新硬盘,每个硬盘创建一个分区,格式化
|
|
||||||
- 挂载新增的硬盘分区
|
|
||||||
```bash
|
|
||||||
mkdir -p /mnt/minio{5,6,7,8}
|
|
||||||
mount /dev/sdf1 /mnt/minio5
|
|
||||||
mount /dev/sdg1 /mnt/minio6
|
|
||||||
mount /dev/sdh1 /mnt/minio7
|
|
||||||
mount /dev/sdi1 /mnt/minio8
|
|
||||||
```
|
|
||||||
|
|
||||||
- 建议在 fstab 中配置开机自动挂载
|
|
||||||
|
|
||||||
### 扩容
|
|
||||||
- 在全部服务器上执行如下操作
|
|
||||||
- 停止 minio 服务
|
|
||||||
```bash
|
|
||||||
systemctl stop minio
|
|
||||||
```
|
|
||||||
|
|
||||||
- 修改 /etc/systemd/system/minio.service,增加新的 server pool,内容如下
|
|
||||||
```ini
|
|
||||||
[Unit]
|
|
||||||
Description=MinIO
|
|
||||||
After=network.service
|
|
||||||
Wants=network.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Environment=MINIO_ROOT_USER=XXX
|
|
||||||
Environment=MINIO_ROOT_PASSWORD=XXXXXXXX
|
|
||||||
ExecStart=/usr/local/bin/minio server \
|
|
||||||
--console-address ":9001" \
|
|
||||||
http://X{1...4}.X.X:9000/mnt/minio{1...4} \
|
|
||||||
http://X{1...4}.X.X:9000/mnt/minio{5...8}
|
|
||||||
#Restart=on-failure
|
|
||||||
RestartSec=10s
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
- 启动 minio 服务
|
|
||||||
```bash
|
|
||||||
systemctl start minio
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 客户端常用操作
|
## 客户端常用操作
|
||||||
- 创建 alias,**注意这里是 api 调用,要用 eth0 网卡 ip**
|
- 创建 alias,**注意这里是 api 调用,要用 eth0 网卡 ip**
|
||||||
```bash
|
```bash
|
||||||
mc alias set XXX http://192.168.1.X:9000 XXX XXXXXXXX
|
mc alias set $ALIAS_NAME http://192.168.1.X:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD
|
||||||
```
|
```
|
||||||
|
|
||||||
- 创建 bucket
|
- 创建 bucket
|
||||||
```bash
|
```bash
|
||||||
mc mb XXX/XXX
|
mc mb $ALIAS_NAME $BUCKET_NAME/$SUB_DIR
|
||||||
```
|
```
|
||||||
|
|
||||||
- 创建用户
|
- 创建用户
|
||||||
```bash
|
```bash
|
||||||
mc admin user add XXX XXXXXXXX
|
mc admin user add $ALIAS_NAME $NEW_USER_NAME $NEW_PASSWORD
|
||||||
```
|
```
|
||||||
|
|
||||||
- 给新增用户授权
|
- 给新增用户授权
|
||||||
```bash
|
```bash
|
||||||
mc admin policy set XXX readwrite user=XXX
|
mc admin policy attach $ALIAS_NAME/$BUCKET_NAME/$SUB_DIR readwrite --user $NEW_USER_NAME
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: "安装 MySQL"
|
title: "安装 MySQL"
|
||||||
date: 2019-10-30T13:00:28+08:00
|
date: 2019-10-30T13:00:37+08:00
|
||||||
lastmod: 2022-03-28T20:00:00+08:00
|
lastmod: 2024-07-05T20:36:00+08:00
|
||||||
tags: ["centos", "yum", "mysql"]
|
tags: ["centos", "yum", "mysql"]
|
||||||
categories: ["database"]
|
categories: ["database"]
|
||||||
---
|
---
|
||||||
@ -52,10 +52,89 @@ categories: ["database"]
|
|||||||
# 输入查找到的密码
|
# 输入查找到的密码
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 安装 MySQL5.7 通用二进制包
|
||||||
|
### 环境
|
||||||
|
- CentOS 7.9 x86_64 最小安装
|
||||||
|
- MySQL 5.7.44
|
||||||
|
- 普通用户 mortal
|
||||||
|
|
||||||
|
### 安装 mysql
|
||||||
|
- 下载 MySQL5.7.44 通用二进制包
|
||||||
|
```bash
|
||||||
|
curl -LO https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
- 解压
|
||||||
|
```bash
|
||||||
|
tar zxf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
|
||||||
|
mv mysql-5.7.44-linux-glibc2.12-x86_64 /mysql57
|
||||||
|
chown -R root.root /mysql57
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建普通用户 mortal,切换到 mortal 用户下
|
||||||
|
```bash
|
||||||
|
useradd -m mortal
|
||||||
|
echo -e 'mortal hard nofile 5120\nmortal soft nofile 5120\n' \
|
||||||
|
> /etc/security/limits.d/mortal
|
||||||
|
su - mortal
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建实例目录
|
||||||
|
```bash
|
||||||
|
cd ~
|
||||||
|
mkdir -p mysql-6033/{db,log,priv-files}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建配置文件 mysql-6033/my.cnf,内容如下
|
||||||
|
```
|
||||||
|
[mysqld]
|
||||||
|
symbolic-links=0
|
||||||
|
port = 6033
|
||||||
|
basedir = /mysql57
|
||||||
|
datadir = /home/lijc/mysql-6033/db
|
||||||
|
socket = /home/lijc/mysql-6033/sock
|
||||||
|
pid-file = /home/lijc/mysql-6033/pid
|
||||||
|
secure-file-priv = /home/lijc/mysql-6033/priv-files
|
||||||
|
log-timestamps = SYSTEM
|
||||||
|
explicit_defaults_for_timestamp = 1
|
||||||
|
log-error = /home/lijc/mysql-6033/log/error.log
|
||||||
|
slow-query-log = TRUE
|
||||||
|
slow-query-log-file = /home/lijc/mysql-6033/log/slow.log
|
||||||
|
character-set-server = utf8mb4
|
||||||
|
default-storage-engine = innodb
|
||||||
|
lower-case-table-names = 1
|
||||||
|
```
|
||||||
|
|
||||||
|
### 初始化基础数据
|
||||||
|
- 初始化实例的数据目录
|
||||||
|
```bash
|
||||||
|
/mysql57/bin/mysqld \
|
||||||
|
--defaults-file=/home/mortal/mysql-6033/my.cnf \
|
||||||
|
--initialize-insecure
|
||||||
|
```
|
||||||
|
|
||||||
|
### 启动 mysql
|
||||||
|
- 启动实例
|
||||||
|
```bash
|
||||||
|
/mysql57/bin/mysqld --defaults-file=/home/mortal/mysql-6033/my.cnf --daemonize
|
||||||
|
```
|
||||||
|
|
||||||
|
### 设置 root 密码
|
||||||
|
- 设置 mysql root 账户的密码
|
||||||
|
```bash
|
||||||
|
/mysql57/bin/mysqladmin -S /home/mortal/mysql-6033/sock password
|
||||||
|
```
|
||||||
|
|
||||||
|
### 客户端链接
|
||||||
|
- 使用本机客户端登陆 mysql root 账户
|
||||||
|
```bash
|
||||||
|
/mysql57/bin/mysql -S /home/mortal/mysql-6033/mysqld.sock -p
|
||||||
|
```
|
||||||
|
|
||||||
## 安装 MySQL8 通用二进制包
|
## 安装 MySQL8 通用二进制包
|
||||||
### 环境
|
### 环境
|
||||||
- CentOS 7.9 x86_64 最小安装
|
- CentOS 7.9 x86_64 最小安装
|
||||||
- MySQL 8.0.28 多实例
|
- MySQL 8.0.37 多实例
|
||||||
- 普通用户 mortal
|
- 普通用户 mortal
|
||||||
|
|
||||||
### 安装 mysql
|
### 安装 mysql
|
||||||
@ -69,20 +148,20 @@ categories: ["database"]
|
|||||||
```bash
|
```bash
|
||||||
cd ~
|
cd ~
|
||||||
# 这是 debug 版本,软件包很大
|
# 这是 debug 版本,软件包很大
|
||||||
curl -LO https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
|
curl -LO https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.37-linux-glibc2.17-x86_64.tar.xz
|
||||||
# 这是 strip 版本,软件包轻量,推荐
|
# 这是 strip 版本,软件包轻量,推荐
|
||||||
curl -LO https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz
|
curl -LO https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.37-linux-glibc2.17-x86_64-minimal.tar.xz
|
||||||
```
|
```
|
||||||
|
|
||||||
- 解压
|
- 解压
|
||||||
```bash
|
```bash
|
||||||
cd ~
|
cd ~
|
||||||
# debug 版本
|
# debug 版本
|
||||||
tar xf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
|
tar xf mysql-8.0.37-linux-glibc2.12-x86_64.tar.xz
|
||||||
mv mysql-8.0.28-linux-glibc2.12-x86_64 mysql
|
mv mysql-8.0.37-linux-glibc2.12-x86_64 mysql
|
||||||
# strip 版本
|
# strip 版本
|
||||||
tar xf mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz
|
tar xf mysql-8.0.37-linux-glibc2.17-x86_64-minimal.tar.xz
|
||||||
mv mysql-8.0.28-linux-glibc2.17-x86_64-minimal mysql
|
mv mysql-8.0.37-linux-glibc2.17-x86_64-minimal mysql
|
||||||
```
|
```
|
||||||
|
|
||||||
- 创建三个实例的目录
|
- 创建三个实例的目录
|
||||||
|
@ -427,3 +427,26 @@ show global status where Variable_name in
|
|||||||
lines terminated by '\n';
|
lines terminated by '\n';
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## mysql8 配置登录失败 5 次锁定 5 分钟
|
||||||
|
- 安装插件
|
||||||
|
```
|
||||||
|
docker exec -ti mysql mysql -e "
|
||||||
|
install plugin CONNECTION_CONTROL soname 'connection_control.so';
|
||||||
|
install plugin CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS soname 'connection_control.so';
|
||||||
|
"
|
||||||
|
```
|
||||||
|
|
||||||
|
- 查看插件列表
|
||||||
|
```
|
||||||
|
docker exec -ti mysql mysql -e "show plugins"
|
||||||
|
# 此时会看到最后两行时新激活的插件
|
||||||
|
```
|
||||||
|
|
||||||
|
- 修改 my.cnf,增加两行
|
||||||
|
```
|
||||||
|
connection-control-failed-connections-threshold=5
|
||||||
|
connection-control-min-connection-delay=300000
|
||||||
|
```
|
||||||
|
|
||||||
|
- 重启 mysql
|
||||||
|
|
||||||
|
129
content/post/nginx-install.md
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
---
|
||||||
|
title: "Nginx 安装"
|
||||||
|
date: 2023-03-01T18:07:00+08:00
|
||||||
|
lastmod: 2023-03-01T18:07:00+08:00
|
||||||
|
tags: ["nginx"]
|
||||||
|
categories: ["web"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## 环境
|
||||||
|
- 操作系统 CentOS7.9
|
||||||
|
|
||||||
|
## 包管理器直接安装
|
||||||
|
- 创建 yum 源文件 /etc/yum.repos.d/nginx-nju.repo,内容如下
|
||||||
|
```ini
|
||||||
|
echo '[nginx-stable]
|
||||||
|
name=nginx stable repo
|
||||||
|
#baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
|
||||||
|
baseurl=https://mirrors.nju.edu.cn/nginx/rhel/$releasever/$basearch/
|
||||||
|
gpgcheck=0
|
||||||
|
enabled=1
|
||||||
|
gpgkey=https://nginx.org/keys/nginx_signing.key
|
||||||
|
module_hotfixes=true
|
||||||
|
```
|
||||||
|
|
||||||
|
- 安装 nginx
|
||||||
|
```bash
|
||||||
|
yum makecache
|
||||||
|
yum install nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
## 编译安装
|
||||||
|
- 下载 stable 版本的 nginx 源码包,下载地址: [https://nginx.org/en/download.html](https://nginx.org/en/download.html)
|
||||||
|
- 解压源码包,进入源码包根目录下
|
||||||
|
- 检查依赖
|
||||||
|
```bash
|
||||||
|
./configure \
|
||||||
|
--prefix=$HOME/nginx \
|
||||||
|
--with-threads \
|
||||||
|
--with-compat \
|
||||||
|
--with-http_addition_module \
|
||||||
|
--with-http_auth_request_module \
|
||||||
|
--with-http_gunzip_module \
|
||||||
|
--with-http_gzip_static_module \
|
||||||
|
--with-http_random_index_module \
|
||||||
|
--with-http_realip_module \
|
||||||
|
--with-http_secure_link_module \
|
||||||
|
--with-http_slice_module \
|
||||||
|
--with-http_ssl_module \
|
||||||
|
--with-http_stub_status_module \
|
||||||
|
--with-http_sub_module \
|
||||||
|
--with-http_v2_module \
|
||||||
|
--with-stream \
|
||||||
|
--with-stream_realip_module \
|
||||||
|
--with-stream_ssl_module \
|
||||||
|
--with-stream_ssl_preread_module \
|
||||||
|
--with-http_dav_module \
|
||||||
|
--with-http_flv_module \
|
||||||
|
--with-http_mp4_module
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在 centos 7.9 容器中编译时需要安装如下几个包
|
||||||
|
```
|
||||||
|
gcc
|
||||||
|
make
|
||||||
|
openssl-devel
|
||||||
|
pcre-devel
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编译安装
|
||||||
|
```bash
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 清空 nginx 配置文件($HOME/nginx/conf/nginx.conf),替换内容如下
|
||||||
|
```
|
||||||
|
#user nobody;
|
||||||
|
worker_processes auto;
|
||||||
|
error_log logs/error.log;
|
||||||
|
pid logs/nginx.pid;
|
||||||
|
worker_rlimit_nofile 65535;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 8192;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
default_type application/octet-stream;
|
||||||
|
log_format main '$remote_addr [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
access_log logs/access.log main;
|
||||||
|
gzip on;
|
||||||
|
sendfile on;
|
||||||
|
#tcp_nopush on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
include mime.types;
|
||||||
|
include http.d/*.conf;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream {
|
||||||
|
log_format main '$remote_addr [$time_local] '
|
||||||
|
'$protocol $status $bytes_sent $bytes_received '
|
||||||
|
'$session_time "$upstream_addr" "$upstream_bytes_sent" '
|
||||||
|
'"$upstream_bytes_received" "$upstream_connect_time"';
|
||||||
|
access_log logs/stream.log main;
|
||||||
|
include stream.d/*.conf;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建 nginx 配置子目录,清空 html 目录
|
||||||
|
```bash
|
||||||
|
mkdir -p $HOME/nginx/conf/{http.d,stream.d}
|
||||||
|
rm -f $HOME/nginx/html/*
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建一个简单的 80 端口配置文件($HOME/nginx/conf/http.d/80.conf),内容如下
|
||||||
|
```
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
return 200 "Test nginx 80\n";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 启动 nginx
|
||||||
|
```bash
|
||||||
|
$HOME/nginx/sbin/nginx
|
||||||
|
```
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: "Nginx 笔记"
|
title: "Nginx 笔记"
|
||||||
date: 2019-10-30T11:47:55+08:00
|
date: 2019-10-30T11:47:55+08:00
|
||||||
lastmod: 2019-10-30T11:47:55+08:00
|
lastmod: 2024-11-28T13:22:00+08:00
|
||||||
tags: ["nginx", "https", "ssl", "反向代理"]
|
tags: ["nginx", "https", "ssl", "反向代理"]
|
||||||
categories: ["web"]
|
categories: ["web"]
|
||||||
---
|
---
|
||||||
@ -31,13 +31,65 @@ categories: ["web"]
|
|||||||
- $request_uri 包含请求参数的原始URI,不包含主机名,如"/foo/bar.php?arg=baz"
|
- $request_uri 包含请求参数的原始URI,不包含主机名,如"/foo/bar.php?arg=baz"
|
||||||
- $document_uri $uri 不带请求参数的当前URI,不包含主机名,如"/foo/bar.html"
|
- $document_uri $uri 不带请求参数的当前URI,不包含主机名,如"/foo/bar.html"
|
||||||
|
|
||||||
|
## map
|
||||||
|
- 语法
|
||||||
|
```
|
||||||
|
map 源变量 自定义变量 {
|
||||||
|
hostnames; # 可以使用通配来匹配源变量
|
||||||
|
default 0; # 如果都不匹配,自定义变量的值是 0
|
||||||
|
源变量匹配字符串1 自定义变量值1;
|
||||||
|
源变量匹配字符串2 自定义变量值2;
|
||||||
|
...
|
||||||
|
源变量匹配字符串n 自定义变量值n;
|
||||||
|
include filename; # 包含“源变量匹配字符串”和“自定义变量值”对应关系的文件
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 位置:http
|
||||||
|
- 匹配优先级,由高到低
|
||||||
|
* 常量
|
||||||
|
* 固定后缀的通配,示例如下
|
||||||
|
```
|
||||||
|
*.aa.com 1;
|
||||||
|
*.bb.cn 2;
|
||||||
|
```
|
||||||
|
|
||||||
|
* 固定前缀的通配,示例如下
|
||||||
|
```
|
||||||
|
aa.bb.*
|
||||||
|
cc.*
|
||||||
|
```
|
||||||
|
|
||||||
|
* 正则,必须以“~”或“~\*”开头,优先匹配第一个,可以包含命名捕获和位置捕获,示例如下
|
||||||
|
```
|
||||||
|
~^ab.cd$ # “~”开头,大小写敏感
|
||||||
|
~*ab.cd$ # “~*”开头,大小写不敏感
|
||||||
|
~^ab(?<name>.*)cd$ # 包含命名捕获
|
||||||
|
~^ab(/.*) # 包含位置捕获
|
||||||
|
```
|
||||||
|
|
||||||
## rewrite
|
## rewrite
|
||||||
- rewrite {url正则} {replacement} {flag};
|
- rewrite {url正则} {replacement} {last|break|redirect|permanent};
|
||||||
- flag
|
|
||||||
- last 完成 rewrite,重新开始匹配
|
### location {} 外
|
||||||
- break 重写后不再匹配后续 rewrite
|
- break 和 last 一样,只终止后续 server 级别的 rewrite
|
||||||
- redirect 返回 302 临时重定向
|
|
||||||
- permanent 返回 301 永久重定向
|
### location {} 内
|
||||||
|
- last
|
||||||
|
- 屏蔽当前 location {} 内的 root 和 proxy_pass
|
||||||
|
- 终止当前 location {} 内后续的 rewrite
|
||||||
|
- 尝试匹配其他 location {}
|
||||||
|
- 尝试执行 server 级别的 root
|
||||||
|
|
||||||
|
- break
|
||||||
|
- 终止当前 location {} 内后续的 rewrite
|
||||||
|
- 尝试执行当前 location {} 内的 proxy_pass
|
||||||
|
- 尝试执行当前 location {} 内的 root
|
||||||
|
- 尝试执行 server 级别的 root
|
||||||
|
|
||||||
|
### 重新发起请求
|
||||||
|
- redirect 返回 302 临时重定向
|
||||||
|
- permanent 返回 301 永久重定向
|
||||||
|
|
||||||
## if
|
## if
|
||||||
- if(condition){...}
|
- if(condition){...}
|
||||||
@ -58,9 +110,52 @@ categories: ["web"]
|
|||||||
- / 通用匹配,可匹配任何请求,匹配后继续向下搜索
|
- / 通用匹配,可匹配任何请求,匹配后继续向下搜索
|
||||||
|
|
||||||
## try_files
|
## try_files
|
||||||
- try_files {file} ... {uri}
|
- 未找到这四个文件时,跳转到 url:/a/b/c
|
||||||
- try_files {file} ... ={code}
|
```
|
||||||
- try_files {file} ... {location_name}
|
try_files file1 file2 file3 file4 /a/b/c;
|
||||||
|
```
|
||||||
|
|
||||||
|
- 未找到文件或目录时返回 403
|
||||||
|
```
|
||||||
|
try_files file1 dir2/ =403;
|
||||||
|
```
|
||||||
|
|
||||||
|
- 直接跳转到 location @app
|
||||||
|
```
|
||||||
|
try_files _ @app;
|
||||||
|
```
|
||||||
|
|
||||||
|
## error_page
|
||||||
|
- 语法
|
||||||
|
```
|
||||||
|
error_page code ... [=[response]] uri;
|
||||||
|
# code 只能是 4xx 或 5xx
|
||||||
|
# uri 可以包含变量,内部重定向请求,方法是 GET
|
||||||
|
```
|
||||||
|
|
||||||
|
- 位置: http, server, location, if in location
|
||||||
|
- 5xx 重定向到 /fk.html
|
||||||
|
```
|
||||||
|
error_page 500 502 503 504 /fk.html;
|
||||||
|
```
|
||||||
|
|
||||||
|
- 指定响应码
|
||||||
|
```
|
||||||
|
error_page 404 =200 /fk.html;
|
||||||
|
# 404 重定向到 /fk.html,返回 200
|
||||||
|
|
||||||
|
error_page 401 = /proxy/api;
|
||||||
|
# 401 重定向到一个反代 location,返回反代接口的响应码
|
||||||
|
```
|
||||||
|
|
||||||
|
- url 重定向
|
||||||
|
```
|
||||||
|
error_page 403 http://another-site/a/b/c;
|
||||||
|
# 403 重定向到 302,返回 url
|
||||||
|
|
||||||
|
error_page 403 =301 http://another-site/a/b/c;
|
||||||
|
# 403 重定向到 301,返回 url
|
||||||
|
```
|
||||||
|
|
||||||
## 客户端访问控制
|
## 客户端访问控制
|
||||||
- deny all 拒绝全部访问
|
- deny all 拒绝全部访问
|
||||||
@ -75,7 +170,6 @@ categories: ["web"]
|
|||||||
location / {
|
location / {
|
||||||
root /var/www/html/;
|
root /var/www/html/;
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
try_files $uri $uri/ /index.html =404;
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -97,6 +191,15 @@ location ^~ /share/ {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 禁止浏览器缓存
|
||||||
|
```nginx
|
||||||
|
loaction ^~ /xxxxweb/ {
|
||||||
|
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
|
||||||
|
expires off;
|
||||||
|
etag off;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 反向代理负载均衡
|
## 反向代理负载均衡
|
||||||
- /etc/nginx/conf.d/upstream.conf
|
- /etc/nginx/conf.d/upstream.conf
|
||||||
```nginx
|
```nginx
|
||||||
@ -115,21 +218,35 @@ location ^~ /share/ {
|
|||||||
listen 80;
|
listen 80;
|
||||||
server_name _;
|
server_name _;
|
||||||
location ^~ /webapp/ {
|
location ^~ /webapp/ {
|
||||||
proxy_pass http://tomcat;
|
proxy_pass http://tomcat;
|
||||||
proxy_set_header Host $host:$server_port;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
## 增加/修改请求头
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
#proxy_set_header Host $host:$server_port;
|
||||||
#proxy_set_header X-Forwarded-Host $host;
|
#proxy_set_header X-Real-IP $remote_addr;
|
||||||
#proxy_set_header X-Forwarded-Server $host;
|
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
client_max_body_size 8m;
|
#proxy_set_header X-Forwarded-Host $host;
|
||||||
client_body_buffer_size 8m;
|
#proxy_set_header X-Forwarded-Server $host;
|
||||||
proxy_connect_timeout 2s;
|
|
||||||
#proxy_send_timeout 16;
|
## 设置请求体上限
|
||||||
#proxy_read_timeout 16;
|
#client_max_body_size 8m;
|
||||||
proxy_buffer_size 64k;
|
#client_body_buffer_size 8m;
|
||||||
proxy_buffers 4 64k;
|
|
||||||
proxy_busy_buffers_size 128k;
|
## 设置连接超时、发送请求超时和读取响应超时
|
||||||
|
#proxy_connect_timeout 2s;
|
||||||
|
#proxy_send_timeout 16;
|
||||||
|
#proxy_read_timeout 16;
|
||||||
|
|
||||||
|
## 设置响应缓存大小
|
||||||
|
#proxy_buffer_size 64k;
|
||||||
|
#proxy_buffers 4 64k;
|
||||||
|
#proxy_busy_buffers_size 128k;
|
||||||
#proxy_max_temp_file_size 0;
|
#proxy_max_temp_file_size 0;
|
||||||
|
|
||||||
|
## 禁用相应缓存
|
||||||
|
#proxy_cache off;
|
||||||
|
#proxy_buffering off;
|
||||||
|
|
||||||
|
## 跨域
|
||||||
#add_header 'Access-Control-Allow-Origin' *;
|
#add_header 'Access-Control-Allow-Origin' *;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +277,7 @@ location /websocket/ {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 创建 ssl 密钥
|
## 自签 ssl 证书
|
||||||
```bash
|
```bash
|
||||||
mkdir /etc/nginx/ssl && cd /etc/nginx/ssl
|
mkdir /etc/nginx/ssl && cd /etc/nginx/ssl
|
||||||
openssl genrsa -out ssl.key 2048
|
openssl genrsa -out ssl.key 2048
|
||||||
@ -180,6 +297,8 @@ server {
|
|||||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
|
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
|
||||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers on;
|
||||||
|
default_type text/plain;
|
||||||
|
return 200 "OK.\n";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -229,6 +348,8 @@ server {
|
|||||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
|
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
|
||||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers on;
|
||||||
|
default_type text/plain;
|
||||||
|
return 200 "OK.\n";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
183
content/post/openssh-upgrade.md
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
---
|
||||||
|
title: "OpenSSH 升级"
|
||||||
|
date: 2024-07-02T19:00:00+08:00
|
||||||
|
lastmod: 2024-07-02T19:00:00+08:00
|
||||||
|
keywords: []
|
||||||
|
tags: ["openssh", "ssh"]
|
||||||
|
categories: ["os"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## 源码包
|
||||||
|
- [openssh 源码包](https://www.openssh.com/portable.html)
|
||||||
|
- [openssl 源码包](https://www.openssl.org/source/)
|
||||||
|
|
||||||
|
## 不带 openssl(不推荐)
|
||||||
|
### 编译 openssh
|
||||||
|
- 下载 openssh 源码包,解压
|
||||||
|
```bash
|
||||||
|
curl -LO https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz
|
||||||
|
tar zxf openssh-9.8p1.tar.gz
|
||||||
|
cd openssh-9.8p1/
|
||||||
|
# 版本信息在 version.h
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编译安装 openssh
|
||||||
|
```bash
|
||||||
|
mkdir /opt/openssh
|
||||||
|
./configure --prefix=/opt/openssh --without-openssl
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编辑 /opt/openssh/etc/sshd_config,修改常用配置
|
||||||
|
```
|
||||||
|
# 避免与系统自带的 sshd 端口冲突
|
||||||
|
Port 22222
|
||||||
|
|
||||||
|
# 允许 root 用户登录,允许私钥认证,允许密码认证
|
||||||
|
PermitRootLogin yes
|
||||||
|
PubkeyAuthentication yes
|
||||||
|
PasswordAuthentication yes
|
||||||
|
|
||||||
|
# 开启 ssh 转发
|
||||||
|
AllowTcpForwarding yes
|
||||||
|
GatewayPorts yes
|
||||||
|
|
||||||
|
# ssh 保活
|
||||||
|
TCPKeepAlive yes
|
||||||
|
ClientAliveInterval 60
|
||||||
|
ClientAliveCountMax 3
|
||||||
|
|
||||||
|
# 禁用 dns 解析
|
||||||
|
UseDNS no
|
||||||
|
|
||||||
|
# 避免与系统自带的 sshd pid 文件冲突
|
||||||
|
PidFile /var/run/openssh.pid
|
||||||
|
```
|
||||||
|
|
||||||
|
### 创建 systemd 启动文件
|
||||||
|
- 创建 /opt/openssh/openssh.service,内容如下
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=OpenSSH server daemon
|
||||||
|
After=network.target sshd-keygen.service
|
||||||
|
Wants=sshd-keygen.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/opt/openssh/sbin/sshd -D
|
||||||
|
KillMode=process
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=42s
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
### 打包
|
||||||
|
- 进入 /opt 目录下,打包 openssh 目录
|
||||||
|
```
|
||||||
|
cd /opt
|
||||||
|
tar zcf /tmp/openssh-9.8p1-without-openssl.tgz openssh/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 带 openssl
|
||||||
|
### 编译 openssl
|
||||||
|
- 下载 openssl 源码包,解压
|
||||||
|
```bash
|
||||||
|
curl -LO https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
|
||||||
|
tar zxf openssl-1.1.1w.tar.gz
|
||||||
|
cd openssl-1.1.1w
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编译安装 openssl
|
||||||
|
```bash
|
||||||
|
mkdir /opt/openssl
|
||||||
|
./configure --prefix=/opt/openssl
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
### 编译 openssh
|
||||||
|
- 下载 openssh 源码包,解压,同上
|
||||||
|
- 编译安装 openssh
|
||||||
|
```bash
|
||||||
|
mkdir /opt/openssh
|
||||||
|
export PATH=/opt/openssl/bin:$PATH
|
||||||
|
export LD_LIBRARY_PATH=/opt/openssl/lib
|
||||||
|
./configure --prefix=/opt/openssh --with-ssl-dir=/opt/openssl
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编辑 /opt/openssh/etc/sshd_config,修改常用配置
|
||||||
|
```
|
||||||
|
# 避免与系统自带的 sshd 端口冲突
|
||||||
|
Port 22222
|
||||||
|
|
||||||
|
# 允许 root 用户登录,允许私钥认证,允许密码认证
|
||||||
|
PermitRootLogin yes
|
||||||
|
PubkeyAuthentication yes
|
||||||
|
PasswordAuthentication yes
|
||||||
|
|
||||||
|
# 开启 ssh 转发
|
||||||
|
AllowTcpForwarding yes
|
||||||
|
GatewayPorts yes
|
||||||
|
|
||||||
|
# ssh 保活
|
||||||
|
TCPKeepAlive yes
|
||||||
|
ClientAliveInterval 60
|
||||||
|
ClientAliveCountMax 3
|
||||||
|
|
||||||
|
# 禁用 dns 解析
|
||||||
|
UseDNS no
|
||||||
|
|
||||||
|
# 避免与系统自带的 sshd pid 文件冲突
|
||||||
|
PidFile /var/run/openssh.pid
|
||||||
|
```
|
||||||
|
|
||||||
|
### 创建 systemd 启动文件
|
||||||
|
- 创建 /opt/openssh/openssh.service,内容如下
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=OpenSSH server daemon
|
||||||
|
After=network.target sshd-keygen.service
|
||||||
|
Wants=sshd-keygen.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Environment=LD_LIBRARY_PATH=/opt/openssl/lib
|
||||||
|
ExecStart=/opt/openssh/sbin/sshd -D
|
||||||
|
KillMode=process
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=42s
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
### 打包
|
||||||
|
- 进入 /opt 目录下,打包 openssl 和 openssh 目录
|
||||||
|
```bash
|
||||||
|
cd /opt
|
||||||
|
tar zcf /tmp/openssh-9.8p1-with-openssl.tgz openssl/ openssh/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 部署
|
||||||
|
- 上传部署包到目标服务器中,解压
|
||||||
|
```bash
|
||||||
|
tar zxf openssh-9.8p1-with-openssl.tgz -C /opt/
|
||||||
|
```
|
||||||
|
|
||||||
|
- 复制 systemd 启动文件
|
||||||
|
```bash
|
||||||
|
cp /opt/openssh/openssh.service /etc/systemd/system/
|
||||||
|
```
|
||||||
|
|
||||||
|
- 启动 openssh,并设置开机自动启动
|
||||||
|
```bash
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl start openssh
|
||||||
|
systemctl enable openssh
|
||||||
|
```
|
||||||
|
|
@ -36,6 +36,11 @@ vpn 客户端 | vpn-client | CentOS7 | 192.168.1.91
|
|||||||
cd /opt/easy-rsa
|
cd /opt/easy-rsa
|
||||||
./easyrsa init-pki
|
./easyrsa init-pki
|
||||||
```
|
```
|
||||||
|
- 修改 /opt/easy-rsa/pki/safessl-easyrsa.conf 中如下配置,增加证书有效时间为 10 年
|
||||||
|
```
|
||||||
|
default_days = 3650
|
||||||
|
default_crl_days = 3650
|
||||||
|
```
|
||||||
- 生成免密 ca 证书
|
- 生成免密 ca 证书
|
||||||
```bash
|
```bash
|
||||||
# 使用默认 common name 即可
|
# 使用默认 common name 即可
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Dnsmasq 实现网络 PXE 装机"
|
|
||||||
date: 2019-11-08T15:52:55+08:00
|
|
||||||
lastmod: 2019-11-08T15:52:55+08:00
|
|
||||||
tags: ["dnsmasq", "pxe"]
|
|
||||||
categories: ["OS"]
|
|
||||||
---
|
|
||||||
|
|
||||||
## 把 dnsmasq 配置成 pxe 服务器
|
|
||||||
- 安装 dnsmasq
|
|
||||||
```bash
|
|
||||||
# rhel
|
|
||||||
yum install dnsmasq
|
|
||||||
# archlinux
|
|
||||||
pacman -S dnsmasq
|
|
||||||
```
|
|
||||||
- 修改配置 /etc/dnsmasq.conf
|
|
||||||
```ini
|
|
||||||
port=0 # 用不着 dns 功能,可以关闭
|
|
||||||
#interface=ens8u2u4u1 # 指定网卡
|
|
||||||
dhcp-range=10.0.86.1,10.0.86.9,255.255.255.0,1h
|
|
||||||
#dhcp-boot=pxelinux.0 # bios 引导
|
|
||||||
dhcp-boot=grubx64.efi # efi 引导
|
|
||||||
enable-tftp
|
|
||||||
tftp-root=/var/ftpd
|
|
||||||
```
|
|
||||||
- 启动 dnsmasq
|
|
||||||
```bash
|
|
||||||
systemctl start dnsmasq
|
|
||||||
```
|
|
||||||
|
|
||||||
## 安装 CentOS7/8
|
|
||||||
- **本次测试使用 CentOS7.7 和 CentOS8.0 镜像**
|
|
||||||
|
|
||||||
### 挂载系统镜像,提供软件源服务
|
|
||||||
- 下载 centos7/8 镜像到 dnsmasq 服务器
|
|
||||||
- 挂载镜像到 /mnt 目录
|
|
||||||
```bash
|
|
||||||
mount -o loop xxxx.iso /mnt
|
|
||||||
```
|
|
||||||
- 直接在系统镜像的挂载目录(/mnt)启动 http 服务
|
|
||||||
```bash
|
|
||||||
cd /mnt
|
|
||||||
python2 -m SimpleHTTPServer 10086
|
|
||||||
# 或者使用 python3
|
|
||||||
python3 -m http.server 10086
|
|
||||||
```
|
|
||||||
|
|
||||||
### 网络 BIOS 引导
|
|
||||||
- 复制 centos7/8 镜像里的启动文件到 dnsmasq 服务器的 /var/ftpd/ 下
|
|
||||||
```bash
|
|
||||||
cd /var/ftpd
|
|
||||||
cp /mnt/isolinux/* .
|
|
||||||
mkidr pxelinux.cfg
|
|
||||||
mv isolinux.cfg pxelinux.cfg/default
|
|
||||||
```
|
|
||||||
- 打开 /var/ftpd/pxelinux.cfg/default,修改第一个启动项
|
|
||||||
```
|
|
||||||
label linux
|
|
||||||
menu label ^Install CentOS 7/8
|
|
||||||
kernel vmlinuz
|
|
||||||
append initrd=initrd.img inst.repo=http://10.0.86.1:10086/ quiet
|
|
||||||
# ks 参数: inst.ks=<ks.cfg url>
|
|
||||||
```
|
|
||||||
- 在 centos7/8 上安装 syslinux
|
|
||||||
```bash
|
|
||||||
yum install syslinux # centos7
|
|
||||||
dnf install syslinux # centos 8
|
|
||||||
```
|
|
||||||
- 把 /user/share/syslinux/pxelinux.0 复制到 dnsmasq 服务器的 /var/ftpd/ 下
|
|
||||||
- 修改文件权限,确保 dnsmasq 用户可读
|
|
||||||
```bash
|
|
||||||
chown -R dnsmasq.dnsmasq /var/ftpd/
|
|
||||||
```
|
|
||||||
|
|
||||||
### 网络 EFI 引导
|
|
||||||
- **不支持 secure boot**
|
|
||||||
- 复制 centos7/8 镜像里的启动文件到 dnsmasq 服务器的 /var/ftpd/ 下
|
|
||||||
```bash
|
|
||||||
cp -a /mnt/EFI/BOOT/* /var/ftpd/
|
|
||||||
```
|
|
||||||
- 打开 /var/ftpd/grub.cfg,修改第一个启动项
|
|
||||||
```
|
|
||||||
menuentry 'Install CentOS 7/8' --class fedora --class gnu-linux --class gnu --class os {
|
|
||||||
linuxefi vmlinuz inst.repo=http://10.0.86.1:10086/ quiet
|
|
||||||
initrdefi initrd.img
|
|
||||||
}
|
|
||||||
# ks 参数: inst.ks=<ks.cfg url>
|
|
||||||
```
|
|
||||||
- 修改文件权限,确保 dnsmasq 用户可读
|
|
||||||
```bash
|
|
||||||
chown -R dnsmasq.dnsmasq /var/ftpd/
|
|
||||||
```
|
|
||||||
|
|
||||||
## 装机
|
|
||||||
- 把待安装机器和 dnsmasq 服务器接入同一个交换机(无其他 dhcp 广播)
|
|
||||||
- 启动待安装机器,选择 pxe 引导,从第一个启动项启动
|
|
||||||
|
|
160
content/post/pxe.md
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
---
|
||||||
|
title: "PXE 网络装机"
|
||||||
|
date: 2019-11-08T15:52:55+08:00
|
||||||
|
lastmod: 2024-11-08T18:17:00+08:00
|
||||||
|
tags: ["pxe"]
|
||||||
|
categories: ["OS"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## 部署 dhcp 和 tft 服务
|
||||||
|
- 安装 dnsmasq
|
||||||
|
```bash
|
||||||
|
# rhel
|
||||||
|
yum install dnsmasq
|
||||||
|
# archlinux
|
||||||
|
pacman -S dnsmasq
|
||||||
|
```
|
||||||
|
|
||||||
|
- 修改配置 /etc/dnsmasq.conf
|
||||||
|
```ini
|
||||||
|
port=0 # 用不着 dns 功能,可以关闭
|
||||||
|
dhcp-range=10.0.86.2,10.0.86.9,255.255.255.0,1h
|
||||||
|
#dhcp-boot=pxelinux.0 # bios 引导(未测试)
|
||||||
|
dhcp-boot=grubx64.efi # efi 引导
|
||||||
|
enable-tftp
|
||||||
|
tftp-root=/var/ftp
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在其中一个网卡上配置 ip: 10.0.86.1/24
|
||||||
|
- 启动 dnsmasq
|
||||||
|
```bash
|
||||||
|
systemctl start dnsmasq
|
||||||
|
```
|
||||||
|
|
||||||
|
## 挂载操作系统镜像
|
||||||
|
- 目前已测试过的操作系统
|
||||||
|
* centos 7/8/9
|
||||||
|
* rockyLinux 8/9
|
||||||
|
* 银河麒麟服务器版 V10 SP3
|
||||||
|
* 华为欧拉 24.03 LTS
|
||||||
|
|
||||||
|
- 上传操作系统镜像 iso 到 dnsmasq 服务器
|
||||||
|
- 挂载 iso 到 /mnt/iso 目录
|
||||||
|
```bash
|
||||||
|
mkdir /mnt/iso
|
||||||
|
mount -o loop xxxx.iso /mnt/iso
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在系统镜像的挂载目录(/mnt)启动 http 服务
|
||||||
|
```bash
|
||||||
|
cd /mnt
|
||||||
|
python2 -m SimpleHTTPServer 10086
|
||||||
|
# 或者使用 python3
|
||||||
|
python3 -m http.server 10086
|
||||||
|
```
|
||||||
|
|
||||||
|
## 创建 kicksart 自动安装脚本
|
||||||
|
- 创建 /mnt/ks.cfg 文件,内容如下
|
||||||
|
```
|
||||||
|
# Use graphical install
|
||||||
|
graphical
|
||||||
|
|
||||||
|
# Keyboard layouts
|
||||||
|
keyboard --vckeymap=cn --xlayouts='cn'
|
||||||
|
# System language
|
||||||
|
lang zh_CN.UTF-8
|
||||||
|
|
||||||
|
# 注释其中可能存在的 U盘或光盘安装设备配置项 “harddrive”
|
||||||
|
# Use hard drive installation media
|
||||||
|
#harddrive --dir= --partition=LABEL=openEuler-24.03-LTS-x86_64
|
||||||
|
|
||||||
|
%packages
|
||||||
|
@^minimal-environment
|
||||||
|
|
||||||
|
%end
|
||||||
|
|
||||||
|
# Run the Setup Agent on first boot
|
||||||
|
firstboot --enable
|
||||||
|
|
||||||
|
# 确认系统硬盘设备名,sata 或 sas 第一块盘是 sda,nvme 第一块盘是 nvme0n1
|
||||||
|
# Generated using Blivet version 3.8.2
|
||||||
|
ignoredisk --only-use=sda
|
||||||
|
# Partition clearing information
|
||||||
|
clearpart --none --initlabel
|
||||||
|
# Disk partitioning information
|
||||||
|
# 创建 efi 分区,传统 BIOS 引导不需要 efi 分区
|
||||||
|
part /boot/efi --fstype="efi" --ondisk=sda --size=256 --fsoptions="umask=0077,shortname=winnt"
|
||||||
|
# 这里指定 size 是 99GB,可按实际容量调整
|
||||||
|
part / --fstype="xfs" --ondisk=sda --size=101376
|
||||||
|
|
||||||
|
# System timezone
|
||||||
|
timezone Asia/Shanghai --utc
|
||||||
|
|
||||||
|
# Root password
|
||||||
|
rootpw --iscrypted $y$j9T$VB3hYFCRRHaCTsOM/DwE2KUX$Ci6f4pASC887sewVuvjFqTXHN.g5nsVsPoca9RntMdD
|
||||||
|
|
||||||
|
%addon com_redhat_kdump --disable --reserve-mb='auto'
|
||||||
|
|
||||||
|
%end
|
||||||
|
|
||||||
|
%anaconda
|
||||||
|
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
|
||||||
|
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
|
||||||
|
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
|
||||||
|
%end
|
||||||
|
|
||||||
|
# 安装完成后的操作,这里禁用了 selinux 和自带的防火墙
|
||||||
|
%post
|
||||||
|
/usr/bin/systemctl disable firewalld
|
||||||
|
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
|
||||||
|
%end
|
||||||
|
```
|
||||||
|
|
||||||
|
## 复制网络引导文件
|
||||||
|
### EFI 引导
|
||||||
|
- **不支持 secure boot**
|
||||||
|
- 复制镜像里的启动文件到 dnsmasq 服务器的 /var/ftp/ 下
|
||||||
|
```bash
|
||||||
|
cp -a /mnt/EFI/BOOT/* /var/ftp/
|
||||||
|
cp -a /mnt/images/pxeboot/{initrd.img,vmlinuz} /var/ftp/
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编辑 /var/ftp/grub.cfg,修改第一个启动项
|
||||||
|
```
|
||||||
|
menuentry ... --class gnu-linux --class gnu --class os {
|
||||||
|
linuxefi vmlinuz inst.repo=http://10.0.86.1:10086/iso inst.ks=http://10.0.86.1:10086/ks.cfg ...
|
||||||
|
initrdefi initrd.img
|
||||||
|
}
|
||||||
|
# 增加 inst.repo 和 inst.ks 这俩参数,其他不变
|
||||||
|
```
|
||||||
|
|
||||||
|
### 传统 BIOS 引导(未测试)
|
||||||
|
- 复制镜像里的启动文件到 dnsmasq 服务器的 /var/ftp/ 下
|
||||||
|
```bash
|
||||||
|
cd /var/ftp
|
||||||
|
cp /mnt/isolinux/* .
|
||||||
|
mkidr pxelinux.cfg
|
||||||
|
mv isolinux.cfg pxelinux.cfg/default
|
||||||
|
```
|
||||||
|
|
||||||
|
- 打开 /var/ftp/pxelinux.cfg/default,修改第一个启动项
|
||||||
|
```
|
||||||
|
label linux
|
||||||
|
menu label ...
|
||||||
|
kernel vmlinuz
|
||||||
|
append initrd=initrd.img inst.repo=http://10.0.86.1:10086 ...
|
||||||
|
# ks 参数: inst.ks=<ks.cfg url>
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在 centos7/8 上安装 syslinux
|
||||||
|
```bash
|
||||||
|
yum install syslinux # centos7
|
||||||
|
dnf install syslinux # centos 8
|
||||||
|
```
|
||||||
|
|
||||||
|
- 把 /user/share/syslinux/pxelinux.0 复制到 dnsmasq 服务器的 /var/ftp/ 下
|
||||||
|
|
||||||
|
## 装机
|
||||||
|
- 把待安装机器和 pxe 服务器接入同一个交换机(无其他 dhcp 广播)
|
||||||
|
- 启动待安装机器,选择 pxe 引导
|
||||||
|
|
95
content/post/qemu-aarch64.md
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
---
|
||||||
|
title: "Qemu 启动 arm64 虚拟机"
|
||||||
|
date: 2025-04-24T17:35:00+08:00
|
||||||
|
lastmod: 2025-04-24T17:35:00+08:00
|
||||||
|
tags: ["kvm", "虚拟化"]
|
||||||
|
categories: ["kvm"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## 安装 qemu
|
||||||
|
- 安装依赖
|
||||||
|
```
|
||||||
|
dnf install \
|
||||||
|
gcc make cmake ninja-build \
|
||||||
|
xz bzip2 \
|
||||||
|
python3 perl-interpreter \
|
||||||
|
glib2-devel pixman-devel zlib-devel \
|
||||||
|
diffutils findutils
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编译 qemu
|
||||||
|
```
|
||||||
|
curl -LO https://download.qemu.org/qemu-6.2.0.tar.xz
|
||||||
|
tar xf qemu-6.2.0.tar.xz
|
||||||
|
cd qemu-6.2.0
|
||||||
|
mkdir /opt/qemu-aarch64
|
||||||
|
./configure --prefix=/opt/qemu-aarch64/ –-target-list=aarch64-softmmu
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
- 下载 efi 固件
|
||||||
|
```
|
||||||
|
curl -LO https://releases.linaro.org/components/kernel/uefi-linaro/16.02/release/qemu64/QEMU_EFI.fd
|
||||||
|
```
|
||||||
|
|
||||||
|
## 创建 arm64 虚拟机
|
||||||
|
- 下载 Rocky Linux 8 iso 镜像文件
|
||||||
|
```
|
||||||
|
curl -LO https://mirrors.nju.edu.cn/rocky/8.10/isos/aarch64/Rocky-8.10-aarch64-minimal.iso
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建虚拟硬盘
|
||||||
|
```
|
||||||
|
mkdir /data/qemu
|
||||||
|
/opt/qemu-aarch64/bin/qemu-img create rocky8-aarch64.img 6G
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建虚拟机
|
||||||
|
```
|
||||||
|
/opt/qemu-aarch64/bin/qemu-system-aarch64 \
|
||||||
|
-m 2048 \
|
||||||
|
-cpu cortex-a57 \
|
||||||
|
-smp 2 \
|
||||||
|
-M virt \
|
||||||
|
-bios QEMU_EFI.fd \
|
||||||
|
-nographic \
|
||||||
|
-drive if=none,file=Rocky-8.10-aarch64-minimal.iso,id=cdrom,media=cdrom \
|
||||||
|
-device virtio-scsi-device \
|
||||||
|
-device scsi-cd,drive=cdrom \
|
||||||
|
-drive if=none,format=raw,file=/data/qemu/rocky8-aarch64.img,id=hd0 \
|
||||||
|
-device virtio-blk-device,drive=hd0
|
||||||
|
```
|
||||||
|
|
||||||
|
- 前台启动虚拟机,可以调整处理器核数和内存大小
|
||||||
|
```
|
||||||
|
/opt/qemu-aarch64/bin/qemu-system-aarch64 \
|
||||||
|
-m 4096 \
|
||||||
|
-cpu cortex-a57 \
|
||||||
|
-smp 4 \
|
||||||
|
-M virt -bios /opt/qemu-aarch64/utils/QEMU_EFI.fd \
|
||||||
|
-drive if=none,format=raw,file=/data/qemu/rocky8-aarch64.img,id=hd0 \
|
||||||
|
-device virtio-blk-device,drive=hd0 \
|
||||||
|
-nographic \
|
||||||
|
-display none
|
||||||
|
```
|
||||||
|
|
||||||
|
- 后台启动虚拟机,可以调整处理器核数和内存大小
|
||||||
|
```
|
||||||
|
/opt/qemu-aarch64/bin/qemu-system-aarch64 \
|
||||||
|
-m 4096 \
|
||||||
|
-cpu cortex-a57 \
|
||||||
|
-smp 4 \
|
||||||
|
-M virt -bios /opt/qemu-aarch64/utils/QEMU_EFI.fd \
|
||||||
|
-drive if=none,format=raw,file=/data/qemu/rocky8-aarch64.img,id=hd0 \
|
||||||
|
-device virtio-blk-device,drive=hd0 \
|
||||||
|
-net user,hostfwd=tcp::10022-:22 \
|
||||||
|
-net nic \
|
||||||
|
-display none \
|
||||||
|
-daemonize
|
||||||
|
```
|
||||||
|
|
||||||
|
## 参考
|
||||||
|
- [https://programmersought.com/article/81835534690/](https://programmersought.com/article/81835534690/)
|
||||||
|
- [https://blog.csdn.net/qq_41961459/article/details/119109622](https://blog.csdn.net/qq_41961459/article/details/119109622)
|
||||||
|
|
@ -1,146 +1,147 @@
|
|||||||
---
|
---
|
||||||
title: "CentOS7 安装 Redis 集群"
|
title: "CentOS7 安装 Redis 集群"
|
||||||
date: 2019-11-29T15:14:29+08:00
|
date: 2019-11-29T15:14:29+08:00
|
||||||
lastmod: 2019-11-29T15:14:29+08:00
|
lastmod: 2023-03-01T20:03:00+08:00
|
||||||
tags: ["redis"]
|
tags: ["redis"]
|
||||||
categories: ["database"]
|
categories: ["database"]
|
||||||
---
|
---
|
||||||
|
|
||||||
## 环境
|
## 环境
|
||||||
- 操作系统: CentOS7.7,关闭 firewalld 和 selinux
|
- 操作系统: CentOS7.9,关闭 firewalld 和 selinux
|
||||||
- Redis: 5.0.6
|
- Redis: 5.0.14
|
||||||
- master 实例
|
- master 实例
|
||||||
- 10.0.4.110:6371
|
- 10.0.4.110:6371
|
||||||
- 10.0.4.110:6372
|
- 10.0.4.110:6372
|
||||||
- 10.0.4.110:6373
|
- 10.0.4.110:6373
|
||||||
|
|
||||||
- slave 实例
|
- slave 实例
|
||||||
- 10.0.4.111:6371
|
- 10.0.4.111:6371
|
||||||
- 10.0.4.111:6372
|
- 10.0.4.111:6372
|
||||||
- 10.0.4.111:6373
|
- 10.0.4.111:6373
|
||||||
|
|
||||||
## 编译 redis server
|
## 编译 redis server
|
||||||
- 在 CentOS7.7 测试服务器上下载、编译
|
- 在 CentOS7.9 测试服务器上下载、编译
|
||||||
```bash
|
```bash
|
||||||
wget http://download.redis.io/releases/redis-5.0.6.tar.gz
|
curl -LO http://download.redis.io/releases/redis-5.0.14.tar.gz
|
||||||
tar xzf redis-5.0.6.tar.gz
|
tar zxf redis-5.0.14.tar.gz
|
||||||
cd redis-5.0.6
|
cd redis-5.0.14
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
- 抽取安装文件
|
- 抽取安装文件
|
||||||
```bash
|
```bash
|
||||||
mkdir -p /opt/redis_cluster/{bin,conf}
|
mkdir -p /opt/redis/{bin,conf}
|
||||||
cp src/{redis-server,redis-cli,redis-benchmark} /opt/redis_cluster/bin/
|
cp src/{redis-server,redis-cli,redis-benchmark} /opt/redis/bin/
|
||||||
# redis-check-rdb 和 redis-check-aof 与 redis-server 校验值一致,无需复制
|
cd /opt/redis/bin
|
||||||
|
ln -s redis-server redis-check-aof
|
||||||
|
ln -s redis-server redis-check-rdb
|
||||||
|
ln -s redis-server redis-sentinel
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建 /opt/redis/conf/redis-6379.conf,常用配置如下
|
||||||
```
|
```
|
||||||
- 创建 /opt/redis_cluster/conf/redis.conf,常用配置如下
|
|
||||||
```bash
|
|
||||||
bind 0.0.0.0
|
bind 0.0.0.0
|
||||||
protected-mode yes
|
protected-mode no
|
||||||
tcp-backlog 511
|
port 6379
|
||||||
timeout 3600
|
daemonize yes
|
||||||
tcp-keepalive 300
|
|
||||||
daemonize no
|
|
||||||
supervised no
|
supervised no
|
||||||
|
pidfile log/redis-6379.pid
|
||||||
loglevel notice
|
loglevel notice
|
||||||
|
logfile log/redis-6379.log
|
||||||
always-show-logo no
|
always-show-logo no
|
||||||
|
#save ""
|
||||||
save 900 1
|
save 900 1
|
||||||
save 300 10
|
save 300 10
|
||||||
save 60 10000
|
save 60 10000
|
||||||
stop-writes-on-bgsave-error yes
|
|
||||||
rdbcompression yes
|
|
||||||
rdbchecksum yes
|
|
||||||
dbfilename dump.rdb
|
dbfilename dump.rdb
|
||||||
#masterauth "123456"
|
dir db-6379
|
||||||
replica-serve-stale-data yes
|
maxclients 8192
|
||||||
replica-read-only yes
|
maxmemory 6442450944
|
||||||
repl-diskless-sync no
|
#requirepass xxxx
|
||||||
repl-diskless-sync-delay 5
|
#masterauth xxxx
|
||||||
repl-disable-tcp-nodelay no
|
#cluster-enabled yes
|
||||||
replica-priority 100
|
#cluster-config-file nodes-6379.conf
|
||||||
#requirepass "123456"
|
maxmemory-policy volatile-random
|
||||||
maxclients 10000
|
|
||||||
maxmemory 4294967296
|
|
||||||
maxmemory-policy volatile-lru
|
|
||||||
lazyfree-lazy-eviction no
|
|
||||||
lazyfree-lazy-expire no
|
|
||||||
lazyfree-lazy-server-del no
|
|
||||||
replica-lazy-flush no
|
|
||||||
appendonly no
|
appendonly no
|
||||||
appendfilename "appendonly.aof"
|
|
||||||
appendfsync everysec
|
|
||||||
no-appendfsync-on-rewrite no
|
|
||||||
auto-aof-rewrite-percentage 100
|
|
||||||
auto-aof-rewrite-min-size 64mb
|
|
||||||
aof-load-truncated yes
|
|
||||||
aof-use-rdb-preamble yes
|
|
||||||
lua-time-limit 5000
|
|
||||||
cluster-enabled yes
|
|
||||||
cluster-node-timeout 5000
|
|
||||||
slowlog-log-slower-than 10000
|
|
||||||
slowlog-max-len 128
|
|
||||||
latency-monitor-threshold 0
|
|
||||||
notify-keyspace-events ""
|
|
||||||
hash-max-ziplist-entries 512
|
|
||||||
hash-max-ziplist-value 64
|
|
||||||
list-max-ziplist-size -2
|
|
||||||
list-compress-depth 0
|
|
||||||
set-max-intset-entries 512
|
|
||||||
zset-max-ziplist-entries 128
|
|
||||||
zset-max-ziplist-value 64
|
|
||||||
hll-sparse-max-bytes 3000
|
|
||||||
stream-node-max-bytes 4096
|
|
||||||
stream-node-max-entries 100
|
|
||||||
activerehashing yes
|
|
||||||
client-output-buffer-limit normal 0 0 0
|
|
||||||
client-output-buffer-limit replica 256mb 64mb 60
|
|
||||||
client-output-buffer-limit pubsub 32mb 8mb 60
|
|
||||||
hz 10
|
|
||||||
dynamic-hz yes
|
|
||||||
aof-rewrite-incremental-fsync yes
|
|
||||||
rdb-save-incremental-fsync yes
|
|
||||||
```
|
```
|
||||||
- 创建 /opt/redis_cluster/redis@.service,配置如下
|
|
||||||
|
- 创建 /opt/redis/conf/redis-637{1..3}.conf
|
||||||
|
```bash
|
||||||
|
cd /opt/redis/conf
|
||||||
|
cp redis-6379.conf redis-6371.conf
|
||||||
|
cp redis-6379.conf redis-6372.conf
|
||||||
|
cp redis-6379.conf redis-6373.conf
|
||||||
|
|
||||||
|
sed -i \
|
||||||
|
-e 's/6379/6371/g' \
|
||||||
|
-e '/daemonize/cdaemonize no' \
|
||||||
|
-e '/supervised/csupervised systemd' \
|
||||||
|
-e '/requirepass/crequirepass 123456' \
|
||||||
|
-e '/masterauth/cmasterauth 123456' \
|
||||||
|
-e '/cluster/s/^#//' \
|
||||||
|
redis-6371.conf
|
||||||
|
|
||||||
|
sed -i \
|
||||||
|
-e 's/6379/6372/g' \
|
||||||
|
-e '/daemonize/cdaemonize no' \
|
||||||
|
-e '/supervised/csupervised systemd' \
|
||||||
|
-e '/requirepass/crequirepass 123456' \
|
||||||
|
-e '/masterauth/cmasterauth 123456' \
|
||||||
|
-e '/cluster/s/^#//' \
|
||||||
|
redis-6372.conf
|
||||||
|
|
||||||
|
sed -i \
|
||||||
|
-e 's/6379/6373/g' \
|
||||||
|
-e '/daemonize/cdaemonize no' \
|
||||||
|
-e '/supervised/csupervised systemd' \
|
||||||
|
-e '/requirepass/crequirepass 123456' \
|
||||||
|
-e '/masterauth/cmasterauth 123456' \
|
||||||
|
-e '/cluster/s/^#//' \
|
||||||
|
redis-6373.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建日志目录和数据目录
|
||||||
|
```bash
|
||||||
|
cd /opt/redis
|
||||||
|
mkdir -p db-{6371..6373} log
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建 /opt/redis/redis@.service,内容如下
|
||||||
```ini
|
```ini
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Redis cluster -- node %i
|
Description=Redis cluster -- node %i
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStartPre=/usr/bin/ls -d /var/lib/redis_cluster/%i
|
WorkingDirectory=/opt/redis
|
||||||
ExecStart=/opt/redis_cluster/bin/redis-server /opt/redis_cluster/conf/redis.conf \
|
ExecStart=/opt/redis/bin/redis-server conf/redis-%i.conf
|
||||||
--daemonize no \
|
|
||||||
--port %i \
|
|
||||||
--pidfile /var/run/redis_%i.pid \
|
|
||||||
--logfile /var/log/redis_cluster/%i.log \
|
|
||||||
--dir /var/lib/redis_cluster/%i \
|
|
||||||
--cluster-config-file /var/lib/redis_cluster/%i/nodes.conf
|
|
||||||
ExecStop=/opt/redis_cluster/bin/redis-cli -h 127.0.0.1 -p %i shutdown
|
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=1
|
RestartSec=2
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
```
|
```
|
||||||
|
|
||||||
## 部署
|
## 部署
|
||||||
- 把测试机的 /opt/redis_cluster 目录复制到 10.0.4.110 和 10.0.4.111 上
|
- 把 /opt/redis 目录复制到 10.0.4.110 和 10.0.4.111 上
|
||||||
```bash
|
```bash
|
||||||
scp -r /opt/redis_cluster 10.0.4.110:/opt/
|
scp -r /opt/redis 10.0.4.110:/opt/
|
||||||
scp -r /opt/redis_cluster 10.0.4.111:/opt/
|
scp -r /opt/redis 10.0.4.111:/opt/
|
||||||
```
|
```
|
||||||
|
|
||||||
- 在 10.0.4.110 和 10.0.4.111 上都执行以下操作
|
- 在 10.0.4.110 和 10.0.4.111 上都执行以下操作
|
||||||
```bash
|
```bash
|
||||||
mv /opt/redis_cluster/redis@.service /usr/lib/systemd/system/
|
cp /opt/redis/redis@.service /usr/lib/systemd/system/
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
mkdir -p /var/lib/redis_cluster/{6371..6373}
|
|
||||||
mkdir -p /var/log/redis_cluster
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- 在 10.0.4.110 和 10.0.4.111 上配置实例开机启动
|
- 在 10.0.4.110 和 10.0.4.111 上配置实例开机启动
|
||||||
```bash
|
```bash
|
||||||
systemctl enable redis@6371
|
systemctl enable redis@6371
|
||||||
systemctl enable redis@6372
|
systemctl enable redis@6372
|
||||||
systemctl enable redis@6373
|
systemctl enable redis@6373
|
||||||
```
|
```
|
||||||
|
|
||||||
- 在 10.0.4.110 和 10.0.4.111 上启动全部实例
|
- 在 10.0.4.110 和 10.0.4.111 上启动全部实例
|
||||||
```bash
|
```bash
|
||||||
systemctl start redis@6371
|
systemctl start redis@6371
|
||||||
@ -149,24 +150,30 @@ categories: ["database"]
|
|||||||
```
|
```
|
||||||
|
|
||||||
## 配置集群
|
## 配置集群
|
||||||
- 在 10.0.4.110 或 10.0.4.111 上创建集群,指定三个 master 实例
|
- 在 10.0.4.110 上创建集群,指定三个 master 实例
|
||||||
```bash
|
```bash
|
||||||
/opt/redis_cluster/bin/redis-cli \
|
/opt/redis/bin/redis-cli -a 123456 --no-auth-warning \
|
||||||
--cluster create 10.0.4.110:6371 10.0.4.110:6372 10.0.4.110:6373
|
--cluster create 10.0.4.110:6371 10.0.4.110:6372 10.0.4.110:6373
|
||||||
```
|
```
|
||||||
|
|
||||||
- 输出如下图
|
- 输出如下图
|
||||||

|

|
||||||
|
|
||||||
- 同意配置,输入 "yes",回车后输出如下图
|
- 同意配置,输入 "yes",回车后输出如下图
|
||||||

|

|
||||||
|
|
||||||
- 查看集群当前实例
|
- 查看集群当前实例
|
||||||
```bash
|
```bash
|
||||||
/opt/redis_cluster/bin/redis-cli -p 6371 cluster nodes
|
/opt/redis/bin/redis-cli -a 123456 --no-auth-warning -p 6371 cluster nodes
|
||||||
|
# 这里保存好各个 master 节点的 id,下面增加 slave 节点时会用到
|
||||||
```
|
```
|
||||||
|
|
||||||
- 输出如下图
|
- 输出如下图
|
||||||

|

|
||||||
|
|
||||||
- 添加 slave 实例 10.0.4.111:6371,同步 master 10.0.4.110:6371
|
- 添加 slave 实例 10.0.4.111:6371,同步 master 10.0.4.110:6371
|
||||||
```bash
|
```bash
|
||||||
/opt/redis_cluster/bin/redis-cli \
|
/opt/redis/bin/redis-cli -a 123456 --no-auth-warning \
|
||||||
--cluster add-node 10.0.4.111:6371 10.0.4.110:6371 \
|
--cluster add-node 10.0.4.111:6371 10.0.4.110:6371 \
|
||||||
--cluster-slave \
|
--cluster-slave \
|
||||||
--cluster-master-id 5be0edaf74d1eec50bbe675f9698397023a943b7
|
--cluster-master-id 5be0edaf74d1eec50bbe675f9698397023a943b7
|
||||||
@ -174,32 +181,39 @@ categories: ["database"]
|
|||||||
# --cluster-slave 指定添加 slave 实例
|
# --cluster-slave 指定添加 slave 实例
|
||||||
# --cluster-master-id 指定 10.0.4.110:6371 的 id,即本次添加实例的 master
|
# --cluster-master-id 指定 10.0.4.110:6371 的 id,即本次添加实例的 master
|
||||||
```
|
```
|
||||||
|
|
||||||
- 输出如下图
|
- 输出如下图
|
||||||

|

|
||||||
|
|
||||||
- 添加 slave 实例 10.0.4.111:6372,同步 master 10.0.4.110:6372
|
- 添加 slave 实例 10.0.4.111:6372,同步 master 10.0.4.110:6372
|
||||||
```bash
|
```bash
|
||||||
/opt/redis_cluster/bin/redis-cli \
|
/opt/redis/bin/redis-cli -a 123456 --no-auth-warning \
|
||||||
--cluster add-node 10.0.4.111:6372 10.0.4.110:6371 \
|
--cluster add-node 10.0.4.111:6372 10.0.4.110:6371 \
|
||||||
--cluster-slave \
|
--cluster-slave \
|
||||||
--cluster-master-id 96f2225fdd054d8a16b31726fd1eb0b66c612646
|
--cluster-master-id 96f2225fdd054d8a16b31726fd1eb0b66c612646
|
||||||
```
|
```
|
||||||
|
|
||||||
- 输出如下图
|
- 输出如下图
|
||||||

|

|
||||||
|
|
||||||
- 添加 slave 实例 10.0.4.111:6373,同步 master 10.0.4.110:6373
|
- 添加 slave 实例 10.0.4.111:6373,同步 master 10.0.4.110:6373
|
||||||
```bash
|
```bash
|
||||||
/opt/redis_cluster/bin/redis-cli \
|
/opt/redis/bin/redis-cli -a 123456 --no-auth-warning \
|
||||||
--cluster add-node 10.0.4.111:6373 10.0.4.110:6371 \
|
--cluster add-node 10.0.4.111:6373 10.0.4.110:6371 \
|
||||||
--cluster-slave \
|
--cluster-slave \
|
||||||
--cluster-master-id cd60c238e66c8b4a31355bee4610444a47acef86
|
--cluster-master-id cd60c238e66c8b4a31355bee4610444a47acef86
|
||||||
```
|
```
|
||||||
|
|
||||||
- 输出如下图
|
- 输出如下图
|
||||||

|

|
||||||
|
|
||||||
- 查看集群当前实例
|
- 查看集群当前实例
|
||||||
```bash
|
```bash
|
||||||
/opt/redis_cluster/bin/redis-cli -p 6371 cluster nodes
|
/opt/redis/bin/redis-cli -a 123456 --no-auth-warning -p 6371 cluster nodes
|
||||||
```
|
```
|
||||||
|
|
||||||
- 输出如下图
|
- 输出如下图
|
||||||

|

|
||||||
|
|
||||||
## Docker 部署
|
## Docker 部署
|
||||||
- 安装 docker-ce,参考[这里](https://www.colben.cn/post/docker/#%E5%AE%89%E8%A3%85)
|
- 安装 docker-ce,参考[这里](https://www.colben.cn/post/docker/#%E5%AE%89%E8%A3%85)
|
||||||
|
46
content/post/redis-dump-data.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
title: "Redis 数据迁移"
|
||||||
|
date: 2024-01-31T18:09:00+08:00
|
||||||
|
lastmod: 2024-01-31T18:09:00+08:00
|
||||||
|
tags: ["redis"]
|
||||||
|
categories: ["database"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## 环境
|
||||||
|
- Redis: 5.0.14
|
||||||
|
- 源集群实例
|
||||||
|
```
|
||||||
|
... 127.0.0.10:6371@16371 ... connected 0-5460
|
||||||
|
... 127.0.0.10:6372@16372 ... connected 5461-10922
|
||||||
|
... 127.0.0.10:6373@16373 ... connected 10923-16383
|
||||||
|
```
|
||||||
|
|
||||||
|
- 源集群密码: 123456
|
||||||
|
|
||||||
|
- 目的集群实例
|
||||||
|
```
|
||||||
|
... 127.0.0.11:6371@16371 ... connected 0-5460
|
||||||
|
... 127.0.0.11:6372@16372 ... connected 5461-10922
|
||||||
|
... 127.0.0.11:6373@16373 ... connected 10923-16383
|
||||||
|
```
|
||||||
|
|
||||||
|
- 目的集群密码: 123456
|
||||||
|
- redis 数据迁移工具: [redis-dump-go](https://github.com/yannh/redis-dump-go)
|
||||||
|
|
||||||
|
## 导出源集群数据
|
||||||
|
- 下载 redis-dump-go: [https://github.com/yannh/redis-dump-go](https://github.com/yannh/redis-dump-go)
|
||||||
|
- 导出源集群中每个节点的数据
|
||||||
|
```bash
|
||||||
|
REDISDUMPGO_AUTH=123456 redis-dump-go -host 127.0.0.10 -port 6371 > redis-src-6371.resp
|
||||||
|
REDISDUMPGO_AUTH=123456 redis-dump-go -host 127.0.0.10 -port 6372 > redis-src-6372.resp
|
||||||
|
REDISDUMPGO_AUTH=123456 redis-dump-go -host 127.0.0.10 -port 6373 > redis-src-6373.resp
|
||||||
|
```
|
||||||
|
|
||||||
|
## 导入目的集群
|
||||||
|
- 把数据导入与其 slots 一致的节点中
|
||||||
|
```bash
|
||||||
|
redis-cli -c -h 127.0.0.11 -p 6371 -a 123456 --no-auth-warning --pipe < redis-src-6371.resp
|
||||||
|
redis-cli -c -h 127.0.0.11 -p 6372 -a 123456 --no-auth-warning --pipe < redis-src-6372.resp
|
||||||
|
redis-cli -c -h 127.0.0.11 -p 6373 -a 123456 --no-auth-warning --pipe < redis-src-6373.resp
|
||||||
|
```
|
||||||
|
|
@ -7,17 +7,8 @@ tags: ["ssh", "隧道", "转发"]
|
|||||||
categories: ["shell"]
|
categories: ["shell"]
|
||||||
---
|
---
|
||||||
|
|
||||||
## sshd 常规设置
|
## 开启端口转发配置
|
||||||
- 禁用 root 远程登陆
|
- 修改 sshd 配置
|
||||||
```
|
|
||||||
PermitRootLogin no
|
|
||||||
```
|
|
||||||
- 只允许私钥登陆
|
|
||||||
```
|
|
||||||
PubkeyAuthentication yes
|
|
||||||
PasswordAuthentication no
|
|
||||||
```
|
|
||||||
- 开启端口转发功能
|
|
||||||
```
|
```
|
||||||
AllowTcpForwarding yes
|
AllowTcpForwarding yes
|
||||||
GatewayPorts yes
|
GatewayPorts yes
|
||||||
@ -27,7 +18,7 @@ categories: ["shell"]
|
|||||||
ClientAliveCountMax 3
|
ClientAliveCountMax 3
|
||||||
```
|
```
|
||||||
|
|
||||||
## ssh 参数
|
## ssh 转发用到的参数
|
||||||
- -f 后台运行
|
- -f 后台运行
|
||||||
- -N 仅作端口转发,不执行任何命令
|
- -N 仅作端口转发,不执行任何命令
|
||||||
- -g 绑定端口到全部网卡
|
- -g 绑定端口到全部网卡
|
||||||
|
122
content/post/win-multi-remote.md
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
---
|
||||||
|
title: "Windows 多用户远程桌面"
|
||||||
|
date: 2024-12-24T19:26:00+08:00
|
||||||
|
lastmod: 2024-12-24T19:26:00+08:00
|
||||||
|
keywords: []
|
||||||
|
tags: ["windows"]
|
||||||
|
categories: ["os"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## Win10
|
||||||
|
### 开启远程桌面服务
|
||||||
|
- 登录管理员账号
|
||||||
|
- 单击“开始”,搜索“远程桌面”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 开启远程桌面服务,如下图
|
||||||
|

|
||||||
|
|
||||||
|
### 配置多用户登录
|
||||||
|
- 登录管理员账号
|
||||||
|
- 快捷键 Win + R,运行“gpedit.msc”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 点击“确定”,打开组策略编辑器,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 选择“计算机配置 - 管理模板 - windows组件 - 远程桌面服务 - 远程桌面会话主机 - 连接”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 修改上图红框中的两个设置项
|
||||||
|
* 双击“允许用户通过使用远程桌面服务进行远程连接”,启用该设置,如下图
|
||||||
|

|
||||||
|
|
||||||
|
* 双击“限制连接的数量”,启用该设置,并修改选项“允许的 RD 最大连接数”的值是99,如下图
|
||||||
|

|
||||||
|
|
||||||
|
* 默认情况下,同一个 Windows 用户在同一时间只允许一个人远程连接;如果需要**多人同时远程连接同一个 Windows 账户**,可以双击“将远程桌面服务用户限制到单独的远程桌面服务会话”,禁用该设置,如下图
|
||||||
|

|
||||||
|
|
||||||
|
### 安装 RDPWrap
|
||||||
|
- 浏览器访问: [https://github.com/SobieskiCodes/RDPWrap](https://github.com/SobieskiCodes/RDPWrap),如下图,如果访问不到,考虑开启系统代理实现科学上网
|
||||||
|

|
||||||
|
|
||||||
|
- 点击“Code - Download ZIP”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 下载完成后,解压,右键单击 RDPWrap-master/RDPW_Installer.exe 文件
|
||||||
|
- 选择“以管理员身份运行”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 安装过程中可能会连接 github 下载数据,建议开启科学上网
|
||||||
|
- 等待安装完成后,会自动打开 RDPWrap,提示绿色的“Fully supported”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 安装失败会提示红色的“Not supported”,**需要按下面步骤尝试重新安装**
|
||||||
|
* 卸载已安装的 RDPWrap,右键单击 RDPWrap-master/RDPW_Uninstaller.exe 文件
|
||||||
|
* 选择“以管理员身份运行”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
* 重启 win10 系统
|
||||||
|
* 检查网络,配置系统代理实现正常访问 www.google.com
|
||||||
|
* 重新安装 RDPWrap
|
||||||
|
|
||||||
|
### 创建远程用户
|
||||||
|
- 登录管理员账号
|
||||||
|
- 右键单击“开始”按钮,选择“计算机管理”,打开“计算机管理”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 选择“系统工具 - 本地用户和组 - 用户”,打开用户列表,在用户列表空白处右键单击,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 选择“新用户”,打开“新用户”弹框,输入“用户名”等信息,选中“密码永不过期”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 单击“创建”按钮,此时输入项自动清空,可以继续创建其他用户
|
||||||
|
- 单击“关闭”按钮关闭弹框,在用户列表中找到新建的用户,右键单击,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 选择“属性”,在打开的用户属性窗口,单击“隶属于”标签页,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 单击“添加”按钮,打开的“选择组”对话框,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 单击“高级”按钮,点击右侧的“立即查找”按钮,在“搜索结果”中找到“Remote Desktop User”(倒数第五项),如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 单击“确定”按钮选择该项,再单击“确定”按钮退出“选择组”对话框,返回用户属性窗口
|
||||||
|
- 此时在“隶属于”标签页下可以看到新增的“Remote Desktop User”,如下图
|
||||||
|

|
||||||
|
|
||||||
|
- 单击“应用”按钮和“确定”按钮,关闭用户属性窗口,关闭“计算机管理”窗口,此时就可以用该新增用户远程桌面了
|
||||||
|
|
||||||
|
## Win7
|
||||||
|
### 开启远程服务
|
||||||
|
- 右键单击“计算机”,选择“属性” - “远程”
|
||||||
|
- 选中“勾上允许任意版本远程桌的计算机连接”
|
||||||
|
|
||||||
|
### 创建新用户
|
||||||
|
- 右键单击“计算机”,选择“管理”
|
||||||
|
- 选择“系统工具” - “本地用户和组”,单击“用户”,选择“新用户”
|
||||||
|
- 输入“用户名”,“密码”和“确认密码”,选中“密码永不过期”,单击“创建”
|
||||||
|
|
||||||
|
### 把用户加入远程用户组
|
||||||
|
- 右键单击“计算机”,选择“属性” - “远程”
|
||||||
|
- 单击“选择用户” - “添加”,输入刚创建的用户名,单击“确定”
|
||||||
|
|
||||||
|
### 修改组策略
|
||||||
|
- 单击“开始菜单” - “运行”,输入“gpedit.msc”,打开“本地组策略编辑器”
|
||||||
|
- 选择“计算机配置” - “管理模板” - “Windows 组件” - “远程桌面服务” - “远程桌面会话主机” - “连接”
|
||||||
|
- 双击右侧的“限制连接的数量”,选中“已启用”,设置“允许的 RD 最大连接数”为 99,单击“应用” - “确定”
|
||||||
|
- 双击右侧的“将远程桌面服务用户限制到单独的远程桌面服务会话”,选中“已禁用”,单击“应用” - “确定”
|
||||||
|
|
||||||
|
### 修改系统文件
|
||||||
|
- 下载补丁包 [UniversalTermsrvPatch_20090425.zip](/UniversalTermsrvPatch_20090425.zip)
|
||||||
|
- 解压,以管理员权限运行 UniversalTermsrvPatch-x86.exe(32位)或 UniversalTermsrvPatch-x64.exe(64位)
|
||||||
|
- 单机“破解”后即修改完成
|
||||||
|
|
||||||
|
## 参考
|
||||||
|
- Win10 多用户远程登录,[https://blog.csdn.net/fallingflower/article/details/125215235](https://blog.csdn.net/fallingflower/article/details/125215235),youtube_branch 分支
|
||||||
|
- Win7 多用户远程登录,[https://community.spiceworks.com/t/how-to-enable-concurrent-remote-desktop-sessions-in-windows/1008589](https://community.spiceworks.com/t/how-to-enable-concurrent-remote-desktop-sessions-in-windows/1008589)
|
||||||
|
|
58
content/post/windows.md
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
---
|
||||||
|
title: "Windows 笔记"
|
||||||
|
date: 2023-04-03T16:04:00+08:00
|
||||||
|
lastmod: 2023-04-03T16:04:00+08:00
|
||||||
|
keywords: []
|
||||||
|
tags: ["windows"]
|
||||||
|
categories: ["os"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## 激活 windows
|
||||||
|
- Windows 10 专业版
|
||||||
|
```
|
||||||
|
slmgr /upk
|
||||||
|
slmgr /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX
|
||||||
|
slmgr /skms zh.us.to
|
||||||
|
# 如果 zh.us.to 不通,可以尝试 kms8.msguides.com
|
||||||
|
slmgr /ato
|
||||||
|
```
|
||||||
|
|
||||||
|
- Windows 11 专业版
|
||||||
|
```
|
||||||
|
slmgr.vbs /upk
|
||||||
|
slmgr /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX
|
||||||
|
slmgr /skms kms.loli.best
|
||||||
|
slmgr /ato
|
||||||
|
```
|
||||||
|
|
||||||
|
## win11 恢复 win10 右键菜单
|
||||||
|
- 保存如下文本到“任意文件名.cmd”,双击该 cmd 文件
|
||||||
|
```
|
||||||
|
reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
|
||||||
|
taskkill /f /im explorer.exe & start explorer.exe
|
||||||
|
```
|
||||||
|
|
||||||
|
## win10 登录后自动挂载 webdav
|
||||||
|
### 定时任务
|
||||||
|
- 常规
|
||||||
|
* 安全选项:只在用户登录时运行
|
||||||
|
* 配置:Windows 10
|
||||||
|
|
||||||
|
- 触发器
|
||||||
|
* 开始任务:登陆时
|
||||||
|
* 延迟任务时间:30秒
|
||||||
|
|
||||||
|
- 操作
|
||||||
|
* 操作:启动程序
|
||||||
|
* 程序或脚本:conhost.exe
|
||||||
|
* 添加参数:--headless net use 盘符: http://地址/dav 密码 /user:用户 /persistent:NO
|
||||||
|
|
||||||
|
- 条件
|
||||||
|
* 网络:只有在以下网络连接可用时才启动
|
||||||
|
|
||||||
|
- 设置
|
||||||
|
* 允许按需运行任务
|
||||||
|
* 如果任务失败,按一下频率重新启动:1分钟
|
||||||
|
* 尝试重新启动最多次数:3
|
||||||
|
* 请勿启动新实例
|
||||||
|
|
BIN
static/UniversalTermsrvPatch_20090425.zip
Normal file
BIN
static/img/win10-multi-remote-01.png
Normal file
After Width: | Height: | Size: 400 KiB |
BIN
static/img/win10-multi-remote-02.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
static/img/win10-multi-remote-03.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
static/img/win10-multi-remote-04.png
Normal file
After Width: | Height: | Size: 76 KiB |
BIN
static/img/win10-multi-remote-05.png
Normal file
After Width: | Height: | Size: 303 KiB |
BIN
static/img/win10-multi-remote-06.png
Normal file
After Width: | Height: | Size: 206 KiB |
BIN
static/img/win10-multi-remote-07.png
Normal file
After Width: | Height: | Size: 189 KiB |
BIN
static/img/win10-multi-remote-08.png
Normal file
After Width: | Height: | Size: 134 KiB |
BIN
static/img/win10-multi-remote-09.png
Normal file
After Width: | Height: | Size: 228 KiB |
BIN
static/img/win10-multi-remote-10.png
Normal file
After Width: | Height: | Size: 210 KiB |
BIN
static/img/win10-multi-remote-11.png
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
static/img/win10-multi-remote-12.png
Normal file
After Width: | Height: | Size: 176 KiB |
BIN
static/img/win10-multi-remote-13.png
Normal file
After Width: | Height: | Size: 76 KiB |
BIN
static/img/win10-multi-remote-14.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
static/img/win10-multi-remote-15.png
Normal file
After Width: | Height: | Size: 99 KiB |
BIN
static/img/win10-multi-remote-16.png
Normal file
After Width: | Height: | Size: 126 KiB |
BIN
static/img/win10-multi-remote-17.png
Normal file
After Width: | Height: | Size: 101 KiB |
BIN
static/img/win10-multi-remote-18.png
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
static/img/win10-multi-remote-19.png
Normal file
After Width: | Height: | Size: 132 KiB |
BIN
static/img/win10-multi-remote-20.png
Normal file
After Width: | Height: | Size: 242 KiB |
BIN
static/img/win10-multi-remote-21.png
Normal file
After Width: | Height: | Size: 122 KiB |