> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-zh/jia-mi-huo-bi-yu-wa-kuang/xmrig.md).

# XMRig 挖矿

在 Clore.ai 的 GPU 和 CPU 服务器上使用 XMRig 挖掘门罗币（XMR）和其他加密货币。

{% hint style="info" %}
**XMRig** 是使用最广泛的开源加密货币挖矿程序。它支持 CPU 挖矿（门罗币的 RandomX 算法）和 GPU 挖矿（KawPow、Ethash 等）。本指南介绍在 Clore.ai 服务器上的部署。
{% endhint %}

{% hint style="warning" %}
**开始前**：在挖矿前务必计算收益。把 Clore.ai 的租用成本、矿池费用和当前币价都考虑进去。使用挖矿收益计算器，确保你能获得正收益。
{% endhint %}

***

## 什么是 XMRig？

XMRig 是一款面向 CPU 和 GPU 的高性能跨平台挖矿程序：

| 功能             | 详情                                             |
| -------------- | ---------------------------------------------- |
| **CPU 挖矿**     | 通过 RandomX 挖掘门罗币（XMR）——最佳使用场景                  |
| **GPU 挖矿**     | KawPow（RVN）、Ethash 变体、Octopus                  |
| **算法**         | RandomX、KawPow、Ethash、Autolykos2、Octopus 等更多算法 |
| **Stratum V2** | 现代矿池协议支持                                       |
| **TLS 支持**     | 加密的矿池连接                                        |
| **许可证**        | GPL 3.0，开源                                     |

### 为什么选择 Clore.ai 运行 XMRig？

* **高核心数 CPU**：Clore.ai 服务器通常有 32-128 个 CPU 核心——非常适合 RandomX
* **现货价格**：在低峰时段以更低价格租用
* **无需硬件投入**：无需购买和维护硬件即可挖矿
* **灵活性**：根据收益切换算法或币种

***

## 先检查收益

{% hint style="danger" %}
**在租用成本上花一分钱之前先做这件事！**

挖矿收益每天都在变化。开始前务必核实。
{% endhint %}

### 收益计算器

* [minerstat.com/calc](https://minerstat.com/calc) ——多算法
* [whattomine.com](https://whattomine.com) ——综合
* [xmrig.com/docs/algorithms](https://xmrig.com/docs/algorithms) ——算力参考

### 快速计算

```
每日利润 =（每日收益，美元）-（每日租用成本）

示例（门罗币，32 核服务器）：
- 算力：约 32,000 H/s（每核心 1,000 H/s）
- 每日 XMR 收益：约 0.001-0.003 XMR/天
- XMR 价格（示例）：$160
- 每日收入：$0.16-0.48
- 服务器租用（32 核，约 $0.20/小时）：$4.80/天

结果：亏损。高核心数服务器通常不适合独立挖矿。

更好的做法：寻找租金低于每日收益的低价高核心数服务器
```

{% hint style="success" %}
**在什么情况下有意义**：当你找到一台 64 核以上、价格为 $0.05-0.10/小时的服务器，或在适合 GPU 挖矿的币种上以低现货价格租到 GPU 服务器时，就有意义。务必先计算！
{% endhint %}

***

## 前提条件

| 要求          | 详情                                |
| ----------- | --------------------------------- |
| Clore.ai 账户 | 使用 CLORE 余额                       |
| 矿池账户        | 在 supportXMR.com、MoneroOcean 等处创建 |
| 门罗币钱包       | 在 getmonero.org 下载（用于 XMR 挖矿）     |
| SSH 访问      | 端口 22                             |

### 创建门罗币钱包

```bash
# 选项 1：CLI 钱包
wget https://downloads.getmonero.org/cli/linux64
tar xzf monero-linux-x64-*.tar.bz2
./monero-x86_64-linux-gnu-v*/monero-wallet-cli --generate-new-wallet mywallet

# 选项 2：GUI 钱包（本地机器）
# 下载地址：https://www.getmonero.org/downloads/
```

保存你的钱包地址——格式类似：

```
43xxxx...long string...xxxx
```

***

## 步骤 1：租用服务器

### 用于 CPU 挖矿（门罗币/RandomX）

1. 前往 [clore.ai](https://clore.ai) → **市场**
2. 筛选条件 **CPU 核心**：优先选择 32 核以上
3. 寻找 CPU 线程数高的服务器
4. 端口 **22** 就足够了
5. 订购服务器

### 用于 GPU 挖矿（KawPow、Octopus）

1. 筛选条件 **GPU**：RTX 3080+、RTX 4090 可获得最佳性能
2. 所需端口： **22** 仅
3. 仅 NVIDIA GPU 支持 CUDA 挖矿

{% hint style="info" %}
**Clore.ai 上的 CPU 与 GPU**：Clore.ai 主要是一个 GPU 市场。对于门罗币（RandomX），专用 CPU 服务器可能更便宜。对于可用 GPU 挖矿的币种，NVIDIA 服务器性能更好。
{% endhint %}

***

## 步骤 2：通过 Docker 部署 XMRig

### 自定义 Dockerfile

创建一个 `Dockerfile` 在服务器上：

```dockerfile
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# 安装依赖
RUN apt-get update && apt-get install -y \
    wget \
    libssl-dev \
    libhwloc-dev \
    libuv1-dev \
    build-essential \
    cmake \
    git \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /opt/xmrig

# 下载 XMRig 发布包
RUN wget https://github.com/xmrig/xmrig/releases/download/v6.21.3/xmrig-6.21.3-linux-static-x64.tar.gz \
    && tar xzf xmrig-*.tar.gz \
    && mv xmrig-*/xmrig . \
    && rm -rf xmrig-*.tar.gz xmrig-*/

# 创建配置目录
RUN mkdir -p /etc/xmrig

ENTRYPOINT ["/opt/xmrig/xmrig"]
```

### 构建镜像

```bash
docker build -t xmrig-miner .
```

### 运行 CPU 挖矿（门罗币）

```bash
docker run -d \\
  --name xmrig-cpu \
  --restart unless-stopped \
  --privileged \
  xmrig-miner \
  -o pool.supportxmr.com:443 \
  -u YOUR_MONERO_WALLET_ADDRESS \
  -p worker1 \
  -k \
  --tls \
  --cpu-max-threads-hint=100 \
  --log-file=/var/log/xmrig.log
```

### 运行 GPU 挖矿（KawPow - Ravencoin）

```bash
docker run -d \\
  --name xmrig-gpu \
  --restart unless-stopped \
  --gpus all \\
  xmrig-miner \
  -a kawpow \
  -o rvn.2miners.com:6060 \
  -u YOUR_RVN_WALLET.worker1 \
  --log-file=/var/log/xmrig.log
```

***

## 步骤 3：配置文件方法

使用配置文件比命令行参数更简洁。

### 创建 `config.json`

```json
{
    "autosave": true,
    "background": false,
    "colors": true,
    "title": true,
    "api": {
        "id": null,
        "worker-id": "clore-worker-1",
        "port": 9090,
        "access-token": null,
        "restricted": true
    },
    "http": {
        "enabled": true,
        "host": "0.0.0.0",
        "port": 9090,
        "access-token": null,
        "restricted": true
    },
    "randomx": {
        "init": -1,
        "init-avx2": -1,
        "mode": "auto",
        "1gb-pages": false,
        "rdmsr": true,
        "wrmsr": true,
        "cache_qos": false,
        "numa": true,
        "scratchpad_prefetch_mode": 1
    },
    "cpu": {
        "enabled": true,
        "huge-pages": true,
        "huge-pages-jit": false,
        "hw-aes": null,
        "priority": null,
        "memory-pool": false,
        "yield": true,
        "max-threads-hint": 100,
        "asm": true,
        "argon2-impl": null,
        "astrobwt-max-size": 550,
        "astrobwt-avx2": false
    },
    "opencl": {
        "enabled": false,
        "cache": true,
        "loader": null,
        "platform": "AMD"
    },
    "cuda": {
        "enabled": true,
        "loader": null,
        "nvml": true
    },
    "log-file": null,
    "donate-level": 1,
    "donate-over-proxy": 1,
    "pools": [
        {
            "algo": null,
            "coin": "XMR",
            "url": "pool.supportxmr.com:443",
            "user": "YOUR_MONERO_WALLET_ADDRESS",
            "pass": "worker1",
            "rig-id": null,
            "nicehash": false,
            "keepalive": true,
            "enabled": true,
            "tls": true,
            "tls-fingerprint": null,
            "daemon": false,
            "socks5": null,
            "self-select": null,
            "submit-to-origin": false
        }
    ],
    "print-time": 60,
    "health-print-time": 60,
    "dmi": true,
    "retries": 5,
    "retry-pause": 5,
    "syslog": false,
    "tls": {
        "enabled": false,
        "protocols": null,
        "cert": null,
        "cert_key": null,
        "ciphers": null,
        "ciphersuites": null,
        "dhparam": null
    },
    "dns": {
        "ipv6": false,
        "ttl": 30
    },
    "user-agent": null,
    "verbose": 0,
    "watch": true
}
```

替换 `YOUR_MONERO_WALLET_ADDRESS` 并替换为你的实际钱包地址。

### 使用配置文件运行

```bash
docker run -d \\
  --name xmrig \
  --restart unless-stopped \
  --privileged \
  -v $(pwd)/config.json:/etc/xmrig/config.json \
  xmrig-miner \
  --config=/etc/xmrig/config.json
```

***

## 步骤 4：启用大页（性能提升）

RandomX 从 1GB 大页中获益显著。在主机上启用：

```bash
# 启用大页（在 Clore.ai 服务器上以 root 身份运行）
echo 1 > /proc/sys/vm/nr_hugepages

# 对于 1GB 大页（如果 CPU 支持）
mkdir -p /mnt/hugepages-1g
mount -t hugetlbfs -o pagesize=1G none /mnt/hugepages-1g
echo 4 > /proc/sys/vm/nr_hugepages

# 使其持久化
echo "vm.nr_hugepages = 128" >> /etc/sysctl.conf
sysctl -p
```

{% hint style="info" %}
**性能影响**：大页在某些 CPU 上可使门罗币算力提升 20-50%。如果你能访问主机系统，值得启用。
{% endhint %}

***

## 步骤 5：监控挖矿

### 检查容器状态

```bash
# 查看实时日志
docker logs xmrig -f

# 通过 API 检查统计信息
curl http://localhost:9090/2/summary | python3 -m json.tool
```

### 示例日志输出

```
[2024-03-01 10:15:23.456]  miner    speed 10s/60s/15m 31.2k 31.4k 31.1k H/s max 32.1k H/s
[2024-03-01 10:15:30.123]  net      accepted (1/0) diff 200001 (123 ms)
[2024-03-01 10:16:00.789]  miner    speed 10s/60s/15m 31.5k 31.3k 31.2k H/s max 32.1k H/s
```

### 需要关注的关键指标

| 指标      | 含义          |
| ------- | ----------- |
| H/s（算力） | 挖矿速度——越高越好  |
| 已接受份额   | 提交到矿池的有效工作  |
| 被拒绝份额   | 无效工作——应接近 0 |
| 延迟      | 矿池连接速度      |

### 矿池仪表板

在你的矿池网站上查看进度：

* **SupportXMR**: `https://supportxmr.com/#/dashboard?wallet=YOUR_ADDRESS`
* **MoneroOcean**: `https://moneroocean.stream/#/dashboard?wallet=YOUR_ADDRESS`
* **2Miners**: `https://xmr.2miners.com/account/YOUR_ADDRESS`

***

## 热门矿池

### 门罗币（XMR）矿池

| 矿池          | 网址                          | 手续费  | 最低支付      |
| ----------- | --------------------------- | ---- | --------- |
| SupportXMR  | pool.supportxmr.com:443     | 0.6% | 0.1 XMR   |
| MoneroOcean | gulf.moneroocean.stream:443 | 0%   | 0.003 XMR |
| XMRig 矿池    | pool.xmrig.com:443          | 1%   | 0.01 XMR  |
| MineXMR     | pool.minexmr.com:4444       | 1%   | 0.004 XMR |

### 可用 GPU 挖矿的币种

| 币种                    | 算法         | 矿池示例                 |
| --------------------- | ---------- | -------------------- |
| Ravencoin（RVN）        | KawPow     | rvn.2miners.com:6060 |
| Ergo（ERG）             | Autolykos2 | erg.2miners.com:8888 |
| Conflux（CFX）          | Octopus    | cfx.2miners.com:4040 |
| Ethereum Classic（ETC） | Etchash    | etc.2miners.com:1010 |

{% hint style="info" %}
**MoneroOcean 比较特殊**：它会在任意时刻自动将你的矿机切换到最有利润的算法，同时仍以 XMR 支付。非常适合最大化收益。
{% endhint %}

***

## MoneroOcean：自动收益切换

MoneroOcean 会自动挖掘当前最赚钱的算法：

```bash
docker run -d \\
  --name xmrig-mo \
  --restart unless-stopped \
  --privileged \
  xmrig-miner \
  --algo=rx/0 \
  -o gulf.moneroocean.stream:443 \
  -u YOUR_MONERO_WALLET \
  -p "YOUR_WORKER:PERFORMANCE_FEE" \
  --tls \
  --cpu-max-threads-hint=95
```

***

## 优化提示

### CPU 优化

```bash
# 使用所有 CPU 线程
--cpu-max-threads-hint=100

# 设置 CPU 优先级（0=最低，5=最高）
--cpu-priority=3

# 禁用让出时间片（不要与其他进程共享 CPU）
--no-yield

# 启用 AVX2 以加快 RandomX
#（如果 CPU 支持则自动启用）
```

### GPU 优化（CUDA）

```json
"cuda": {
    "enabled": true,
    "loader": null,
    "nvml": true,
    "devices": [
        {
            "index": 0,
            "threads": 512,
            "blocks": 0,
            "bfactor": 0,
            "bsleep": 0,
            "affinity": -1
        }
    ]
}
```

### 双挖矿（CPU + GPU）

```json
"cpu": {
    "enabled": true,
    "max-threads-hint": 100
},
"cuda": {
    "enabled": true,
    "nvml": true
}
```

***

## 安全注意事项

{% hint style="warning" %}
**挖矿安全检查清单：**

* 尽可能不要以 root 身份运行矿工程序
* 不要将 XMRig API 端口（9090）公开暴露
* 使用 TLS 连接到矿池（`--tls` 标志）
* 保持 XMRig 更新以修补漏洞
* 监控异常的 CPU/GPU 使用率飙升
  {% endhint %}

### 保护 API 端点

```json
"api": {
    "port": 9090,
    "access-token": "your-secret-token-here",
    "restricted": true
}
```

```bash
# 使用令牌访问
curl -H "Authorization: Bearer your-secret-token-here" \
     http://localhost:9090/2/summary
```

***

## 自动化收益监控脚本

```bash
#!/bin/bash
# monitor-mining.sh

WALLET="YOUR_WALLET_ADDRESS"
RENTAL_COST_PER_HOUR=0.50  # 你的 Clore.ai 成本（美元）

while true; do
  # 获取当前算力
  HASHRATE=$(curl -s http://localhost:9090/2/summary | \
             python3 -c "import sys,json; d=json.load(sys.stdin); print(d['hashrate']['total'][0])")
  
  echo "$(date): Hashrate: ${HASHRATE} H/s"
  echo "$(date): Hourly cost: \$${RENTAL_COST_PER_HOUR}"
  
  # 检查已接受份额
  ACCEPTED=$(curl -s http://localhost:9090/2/summary | \
             python3 -c "import sys,json; d=json.load(sys.stdin); print(d['results']['shares_good'])")
  echo "$(date): Accepted shares: ${ACCEPTED}"
  
  sleep 300  # 每 5 分钟检查一次
done
```

***

## 故障排查

### 算力过低

```bash
# 检查容器中的 CPU 分配
docker exec xmrig cat /proc/cpuinfo | grep processor | wc -l

# 确保已启用大页
cat /proc/sys/vm/nr_hugepages

# 检查是否存在温度降频
watch -n1 "sensors 2>/dev/null | grep temp || cat /sys/class/thermal/thermal_zone*/temp"
```

### 连接问题

```bash
# 测试矿池连接
curl -k telnet://pool.supportxmr.com:443

# 如果被阻止则使用备用矿池
# 尝试：xmr.pool.minergate.com:443
```

### CUDA 错误

```bash
# 验证容器中的 GPU 访问
docker exec xmrig-gpu nvidia-smi

# 如果缺失，请在 docker run 中添加 --gpus all
docker stop xmrig-gpu
docker rm xmrig-gpu
# 重新使用 --gpus all 运行
```

### 容器持续重启

```bash
# 检查退出代码
docker inspect xmrig --format='{{.State.ExitCode}}'

# 查看详细日志
docker logs xmrig --since 5m

# 常见原因：
# - 钱包地址无效
# - 矿池连接失败
# - 配置文件语法错误
```

***

## 法律与道德说明

{% hint style="info" %}
**重要注意事项：**

1. **检查 Clore.ai 服务条款**：确保在您租用的服务器上允许挖矿
2. **税务合规**：在您所在司法辖区，挖出的加密货币可能属于应税收入
3. **盈利能力**：云挖矿通常不赚钱——请先算清楚
4. **网络效应**：挖矿有助于区块链安全（正向贡献）
   {% endhint %}

***

## 快速参考

### 命令行参数

| 参数                         | 描述                 |
| -------------------------- | ------------------ |
| `-o URL`                   | 矿池地址               |
| `-u ADDRESS`               | 钱包地址               |
| `-p WORKER`                | 矿工名                |
| `-a ALGO`                  | 算法（Monero 使用 rx/0） |
| `--tls`                    | 启用 TLS 加密          |
| `-k`                       | 保持连接               |
| `--cpu-max-threads-hint=N` | 使用 N% 的 CPU 线程     |
| `--donate-level=0`         | 禁用开发者捐赠            |

### 算法参考

| 算法         | 币种             | 最佳硬件         |
| ---------- | -------------- | ------------ |
| rx/0       | Monero（XMR）    | CPU（RandomX） |
| kawpow     | Ravencoin（RVN） | GPU          |
| autolykos2 | Ergo（ERG）      | GPU          |
| octopus    | Conflux（CFX）   | GPU          |
| etchash    | ETC            | GPU          |

***

## 有用链接

* [XMRig GitHub](https://github.com/xmrig/xmrig)
* [XMRig 文档](https://xmrig.com/docs)
* [WhatToMine 计算器](https://whattomine.com)
* [MoneroOcean 矿池](https://moneroocean.stream)
* [SupportXMR 矿池](https://supportxmr.com)
* [Clore.ai 市场](https://clore.ai)

***

## 总结

| 步骤 | 操作                            |
| -- | ----------------------------- |
| 1  | 先计算收益                         |
| 2  | 在 getmonero.org 创建 Monero 钱包  |
| 3  | 在矿池注册                         |
| 4  | 租用服务器（XMR 用 CPU 核心，其它币种用 GPU） |
| 5  | 构建 XMRig Docker 镜像            |
| 6  | 使用钱包和矿池配置 config.json         |
| 7  | 启用大页以提升 20-50% 的算力            |
| 8  | 开始挖矿，并通过矿池仪表板监控               |

Clore.ai 上的 XMRig 让您按需使用高性能挖矿硬件。请策略性地使用——价格高、租金低时再挖矿。务必先算账。⛏️

***

## Clore.ai GPU 推荐

| 使用场景  | 推荐 GPU         | Clore.ai 预计成本     |
| ----- | -------------- | ----------------- |
| 入门级挖矿 | RTX 3080（10GB） | $0.05–0.19/gpu/hr |
| 最佳挖矿  | RTX 3090（24GB） | $0.07–0.21/gpu/hr |
| 高性能挖矿 | RTX 4090（24GB） | $0.14–0.42/gpu/hr |

> 💡 本指南中的所有示例都可以部署在 [Clore.ai](https://clore.ai/marketplace) GPU 服务器上。浏览可用 GPU 并按小时租用——无需承诺，拥有完整 root 访问权限。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/jia-mi-huo-bi-yu-wa-kuang/xmrig.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
