Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wenerme committed Apr 2, 2024
1 parent 2de2575 commit 0e1da89
Show file tree
Hide file tree
Showing 54 changed files with 1,414 additions and 659 deletions.
4 changes: 3 additions & 1 deletion notes/db/kv/kv-awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ title: KV DB Awesome

## 服务

- Redis
- [placeholderkv/placeholderkv](./redis/placeholderkv.md)
- Redis 最后的 BSD fork
- [Redis](./redis/README.md)
- [FoundationDB](https://github.com/apple/foundationdb)
- [FoundationDB/awesome-foundationdb](https://github.com/FoundationDB/awesome-foundationdb)
- [microsoft/FASTER](https://github.com/microsoft/FASTER)
Expand Down
6 changes: 5 additions & 1 deletion notes/db/kv/redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ title: Redis
# Redis

- [redis/redis](https://github.com/redis/redis)
- BSD-3, C
- RSALv2, SSPLv1, C
- 7.2 BSD-3 -> RSALv2, SSPLv1
- BSD fork
- [PlaceHolderKV](./placeholderkv.md)
- https://codeberg.org/redict/redict
- 支持的数据类型: string, bitmap, hll, list, pub/sub, hash, set, sorted set, stream
- Redis Stack 扩展: bloom, cuckoo, count-min, graph, json, suggest, search, t-digest, timeserial, top-k
- 参考
Expand Down
14 changes: 14 additions & 0 deletions notes/db/relational/postgresql/postgres-supabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ title: Supabase PostgreSQL Image
- 扩展
- [supabase/supautils](https://github.com/supabase/supautils)

```bash
# 注意 superuser 为 supabase_admin 密码和 postgres 相同
# 建议登录为 supabase_admin 然后 alter user postgres with superuser
PASSWORD=$(uuidgen | tr -d '[[:space:]]')
docker run -d --restart=always \
-e POSTGRES_PASSWORD=$PASSWORD \
-p 5432:5432 \
-e POSTGRES_INITDB_ARGS="--encoding=UTF-8 --lc-collate=C --lc-ctype=C" \
-v /data/postgres/data:/var/lib/postgresql/data \
--name postgres supabase/postgres:15.1.1.33 \
-clisten_addresses=* \
-cshared_preload_libraries=pg_stat_statements,pg_stat_monitor,pgaudit,plpgsql,plpgsql_check,pg_cron,pg_net,timescaledb,auto_explain,pg_tle
```

```conf
unix_socket_directories = '/var/run/postgresql'
session_preload_libraries = 'supautils'
Expand Down
12 changes: 12 additions & 0 deletions notes/db/relational/postgresql/postgresql-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -894,3 +894,15 @@ on conflict(value) do update set (label,extensions)= (excluded.label,excluded.ex
## for update nowait - FOR UPDATE cannot be applied to the nullable side of an outer join

- mikroorm LockMode.PESSIMISTIC_WRITE_OR_FAIL

## permission denied to set session authorization

```sql
-- 获取当前的 superuser
SELECT usename
FROM pg_catalog.pg_user
WHERE usesuper = true;
```

- ⚠️注意 [supabase](./postgres-supabase.md) 的 pg superuser 是 supabase_admin
- supabase_admin 密码和 postgres 相同,登录后 `ALTER USER postgres WITH SUPERUSER`
1 change: 1 addition & 0 deletions notes/dev/dev-awesome.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ tags:
- [boyter/scc](https://github.com/boyter/scc)

```bash
brew install scc
# -M '[.]pb[.]' -M 'generated'
scc --exclude-dir={vendor,.gen,node_modules} -M '_test.go' --no-gen .
```
Expand Down
39 changes: 35 additions & 4 deletions notes/dev/dict.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,21 @@ tags:
- 达成活动可能有一定条件 - 例如 A 转变为 B 还是 C 取决于一定条件
- 活动底层也是通过事件驱动

## notes vs comment vs remark

- notes
- 简单信息
- 个人参考或者提醒
- 对话、会议、演讲的总结,对某个主题的思考和观察
- 使用场景:学习、会议记录、个人备忘录,或者任何需要记录关键信息的场合。
- comment
- 对某个话题、事件或意见的评价或解释
- 包含个人的看法、批评、或者解释
- 强调能 reply
- 使用场景:在线讨论、代码评审、书籍或文章边注,或者任何需要提供反馈、见解的地方。
- remark
- 暗示了观点的智慧或机智,但也可以是比较普通的评论。

## Supplier vs. Provider vs. Vendor

建议同等对待 “服务商”和“供应商”。
Expand Down Expand Up @@ -964,6 +979,7 @@ tags:
- status - 等待处理, 正在进行, 暂时延迟, 即将完成

---

- 参考
- Dynamic365 entity state & status
- Status (statecode) - Status Reason (statuscode)
Expand Down Expand Up @@ -1194,14 +1210,29 @@ tags:

虽然传统翻译里用 “命名空间” 翻译 namespace 概念,但是认为如果就是指代 “Namespace”,那 “名字空间” 更合适。

## area vs region vs district
## area vs region vs district vs location vs address

- 抽象层级 region > area > district > location > address

---

- area
- 小区域范围
- 小区域
- 面积或区域的广泛概念,可以指自然地理区域、行政划分、或者某个具体的空间或场所。
- 通常用于泛指一个较大的地理、社会或功能区域,不特指具体的行政单位。例如,可以说“住宅区”、“商业区”等。
- region
- 大的地理位置区域
- 大区域
- 区域,常指较大的地理或行政区域,可以跨越多个国家或包含多个州、省。
- 常用于描述具有某种共同地理特征、文化特征或经济特征的大片区域。例如,亚马逊雨林、中东地区等。
- district
- 行政区划
- 区或地区,一般指一个较小的行政划分单元,如城市的一部分或乡镇。
- 在行政管理、选举、商业等多个领域中有特定含义。例如,学区(教育行政区域)、商业区。
- location
- 位置,指一个点或者一个很小的区域在空间上的具体位置。
- 通常用于指明某个具体的地点或地理位置,无论是通过描述、坐标还是其他方式。例如,“我们公司的位置在市中心。”
- address
- 地址,更具体、更正式地标识某个位置或场所的信息。
- 用于邮件寄送、定位、识别某个特定的住所、建筑或机构等。它通常包括街道名、门牌号、城市、州/省、国家和邮政编码等信息。

## mobile vs phone vs tel

Expand Down
27 changes: 24 additions & 3 deletions notes/dev/std/unicode/unicode-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ echo '你好!' | iconv -f UTF-8 -t GB2312 - | hexdump -C
- BMP - Basic Multilingual Plane
- 基本多文种平面
- U+0000 to U+FFFF
- SIP - Supplementary Ideographic Plane
- 补充表意文字平面
- Plane 2 - 第二辅助平面
- U+20000 to U+2A6DF
- TIP - Tertiary Ideographic Plane
- 第三辅助平面
- Plane 3
- U+2A700 to U+2B73F

## 中文
## CJK

**中文**

Expand All @@ -34,16 +42,29 @@ echo '你好!' | iconv -f UTF-8 -t GB2312 - | hexdump -C
/[\u4e00-\u9fa5\u3400-\u4DBF]|[\u{20000}-\u{2A6DF}]/u
```

- 扩展A区(Extension A)
- 中日韩统一表意文字(U+4E00-U+9FA5) - `/[\u4e00-\u9fa5]/`
- 20902
- 〇 U+3007 - 特殊修正
- 扩展A区(Extension A) - U+3400-U+4DB5
- 6,582
- 罕见汉字、少数民族汉字
- 扩展B区(Extension B)
- 中日韩统一表意文字扩展区A
- https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_Extension_A
- 扩展B区(Extension B) - U+20000-U+2A6D6 - A+B
- 42,711
- 罕见、古老汉字
- 扩展C区(U+2A700到U+2B73F)
- 扩展D区(U+2B740到U+2B81F)
- 扩展E区(U+2B820到U+2CEAF)
- 扩展F区(U+2CEB0到U+2EBEF)
- 中日韩统一表意文字
- https://en.wikipedia.org/wiki/CJK_Unified_Ideographs

| 区块名 | 码位数 | 未分配 | 编码范围 |
| ------------------------- | ------ | ------ | --------------- |
| 中日韩统一表意文字 | 20,992 | 0 | U+4E00-U+9FA5 |
| 中日韩统一表意文字扩展区A | 6,592 | 0 | U+3400-U+4DB5 |
| 中日韩统一表意文字扩展区B | 42,720 | 0 | U+20000-U+2A6DF |

## 200b

Expand Down
44 changes: 44 additions & 0 deletions notes/devops/kubernetes/distro/k3s/k3s-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,50 @@ ETCDCTL_API=3 etcdctl --endpoints=unix:///var/lib/rancher/k3s/server/kine.sock g
# ETCDCTL_API=3 etcdctl --endpoints=unix:///var/lib/rancher/k3s/server/kine.sock get / --prefix
```

## DNS 问题

```bash
nslookup kubernetes.default

# 确保网络正常
ping 1.1.1.1
```

- 确保 coredns 能联网
- kube-dns.kube-system.svc.cluster.local
- 10.43.0.10
- coredns

## flannel 网络问题

```bash
# 排查 host 路由
route -n

cat /run/flannel/subnet.env

# host
ping 10.42.0.1

# 排查 pod 网络
tcpdump -i cni0 -nn -s0 -v -l host
```

```ini title="subnet.env"
FLANNEL_NETWORK=10.42.0.0/16
FLANNEL_SUBNET=10.42.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true
```

## pod 之间网络不通

```bash
iptables -P FORWARD ACCEPT
```

- https://github.com/k3s-io/k3s/issues/8809

## containerd 配置

- /var/lib/rancher/k3s/agent/etc/containerd/config.toml
Expand Down
8 changes: 4 additions & 4 deletions notes/devops/kubernetes/distro/k3s/k3s-upgrade.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
tags:
- Upgrade
- Upgrade
---

# K3S 升级 {#upgrade}
Expand All @@ -13,8 +13,7 @@ rc-update del k3s
reboot

# 升级
k3s -v # 当前版本
cp $(which k3s) k3s.last # backup
k3s -v # 当前版本

sudo apk add jq

Expand All @@ -35,7 +34,8 @@ sha256sum -c sha256sum-${ARCH}.txt --ignore-missing

cp k3s$SUFFIX k3s.$VERSION_K3S
chmod +x k3s.$VERSION_K3S
sudo cp k3s.$VERSION_K3S $(which k3s)
cp $(which k3s) k3s.last # backup
sudo cp k3s.$VERSION_K3S $(which k3s) # replace

sudo k3s check-config
k3s -v
Expand Down
46 changes: 29 additions & 17 deletions notes/devops/kubernetes/network/apisix-ingress.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ title: Apisix Ingress

# Apisix Ingress

:::caution

- 不建议使用
- 依赖 etcd
- etcd 难维护
- helm 直接启动的 etcd 可能会有各种问题 - 可能导致无法启动
- 没必要为了 apisix 专门去维护 etcd
- etcd 非常吃 IO - IO 慢的时候 CPU 非常高
- 建议尝试 kong - 使用现有的 DB 作为 backend

:::

- Helm
- https://charts.apiseven.com apisix
- apisix 依赖 apisix-dashboard, apisix-ingress-controller, etcd
Expand Down Expand Up @@ -48,23 +60,23 @@ spec:

```yaml
annotations:
k8s.apisix.apache.org/enable-cors: "true"
k8s.apisix.apache.org/cors-allow-origin: "https://foo.com,http://bar.com:8080"
k8s.apisix.apache.org/cors-allow-headers: "Host: https://bar.com:8080"
k8s.apisix.apache.org/cors-allow-methods: "GET,POST"
k8s.apisix.apache.org/allowlist-source-range: "10.0.5.0/16,127.0.0.1,192.168.3.98"
k8s.apisix.apache.org/blocklist-source-range: "127.0.0.1,172.17.0.0/16"
k8s.apisix.apache.org/http-allow-methods: "GET,POST"
k8s.apisix.apache.org/http-block-method: "PUT,DELETE"
k8s.apisix.apache.org/rewrite-target-regex: "/app/(.*)"
k8s.apisix.apache.org/rewrite-target-regex-template: "/$1"
k8s.apisix.apache.org/http-to-https: "true"
k8s.apisix.apache.org/use-regex: "true"
k8s.apisix.apache.org/enable-websocket: "true"
k8s.apisix.apache.org/enable-response-rewrite: "true"
k8s.apisix.apache.org/response-rewrite-status-code: "404"
k8s.apisix.apache.org/response-rewrite-body: "bar-body"
k8s.apisix.apache.org/response-rewrite-body-base64: "true"
k8s.apisix.apache.org/enable-cors: 'true'
k8s.apisix.apache.org/cors-allow-origin: 'https://foo.com,http://bar.com:8080'
k8s.apisix.apache.org/cors-allow-headers: 'Host: https://bar.com:8080'
k8s.apisix.apache.org/cors-allow-methods: 'GET,POST'
k8s.apisix.apache.org/allowlist-source-range: '10.0.5.0/16,127.0.0.1,192.168.3.98'
k8s.apisix.apache.org/blocklist-source-range: '127.0.0.1,172.17.0.0/16'
k8s.apisix.apache.org/http-allow-methods: 'GET,POST'
k8s.apisix.apache.org/http-block-method: 'PUT,DELETE'
k8s.apisix.apache.org/rewrite-target-regex: '/app/(.*)'
k8s.apisix.apache.org/rewrite-target-regex-template: '/$1'
k8s.apisix.apache.org/http-to-https: 'true'
k8s.apisix.apache.org/use-regex: 'true'
k8s.apisix.apache.org/enable-websocket: 'true'
k8s.apisix.apache.org/enable-response-rewrite: 'true'
k8s.apisix.apache.org/response-rewrite-status-code: '404'
k8s.apisix.apache.org/response-rewrite-body: 'bar-body'
k8s.apisix.apache.org/response-rewrite-body-base64: 'true'
# 可以通过 Prefix 路由
# path: /helloworld.Greeter/SayHello
k8s.apisix.apache.org/upstream-scheme: grpcs
Expand Down
29 changes: 0 additions & 29 deletions notes/devops/web/haproxy/haproxy-conf.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,35 +350,6 @@ hdr(host)
hdr_end(host) -i .wener.me
hdr_beg(host) -i .wener.me

## Logging

```haproxy
global
# syslog UNIX socket
log /dev/log local0
# 本地 syslog server
log 127.0.0.1 local1 notice
# log 到 hostname 为 rsyslog 的服务器
log rsyslog:514 local0
# stdout - 用于容器环境
log stdout format raw local0
log stdout format raw daemon debug
defaults
log global
mode http
option httplog
backend s1
mode tcp
option tcplog
```

- https://www.haproxy.com/documentation/hapee/latest/onepage/#8
- https://www.haproxy.com/documentation/hapee/latest/observability/logging/overview/
- https://www.haproxy.com/blog/introduction-to-haproxy-logging/

## 参考

Expand Down

0 comments on commit 0e1da89

Please sign in to comment.