From e1135a21fe68004d10a388a8b9d1eb41ae66e3f5 Mon Sep 17 00:00:00 2001
From: Lin_qiang <1667704220@qq.com>
Date: Wed, 16 Apr 2025 14:56:16 +0800
Subject: [PATCH] =?UTF-8?q?lite=E7=89=88=E4=B8=BB=E5=A4=87=E9=83=A8?=
=?UTF-8?q?=E7=BD=B2=E8=B5=84=E6=96=99=E8=A1=A5=E5=85=85=E4=BB=A5=E5=8F=8A?=
=?UTF-8?q?AGEGraph=E8=B5=84=E6=96=99=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../zh/docs/DataVec/openGauss-AGEGraph.md | 99 +++++++------------
...1\350\243\205_\345\256\271\345\231\250.md" | 37 +++++++
...1\350\243\205_\345\256\271\345\231\250.md" | 90 +++++++++++++++++
content/docs-lite/zh/menu/index.md | 2 +
content/zh/docs/DataVec/openGauss-AGEGraph.md | 99 +++++++------------
5 files changed, 203 insertions(+), 124 deletions(-)
create mode 100644 "content/docs-lite/zh/docs/InstallationGuide/\344\270\200\344\270\273\344\270\244\345\244\207\344\270\215\345\270\246cm\345\256\211\350\243\205_\345\256\271\345\231\250.md"
create mode 100644 "content/docs-lite/zh/docs/InstallationGuide/\345\215\225\350\212\202\347\202\271\345\256\211\350\243\205_\345\256\271\345\231\250.md"
diff --git a/content/docs-lite/zh/docs/DataVec/openGauss-AGEGraph.md b/content/docs-lite/zh/docs/DataVec/openGauss-AGEGraph.md
index a52f2c466..6b28efaa7 100644
--- a/content/docs-lite/zh/docs/DataVec/openGauss-AGEGraph.md
+++ b/content/docs-lite/zh/docs/DataVec/openGauss-AGEGraph.md
@@ -18,60 +18,12 @@ CONTAINER ID IMAGE COMMA
253714c9c869 opengauss:7.0.0-rc1 "entrypoint.sh gauss…" 8 minutes ago Up 8 minutes 0.0.0.0:6543->5432/tcp opengauss-age
```
-#### 1.2 AGE插件安装
+#### 1.2 python依赖安装
```
-#进入openGauss容器中 253714c9c869为 CONTAINER ID
-docker exec -it 253714c9c869 bash
-
-#切换到omm用户
-su omm
-
-#omm用户,连接数据库,默认使用omm数据库
-gsql -r
-
-#连接数据库后,omm数据库安装age插件
-create extension age;
-
-#退出数据库连接
-\q
-
+pip install -U langchain_community langchain langgraph langchain-ollama langchain-experimental langchain-openai langchain-opengauss
```
-#### 1.3 python依赖安装
-
-```
-pip install -U langchain_community langchain langgraph langchain-ollama langchain-experimental langchain-openai
-```
-下载已适配的 langchain_community 仓库,操作如下:
-
-##### 1.3.1 下载适配好的langchain_community仓
-```
-git clone https://gitee.com/lin-qiang123/langchain.git
-```
-##### 1.3.2 查找pip 安装的langchain_community位置
-```
-pip show langchain_community
-```
-输出
-
-```
-Name: langchain-community
-Version: 0.3.20
-Summary: Community contributed LangChain integrations.
-Home-page:
-Author:
-Author-email:
-License: MIT
-Location: c:\users\test\appdata\local\programs\python\python310\lib\site-packages #依赖库安装的位置
-Requires: numpy, PyYAML, aiohttp, tenacity, dataclasses-json, langchain, httpx-sse, SQLAlchemy, pydantic-settings, langchain-core, langsmith, requests
-Required-by: langchain-experimental
-```
-
-##### 1.3.3 替换langchain-community
-在git clone 下来的代码仓中,找到langchain\libs\community\langchain_community文件夹,复制并且覆盖到`Location`显示的文件夹中
-
-
### 2. 利用 模型和 openGauss AGEGraph 快速构建知识图谱和检索
本文使用百炼大模型,取得api-key,并且配置DASHSCOPE_API_KEY环境变量
#### 2.1 初始化大模型
@@ -120,26 +72,49 @@ print(f"Relationships from graph doc:{graph_documents[0].relationships}")
Nodes from graph doc:[Node(id='Nobel Prize', type='Award', properties={}), Node(id='University of Paris', type='Organization', properties={}), Node(id='Marie Curie', type='Person', properties={}), Node(id='radioactivity', type='ResearchField', properties={}), Node(id='Pierre Curie', type='Person', properties={})]
Relationships from graph doc:[Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='radioactivity', type='ResearchField', properties={}), type='FIELD_OF_RESEARCH', properties={}), Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='Nobel Prize', type='Award', properties={}), type='AWARD', properties={}), Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='Nobel Prize', type='Award', properties={}), type='AWARD', properties={}), Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='Pierre Curie', type='Person', properties={}), type='SPOUSE', properties={}), Relationship(source=Node(id='Pierre Curie', type='Person', properties={}), target=Node(id='Nobel Prize', type='Award', properties={}), type='AWARD', properties={}), Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='University of Paris', type='Organization', properties={}), type='WORKS_AT', properties={})]
```
-#### 2.3 实例化 openGauss AGEGraph 客户端,持久化图数据
+#### 2.3 openGauss AGE插件安装
+如果对应的数据库已经创建age插件,此步骤可以忽略
```
-from langchain_community.graphs.age_graph import AGEGraph
+import psycopg2
+connection = psycopg2.connect(
+ database = "omm",
+ user = "gaussdb",
+ password = "YourPassoword",
+ host = "Your IP",
+ port = 8888
+)
+
+try:
+ cursor = connection.cursor()
+ sql_qeury = "create extension age;"
+ cursor.execute(sql_query)
+ connection.commit()
+except Exception as e:
+ print(e)
+finally:
+ cursor.close()
+ connection.close()
+```
+#### 2.4 实例化 openGauss AGEGraph 客户端,持久化图数据
-conf = {
- "database": "omm",
- "user": "gaussdb",
- "password": "YourPassoword",
- "host": "Your IP",
- "port": 8888,
- "sslmode": "disable"
-}
-graph=AGEGraph(graph_name='graph_test1',conf=conf,create=True)
+```
+from langchain_opengauss import openGaussAGEGraph, openGaussSettings
+
+conf = openGaussSettings(
+ database = "omm",
+ user = "gaussdb",
+ password = "YourPassoword",
+ host = "Your IP",
+ port = 8888
+)
+graph=openGaussAGEGraph(graph_name='graph_test1',conf=conf,create=True)
graph.add_graph_documents(graph_documents)
graph.refresh_schema()
```
-#### 2.4 大模型 Text2Cypher:提取问题关键词并生成图检索语句
+#### 2.5 大模型 Text2Cypher:提取问题关键词并生成图检索语句
通过增加提示词`cypher_prompt`,可以让大模型生成的图查询语句更加精准
```
diff --git "a/content/docs-lite/zh/docs/InstallationGuide/\344\270\200\344\270\273\344\270\244\345\244\207\344\270\215\345\270\246cm\345\256\211\350\243\205_\345\256\271\345\231\250.md" "b/content/docs-lite/zh/docs/InstallationGuide/\344\270\200\344\270\273\344\270\244\345\244\207\344\270\215\345\270\246cm\345\256\211\350\243\205_\345\256\271\345\231\250.md"
new file mode 100644
index 000000000..2846479a2
--- /dev/null
+++ "b/content/docs-lite/zh/docs/InstallationGuide/\344\270\200\344\270\273\344\270\244\345\244\207\344\270\215\345\270\246cm\345\256\211\350\243\205_\345\256\271\345\231\250.md"
@@ -0,0 +1,37 @@
+# 轻量版一主两备不带cm安装_容器
+
+### 1. 获取镜像
+参考[容器镜像安装](./容器镜像安装.md),获取openGauss docker镜像并且修改镜像名称
+```
+# 9aa832ba6684需修改为安装镜像对应的IMAGE ID
+docker tag 9aa832ba6684 opengauss:7.0.0-RC1
+```
+### 2. 获取主备容器化部署脚本
+
+主备容器部署脚本为`create_master_slave.sh`,可以从[openGauss-server仓库](https://gitee.com/opengauss/openGauss-server/tree/master/docker/dockerfiles)获取
+
+### 3. 创建容器路径映射目录
+```
+# 创建容器路径映射目录, 可以根据需要自行修改
+mkdir -p /opt/test/{dn_6001,dn_6002,dn_6003}
+```
+
+### 4. 修改部署脚本
+```
+# 修改create_master_slave.sh脚本, 添加路径映射,路径要与创建的容器路径映射目录一致
+sed -i '/^SLAVE_COUNT=1$/a MASTER_OUT_DIR="/opt/test/dn_6001"\nSLAVE_OUT_DIR=("/opt/test/dn_6002" "/opt/test/dn_6003")' create_master_slave.sh
+sed -i '/-e GS_PORT=$MASTER_HOST_PORT/i -v $MASTER_OUT_DIR:/var/lib/opengauss \\' create_master_slave.sh
+sed -i '/-e GS_PORT=$local_port/i \ -v ${SLAVE_OUT_DIR[$i]}:/var/lib/opengauss \\' create_master_slave.sh
+
+```
+
+### 5. 执行脚本创建容器集群
+
+```
+# 创建容器集群, 这里VERSION要跟镜像的TAG相同
+sh create_master_slave.sh --SLAVE_COUNT 2 --NETWORK_NAME net_700 --VERSION 7.0.0-RC1 --MASTER_HOST_PORT 4432
+
+# 创建完成后,查询集群状态
+docker exec dn_6001 su - omm -c "gs_ctl query -D /var/lib/opengauss/data"
+```
+
diff --git "a/content/docs-lite/zh/docs/InstallationGuide/\345\215\225\350\212\202\347\202\271\345\256\211\350\243\205_\345\256\271\345\231\250.md" "b/content/docs-lite/zh/docs/InstallationGuide/\345\215\225\350\212\202\347\202\271\345\256\211\350\243\205_\345\256\271\345\231\250.md"
new file mode 100644
index 000000000..bd257894a
--- /dev/null
+++ "b/content/docs-lite/zh/docs/InstallationGuide/\345\215\225\350\212\202\347\202\271\345\256\211\350\243\205_\345\256\271\345\231\250.md"
@@ -0,0 +1,90 @@
+# lite版本单节点安装_容器
+
+本章节主要介绍通过Docker安装openGauss,方便DevOps用户的安装、配置和环境设置。
+
+## 构建容器的架构和操作系统版本
+
+- x86-64 CentOS 7.6
+
+- ARM64 openEuler 20.03 LTS
+
+## 配置准备
+
+使用 buildDockerImage.sh脚本构建docker镜像,buildDockerImage.sh是一个方便使用的shell脚本,提供SHA256的检查。buildDockerImage.sh脚本可以从[openGauss-server仓库](https://gitee.com/opengauss/openGauss-server/tree/master/docker/dockerfiles)下载。
+
+## 单机数据库容器安装
+
+### 创建lite版本openGauss docker镜像
+
+> **说明:**
+>
+>- 安装前需要提供openGauss二进制安装包(openGauss-Lite-X.X.X-openEuler20.03-x86_64.tar.gz,X.X.X为openGauss当前版本号)放到 dockerfiles/文件夹。二进制包可以从 [https://www.opengauss.org/zh/download/](https://www.opengauss.org/zh/download/)下载,确保有正确的yum源。
+>
+>- 安装前需要从华为开源镜像站获取repo文件,并放到openGauss-server/docker/dockerfiles/X.X.X文件夹下面。
+> ```
+> ## openEuler_aarch64.repo获取方法:
+> wget -O openEuler_aarch64.repo https://mirrors.huaweicloud.com/repository/conf/openeuler_aarch64.repo
+> ## CentOS-Base.repo获取方法:
+> wget -O CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-anon.repo
+>
+> ```
+
+在dockerfiles文件夹运行buildDockerImage.sh脚本。
+
+```
+#为对应的dockerfiles目录下的版本号文件夹名称
+sh buildDockerImage.sh -i -v -m "lite"
+```
+
+### 环境变量
+
+为了更灵活的使用openGauss镜像,可以设置额外的参数。未来我们会扩充更多的可控制参数,当前版本支持以下变量的设定。
+
+**GS\_PASSWORD**
+
+使用openGauss镜像的时候,必须设置该参数。该参数值不能为空或者不定义。该参数设置了openGauss数据库的超级用户omm以及测试用户gaussdb的密码。openGauss安装时默认会创建omm超级用户,该用户名暂时无法修改。测试用户gaussdb是在entrypoint.sh中自定义创建的用户。
+
+openGauss镜像配置了本地信任机制,因此在容器内连接数据库无需密码,但是如果要从容器外部(其它主机或者其它容器)连接则必须要输入密码。
+
+**openGauss的密码有复杂度要求**
+
+密码长度8个字符以上,必须同时包含大写字母、小写字母、数字、以及特殊符号(特殊符号仅包含“\#?!@$%^&\*-”,并且“!$&”需要用转义符“\\”进行转义)。
+
+**GS\_NODENAME**
+
+指定数据库节点名称,默认为gaussdb。
+
+**GS\_USERNAME**
+
+指定数据库连接用户名,默认为gaussdb。
+
+**GS\_PORT**
+
+指定数据库端口,默认为5432。
+
+### 开启实例
+
+```
+$ docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Enmo@123 opengauss:X.X.X
+```
+
+### 从操作系统层面连接数据库
+
+```
+$ docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Enmo@123 -p 8888:5432 opengauss:X.X.X
+$ gsql -d postgres -U gaussdb -W'Enmo@123' -h your-host-ip -p 8888 # 宿主机需要安装gsql客户端。
+```
+
+### 数据持久化
+
+```
+$ docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Enmo@123 -v /opengauss:/var/lib/opengauss opengauss:X.X.X
+```
+
+>**说明**
+>
+>1. 对于使用其他版本的数据库构建容器镜像,可以参考`openGauss-server/docker/dockerfiles/X.X.X`里面的配置文件,只需要修改为对应的版本号即可。
+>
+>2. 对于构建openEuler-arm的容器镜像,如果`openeuler-20.03-lts:latest`镜像下载不下来,可以在openEuler官方网站`https://repo.openeuler.org/openEuler-20.03-LTS/docker_img/aarch64/`下载容器镜像压缩包`openEuler-docker.aarch64.tar.xz`,然后使用`docker load -i openEuler-docker.aarch64.tar.xz`导入到本地镜像列表。
+>
+>3. 在进行构建时候,如果遇到yum源下载超时,请检查下代理,也可以在buildDockerImage.sh脚本里面的`docker build`命令后加上`--network host`使用宿主机的网络。
diff --git a/content/docs-lite/zh/menu/index.md b/content/docs-lite/zh/menu/index.md
index 9a59b7fb1..8fe0cd19a 100644
--- a/content/docs-lite/zh/menu/index.md
+++ b/content/docs-lite/zh/menu/index.md
@@ -163,6 +163,8 @@ headless: true
- [安装指南]({{< relref "./docs/InstallationGuide/Installation.md" >}})
- [安装概述]({{< relref "./docs/InstallationGuide/安装概述.md" >}})
- [容器镜像安装]({{< relref "./docs/InstallationGuide/容器镜像安装.md" >}})
+ - [单节点安装]({{< relref "./docs/InstallationGuide/单节点安装_容器.md" >}})
+ - [一主两备安装]({{< relref "./docs/InstallationGuide/一主两备不带cm安装_容器.md" >}})
- [安装准备]({{< relref "./docs/InstallationGuide/安装准备.md" >}})
- [获取安装包]({{< relref "./docs/InstallationGuide/获取安装包.md" >}})
- [准备软硬件安装环境]({{< relref "./docs/InstallationGuide/准备软硬件安装环境.md" >}})
diff --git a/content/zh/docs/DataVec/openGauss-AGEGraph.md b/content/zh/docs/DataVec/openGauss-AGEGraph.md
index a52f2c466..6b28efaa7 100644
--- a/content/zh/docs/DataVec/openGauss-AGEGraph.md
+++ b/content/zh/docs/DataVec/openGauss-AGEGraph.md
@@ -18,60 +18,12 @@ CONTAINER ID IMAGE COMMA
253714c9c869 opengauss:7.0.0-rc1 "entrypoint.sh gauss…" 8 minutes ago Up 8 minutes 0.0.0.0:6543->5432/tcp opengauss-age
```
-#### 1.2 AGE插件安装
+#### 1.2 python依赖安装
```
-#进入openGauss容器中 253714c9c869为 CONTAINER ID
-docker exec -it 253714c9c869 bash
-
-#切换到omm用户
-su omm
-
-#omm用户,连接数据库,默认使用omm数据库
-gsql -r
-
-#连接数据库后,omm数据库安装age插件
-create extension age;
-
-#退出数据库连接
-\q
-
+pip install -U langchain_community langchain langgraph langchain-ollama langchain-experimental langchain-openai langchain-opengauss
```
-#### 1.3 python依赖安装
-
-```
-pip install -U langchain_community langchain langgraph langchain-ollama langchain-experimental langchain-openai
-```
-下载已适配的 langchain_community 仓库,操作如下:
-
-##### 1.3.1 下载适配好的langchain_community仓
-```
-git clone https://gitee.com/lin-qiang123/langchain.git
-```
-##### 1.3.2 查找pip 安装的langchain_community位置
-```
-pip show langchain_community
-```
-输出
-
-```
-Name: langchain-community
-Version: 0.3.20
-Summary: Community contributed LangChain integrations.
-Home-page:
-Author:
-Author-email:
-License: MIT
-Location: c:\users\test\appdata\local\programs\python\python310\lib\site-packages #依赖库安装的位置
-Requires: numpy, PyYAML, aiohttp, tenacity, dataclasses-json, langchain, httpx-sse, SQLAlchemy, pydantic-settings, langchain-core, langsmith, requests
-Required-by: langchain-experimental
-```
-
-##### 1.3.3 替换langchain-community
-在git clone 下来的代码仓中,找到langchain\libs\community\langchain_community文件夹,复制并且覆盖到`Location`显示的文件夹中
-
-
### 2. 利用 模型和 openGauss AGEGraph 快速构建知识图谱和检索
本文使用百炼大模型,取得api-key,并且配置DASHSCOPE_API_KEY环境变量
#### 2.1 初始化大模型
@@ -120,26 +72,49 @@ print(f"Relationships from graph doc:{graph_documents[0].relationships}")
Nodes from graph doc:[Node(id='Nobel Prize', type='Award', properties={}), Node(id='University of Paris', type='Organization', properties={}), Node(id='Marie Curie', type='Person', properties={}), Node(id='radioactivity', type='ResearchField', properties={}), Node(id='Pierre Curie', type='Person', properties={})]
Relationships from graph doc:[Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='radioactivity', type='ResearchField', properties={}), type='FIELD_OF_RESEARCH', properties={}), Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='Nobel Prize', type='Award', properties={}), type='AWARD', properties={}), Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='Nobel Prize', type='Award', properties={}), type='AWARD', properties={}), Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='Pierre Curie', type='Person', properties={}), type='SPOUSE', properties={}), Relationship(source=Node(id='Pierre Curie', type='Person', properties={}), target=Node(id='Nobel Prize', type='Award', properties={}), type='AWARD', properties={}), Relationship(source=Node(id='Marie Curie', type='Person', properties={}), target=Node(id='University of Paris', type='Organization', properties={}), type='WORKS_AT', properties={})]
```
-#### 2.3 实例化 openGauss AGEGraph 客户端,持久化图数据
+#### 2.3 openGauss AGE插件安装
+如果对应的数据库已经创建age插件,此步骤可以忽略
```
-from langchain_community.graphs.age_graph import AGEGraph
+import psycopg2
+connection = psycopg2.connect(
+ database = "omm",
+ user = "gaussdb",
+ password = "YourPassoword",
+ host = "Your IP",
+ port = 8888
+)
+
+try:
+ cursor = connection.cursor()
+ sql_qeury = "create extension age;"
+ cursor.execute(sql_query)
+ connection.commit()
+except Exception as e:
+ print(e)
+finally:
+ cursor.close()
+ connection.close()
+```
+#### 2.4 实例化 openGauss AGEGraph 客户端,持久化图数据
-conf = {
- "database": "omm",
- "user": "gaussdb",
- "password": "YourPassoword",
- "host": "Your IP",
- "port": 8888,
- "sslmode": "disable"
-}
-graph=AGEGraph(graph_name='graph_test1',conf=conf,create=True)
+```
+from langchain_opengauss import openGaussAGEGraph, openGaussSettings
+
+conf = openGaussSettings(
+ database = "omm",
+ user = "gaussdb",
+ password = "YourPassoword",
+ host = "Your IP",
+ port = 8888
+)
+graph=openGaussAGEGraph(graph_name='graph_test1',conf=conf,create=True)
graph.add_graph_documents(graph_documents)
graph.refresh_schema()
```
-#### 2.4 大模型 Text2Cypher:提取问题关键词并生成图检索语句
+#### 2.5 大模型 Text2Cypher:提取问题关键词并生成图检索语句
通过增加提示词`cypher_prompt`,可以让大模型生成的图查询语句更加精准
```
--
Gitee