RAGFlow 本地安装与配置(非docker方式)
一. 运行环境
- windows10
- CPU i7-12700F 2.10GHz
- 内存 32G
- GPU RTX 4060 Ti 8G
- wsl 2
- Ubuntu-22.04
1. 防火墙配置
wsl默认访问windows的本机服务需要配置防火墙,否则访问会失败。
windows10的防火墙配置:
-
打开windows的防火墙
-
点击左侧的“允许应用通过防火墙”
-
点击右侧的“更改设置”
-
点击“添加或删除程序”
-
点击“添加” wsl.exe ,点击“确定”
-
点击“确定”,关闭防火墙设置。
或者直接 右键 powerShell 管理员执行:
New-NetFirewallRule -DisplayName "Allow WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
必要时重启wsl:
wsl --shutdown
wsl
二、下载代码与配置安装
1. 下载源代码
git clone https://gitcode.com/gh_mirrors/ra/ragflow.git #克隆代码到本地
cd /xxx/ragflow #进入到 ragflow 目录下
根据readme文件使用docker-compose 启动服务,但是我没有使用docker-compose, 而是直接在本地运行的。
2. 修改配置文件
RAGFlow 配置文件位于 conf/service_conf.yaml
,你可以根据需要修改配置文件。
- 以下是我的配置文件:
ragflow:host: 0.0.0.0 # 服务监听的 IP 地址http_port: 9380 # HTTP 服务端口
mysql:name: 'rag_flow'user: 'ragflow'password: 'ragflow'host: '172.27.224.1' # 安装在我windows10上的mysql的ip地址port: 3366max_connections: 100stale_timeout: 30
minio:user: 'minioadmin'password: 'minioadmin'host: '172.27.224.1:9000' # 安装在我windows10上的minio的ip地址
es:hosts: 'http://172.27.224.1:9200' # 安装在我windows10上的elasticsearch的ip地址
redis:db: 1host: '172.27.224.1:6389'password: ''
3. 安装依赖服务
有些服务是我原来就是已经安装好的,不用再重新安装,直接配置就可以了。
需要注意的是,监听端口不能是 127.0.0.1, 否则wsl无法访问服务, 必须是 0.0.0.0。
3.1 安装mysql并配置
mysql 安装在我windows10上的mysql的ip地址:172.27.224.1,通过wsl访问windows的本机服务需要配置防火墙,详见防火墙配置章节。
mysql的安装不在这里介绍。
根据配置文件,需要在mysql中创建数据库和用户:
CREATE DATABASE IF NOT EXISTS rag_flow; --#创建数据库
USE rag_flow;
create user 'ragflow'@'%' identified by 'ragflow'; -- #创建用户
grant all privileges on rag_flow.* to 'ragflow'@'%'; -- #赋予用户所有权限
flush privileges; -- #刷新权限
3.2 安装minio
minio 安装在我windows10上的minio的ip地址:172.27.224.1:9000,通过wsl访问windows的本机服务需要配置防火墙,详见防火墙配置章节。
minio的安装不在这里介绍,详见minio安装章节。
安装成系统服务minio服务
用 NSSM 工具安装服务:
下载 NSSM
https://nssm.cc/download
安装服务
nssm install MinIO
在弹出窗口中配置:
Path: D:\ProgramFiles\minio\minio.exe
Arguments: server D:\minio-data --console-address :9001
Startup type: Automatic
启动服务:
nssm start MinIO
** 防火墙规则 **
确保防火墙允许 MinIO 端口(如 9000 和 9001):
New-NetFirewallRule -DisplayName "MinIO Ports" -Direction Inbound -Protocol TCP -LocalPort 9000,9001 -Action Allow
3.3 安装elasticsearch
elasticsearch 安装在我windows10上的elasticsearch的ip地址:172.27.224.1:9200,通过wsl访问windows的本机服务需要配置防火墙,详见防火墙配置章节。
elasticsearch的安装不在这里介绍,详见elasticsearch安装章节。
# 启动elasticsearch服务
D:\xxx\elasticsearch-8.10.4\bin\elasticsearch.bat
3.4 安装Redis
redis 安装在我windows10上的redis的ip地址:172.27.224.1:6389,通过wsl访问windows的本机服务需要配置防火墙,详见防火墙配置章节。
redis的安装不在这里介绍,详见redis安装章节。
所有的配置都没有使用docker,是直接在本地运行的。
4 安装python及依赖包
安装 wsl 后,在 wsl 中安装以下软件:
4.1 miniconda3
conda create -n ragflow python=3.10 -y #创建 python3.10 的环境conda activate ragflow #切换到 ragflow 环境cd /xxx/ragflow #进入到 ragflow 目录下
4.2 修改 pyproject.toml
将原来的 license = { "file": "LICENSE" } 改为 license = "Apache-2.0"
创建目录:
mkdir flask_session
pip install -e .[env] #安装依赖包
4.3 执行命令启动后台服务
python api/ragflow_server.py --config conf/service_conf.yaml #启动服务
如果控制台出现这样的信息,那恭喜你,说明后端启动成功。
2025-04-11 10:56:53,002 INFO 47499 ragflow_server log path: /xxx/ragflow/logs/ragflow_server.log, log levels: {'peewee': 'WARNING', 'pdfminer': 'WARNING', 'root': 'INFO'}
2025-04-11 10:56:54,162 INFO 47499 found 1 gpus
2025-04-11 10:56:55,358 WARNING 47499 RedisDB.__open__ host: 172.27.224.1:6389
2025-04-11 10:56:55,555 INFO 47499 init database on cluster mode successfully
2025-04-11 10:56:57,242 INFO 47499 load_model /xxx/ragflow/rag/res/deepdoc/det.onnx uses GPU
2025-04-11 10:56:57.298517521 [W:onnxruntime:, session_state.cc:1166 VerifyEachNodeIsAssignedToAnEp] Some nodes were not assigned to the preferred execution providers which may or may not have an negative impact on performance. e.g. ORT explicitly assigns shape related ops to CPU to improve perf.
2025-04-11 10:56:57.298543847 [W:onnxruntime:, session_state.cc:1168 VerifyEachNodeIsAssignedToAnEp] Rerunning with verbose output on a non-minimal build will show node assignments.
2025-04-11 10:56:57,316 INFO 47499 load_model /xxx/ragflow/rag/res/deepdoc/rec.onnx uses GPU
2025-04-11 10:57:00,744 INFO 47499 ____ ___ ______ ______ __ / __ \ / | / ____// ____// /____ _ __/ /_/ // /| | / / __ / /_ / // __ \| | /| / // _, _// ___ |/ /_/ // __/ / // /_/ /| |/ |/ / /_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/ 2025-04-11 10:57:00,757 INFO 47499 RAGFlow version: v0.17.2-250-gd0897312 full
2025-04-11 10:57:00,757 INFO 47499 project base: /xxx/ragflow
2025-04-11 10:57:00,757 INFO 47499 Current configs, from /xxx/ragflow/conf/service_conf.yaml:ragflow: {'host': '0.0.0.0', 'http_port': 9380}mysql: {'name': 'rag_flow', 'user': 'ragflow', 'password': '********', 'host': '172.27.224.1', 'port': 3366, 'max_connections': 100, 'stale_timeout': 30}minio: {'user': 'minioadmin', 'password': '********', 'host': '172.27.224.1:9000'}es: {'hosts': 'http://172.27.224.1:9200'}redis: {'db': 1, 'host': '172.27.224.1:6389', 'password': '********'}
2025-04-11 10:57:00,758 INFO 47499 Use Elasticsearch http://172.27.224.1:9200 as the doc engine.
2025-04-11 10:57:00,765 INFO 47499 GET http://172.27.224.1:9200/ [status:200 duration:0.006s]
2025-04-11 10:57:00,767 INFO 47499 HEAD http://172.27.224.1:9200/ [status:200 duration:0.002s]
2025-04-11 10:57:00,767 INFO 47499 Elasticsearch http://172.27.224.1:9200 is healthy.
2025-04-11 10:57:00,770 WARNING 47499 Load term.freq FAIL!
2025-04-11 10:57:00,772 WARNING 47499 Realtime synonym is disabled, since no redis connection.
2025-04-11 10:57:00,774 WARNING 47499 Load term.freq FAIL!
2025-04-11 10:57:00,775 WARNING 47499 Realtime synonym is disabled, since no redis connection.
2025-04-11 10:57:00,775 INFO 47499 MAX_CONTENT_LENGTH: 134217728
2025-04-11 10:57:00,776 INFO 47499 MAX_FILE_COUNT_PER_USER: 0
2025-04-11 10:57:11,456 INFO 47499 init web data success:1.5318384170532227
2025-04-11 10:57:11,456 INFO 47499 update_progress lock_value: 74a7ce79-c014-433c-b8a1-e1140c32ea31
2025-04-11 10:57:11,456 INFO 47499 RAGFlow HTTP server start...
2025-04-11 10:57:11,458 INFO 47499 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.* Running on all addresses (0.0.0.0)* Running on http://127.0.0.1:9380* Running on http://172.27.226.246:9380
2025-04-11 10:57:11,458 INFO 47499 Press CTRL+C to quit
4.4 启动前端服务
cd /xxx/ragflow/web #进入到 web 目录下
yarn install #安装依赖包
yarn start #启动前端服务
这里需要nodejs 18以上的版本,我使用的是nvs 管理nodejs版本。
$ nvs use 23.11.0 #使用nodejs 23.11.0版本
$ node -v
v23.11.0
$ yarn install
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
$ umi setup
info - [你知道吗?] 请求加载态、数据管理、避免竟态问题,用 react-query 帮你全部解决,详见 https://umijs.org/docs/max/react-query
info - generate files
info - Preparing...
info - [icons] generate icons local:google, local:github
$ cd .. && husky web/.husky
Done in 2.42s.$ yarn start
yarn run v1.22.19
$ npm run dev> dev
> cross-env UMI_DEV_SERVER_COMPRESS=none umi devinfo - [你知道吗?] CSS 不够灵活、编写动态样式太繁琐怎么办?试试 styled-components 插件,详见 https://umijs.org/docs/max/styled-components
Mako https://makojs.dev is a new fast Rust based bundler from us, which is heavily optimized for umi and much faster than webpack. Visit https://makojs.dev/docs/getting-started#bundle-with-umi for more details if you want to give it a try.
info - Umi v4.4.6
info - Preparing...
info - [icons] generate icons local:google, local:github
info - [plugin: ./node_modules/@umijs/plugins/dist/tailwindcss] tailwindcss service started
info - [icons] generate icons local:google, local:githubRebuilding...Done in 459ms.
info - MFSU eager strategy enabled
info - [MFSU][eager] restored cache
[HPM] Proxy created: /api,/v1 -> http://127.0.0.1:9380/
event - [MFSU][eager] start build deps
info - [MFSU] skip buildDeps
ready - ║ > Network: http://172.27.226.246:9222 ║║ ║║ Now you can open browser with the above addresses↑ ║╚════════════════════════════════════════════════════╝
info - [MFSU][eager] worker init, takes 402ms
info - [icons] generate icons local:google, local:github
event - [Webpack] Compiled in 2396 ms (1499 modules)
wait - [Webpack] Compiling...
event - [MFSU][eager] start build deps
info - [MFSU] skip buildDeps
event - [Webpack] Compiled in 446 ms (1470 modules)
wait - [Webpack] Compiling...
event - [MFSU][eager] start build deps
info - [MFSU] skip buildDeps
event - [Webpack] Compiled in 235 ms (1470 modules)
5. 启动成功
在浏览器里面打开 http://172.27.226.246:9222 就可以访问前端服务了。
报错及处理措施
报错1
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Traceback (most recent call last):File "/xxx/ragflow/api/ragflow_server.py", line 35, in <module>from api import settingsFile "/xxx/ragflow/api/settings.py", line 20, in <module>import rag.utils.es_connFile "/xxx/ragflow/rag/utils/es_conn.py", line 33, in <module>from rag.nlp import is_english, rag_tokenizerFile "/xxx/ragflow/rag/nlp/__init__.py", line 22, in <module>from . import rag_tokenizerFile "/xxx/ragflow/rag/nlp/rag_tokenizer.py", line 26, in <module>from nltk import word_tokenizeFile "/home/chunlei/miniconda3/envs/ragflow/lib/python3.10/site-packages/nltk/__init__.py", line 133, in <module>from nltk.collocations import *File "/home/chunlei/miniconda3/envs/ragflow/lib/python3.10/site-packages/nltk/collocations.py", line 36, in <module>from nltk.metrics import (File "/home/chunlei/miniconda3/envs/ragflow/lib/python3.10/site-packages/nltk/metrics/__init__.py", line 18, in <module>from nltk.metrics.association import (File "/home/chunlei/miniconda3/envs/ragflow/lib/python3.10/site-packages/nltk/metrics/association.py", line 26, in <module>from scipy.stats import fisher_exactFile "/home/chunlei/miniconda3/envs/ragflow/lib/python3.10/site-packages/scipy/stats/__init__.py", line 605, in <module>from ._stats_py import *File "/home/chunlei/miniconda3/envs/ragflow/lib/python3.10/site-packages/scipy/stats/_stats_py.py", line 37, in <module>from scipy.spatial.distance import cdistFile "/home/chunlei/miniconda3/envs/ragflow/lib/python3.10/site-packages/scipy/spatial/__init__.py", line 110, in <module>from ._kdtree import *File "/home/chunlei/miniconda3/envs/ragflow/lib/python3.10/site-packages/scipy/spatial/_kdtree.py", line 4, in <module>from ._ckdtree import cKDTree, cKDTreeNodeFile "_ckdtree.pyx", line 1, in init scipy.spatial._ckdtree
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
解决:
这个错误通常是由于 numpy 版本不兼容导致的。具体来说,scipy 和 numpy 之间的版本不匹配可能会导致这种二进制不兼容的问题。以下是解决这个问题的步骤:
或者 确保 numpy 和 scipy 的版本兼容: 如果你不想升级到最新版本,可以尝试安装特定版本的 numpy 和 scipy,确保它们之间的兼容性。例如:
pip install --upgrade numpy scipy
或 pip install numpy==1.26.0 scipy==1.11.0