ubuntu24.04 部署 ragflow + 阿里百炼大模型 + docker ,系统使用阿里源,采用纯cpu 无gpu方案 详细的部署方法1
下面给你一套在 Ubuntu 24.04(阿里云源)+ Docker + CPU-only(无GPU)环境部署:
RAGFlow + 阿里云百炼(DashScope)大模型接入 + Ollama/可选嵌入模型 + Docker Compose
这是目前生产里比较稳的一种“CPU RAG方案”。
一、整体架构(你最终会跑的东西)
你这套系统本质是:
-
RAGFlow(RAG框架)
-
Elasticsearch(向量/检索)
-
Ollama(可选,本地embedding/小模型)
-
阿里百炼 DashScope(LLM 主模型)
-
Docker Compose 一键编排
二、Ubuntu 24.04 基础环境(阿里源优化)
1. 替换阿里APT源(建议)
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo sed -i 's|http://.*ubuntu.com|https://mirrors.aliyun.com|g' /etc/apt/sources.list
sudo apt update && sudo apt upgrade -y
2. 安装基础依赖
sudo apt install -y \
git curl wget vim \
ca-certificates gnupg lsb-release \
htop net-tools
3. Docker + Compose(必须24+)
安装 Docker(官方方式)
curl -fsSL https://get.docker.com | bash
sudo usermod -aG docker $USER
newgrp docker
验证
docker -v
docker compose version
4. 内核参数(RAGFlow必须)
sudo sysctl -w vm.max_map_count=262144
echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf
三、部署 RAGFlow(CPU版本)
1. 克隆项目
git clone https://github.com/infiniflow/ragflow.git
cd ragflow
2. 使用 CPU docker-compose
进入 docker 目录:
cd docker
查看 compose:
ls
你会看到类似:
-
docker-compose.yml
-
.env
-
service_conf.yaml.template
3. 修改 .env(关键)
打开:
vim .env
重点改这些(CPU模式):
# CPU模式
RAGFLOW_MODE=cpu
# 端口
RAGFLOW_PORT=80
# 禁用GPU
USE_GPU=false
4. 启动 RAGFlow
docker compose up -d
第一次会拉取:
-
Elasticsearch
-
RAGFlow backend
-
worker
-
frontend
5. 检查状态
docker ps
访问:
http://你的服务器IP
四、接入阿里云百炼(DashScope LLM)
这是你最关键的一步。
1. 获取 API Key
进入阿里云百炼:
创建:
-
API Key(DashScope)
2. 在 RAGFlow 中配置 LLM
进入 RAGFlow Web UI:
Settings → Model Provider → Add Model
选择:
DashScope / Alibaba Cloud
填写:
API Key: sk-xxxx
Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1
Model: qwen-plus 或 qwen-max
3. 推荐模型(CPU RAG稳定)
-
qwen-turbo(最快,推荐默认)
-
qwen-plus(平衡)
-
qwen-max(效果最好,贵)
五、嵌入模型(CPU方案推荐)
你有两种方式:
方案A(推荐):阿里Embedding(省事)
在百炼里选:
text-embedding-v3
配置:
Provider: DashScope
Model: text-embedding-v3
方案B:本地 Ollama(CPU)
安装 Ollama:
curl -fsSL https://ollama.com/install.sh | sh
启动:
ollama serve
拉 embedding:
ollama pull bge-m3
RAGFlow连接 Ollama:
http://host.docker.internal:11434
⚠️ CPU机器也能跑,但比阿里 embedding 慢
六、Docker CPU优化(重要)
编辑:
docker-compose.yml
加:
deploy:
resources:
limits:
cpus: "4"
memory: 8G
七、常见坑(非常重要)
1. Elasticsearch 起不来
vm.max_map_count < 262144
解决:
sudo sysctl -w vm.max_map_count=262144
2. CPU太慢
建议:
-
用 qwen-turbo
-
embedding 用 text-embedding-v3
-
不要本地大模型
3. Docker 内存爆
至少:
-
16GB RAM(最低)
-
推荐 32GB
八、完整启动流程(总结版)
# 1. 安装docker
curl -fsSL https://get.docker.com | bash
# 2. clone
git clone https://github.com/infiniflow/ragflow.git
cd ragflow/docker
# 3. 系统参数
sudo sysctl -w vm.max_map_count=262144
# 4. 启动
docker compose up -d
九、推荐生产级组合(CPU最优)
| 模块 | 方案 |
|---|---|
| RAG框架 | RAGFlow |
| LLM | 阿里百炼 qwen-turbo |
| Embedding | text-embedding-v3 |
| 向量 | Elasticsearch |
| 部署 | Docker Compose |
| OS | Ubuntu 24.04(阿里源) |
如果你要进阶(我可以继续帮你)
我可以再帮你细化这三块:
🚀 1. 生产级 docker-compose(含Nginx + HTTPS)
🚀 2. RAGFlow + 百炼 prompt 最佳实践(中文知识库优化)
🚀 3. Elasticsearch 调优(CPU 低配提速 3-5倍)
只要你说你机器配置(CPU/内存/磁盘),我可以给你一套“可直接上线版本”。
No Comments