✅ 宝塔 PostgreSQL 安装UUID指南

😊补充:没有安装成功 的扩展

如果你在使用springAI中检索事增强RAG在自动或者手动创建数据库的时候报错如下:主要信息

#error "please use configure's --with-uuid switch to select a UUID library"

你遇到的错误非常典型: 因为 uuid-ossp 扩展依赖系统上的 UUID 库 (如 libuuidOSSP 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 时声明。

相关推荐
一瓢西湖水10 小时前
列式数据库-以clickHouse为例
数据库·clickhouse
Elastic 中国社区官方博客10 小时前
使用 Elastic Cloud Serverless 扩展批量索引
大数据·运维·数据库·elasticsearch·搜索引擎·云原生·serverless
liulanba10 小时前
AI Agent技术完整指南 第一部分:基础理论
数据库·人工智能·oracle
逆天小北鼻10 小时前
Oracle 服务端与客户端的核心区分要点
数据库·oracle
2501_9462429310 小时前
MPV-EASY Player (MPV播放器) v0.41.0.1
数据库·经验分享·云计算·计算机外设·github·电脑·csdn开发云
MySQL实战11 小时前
Redis 7.0 新特性之maxmemory-clients:限制客户端内存总使用量
数据库·redis
VX:Fegn089512 小时前
计算机毕业设计|基于springboot + vue校园社团管理系统(源码+数据库+文档)
前端·数据库·vue.js·spring boot·后端·课程设计
北亚数据恢复12 小时前
虚拟机数据恢复—ESXi虚拟机下SqlServer数据库数据恢复案例
数据库
susu108301891113 小时前
使用navicat创建事件event报错You have an error in your SQL syntax
数据库·sql