260311-openclaw-cn部署和使用

openclaw-cn

1
2
3
4
5
6
7
PNPM_HOME
pnpm config set global-bin-dir "C:\Users\Administrator\pnpm"

openclaw-cn@latest
npm config set registry https://registry.npmmirror.com/

pnpm add -g openclaw-cn@latest --registry=https://registry.npmmirror.com

配置参数

1
2
3
4
5
openclaw-cn onboard --install-daemon

安装引导完成。仪表盘已使用您的令牌打开;保留该标签页以控制Clawdbot

openclaw-cn gateway --port 18789

Ollama模型配置

1
2
3
4
5
6
7
8
9
10
# 推荐,约4.7GB
ollama pull qwen2.5:7b

echo FROM qwen2.5:7b > Modelfile
echo PARAMETER num_ctx 32768 >> Modelfile

ollama create qwen2.5:7b-32k -f ./Modelfile

# 查看模型列表,确认新模型已出现
ollama list

OpenClaw对接Ollama配置

  1. 按提示进行配置:在向导中,当问到模型提供商时,请严格按照下表进行选择和填写:
配置项 操作/选择 说明
Model/auth provider Custom Provider 选择自定义提供商,拉到列表最底部即可找到。
API Base URL http://127.0.0.1:11434/v1 这是Ollama服务的默认本地地址,末尾的 /v1 必须保留
API Key 任意字符 (如 ollama) Ollama本地服务不验证密钥,但不能留空,随便填一个即可。
Endpoint compatibility OpenAI-compatible 选择与OpenAI兼容的模式,这是Ollama支持的接口类型。
Model ID qwen2.5:7b-32k 输入我们刚刚在Ollama中创建的模型名称,必须完全一致。

配置完成后,如果看到 “Verification successful” 的提示,就说明OpenClaw已成功连接到本地的Ollama模型了。同时,命令行会显示Web
UI的地址(通常是 http://127.0.0.1:18789)和一个访问Token,

1
2
3
4
5
6
7
8
9
Custom Provider

http://127.0.0.1:11434/v1

ollama

OpenAI-compatible

qwen2.5:7b-32k

结合你之前的步骤,你已经有了本地Ollama模型。如果想体验混合架构,可以参考这个思路:

  1. 添加云端模型:通过 openclaw onboard 命令或OpenClaw的Web界面,再次进入模型配置向导。这次选择另一个提供商,比如OpenAIClaude或国内的阿里云百炼,并填入你的云端API Key。
  2. 切换使用:配置好后,你就可以在对话中通过指令或界面下拉菜单,自由选择是用本地模型处理文件,还是调用云端模型进行复杂创作了。

Qwen大模型配置参数

1
2
3
https://dashscope.aliyuncs.com/compatible-mode/v1

qwen3.5-plus

260310-openclaw部署和使用

必需环境

  • Node.js ≥ 22.0.0

  • npm ≥ 10.0.0(或 pnpm ≥ 8.0.0)

安装NodeJs

1

配置npm 或者 pnpm 仓库源

1
2
3
4
5
# 如果还没有安装 pnpm
npm install -g pnpm

# 安装 OpenClaw
pnpm add -g openclaw@latest

安装openclaw

1
2
3
npm install -g openclaw@latest

openclaw --version

启动配置向导

1
2
3
4
openclaw onboard --install-daemon

# 启动 Gateway 控制平面
openclaw gateway --port 18789 --verbose

在终端执行以下命令:

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
openclaw onboard --install-daemon

? 选择 AI 模型供应商:
❯ MiniMax M2.5(CN) - 国内可用,中文支持好
Kimi - 月之暗面,长文本处理强
DeepSeek - 推理能力强,代码能力出色
Claude - Anthropic 出品(需国际网络)
OpenAI GPT - 经典选择(需国际网络)
Gemini - Google 出品(需国际网络)
Ollama - 本地模型,完全离线


? 输入 API Key: [粘贴你的 API Key]
✓ 正在验证 API Key...
✓ 认证成功!


? 是否现在配置 Channel(渠道)?
❯ 跳过,稍后配置

? 是否现在安装 Skills(技能)?
❯ 跳过,稍后安装

? 是否现在配置 Hooks(钩子)?
❯ 跳过,稍后配置

常用命令

管理命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 打开 Web Dashboard
openclaw dashboard

# 启动 Gateway 控制平面
openclaw gateway --port 18789 --verbose

# 查看运行状态
openclaw status

# 查看日志
openclaw logs

# 运行诊断工具
openclaw doctor

# 停止所有服务
openclaw stop

Agent 命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 与助手对话
openclaw agent --message "你好" --thinking high

# 发送消息到指定渠道
openclaw message send --to +1234567890 --message "Hello from OpenClaw"

# 列出所有 Agent
openclaw agents list

# 添加新 Agent
openclaw agents add <agent-name>

# 编辑 Agent 配置
openclaw agents edit <agent-name>

Channel 命令

1
2
3
4
5
6
7
8
9
10
11
# 列出所有渠道
openclaw channels list

# 添加新渠道
openclaw channels add

# 删除渠道
openclaw channels remove <channel-name>

# 重启渠道
openclaw channels restart <channel-name>

Skill 命令

1
2
3
4
5
6
7
8
9
10
11
# 列出已安装的技能
openclaw skills list

# 搜索技能(需要先安装 clawhub)
clawhub search <关键词>

# 安装技能
clawhub install <skill-name>

# 卸载技能
openclaw skills uninstall <skill-name>

Plugin 命令

1
2
3
4
5
6
7
8
# 列出所有插件
openclaw plugins list

# 启用插件
openclaw plugins enable <plugin-name>

# 禁用插件
openclaw plugins disable <plugin-name>

更新命令

1
2
3
4
5
6
7
# 更新到最新稳定版
openclaw update

# 切换版本通道
openclaw update --channel stable # 稳定版
openclaw update --channel beta # 测试版
openclaw update --channel dev # 开发版

部署QWen自定义大模型参数

1
2
https://dashscope.aliyuncs.com/compatible-mode/v1
qwen3.5-plus

260309-Virtualbox主机和虚拟机之间文件夹共享及双向拷贝(Windows<->Windows, Windows<->Linux)

记录下,Virtualbox下如何实现主机和虚拟机之间文件夹共享及双向拷贝
关于双向拷贝
1.设置虚拟机为“双向”共享粘贴

有的人反应只要设置双向粘贴就可以,但是我的不行,我还需要再给虚拟机安装一下增强功能。需要启动虚拟机,安装菜单项“设备”中的最后一项。

安装完增强功能,注意要重启虚拟机,双向拷贝才被启用。

关于文件夹共享
情况一:
Host操作系统:Windows 7
Guest操作系统:Windows Server
1.首先设置共享文件夹

2.虚拟机中的菜单项中,设备 - 分配光驱 – 选择一个虚拟光盘。在弹出的对话框选择 VirtualBox 安装目录下选择
VBoxGuestAdditions.iso
3.虚拟机中的光驱,运行VBoxWindowsAdditions.exe,安装完成后,重启虚拟机中的系统,就能看到主机中的共享目录了。


情况二:
Host操作系统:Windows 7
Guest操作系统:Oracle Linux

和情况一一样先设置共享目录。
然后在Linux虚拟机上边的菜单中,设备->安装增强功能。

出现VBOXADDITIONS,然后运行此软件

可以看到共享文件夹了

挂在这个目录到Linux本地目录。
首先创建一个文件夹
mkdir /home/share
改为可读可写
cd /home/share
chmod 777 .

运行命令加载
sudo mount -t vboxsf -o uid=1000,gid=1000 Share /home/share
红色Share为VirtualBox共享目录的名字

蓝色的/home/share为刚刚创建的目标目录。

260227-Linux-pid-proc(exe & cwd & fd & cmdline)查找文件位置

sudo netstat -tulnp | grep :<端口号>

  • -t:TCP 端口
  • -u:UDP 端口
  • -l:仅显示监听套接字
  • -n:不解析服务名(直接显示端口号)
  • -p:显示进程 PID 和名称

根据 PID 查找相关文件位置

有了 PID,就可以查看该进程的详细信息:

1️⃣ 找到进程的可执行文件路径

1
ls -l /proc/<PID>/exe

示例:ls -l /proc/12345/exe 会显示指向实际可执行文件的符号链接。

2️⃣ 找到进程的当前工作目录

1
pwdx <PID>

或者:

1
readlink /proc/<PID>/cwd

3️⃣ 查看进程打开的所有文件(包括配置文件、日志文件等)

1
ls -l /proc/<PID>/fd/

这列出了该进程打开的所有文件描述符,通过符号链接可以看到实际的文件路径。

4️⃣ 查看进程的完整命令行参数(可能包含配置文件路径)

1
2
3
ps -ef | grep <PID>
# 或者
cat /proc/<PID>/cmdline | tr '\0' ' '

cmdline 文件以 \0 分隔参数,用 tr 转换为空格以便阅读。

5️⃣ 如果进程是一个服务(systemd 管理的),可以查看其单元文件

1
2
systemctl status <服务名>   # 先找到服务名
systemctl cat <服务名> # 查看服务配置文件,其中可能包含 ExecStart 等路径

260225-git config --global全局配置参数

先配置好参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
git config --global user.email "css@110.com"
git config --global user.name "css"

git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999
git config --global http.postBuffer 524288000
git config --global fetch.parallel 10

git config --global http.timeout 300
git config --global fetch.timeout 300
git config --global ssh.connectTimeout 300

git config --global http.postBuffer 524288000
git config --global core.packedGitWindowSize 128m
git config --global core.packedGitLimit 128m
git config --global core.compression 0
git config --global http.timeout 300
git config --global fetch.timeout 300
git config --global http.keepAlive false

Git Clone Depth=1

1
2
3
4
5
6
# 浅克隆(--depth=1 仅拉取最新提交)
git clone --depth=1 https://github.com/xxx/xxx.git

# 若需要完整历史,克隆后补全
cd xxx
git fetch --unshallow

配置参数中文描述

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
git config --global user.email "xx@qq.com"
git config --global user.name "xx"

git config --list # 查看配置的信息

# 设置低速超时时间为999999秒(几乎不超时)
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999

# 设置HTTP缓冲区大小为500MB(默认通常较小)
git config --global http.postBuffer 524288000

# 设置压缩级别(0-9,0是不压缩,9是最大压缩)
git config --global core.compression 0

# 设置并行下载数量-启用并行下载(同时下载多个对象)
git config --global fetch.parallel 10

# 设置连接超时(单位:秒,建议设为300)
git config --global http.timeout 300
# 设置拉取/推送超时
git config --global fetch.timeout 300
# 设置SSH连接超时(若用SSH协议)
git config --global ssh.connectTimeout 300

# 浅克隆(--depth=1 仅拉取最新提交)
git clone --depth=1 https://github.com/xxx/xxx.git
# 若需要完整历史,克隆后补全
cd xxx
git fetch --unshallow

未确认配置参数

1
2
3
4
5
6
7
8
9
10
11

git config --global core.autocrlf input #自动转换坑太大,提交到git是自动将换行符转换为lf

#拒绝提交包含混合换行符的文件
git config --global core.safecrlf true

#允许提交包含混合换行符的文件
git config --global core.safecrlf false

#提交包含混合换行符的文件时给出警告
git config --global core.safecrlf warn

260210-mongodb(copyDatabase) show database 如何调整数据库名称

在 MongoDB 中,没有直接的 plain复制 rename database 命令

copydatabase()已过期
copydatabase()已过期
copydatabase()已过期

方法1:使用plain复制mongodump和plain复制mongorestore(适合大型数据库)

1
2
3
4
5
6
7
8
9
10
# 1. 导出旧数据库
mongodump --db old_db_name --out /backup/path/

# 2. 导入为新数据库名
mongorestore --db new_db_name /backup/path/old_db_name/

# 3. 删除旧数据库(通过 mongo shell)
mongo
> use old_db_name
> db.dropDatabase()

方法2:使用plain复制mongosh的聚合管道(MongoDB 4.2+)

1
2
3
4
5
6
7
// 遍历所有集合并复制
use
old_db_name

db.getCollectionNames().forEach(function (coll) {
db[coll].aggregate([{$out: {db: "new_db_name", coll: coll}}]);
});

⚠️ 注意事项

项目 说明
索引 复制后需要重新创建索引
用户权限 数据库用户不会自动复制,需手动创建
磁盘空间 确保有足够空间存储两份数据
生产环境 建议在维护窗口操作,或先备份

快速检查命令

1
2
3
4
5
6
7
8
9
10
// 查看所有数据库
show
dbs

// 查看当前数据库
db.getName()

// 切换数据库
use
database_name

**推荐在生产环境使用 plain复制 mongodump/mongorestore**,更加稳定可靠,且可以验证数据完整性。

260210-MongoDBHA-MongoDB集群-重置绑定关系-(Replica Set)副本集集群搭建

这是一个涉及数据库运维的操作,需要谨慎处理。

MongoDB 集群配置删除与重新绑定

1. 理解 MongoDB 集群配置存储位置

MongoDB 集群配置主要存储在 Config Servers 中:

  • Config Database (plain复制 config): 包含分片集群的元数据
  • Local Database: 每个节点存储的副本集配置

2. 删除集群配置的方法

场景 A: 完全重置分片集群

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
# 1. 停止所有 mongos 路由进程
killall mongos # 或使用 systemctl stop mongos

# 2. 停止所有分片 mongod 实例
# 在每个分片节点上执行
killall mongod

# 3. 停止 Config Server 副本集
# 在所有 config server 节点上执行
killall mongod

# 4. 清除 Config Server 数据目录(⚠️ 危险操作)
# 假设数据目录为 /data/configdb
rm -rf /data/configdb/*

# 5. 重新初始化 Config Server 副本集
mongod --configsvr --replSet configRS --dbpath /data/configdb --port 27019

# 连接主节点初始化
rs.initiate({
_id: "configRS",
configsvr: true,
members: [
{ _id: 0, host: "cfg1.example.com:27019" },
{ _id: 1, host: "cfg2.example.com:27019" },
{ _id: 2, host: "cfg3.example.com:27019" }
]
})

场景 B: 仅移除分片(保留集群框架)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 连接到 mongos
mongo--
host
mongos.example.com--
port
27017

// 1. 查看当前分片
sh.status()

// 2. 移除分片(会迁移数据)
use
admin
db.runCommand({removeShard: "shard0000"})

// 3. 检查移除进度,直到状态为 "completed"
db.runCommand({removeShard: "shard0000"})

// 4. 如果需要强制移除(数据已备份)
db.runCommand({removeShard: "shard0000", drop: true})

场景 C: 重置副本集配置(非分片集群)

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
// 连接到副本集成员
mongo--
host
mongod.example.com--
port
27017

// 1. 查看当前配置
rs.conf()

// 2. 强制重新配置(适用于节点变更)
rs.reconfig({
_id: "myReplicaSet",
members: [
{_id: 0, host: "newhost1:27017"},
{_id: 1, host: "newhost2:27017"},
{_id: 2, host: "newhost3:27017"}
]
}, {force: true}) // force: true 用于强制重新配置

// 3. 或者完全重置(先删除 local 数据库的配置)
use
local
db.system.replset.remove({}) // ⚠️ 仅在确定要重置时执行
// 然后重启 mongod,重新执行 rs.initiate()

3. 重新绑定新配置

步骤 1: 重新配置 Config Server

1
2
3
4
5
6
7
8
9
10
// 初始化新的 Config Server 副本集
rs.initiate({
_id: "configRS",
configsvr: true,
members: [
{_id: 0, host: "new-cfg1:27019", priority: 2},
{_id: 1, host: "new-cfg2:27019"},
{_id: 2, host: "new-cfg3:27019", arbiterOnly: true}
]
})

步骤 2: 启动 mongos 并配置分片

1
2
# 启动 mongos,指向新的 config server
mongos --configdb configRS/new-cfg1:27019,new-cfg2:27019,new-cfg3:27019 --port 27017
1
2
3
4
5
6
7
8
9
// 连接到 mongos 添加分片
sh.addShard("shardRS1/shard1-node1:27018,shard1-node2:27018")
sh.addShard("shardRS2/shard2-node1:27018,shard2-node2:27018")

// 启用数据库分片
sh.enableSharding("myDatabase")

// 对集合进行分片
sh.shardCollection("myDatabase.myCollection", {shardKey: 1})

4. 关键注意事项

操作 风险等级 说明
删除 Config Server 数据 🔴 极高 会丢失所有分片元数据
强制 rs.reconfig 🟡 中等 可能导致脑裂
removeShard 🟢 较低 数据会自动迁移
停止 mongos 🟢 低 仅影响路由,不丢数据

5. 安全操作建议

1
2
3
4
# 操作前务必备份
mongodump --host configRS/cfg1:27019 --db config --out /backup/config_$(date +%Y%m%d)

# 或者使用文件系统快照(如果使用 WiredTiger)

6. 常见问题排查

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// 检查 Config Server 状态
use
admin
db.runCommand({getShardMap: 1})

// 查看分片连接状态
sh.status()

// 检查 balancer 状态
sh.getBalancerState()

// 如果配置不一致,强制刷新
use
admin
db.adminCommand({flushRouterConfig: 1})

⚠️ 重要提醒

  • 在生产环境执行前,务必在测试环境验证
  • 确保有完整的数据备份
  • 操作期间会有服务中断,选择维护窗口执行
  • 如果是云托管 MongoDB (Atlas),请使用提供商的控制台操作,不要手动修改

2602-(perfmon.msc)Windows定位和排查CPU占用高进程问题

perfmon.msc(定位CPU问题)

perfmon.msc(性能监视器)定位 Windows CPU 问题,核心是通过添加关键计数器实时监控 / 日志分析,先判断 CPU
瓶颈类型,再定位到进程 / 线程,最后结合 JDK 工具深挖 Java 问题,以下是精准可落地的完整流程

二、添加 CPU 核心计数器(必选)

这是判断 CPU 瓶颈的核心步骤,优先添加以下计数器,覆盖整体、用户 / 内核、进程、线程与中断维度:

计数器路径 作用 正常阈值 异常判断
\Processor(*)% Processor Time 整体 CPU 使用率(* 含所有核心,_Total 为总和) < 70% 持续 > 80% 为瓶颈,>90% 严重
\Processor(*)% User Time 用户态 CPU(如 Java 应用) < 50% 持续 > 80% 多为应用代码问题
\Processor(*)% Privileged Time 内核态 CPU(如驱动、系统调用) < 30% 持续 > 50% 多为驱动 / 系统服务问题
\Process(*)% Processor Time 单个进程 CPU 占用(筛选 java.exe/javaw.exe) 占比高的进程优先排查
\Thread(*)% Processor Time 单个线程 CPU 占用(需指定进程 PID) 定位进程内高 CPU 线程
\System\Processor Queue Length CPU 等待队列长度 每核心 < 2 持续 > 2 且 CPU 高,说明调度拥堵
\Processor(*)% Interrupt Time 中断占用时间 < 5% 持续 > 10% 多为硬件 / 驱动问题

添加操作步骤

  1. 右键性能监视器图表→「添加计数器」;
  2. 在弹出窗口中,依次展开上述计数器类别,选中目标计数器→「添加」→「确定」;
  3. 若需监控特定 Java 进程,在 \Process 类别中筛选 PID 对应的 java.exe/javaw.exe。

通过arthas thread -n 5 指定进程PID查看

1
2
3
4
5
6
7
8
9
10
11
12
"flow-execute290488" Id=930149 cpuUsage=46.42% deltaTime=93ms time=31828ms RUNNABLE
at com.oracle.truffle.api.library.LibraryFactory.dispatch(LibraryFactory.java:548)
at com.oracle.truffle.api.library.LibraryFactory.getUncached(LibraryFactory.java:396)
at com.oracle.truffle.api.interop.InteropLibraryGen$UncachedDispatch.getArraySize(InteropLibraryGen.java:7348)
at com.oracle.truffle.host.HostProxy.getMembers(HostProxy.java:271)
at com.oracle.truffle.host.HostProxyGen$InteropLibraryExports$Cached.getMembers(HostProxyGen.java:941)
at com.oracle.truffle.api.interop.InteropLibrary.getMembers(InteropLibrary.java:734)
at com.oracle.truffle.polyglot.PolyglotMap$Cache$EntrySet.doCached(PolyglotMap.java:589)
at com.oracle.truffle.polyglot.PolyglotMapFactory$CacheFactory$EntrySetNodeGen.executeImpl(PolyglotMapFactory.java:323)
at com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:124)
at com.oracle.truffle.api.impl.DefaultCallTarget.call(DefaultCallTarget.java:118)
at com.oracle.truffle.polyglot.PolyglotMap.entrySet(PolyglotMap.java:131)