晨曦's Blog

This is a window to the soul

https://github.com/SuperManito/LinuxMirrors

https://linuxmirrors.cn/use/

替换源

1
2
3
4
5
6
7
8
# GNU/Linux 更换系统软件源
bash <(curl -sSL https://linuxmirrors.cn/main.sh)

# Docker 安装与换源
bash <(curl -sSL https://linuxmirrors.cn/docker.sh)

# Docker 更换镜像加速器
bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry

还原源

1
2
cp -rf /etc/yum.repos.d.bak /etc/yum.repos.d
yum makecache

FAQ

1、检测到系统存在已备份的 repo 源文件,是否跳过覆盖备份?

1
这里选择 “否” 尽量不要覆盖最开始备份

2、使用阿里云镜像站的 Rocky Linux 软件源

1
2
3
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--source mirrors.aliyun.com \
--branch rockylinux

现象

POD 重启后一直 Pending,且 describe 无事件显示

排查

发现是 kube-scheduler 挂了

处理

1、重启了 kube-scheduler 后发现并为恢复

1
docker restart kube-scheduler

2、重启了 Docker 后恢复 (这里忘记看 Docker 的状态了)

1
2
3
systemctl daemon-reload

systemctl restart docker

结论

Docker 假死

之前 Python 主要是利用 Pyenv 做环境管理,pip 做包管理,接下来试试 UV

安装 UV

1
2
3
curl -LsSf https://astral.sh/uv/install.sh | sh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

安装 Python

1
2
3
4
5
6
7
8
# 显示已经安装或可安装版本
uv python list

# 安装指定的Python版本
uv python install 3.12 3.13

# 卸载指定的版本
uv python uninstall 3.12

创建项目

1
2
# 初始化项目,最低兼容3.10版本Python
uv init mcpss --python=3.10

设置虚拟环境

1
2
3
4
5
6
7
8
# 创建虚拟环境
uv venv --python 3.12

# 激活环境
source .venv/bin/activate

# 退出环境
deactivate

安装卸载依赖

1
2
3
4
5
6
7
8
# 安装
uv pip install requests

# 查看
uv pip list

# 卸载
uv pip uninstall requests


未完待续…

错误

1
2
3
# journalctl -u docker.service --since "10 minutes ago"

failed to start daemon: Error initializing network controller: error creating default "bridge" network: failed to allocate gateway (172.20.0.0): Address already in use.

BIP 设置

1
2
3
4
5
6
{
"insecure-registries": [
"0.0.0.0/0"
],
"bip": "172.20.0.1/16"
}

限制

网段不能以.0​结尾,只能以.1​结尾,因为需要一个实际地址分配给 docker0​网卡

参考文档

ZeroOmega 是在 ProxySwitchyOmega 的基础上改进而来,并全面支持新版 manifestV3。其管理界面几乎与 SwitchyOmega 完全相同,使得从 SwitchyOmega 迁移的用户能够实现无缝替换。此外,ZeroOmega 支持配置文件的导入与导出功能,极大地方便了用户操作。目前,ZeroOmega 兼容 Chrome、Firefox 和 Edge 浏览器客户端。

项目地址

插件地址

错误

Fluentd 向 ES 写入数据的时候如下报错:

1
2024-12-27 01:33:27 +0000 [warn]: #0 fluent/log.rb:381:warn: send an error event to @ERROR: error_class=Fluent::Plugin::ElasticsearchErrorHandler::ElasticsearchError error="400 - Rejected by Elasticsearch [error type]: illegal_argument_exception [reason]: 'Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [3000]/[3000] maximum shards open;'" location=nil tag="kubernetes.var.log.containers.dataops-ds-worker-fbc64df5f-k6xrm_dataops_dataops-ds-worker-494d705e1a173657644f86708f16041cf8d429038c969f1237d7f040bbaa313e.log" time=2024-12-27 01:33:21.135254232 +0000

解决

1
2
3
4
5
curl -X PUT -u admin:xxxxxx --insecure https://172.23.8.175:9200/_cluster/settings -H 'Content-Type: application/json' -d '{
"persistent": {
"cluster.max_shards_per_node": 5000
}
}'

其他命令

1
2
curl -X GET -u admin:xxxxxx --insecure https://172.23.8.175:9200/_cat/shards?v
curl -X GET -u admin:xxxxxx --insecure https://172.23.8.175:9200/_cluster/stats?pretty

配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# /etc/lsyncd.conf
settings {
logfile ="/var/log/lsyncd/lsyncd.log",
statusFile ="/var/log/lsyncd/lsyncd.status",
inotifyMode = "CloseWrite",
maxProcesses = 8,
-- nodaemon = false,
}

-- 远程目录同步,rsync模式 + ssh shell

sync {
default.rsync,
-- 同步源目录(本机某个目录,必须保证该文件或目录在源服务器上存在,不然启动会报错)
source = "/etc/coredns/",
-- 同步目标地址和目标目录,注意target如果是普通需要有写权限,以上是将源服务器上/oafiles/目录下的所有文件同步到目标服务器的/hdd/test目录下
target = "root@10.113.75.19:/etc/coredns",
-- excludeFrom = "/etc/rsyncd.d/rsync_exclude.lst",
maxDelays = 1,
delay = 15,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true
}
-- 在文件同步完成后执行的命令
postcmd = "/usr/bin/systemctl restart coredns" # 重启从服务器上的 CoreDNS 服务
}

启动

1
2
3
4
5
6
7
8
9
10
11
12
# /usr/lib/systemd/system/lsyncd.service
[Unit]
Description=Live Syncing (Mirror) Daemon
After=network.target

[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/lsyncd
ExecStart=/usr/bin/lsyncd -nodaemon $LSYNCD_OPTIONS

[Install]
WantedBy=multi-user.target

启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# /usr/local/bin/coredns -dns.port=53 -conf /etc/coredns/Corefile
# /usr/lib/systemd/system/coredns.service

[Unit]
Description=CoreDNS
Documentation=https://coredns.io/manual/toc/
Wants=network-online.target
After=network.target

[Service]
# Type设置为notify时,服务会不断重启
# 关于type的设置,可以参考https://www.freedesktop.org/software/systemd/man/systemd.service.html#Options
Type=simple
User=root
# 指定运行端口和读取的配置文件
ExecStart=/usr/local/bin/coredns -dns.port=53 -conf /etc/coredns/Corefile
StandardOutput=rsyslog
StandardError=rsyslog
Restart=on-failure
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target

# systemctl daemon-reload
# systemctl start coredns
# systemctl status coredns

Corefile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# /etc/coredns/Corefile
# cat Corefile
.:53 {
header {
response set ra aa
response clear rd
}
hosts /etc/coredns/hostsfile { # 这里可以设置单域名hosts
fallthrough
}
prometheus :9153
forward . 223.5.5.5 # 上游DNS服务器
log
errors
whoami
reload
loop
}
jakehu.me {
header {
response set ra aa
response clear rd
}
file /etc/coredns/jakehu.me # 这里可以设置通配
log
loop
reload
errors
}
jakehu.com { # 直接转发到上游,忽略本地dns解析
forward . 223.5.5.5
log
errors
whoami
}

DNS zone file

1
2
3
4
5
6
7
# /etc/coredns/jakehu.me
$ORIGIN jakehu.me.
@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 3600
3600 IN NS a.iana-servers.net.
3600 IN NS b.iana-servers.net.

www IN A 127.0.0.1

如果增加了记录需要将 2017042745​加 1,让配置生效

主从配置

CoreDNS 本身并不直接支持传统的主从配置(如 BIND 的 masters 和 slaves)。不过,以下几种方法可以实现类似的功能:

  1. DNS 转发:通过配置 forward 插件将 DNS 查询转发到另一台服务器,适用于负载均衡或容灾目的。
  2. CoreDNS 与 Consul 集成:通过 Consul 共享服务发现数据,实现多台 CoreDNS 服务器的高可用配置。
  3. DNS 区域同步:通过手动同步 DNS 配置文件,达到多个 CoreDNS 服务器数据一致性。

参考:

https://coredns.io/manual/toc/

方式一:源码部署

参考官方文档:https://hexo.io/zh-cn/docs/github-pages

方式二:一键部署

参考官方文档:https://hexo.io/zh-cn/docs/github-pages

方式三:我的方式

  1. 将源码传入到 github 私有仓库(因为有部分东西不想对公暴露)
  2. 利用私有所在仓库 Actions 进行 build
  3. 再利用 Actions 传入到另一个仓库(jakehu.github.io)
package.json
1
2
3
"scripts": {
"gen": "hexo cl && hexo g"
}
.github/workflows/deployment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
name: Publish Hexo to gitpage
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
npm install -g hexo-cli # 安装 Hexo CLI
npm install # 安装 package.json 中记录的插件
- name: Generate Hexo site
run: |
npm run gen
- name: Deploy to B repo
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.ACCESS_TOKEN }} # Personal access token
external_repository: jakehu/jakehu.github.io # 发布的仓库地址
PUBLISH_BRANCH: master
PUBLISH_DIR: ./public

ACCESS_TOKEN 变量需要在源码仓库 Settings->Secrets and variables->Actions​下进行设置

0%