✅ 宝塔 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 时声明。

相关推荐
m0_4665252913 分钟前
绿盟科技风云卫AI安全能力平台成果重磅发布
大数据·数据库·人工智能·安全
爱学习的阿磊1 小时前
使用Fabric自动化你的部署流程
jvm·数据库·python
枷锁—sha1 小时前
【SRC】SQL注入快速判定与应对策略(一)
网络·数据库·sql·安全·网络安全·系统安全
惜分飞1 小时前
ORA-600 kcratr_nab_less_than_odr和ORA-600 4193故障处理--惜分飞
数据库·oracle
chian-ocean1 小时前
CANN 生态进阶:利用 `profiling-tools` 优化模型性能
数据库·mysql
m0_550024631 小时前
持续集成/持续部署(CI/CD) for Python
jvm·数据库·python
AC赳赳老秦1 小时前
代码生成超越 GPT-4:DeepSeek-V4 编程任务实战与 2026 开发者效率提升指南
数据库·数据仓库·人工智能·科技·rabbitmq·memcache·deepseek
啦啦啦_99991 小时前
Redis-2-queryFormat()方法
数据库·redis·缓存
数据知道2 小时前
PostgreSQL实战:详解如何用Python优雅地从PG中存取处理JSON
python·postgresql·json
玄同7652 小时前
SQLite + LLM:大模型应用落地的轻量级数据存储方案
jvm·数据库·人工智能·python·语言模型·sqlite·知识图谱