😊补充:没有安装成功 的扩展
如果你在使用springAI中检索事增强RAG在自动或者手动创建数据库的时候报错如下:主要信息
#error "please use configure's --with-uuid switch to select a UUID library"
你遇到的错误非常典型: 因为 uuid-ossp 扩展依赖系统上的 UUID 库 (如 libuuid 或 OSSP UUID)在 ✅ 宝塔 PostgreSQL 安装 contrib 扩展完整指南 中没有安装成功。
根据原始编译参数并执行 #configure 中没有指定 没有指定 --with-uuid 参数,导致编译器不知道用哪个 UUID 实现。
✅ 正确解决方案
你需要 重新配置 PostgreSQL 源码,并启用对 UUID 库的支持。
在PotgreSQL中创建uuid-ossp
bash
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

安装失败
第一步:确认系统是否安装了 UUID 开发库
对于 OpenCloudOS / CentOS 系列:
bash
# 安装 libuuid 开发包(通常来自 util-linux)
yum install -y libuuid-devel
# 或(某些版本叫)
dnf install -y libuuid-devel
💡
uuid-ossp在现代 PostgreSQL 中默认使用libuuid(来自 util-linux) ,而不是老式的ossp-uuid。
验证是否安装成功:
bash
ls /usr/include/uuid/uuid.h

如果存在,说明开发头文件已就位。
第二步:回到 PostgreSQL 源码根目录,重新 configure
bash
cd /tmp/postgresql-16.1
先清理旧配置(可选):如果提示命令不存在,跳过即可
bash
make distclean
然后重新运行 configure,加上 --with-uuid=bsd 或 --with-uuid=e2fs:
✅ 在大多数 Linux 发行版(包括 OpenCloudOS/CentOS)中,应使用:
bash
./configure \
--prefix=/www/server/pgsql \
--without-readline \
--with-uuid=e2fs
📌 说明:
-
e2fs表示使用libuuid(由util-linux提供,即libuuid-devel安装的内容) -
不要使用
--with-uuid=ossp,除非你手动安装了ossp-uuid(不推荐)
第三步:编译 uuid-ossp
bash
cd contrib/uuid-ossp
make clean
make
make install
注意如果没有安装yum install -y libuuid-devel的话会报错
root@VM-4-5-opencloudos contrib\]# cd uuid-ossp/ \[root@VM-4-5-opencloudos uuid-ossp\]# make 编译报错 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -fPIC -fvisibility=hidden -I. -I. -I../../src/include -D_GNU_SOURCE -c -o uuid-ossp.o uuid-ossp.c uuid-ossp.c:40:2: error: #error "please use configure's --with-uuid switch to select a UUID library" 40 \| #error "please use configure's --with-uuid switch to select a UUID library" \| \^\~\~\~\~ uuid-ossp.c: In function 'uuid_generate_internal': uuid-ossp.c:275:33: error: unknown type name 'uuid_t'; did you mean 'uid_t'? 275 \| uuid_t uu; \| \^\~\~\~\~\~ \| uid_t uuid-ossp.c:276:58: error: 'uuid_s_ok' undeclared (first use in this function); did you mean 'uuid_ns_oid'? 276 \| uint32_t status = uuid_s_ok; \| \^\~\~\~\~\~\~\~\~ \| uuid_ns_oid uuid-ossp.c:276:58: note: each undeclared identifier is reported only once for each function it appears in uuid-ossp.c:279:33: warning: implicit declaration of function 'uuid_create'; did you mean 'uuid_recv'? \[-Wimplicit-function-declaration\] 279 \| uuid_create(\&uu, \&status); \| \^\~\~\~\~\~\~\~\~\~\~ \| uuid_recv uuid-ossp.c:283:41: warning: implicit declaration of function 'uuid_to_string'; did you mean 'text_to_cstring'? \[-Wimplicit-function-declaration\] 283 \| uuid_to_string(\&uu, \&str, \&status); \| \^\~\~\~\~\~\~\~\~\~\~\~\~\~ \| text_to_cstring uuid-ossp.c:75:20: error: unknown type name 'uuid_t'; did you mean 'uid_t'? 75 \| #define dce_uuid_t uuid_t \| \^\~\~\~\~\~ uuid-ossp.c:323:33: note: in expansion of macro 'dce_uuid_t' 323 \| dce_uuid_t uu; \| \^\~\~\~\~\~\~\~\~\~ uuid-ossp.c:83:11: error: request for member 'time_low' in something not a structure or union 83 \| uu.time_low = pg_hton32(uu.time_low); \\ \| \^ uuid-ossp.c:368:33: note: in expansion of macro 'UUID_TO_NETWORK' 368 \| UUID_TO_NETWORK(uu); \| \^\~\~\~\~\~\~\~\~\~\~\~\~\~\~ In file included from uuid-ossp.c:19: uuid-ossp.c:83:35: error: request for member 'time_low' in something not a structure or union 83 \| uu.time_low = pg_hton32(uu.time_low); \\ \| \^ ../../src/include/port/pg_bswap.h:55:41: note: in definition of macro 'pg_bswap32' 55 \| #define pg_bswap32(x) __builtin_bswap32(x) \| \^ uuid-ossp.c:83:23: note: in expansion of macro 'pg_hton32' 83 \| uu.time_low = pg_hton32(uu.time_low); \\ \| \^\~\~\~\~\~\~\~\~ uuid-ossp.c:368:33: note: in expansion of macro 'UUID_TO_NETWORK' 368 \| UUID_TO_NETWORK(uu); \| \^\~\~\~\~\~\~\~\~\~\~\~\~\~\~ uuid-ossp.c:84:11: error: request for member 'time_mid' in something not a structure or union 84 \| uu.time_mid = pg_hton16(uu.time_mid); \\ \| \^ uuid-ossp.c:368:33: note: in expansion of macro 'UUID_TO_NETWORK' 368 \| UUID_TO_NETWORK(uu); \| \^\~\~\~\~\~\~\~\~\~\~\~\~\~\~ uuid-ossp.c:84:35: error: request for member 'time_mid' in something not a structure or union 84 \| uu.time_mid = pg_hton16(uu.time_mid); \\ \| \^
成功标志如下
make

make install

第四步:验证并启用扩展
检查文件是否存在
bash
ls /www/server/pgsql/share/extension/uuid-ossp.control
ls /www/server/pgsql/lib/uuid-ossp.so

进入数据库:
bash
psql -U postgres -d ai_rag
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"

❓为什么 hstore 能编译,而 uuid-ossp 不能?
-
hstore是纯 C 实现,无外部依赖。 -
uuid-ossp需要调用系统 UUID 生成函数,必须链接libuuid,因此必须在configure时声明。