helm 安装及使用
环境信息
- centos7 5.4.212-1.el7
- kubernetes Server Version: v1.25.0
- Helm 3.10.0
安装
下载 需要的版本
wget https://get.helm.sh/helm-v3.10.0-linux-amd64.tar.gz
解压
tar -xf helm-v3.10.0-linux-amd64.tar.gz
在解压目中找到
helm
程序,移动到需要的目录中cp linux-amd64/helm /usr/local/bin/
验证
$ helm version
version.BuildInfo{Version:"v3.10.0", GitCommit:"ce66412a723e4d89555dc67217607c6579ffcb21", GitTreeState:"clean", GoVersion:"go1.18.6"}
常见用法
查看已安装的 release
helm ls |
卸载
$ helm ls -A |
查看导入的 repo
$ helm repo ls |
搜索/查看可用的 repo
$ helm search repo hashicorp/vault |
查看可用的 releases
$ helm search repo hashicorp/vault -l |
安装
$ helm install vault hashicorp/vault --version 0.25.0 |
Vault 介绍及安装配置
环境信息
- Kubernetes 1.24
- Vault 1.14.0
Vault 简介
Vault 架构及基础概念
Vault 的架构图如下 [1]
从以上架构图可以看到,几乎所有的 Vault 组件都被统称为 Barrier
(屏障)
Vault 架构可以大体分为三个部分: [7]
Sotrage Backend
- 存储后端Barrier
- 屏障层HTTPS API
- API 接口
常用概念
Storage Backend
- Vault 自身不存储数据,因此需要一个存储后端(Storage Backend
),存储后端对 Vault 来说是不受信任的,只用来存储加密数据。 [8]
Initialization
- Vault 在首次启动时需要初始化(Initialization
),这一步会生成一个 Master Key
(加密密钥)用于加密数据,只有加密完成的数据才能保存到 Storage Backend
Unseal
- Vault 启动后,因为不知道 Master Key
(加密密钥)所以无法解密数据(可以访问 Storage Backend
上的数据),这种状态被称为 Sealed
(已封印),在能解封(Unseal
)数据之前,Vault 无法进行任何操作。Unseal
是获取 Master Key
明文的过程,通过 Master Key
可以解密 Encryption Key
从而可以解密存储的数据 [6]
Master Key
- Encryption Key
(用来加密存储的数据,加密密钥和加密数据被一同存储) 是被 Master Key
(主密钥) 保护(加密),必须提供 Master Key
,Vault 才能解密出 Encryption Key
,从而完成数据解密操作。Master Key
与其他 Vault 数据被存放在一起,但使用另一种机制进行加密:解封密钥 ,解封密钥默认使用 沙米尔密钥分割算法 生成 Key Shares
[9]
Key Shares
- 默认情况下,Vault 使用 沙米尔密钥分割算法 将 Master Key
的解封密钥分割成五个 Key Shares
(分割密钥),必须要提供其中任意的三个 Key Shares
才能重建 Master Key
,以完成 Unseal
(解封)操作
Key Shares
(分割密钥)的总数,以及重建Master Key
(主密钥)最少需要的分割密钥数量,都是可以调整的。 沙米尔密钥分割算法 也可以关闭,这样主密钥将被直接提供给管理员,管理员可直接使用它进行解封操作。
认证系统及权限系统处理流程
在解密出 Encryption Key
后,Vault 就可以处理客户端请求了。 HTTPS API 请求进入后的整个流程都由 Vault Core
管理,Core
会强制进行 ACL 检查,并确保 Audit logging
(审计日志)完成记录。
客户端首次连接 Vault 时,需要首先完成身份认证,Vault 的 Auth Method
模块有很多的身份认证方法可选
- 用户友好的认证方法,适合管理员使用,包括:
user/password
、云服务商
、ldap
等,在创建用户的时候,需要为用户绑定Policy
,给予适合的权限 - 应用友好的方法,适合应用程序使用,包括:
public/private keys
、token
、kubernetes
、jwt
等
身份验证请求经 Core
转发给 Auth Method
进行认证,Auth Method
判定请求身份是否有效并返回关联的策略(ACL Policies
)的列表。
ACL Policies
由 Policy Store
负责管理与存储,Core
负责进行 ACL 检查,ACl 的默认行为是 Deny
,意味着除非明确配置 ACL Policy
允许某项操作,否则该操作将被拒绝。
在通过 Auth Method
进行认证,并返回了没有问题的 ACL Policies
后,Token Store
会生成并管理一个新的 Token
,这个 凭证 会返回给客户端,用于客户端后续请求的身份信息。Token
都存在一个 lease
(租期)。Token
关联了相关的 ACL Policies
,这些策略将被用于验证请求的权限。
请求经过验证后,将被路由到 Secret Engine
,如果 Secret Engine
返回了一个 secret
,Core
将其注册到 Expiration Manager
,并给它附件一个 Lease ID
,Lease ID
被客户端用于更新(renew
)或者吊销(revoke
)它得到的 secret
。如果客户端允许租约(lease
) 到期,Expiration Manager
将自动吊销(revoke
) 这个 secret
Secret Engine
Secret Engine
是保存、生成或者加密数据的组件,非常灵活。有的 Secret Engin
只是单纯的存储与读取数据,比如 kv
(键值存储)就可以看作一个加密的 Redis。而其他的 Secret Engine
则可能连接到其他的服务并按需生成动态凭证等。
yum
环境信息
- CentOS Linux release 7.9.2009 (Core)
- yum-3.4.3
yum 命令示例
查询指定命令来自哪个安装包
$ yum whatprovides ip |
rpm
查询已安装文件来自哪个安装包
$ rpm -qf /sbin/ip |
仅下载安装包而不进行安装操作
如果只下载安装包而不进行安装,可以使用 yumdownloader
命令,此命令来自安装包 yum-utils
,如果不存在可以安装 yum-utils
。
yumdownloader <package-name> |
以上下载指定的安装包而不安装,安装包会下载到当前目录
常见错误
The GPG keys listed for the “MySQL 5.7 Community Server” repository are already installed but they are not correct for this package
解决方法
修改对应 yum
源的配置文件,将其中的配置 gpgcheck=1
改为 gpgcheck=0
,以此跳过 key 验证
Prometheus 抓取 Nginx 指标
Prometheus 抓取 Nginx 运行时指标,主要有以下方法:
- Nginx 通过自己的
stub_status
页面 (需要with-http_stub_status_module
模块支持) 暴露出了一些 Nginx 运行时的指标,较为简单,在 Prometheus 中对应的 Metrics 也少。nginx_exporter
主要就是获取stub_status
中内建的指标。 - 可以通过
nginx-vts-exporter
监控 Nginx 更多的指标,但nginx-vts-exporter
依赖于 Nginx 编译安装是添加的第三方模块nginx-module-vts
来实现,指标更为丰富。建议使用此种监控方式。
环境信息
- Centos 7
- Nginx stable 1.24.0
- nginx-vts-exporter v0.10.3
- nginx-module-vts v0.2.2
安装配置 nginx-vts-exporter 和 nginx-module-vts 来监控 Nginx Metrics
Nginx 编译安装 nginx-module-vts 模块
Nginx 编译安装 `nginx-module-vts` 模块Nginx 安装了 nginx-module-vts
后,可以通过以下配置暴露运行时的指标
vhost_traffic_status_zone; |
重启 Nginx 后,访问 http://localhost:8081/status
即可查看到 Nginx 运行时的指标
安装 nginx-vts-exporter
wget https://github.com/hnlq715/nginx-vts-exporter/releases/download/v0.10.3/nginx-vts-exporter-0.10.3.linux-amd64.tar.gz |
创建 systemd
管理配置文件 /usr/lib/systemd/system/nginx-vts-exporter.service
|
启动服务,默认监听端口为 9913
systemctl enable --now nginx-vts-exporter |
浏览器访问 localhost:9913/metrics
即可看到 nginx-vts-exporter
暴露出来的 Metrics
之后 Prometheus 可通过 9913
端口抓取监控数据。
AlertManager 使用
环境信息
- AlertManager 0.24.0
部署配置 AlertManager
AlertManager 是一个专门用于实现告警的工具,可以实现接收 Prometheus 或其它应用发出的告警信息,并对这些告警信息进行 分组、抑制 以及 静默 等操作,然后通过 路由 的方式,根据不同的告警规则配置,分发到不同的告警路由策略中。 [1]
AlertManager 常用的功能主要有:
- 抑制 - 抑制是一种机制,指的是当某一告警信息发送后,可以停止由此告警引发的其它告警,避免相同的告警信息重复发送。
- 静默 - 静默也是一种机制,指的是依据设置的标签,对告警行为进行静默处理。如果 AlertManager 接收到的告警符合静默配置,则 Alertmanager 就不会发送该告警通知。
- 发送告警 - 支持配置多种告警规则,可以根据不同的路由配置,采用不同的告警方式发送告警通知。
- 告警分组 - 分组机制可以将详细的告警信息合并成一个通知。在某些情况下,如系统宕机导致大量的告警被同时触发,在这种情况下分组机制可以将这些被触发的告警信息合并为一个告警通知,从而避免一次性发送大量且属于相同问题的告警,导致无法对问题进行快速定位。
部署 AlertManager
本文部署配置基于 K8S 上安装 Prometheus 并监控 K8S 集群
在名为 prometheus-server-conf
的 ConfigMap
中为 AlertManager 创建配置文件 alertmanager.yml
,并将其挂载到 AlertManager 容器中
global: |
使用为 Prometheus 创建的 PVC 作为 AlertManager 的持久存储,参考以下配置部署 AlertManager
apiVersion: apps/v1 |
部署成功后,从 AlertManager 的域名访问,可以看到 AlertManager 的 web UI
Prometheus Federation 安装配置
如上图所示,在每个数据中心部署单独的 Prometheus Server,用于采集当前数据中心监控数据。并由一个中心的 Prometheus Server 负责聚合多个数据中心的监控数据。这一特性在 Promthues 中称为 Federation (联邦集群)。
Prometheus Federation (联邦集群)的核心在于每一个 Prometheus Server 都包含一个用于获取当前实例中监控样本的接口 /federate
。对于中心 Prometheus Server 而言,无论是从其他的 Prometheus 实例还是 Exporter 实例中获取数据实际上并没有任何差异。
以下配置示例在中心 Prometheus Server 配置其抓取其他 Prometheus Server 的指标,必须至少有一个 match
配置,以指定要抓取的目标 Prometheus Server 的 Job 名称,可以使用正则表达式匹配抓取任务
scrape_configs: |
__name__
是 Prometheus 特殊的预定义标签,表示指标的名称
使用以下配置采集目标 Prometheus Server 的所有指标
params:
'match[]':
- '{job=~".*"}'
cAdvisor 部署使用
cAdvisor 是 Goolgle 开发的用来监控容器运行指标的工具,使用 Go 语言开发。Kubelet 集成了 cAdvisor 来监控采集 Pod 中的容器的运行指标。 [1]
可以直接使用 vAdvisor 配合 Prometheus 来监控 Docker/Containerd 容器运行指标,并配合 Prometheus 及 Grafana 进行图形展示或告警
环境信息
- cAdvisor version v0.47.0 (c7714a77)
- Docker Engine - Community 20.10.9
在 host 上二进制安装部署 cAdvisor
下载二进制包,即可直接运行程序
wget https://github.com/google/cadvisor/releases/download/v0.47.0/cadvisor-v0.47.0-linux-amd64 |
运行之后,默认监听 8080
端口,启动后访问 UI : http://localhost:8080
。Prometheus 会读取 http://localhost:8080/metrics
暴露的指标。
cAdvisor metrics
在 cAdvisor
主机节点中可以使用以下命令列出收集到的指标
curl localhost:8080/metrics |
监控容器是否在运行中
cAdvisor
的指标 container_last_seen
记录了最后一次检测到容器运行时的时间 (Gauge
),如果容器停止运行,这个值会停留在最后一次观察到容器运行的时间,可以通过此指标,使用以下表达式来监控容器是否在运行
container_last_seen - container_last_seen offset 1m == 0 |
脚注
Go 部署使用
安装
执行以下命令安装 Go 环境
wget https://go.dev/dl/go1.14.15.linux-amd64.tar.gz |
执行 go
命令
$ go version |
常见错误
bad ELF interpreter
安装后执行 go
报错
-bash: /usr/local/go/bin/go: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory |
问题原因 为下载的 go
与运行的目标系统不兼容,比如下载了 x86
的安装包,安装到了 64 位的 OS 上。
Ceph 安装使用
环境信息
- Centos7 6.3.8-1.el7.elrepo.x86_64
- Python-3.10.12
- Docker-ce 20.10.9
- Ceph version 17.2.6
服务器环境信息说明
服务器 | IP | 配置 | 用途 |
---|---|---|---|
ceph-node-1 |
10.111.30.100 | centos 7 6.3.8-1 2c 3G 50G |
cephadm 节点monitor daemon |
ceph-node-2 |
10.111.30.110 | centos 7 6.3.8-1 2c 5G 50G |
|
ceph-node-3 |
10.111.30.120 | centos 7 6.3.8-1 2c 5G 50G |
安装
本文档使用 cephadm
安装 Ceph Cluster,使用 cephadm
会首先在 Ceph Cluster 的第一个节点上安装第一个 monitor daemon
,安装时 monitor daemon
必须指定和集群通信的 IP 地址。 [3]
依赖
- Python 3
- Systemd
- Docker
- Time synchronization (such as chrony or NTP)
- LVM2 for provisioning storage devices
需要提前配置好集群节点服务器的主机名,并安装 Python 3、Docker。安装集群时,会自动安装 chrony
用来做时间同步
配置节点防火墙,允许节点之间网络互通
安装 cephadm
使用 curl
安装最新版本 [1]
CEPH_RELEASE=17.2.6 |
将 cephadm
安装到主机系统,Centos 7 未提供最新版本的 repo
./cephadm add-repo --release octopus |
检查安装后的 cephadm
命令路径
$ which cephadm |
Ceph 介绍
Ceph 可以提供(实现)的存储方式包括:
- 块存储 - 提供类似普通硬盘的存储,为客户端提供硬盘
- 文件系统存储 - 分布式的共享文件系统
- 对象存储 - 提供大小无限制的云存储空间
Ceph 是一个分布式的存储系统,非常灵活,若需要扩容,只需要向集群增加节点(服务器)即可,其存储的数据采用多副本的方式进行存储,生产环境中,至少需要存 3 份副本。
Ceph 构成组件
- Monitor Daemon - Ceph Mon 维护 Ceph 存储集群映射的主副本和 Ceph 存储群集的当前状态。监控器需要高度一致性,确保对Ceph 存储集群状态达成一致。维护着展示集群状态的各种图表,包括监视器图、 OSD 图、归置组( PG )图、和 CRUSH 图。默认需要 5 个 [1]
- Mgr - 集群管理组件。默认需要 2 个。主要负责跟踪集群的运行指标及当前状态,包括存储使用率、性能指标及系统负载等。它也负责暴露基于 python 的 Ceph Web Dashboard 和 REST API。
- OSD Daemon - OSD 用于存储数据。 此外,Ceph OSD 利用 Ceph 节点的 CPU、内存和网络来执行数据复制、纠删代码、重新平衡、恢复、监控和报告功能。存储节点有几块硬盘用于存储,该节点就会有几个 osd 进程。
- MDSs - Metadata Server,为 Ceph 文件系统存储元数据
- RGW - 对象存储网关。主要为访问 ceph 的软件提供 API 接口。
参考链接
脚注
常用工具下载链接
常用工具下载目录
包含常用工具:
Xshell 7.0.0
使用参考fiddler-linux.zip
使用参考Fiddler Everywhere 4.2.1
cwrsync_6.2.4_x64_free
使用参考FileZilla_3.62.2_win64
openvpn-connect-3.3.7.2979_signed
VMware-workstation-full-17.0.0-20800274
CentOS-7-x86_64-Minimal-2207-02
Python 3.10.12 编译后的安装文件(
Python-3.10.12.installed.tar
),可以 安装依赖 后,解压直接使用HttpCanary
常用工具链接
m3u8 视频在线播放器
架构图在线绘制工具
代码或文本比对在线工具
随机密码或字符串在线生成
可以使用 shell 命令:
$ openssl rand -base64 |
具体示例,生成 8 位随机字符串
$ openssl rand -base64 8 |
域名 whois 信息在线查询
- WHOIS Lookup by ICANN ICANN 是国际域名与地址分配机构
- https://whois.chinaz.com/
查询出口 ip 地址
- https://whoer.net/zh
- https://whatismyipaddress.com/
- ip-api.com 主要用于查询 IP 地址相关信息的 API,比如地理位置、ASN、ISP 等
JSON 在线校验及格式化
证书工具
查看证书内容
查询证书和私钥是否匹配
centos 系列 rpm 包下载地址
Python3 安装
环境信息
- Centos 7 6.3.8-1.el7.elrepo.x86_64
- Python 3.10.12
编译安装步骤
安装相关依赖
yum -y groupinstall "Development tools" |
Centos 7 默认安装的 openssl
版本太低(1.0.2k-fips
),无法满足 Python 3.10.12
对 SSL 的支持,需要 首先升级 OpenSSL 版本。否则编译安装后使用 SSL 相关功能会报错: ImportError: No module named _ssl
下载安装包并编译安装。使用 --with-openssl=/usr/local/openssl/
指定新版本 openssl
位置
wget https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz |
安装完成后,安装目录为 /usr/local/python3
,要迁移到其他机器使用,可以安装相关依赖后,将安装目录拷贝到其他机器即可正常使用。此版本编译后的文件下载链接
Prometheus 和 Grafana 使用示例
环境信息
- Prometheus 2.44.0
- Grafana 9.5.2
- Kubernetes 1.24
Kubernetes
CPU
Grafana 中获取所有 node 的 CPU 使用率
以下示例中,$node
为在 Grafana 的 Dashboard 中配置的 Variables,其值为 Kubernetes 的节点主机名。$interval
为在 Grafana 的 Dashboard 中配置的 Variables,其值表示 Prometheus 的查询时间范围变量。
100 - avg(rate(node_cpu_seconds_total{mode="idle",kubernetes_io_hostname=~"$node"}[$interval])) * 100 |
Memory
Grafana 中获取所有 node 的 Memory 使用率
100 - (sum(node_memory_MemFree_bytes{kubernetes_io_hostname=~"$node"}) + sum(node_memory_Cached_bytes{kubernetes_io_hostname=~"$node"}) + sum(node_memory_Buffers_bytes{kubernetes_io_hostname=~"$node"})) / sum(node_memory_MemTotal_bytes{kubernetes_io_hostname=~"$node"}) * 100 |
Disk
Grafana 中获取所有 node 的 Disk 使用率
100 - (sum(node_filesystem_avail_bytes{kubernetes_io_hostname=~"$node"}) / sum(node_filesystem_size_bytes{kubernetes_io_hostname=~"$node"})) * 100 |
Network
统计节点物理网卡的流入流出流量
irate(node_network_receive_bytes_total{device!~"cni0|docker.*|flannel.*|veth.*|virbr.*|lo",kubernetes_io_hostname=~"$node"}[$prometheusTimeInterval]) |
Pod
计算集群中可以使用的 Pod 的数量
100 - sum(kubelet_running_pods{kubernetes_io_hostname=~"$node"}) / sum(kube_node_status_capacity{resource="pods",node=~"$node"}) * 100 |
按照 namespace 及 Pod 统计 Pod CPU 使用率
sum(rate(container_cpu_usage_seconds_total[1m])) by (namespace, pod) |
统计 Pod 使用的内存
container_memory_usage_bytes |
统计 Pods 的流量
irate(container_network_receive_bytes_total{namespace=~"$k8sNamespace",interface="eth0",kubernetes_io_hostname=~"$node"}[$prometheusTimeInterval]) |
统计 Pods 的重启次数
sum(kube_pod_container_status_restarts_total{namespace=~"$k8sNamespace"}) by (namespace,container) |
inotify 安装使用
环境信息
- Centos 7
安装
使用系统软件包管理器安装
yum install -y inotify-tools
安装后包含2个命令:
inotifywait
,inotifywatch
,较为常用的命令是inotifywait
编译安装
此处安装版本3.22.6.0
[1]wget https://github.com/inotify-tools/inotify-tools/archive/refs/tags/3.22.6.0.tar.gz
tar -xf 3.22.6.0.tar.gz
cd inotify-tools-3.22.6.0/
yum install -y dh-autoreconf
./autogen.sh && ./configure --prefix=/usr/local/inotify-tools-3.22.6.0 && make && su -c 'make install'
fswatch 安装使用
环境信息
- Centos 7
- fswatch-1.17.1
安装
Centos 7 默认安装的 gcc 版本太低,无法满足 fswatch-1.17.1 的编译配置要求,需要首先升级 gcc 版本,本示例中 gcc-8.3.0 安装位置为 /usr/local/gcc-8.3.0/
,如果系统安装的 gcc 版本符合要求,无需在 ./configure
时指定 gcc 环境变量 CXX=/usr/local/gcc-8.3.0/bin/g++
。
wget https://github.com/emcrisostomo/fswatch/archive/refs/tags/1.17.1.tar.gz |
使用
常用选项。参考文档安装 man
手册 后可以查看详细的帮助文档
fswatch
会为监控到的每条事件记录以下信息
timestamp
- 事件发生的时间戳path
- 触发事件的文件(夹)路径event types
- 空格分割的事件类型
选项 | 说明 | 示例 |
---|---|---|
-0, --print0 |
ASCII NUL character (\0 ) as line separatorSince file names can potentially contain any character but NUL , this option assures that the output of fswatch can be safely parsed using NUL as delimiter, such as using xargs -0 and the shell builtin read -d '' . |
使用示例 |
-1, --one-event |
Exit fswatch after the first set of events is received | |
--event name |
can be used multiple times | |
-e, --exclude regexp |
Exclude paths matching regexp, Multiple exclude filters can be specified using this option multiple times | |
-i, --include regexp |
Include paths matching regexp | |
-f, --format-time format |
Print the event time using the specified format | |
-I, --insensitive |
Use case insensitive regular expressions | |
-m, --monitor name |
Uses the monitor specified by name 可用的 monitor: - inotify_monitor - poll_monitor |
|
-r, --recursive |
Watch subdirectories recursively | |
-t, --timestamp |
Print the event timestamp. | |
-u, --utf-time |
Print the event time in UTC format. When this option is not specified, the time is printed using the system local time, as defined by localtime | |
-l, --latency latency |
监听间隔,默认1s |
常用事件
事件 | 说明 | 示例 |
---|---|---|
NoOp |
Idle event, optionally issued when no changes were detected | |
Created |
The object has been created. | |
Updated |
The object has been updated. The kind of update is monitor-dependent. | |
Removed |
The object has been removed. | |
Renamed |
The object has been renamed. | |
OwnerModified |
The object’s owner has changed. | |
AttributeModified |
An object’s attribute has changed. | |
MovedFrom |
The object has moved from this location to a new location of the same file system. | |
MovedTo |
The object has moved from another location in the same file system into this location. | |
IsFile |
The object is a regular file. | |
IsDir |
The object is a directory. | |
IsSymLink |
The object is a symbolic link. | |
Link |
The object link count has changed. | |
Overflow |
The monitor has overflowed. |
使用示例
输出事件的行分隔符
以下示例中监视文件 nohup.out
,输出事件的每一行使用 \0
分割,read
读取时也使用 \0
(""
) 分割,可以防止文件名中包含了空格,使用 read
时读取文件名不全。
$ fswatch -0 nohup.out | while read -d "" file; do echo ${file}; done |
使用 xargs 处理监听事件
$ fswatch -0 [opts] [paths] | xargs -0 -n 1 -I {} [command] |
fswatch -0
will split records using the NUL character.xargs -0
will split records using the NUL character. This is required to correctly match impedance with fswatch.xargs -n 1
will invoke command every record. If you want to do it every x records, then use xargs -n x.xargs -I {}
will substitute occurrences of {} in command with the parsed argument. If the command you are running
does not need the event path name, just delete this option. If you prefer using another replacement string, substi‐
tute {} with yours.
以下示例监视文件变化后进行备份
fswatch -0 nohup.out | xargs -0 -I {} cp {} {}.`date +%Y%m%d%H%M%S` |
以上命令中
date +%Y%m%d%H%M%S
只会被计算一次,假如第一次执行时date +%Y%m%d%H%M%S
=nohup.out.20230609132143
,那么之后每次触发xargs
,变量date +%Y%m%d%H%M%S
的值都是nohup.out.20230609132143
,不会被重新计算
常见问题
Event queue overflow
执行以下命令,过一段时间后会输出 Event queue overflow
$ fswatch -0 nohup.out | xargs -0 -I {} cp {} {}.`date +%Y%m%d%H%M%S` |
解决方法 可以选择以下之一。
使用
poll_monitor
monitor 而不是默认的inotify_monitor
fswatch -0 --monitor=poll_monitor nohup.out | xargs -0 -I {} cp {} {}.`date +%Y%m%d%H%M%S`
此限制是因为内核参数限制,主要参数
fs.inotify.max_queued_events
[1]查看内核参数
fs.inotify.max_queued_events
的值,默认值为 16384$ sysctl fs.inotify.max_queued_events
fs.inotify.max_queued_events = 16384修改默认值后,重新测试,结果正常
$ sysctl fs.inotify.max_queued_events=1000000
fs.inotify.max_queued_events = 1000000
$ sysctl fs.inotify.max_queued_events
fs.inotify.max_queued_events = 1000000永久修改此参数的值,可以将其写入内核配置文件
/etc/sysctl.conf
脚注
lftp 使用
环境信息
- Centos 7
lftp 安装
yum install -y lftp |
常见用法
查看帮助信息
$ lftp -h |
登陆 FTP
命令格式
lftp ${USER}:${PASSWORD}@${FTPIP}:${FTPPORT} |
上传文件
在一条 shell 命令中执行登陆、上传、退出操作
lftp -u ${USER},${PASSWORD} -p ${FTPPORT} ${FTPIP} -e "put /1.mp4 && exit" |
腾讯云相关配置
Python SDK
安装
pip install tencentcloud-sdk-python-intl-en |
预热功能
import json |