openwrt

开启 Samba

1
2
3
4
5
6
# 安装依赖
opkg install shadow-common shadow-useradd

# 添加用户
useradd share
smbpasswd -a share

扩容 overlay

已验证的镜像类型

1
openwrt-...-...-generic-squashfs-combined-efi.img

扩容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 扩容镜像
dd if=/dev/zero bs=1G count=30 >> openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img
# 分区
$ parted openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img
...
(parted) print
...
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 126MB 109MB

(parted) resizepart 2 100%
(parted) print
...
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 32.3GB 32.3GB

(parted) quit

# [pve] 加载镜像为虚拟机磁盘
qm importdisk 103 openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img local-lvm

挂载新的磁盘

1
2
3
4
5
6
7
8
9
# 格式化磁盘
mkfs.ext4 /dev/sdb

# 安装 block-mount
opkg install block-mount

# 进入网页, 打开 系统 -> 挂载点
挂载点 -> 新增
保存并应用

soft router

镜像

主题

LEDE

更新源配置

腾讯

1
2
3
4
5
6
src/gz openwrt_core https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/targets/x86/64/packages
src/gz openwrt_base https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/packages/x86_64/base
src/gz openwrt_luci https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/packages/x86_64/luci
src/gz openwrt_packages https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/packages/x86_64/packages
src/gz openwrt_routing https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/packages/x86_64/routing
src/gz openwrt_telephony https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/telephony

清华源

1
2
3
4
5
6
7
8
9
src/gz openwrt_core https://mirrors.cloud.tencent.com/lede/snapshots/targets/x86/64/packages
src/gz openwrt_base https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/base
src/gz openwrt_helloworld https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/helloworld
src/gz openwrt_kenzo https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/kenzo
src/gz openwrt_luci https://mirrors.cloud.tencent.com/lede/releases/18.06.9/packages/x86_64/luci
src/gz openwrt_packages https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/packages
src/gz openwrt_routing https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/routing
src/gz openwrt_small https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/small
src/gz openwrt_telephony https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/telephony

PVE

查看 debian 版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 1. 查看文件 release 文件
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

# 2. 通过 lsb-release 命令
$ apt update
$ apt install lsb-release
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

修改 debian 更新源

参考这里

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 安装依赖
apt update
apt install apt-transport-https ca-certificates -y

# 修改源文件
$ mv /etc/apt/sources.list /etc/apt/sources.list.back
$ vi /etc/apt/sources.list
## 输入如下内容 (注意版本, 下面是 bullseye)
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

更新

1
2
apt update
apt upgrade -y

修改更新源

参考这里

proxmox 更新

1
2
3
4
# 添加源文件
vi /etc/apt/sources.list.d/pve-no-subscription.list
# 输入 (注意 debian 版本)
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian bullseye pve-no-subscription

CT 模板加速

1
2
cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back
sed -i 's|http://download.proxmox.com|https://mirrors.tuna.tsinghua.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm

重启生效。

从 qcow2 启动 openwrt

1. 拷贝镜像至 pve

1
scp openwrt-x86-64-generic-squashfs-combined-efi.qcow2 root@192.168.6.60:

2. 创建虚拟机

不用添加硬盘盒配置 CD/DVD 驱动器。

3. 挂载镜像为磁盘

1
2
3
4
# qcow2
qm importdisk 100 openwrt-x86-64-generic-squashfs-combined-efi.qcow2 local-lvm
# img
qm importdisk 100 openwrt-x86-64-generic-squashfs-combined-efi.img local-lvm

这里的 100 是虚拟机 ID

local-lvm 是存储池名称

image-20221105161004992

4. 为虚拟机添加硬盘

image-20221105160819628

选中未使用的磁盘,并点击编辑。

image-20221105160840881

类型选择 IDE。

5. 修改引导

image-20221105161029736

image-20221105161048645

启用新添加的硬盘,并把优先级设为最高(拖动序号前的三条横杠)。

6. 启动虚拟机

保存上述更改,启动虚拟机即可。

硬盘直通

1
2
3
4
5
6
$ vi /etc/default/grub
# 修改 GRUB_CMDLINE_LINUX_DEFAULT 为如下
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"

# 更新 grub
$ update-grub

修改网络地址

1
2
3
$ vim /etc/config/network 
# 修改对应的网络接口地址, 比如 eth0
$ /etc/init.d/network restart

修改密码

1
$ passwd root

Openwrt

初始化

修改网络配置

/etc/config/network

1
2
# interface 'lan'
option ipaddr ... # 修改这里
1
2
$ service network reload
$ service network restart

修改密码

1
$ passwd root

安装应用

1
2
3
opkg install <package>
opkg install <package.ipk>
opkg install <http://path/to/package.ipk>

扩容 overlay

已验证的镜像类型

1
openwrt-...-...-generic-squashfs-combined-efi.img

扩容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 扩容镜像
dd if=/dev/zero bs=1G count=30 >> openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img
# 分区
$ parted openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img
...
(parted) print
...
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 126MB 109MB

(parted) resizepart 2 100%
(parted) print
...
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 32.3GB 32.3GB

(parted) quit

# [pve] 加载镜像为虚拟机磁盘
qm importdisk 103 openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img local-lvm

旁路由

  • 网络 / 接口 / LAN
    • 基本设置
      • ipv4 地址,修改为主路由局域网合法且未被占用地址(如 192.168.6.2~192.168.6.254)
      • 网关,主路由 ip 地址(如 192.168.6.1)
      • 广播地址,如 192.168.6.255
      • DNS 服务器,主路由 ip 地址
      • IPv6 分配长度,已禁用
    • 高级设置
      • 使用内置的 ipv6 管理,关闭
    • 物理设置
      • 关闭桥接
    • DHCP 服务器
      • 忽略此接口
  • 网络 / 防火墙
    • image-20231026230034381
  • 运行 SSR

设备设置

Mac OS

image-20231026230223222

Ubuntu Server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
enp5s0:
dhcp4: false
addresses: [192.168.6.55/24]
match:
macaddress: 2a:04:a0:xx:xx:xx
wakeonlan: true
nameservers:
addresses: [223.6.6.6, 8.8.8.8]
routes:
- to: default
via: 192.168.6.89
metric: 40
enp6s0:
dhcp4: true
version: 2

连通性校验

  • ping 使用 ICMP 协议,代理一般只支持 TCP 和 UDP,所以使用 ping 可能无法判断是否代理成功
1
2
# 可以尝试下面命令
curl https://www.google.com

自定义规则

image-20240519224634959

emacs

使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
注:
C-<chr>: ctrl+字母
M-<car>: alt+字母

命令:
C-x C-c:退出Emacs
C-v:下一屏(页)
M-v:上一屏(页)
C-l:重绘屏幕,并将光标所在行置于屏幕中央
C-p:[移动光标]将光标移动到上一行,列位置不变(p:previous)
C-n:[移动光标]将光标移动到下一行,列位置不变(n:next)
C-b:[移动光标]将光标向左移动一位(b:backward)
C-f:[移动光标]将光标向右移动一位(f:forward)

文件命令:
C-x C-f:打开文件
C-x C-s:保存文件
C-x C-b:列出缓冲区

C-x u:撤销

helm

安装

1
2
3
4
5
6
7
8
9
10
11
12
13
# brew
brew install helm

# snap
sudo snap install helm --classic

# microk8s
microk8s enable helm3
## 使用
microk8s helm3 ...

# arch
sudo pamac install helm

概念

Helm 可以安装 Charts 到 k8s 集群中,为每次安装创建新的 Release。为了获取新的 Charts,可以搜索 Helm Charts Repositories。

Chart

在 Helm 中,Chart 是一个集合,包含所有必要的的资源定义来运行一个应用、工具或者 k8s 集群中的服务。

Repository

Repository 是 Charts 收集和分享的地方。

Release

Release 是 Chart 运行在 k8s 集群中的实例。一个 Chart 可以在相同的集群被安装多次,每次安装都会创建一个新的 Release。

使用

Repo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 添加
helm repo add <name> <url>

# 查看 repo 下的 charts
helm search repo <repo-name>

# 更新 repo
helm repo update <repo-name>

# 列出添加的 repo
helm repo list

# 移除 repo
helm repo remove <repo-name>

# 打包 repo
helm package <relative-path-to-chart>

# 生成 index
helm repo index

Chart

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 搜索
helm search repo <repo-name> # 在添加的 repo 中搜索
helm search hub <repo-name> # 在 hub 中搜索

# 安装一个 Chart
helm install <chart> --generate-name
helm install <release-name> <chart>

# 列出安装的 chart
helm list # 或 helm ls

# 写在一个 chart
helm uninstall <release-name>

# 查看一个 helm 的状态
helm status <release-name>

Values

1
2
3
4
5
6
7
8
9
10
# 查看 chart values
helm show values bitnami/wordpress
# 查看 release values
helm show values <release-name>

# 覆盖 values (使用文件)
echo '{mariadb.auth.database: user0db, mariadb.auth.username: user0}' > values.yaml
helm install -f values.yaml bitnami/wordpress --generate-name
# 覆盖 values (使用命令行参数)
helm install --set mariadb.auth.database=user0db,sample.list={1,2,3},sample.empty.list=[] bitnami/wordpress --generate-name

升级与回滚

升级

1
2
3
4
5
echo "mariadb.auth.username: user1" > panda.yaml
helm upgrade -f panda.yaml <release-name> <chart>

# 示例
helm upgrade -f panda.yaml happy-panda bitnami/wordpress

回滚

1
2
3
4
helm rollback <release-name> <REVISION> --timeout <timeout> --wait

# 查看 revision
helm history <release-name>

模板

1
2
# 查看生成 Manifest
helm template --debug <relative-path-to-chart>

ArtifactHUB

helm artifact hub

自定义 Repo

示例参考 bitnami

推荐系统

推荐系统的典型架构

recommend-system-第 2 页.drawio

如何快速了解一个推荐系统

  • 架构
    • 在线架构,流量接入、策略、在线打分
    • 离线架构,样本日志的产生、收集、清洗、拼接,模型训练平台
  • 数据
    • 用户数据,了解时效性、数据量、存储方式
      • 累计用户画像
      • 实时用户行为数据
    • 正排数据
      • 信息流,视频、文章、图片等
      • 广告,Offer、模板、素材等
  • 代码组织
    • 代码使用到的框架
    • 处理流程
  • 策略
    • 对指标(信息流,点击率预估、停留时长预估,广告,IVR、CTR、CVR、eCPM 等)的调整
  • 特征
    • 特征来源
    • 如何做特征抽取(FE,Feature Extractor)
    • 落特征、特征回流

k9s usage

常用命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 输入冒号进入命令模式
:

# 切换视图
:svc # 服务视图
:deploy # 部署视图
:pod # pod 视图
:rb # 角色绑定视图
:namespace # 命名空间视图
:cj # cronjob

# 退出
^+C (CTRL + C)
:q

ubuntu setup

设置时区

timedatectl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 查看当前时区信息
$ timedatectl
Local time: 一 2023-06-26 16:21:01 CST
Universal time: 一 2023-06-26 08:21:01 UTC
RTC time: 一 2023-06-26 08:21:01
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
# 查看所有可配置的时区名称
$ timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
...
# 设置时区
$ sudo timedatectl set-timezone Asia/Shanghai

tzselect

临时需改时区,重启后失效。

1
$ tzselect

network - use wifi adapter

360 随身 wifi 1 代

驱动

这里这里

1
2
3
4
$ lsusb
...
Bus 001 Device 003: ID 148f:760b Ralink Technology, Corp. MT7601U Wireless Adapter
...

安装驱动

1
2
3
4
5
6
7
sudo apt install git dkms
git clone https://github.com/jeremyb31/mt7601u-5.4.git
sudo dkms add ./mt7601u-5.4
sudo dkms install mt7601u/1.0

# 重启
sudo reboot

360 随身 wifi 2 代

驱动

这里