初始化数据库 postgresql 10.10 时出错:PANIC:无法生成秘密授权令牌
Error when init database postgresql 10.10: PANIC: could not generate secret authorization token
我在 运行 命令时遇到问题:sudo -su user_test ./pgsql/bin/initdb -D /example/folder
我从互联网上研究了很多资源,但没有找到解决方案。
我希望每个人都能帮助我。谢谢
环境:
- initdb (PostgreSQL) 10.10
- OS: uname -a Linux DL2100 3.10.38 #1 SMP Build-gitb1820a8 x86_64 GNU/Linux
selecting default max_connections … 100
selecting default shared_buffers … 128MB
selecting default timezone … Europe/Helsinki
selecting dynamic shared memory implementation … posix
creating configuration files … ok
running bootstrap script … 2020-11-03 11:52:56.303 EET [3928] DEBUG: invoking IpcMemoryCreate(size=148545536)
2020-11-03 11:52:56.303 EET [3928] DEBUG: mmap(148897792) with MAP_HUGETLB failed, huge pages disabled: Cannot allocate memory
2020-11-03 11:52:56.315 EET [3928] DEBUG: SlruScanDirectory invoking callback on pg_notify/0000
2020-11-03 11:52:56.315 EET [3928] DEBUG: removing file "pg_notify/0000"
2020-11-03 11:52:56.316 EET [3928] DEBUG: dynamic shared memory system will support 288 segments
2020-11-03 11:52:56.316 EET [3928] DEBUG: created dynamic shared memory control segment 1852866650 (6928 bytes)
2020-11-03 11:52:56.319 EET [3928] PANIC: could not generate secret authorization token
Aborted
child process exited with exit code 134```
在src/backend/access/transam/xlog.c
中BootStrapXLOG
中抛出错误:
/*
* Generate a random nonce. This is used for authentication requests that
* will fail because the user does not exist. The nonce is used to create
* a genuine-looking password challenge for the non-existent user, in lieu
* of an actual stored password.
*/
if (!pg_backend_random(mock_auth_nonce, MOCK_AUTH_NONCE_LEN))
ereport(PANIC,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("could not generate secret authorization token")));
src/backend/utils/misc/backend_random.c
说:
pg_backend_random() function fills a buffer with random bytes. Normally,
it is just a thin wrapper around pg_strong_random(), but when compiled
with --disable-strong-random, we provide a built-in implementation.
因此,PostgreSQL 似乎是建立在一个具有强随机数来源的系统上(OpenSSL 或 /dev/urandom
,如果你不在 Windows 上),但该设施无法正常工作在您当前的系统上。
尝试使用最新的 v10 次要版本(当前为 10.15)——可能已修复错误。
运行 pg_config --configure
检查是否构建了 PostgreSQL --with-openssl
OpenSSL 也使用 /dev/urandom
,因此随机数来源可能有问题;在那里调查
如果都失败了,从源代码构建 PostgreSQL 并使用
配置它
./configure --disable-strong-random ...
它运行良好。非常感谢,@Laurenz Albe
我在 运行 命令时遇到问题:sudo -su user_test ./pgsql/bin/initdb -D /example/folder
我从互联网上研究了很多资源,但没有找到解决方案。
我希望每个人都能帮助我。谢谢
环境:
- initdb (PostgreSQL) 10.10
- OS: uname -a Linux DL2100 3.10.38 #1 SMP Build-gitb1820a8 x86_64 GNU/Linux
selecting default max_connections … 100
selecting default shared_buffers … 128MB
selecting default timezone … Europe/Helsinki
selecting dynamic shared memory implementation … posix
creating configuration files … ok
running bootstrap script … 2020-11-03 11:52:56.303 EET [3928] DEBUG: invoking IpcMemoryCreate(size=148545536)
2020-11-03 11:52:56.303 EET [3928] DEBUG: mmap(148897792) with MAP_HUGETLB failed, huge pages disabled: Cannot allocate memory
2020-11-03 11:52:56.315 EET [3928] DEBUG: SlruScanDirectory invoking callback on pg_notify/0000
2020-11-03 11:52:56.315 EET [3928] DEBUG: removing file "pg_notify/0000"
2020-11-03 11:52:56.316 EET [3928] DEBUG: dynamic shared memory system will support 288 segments
2020-11-03 11:52:56.316 EET [3928] DEBUG: created dynamic shared memory control segment 1852866650 (6928 bytes)
2020-11-03 11:52:56.319 EET [3928] PANIC: could not generate secret authorization token
Aborted
child process exited with exit code 134```
在src/backend/access/transam/xlog.c
中BootStrapXLOG
中抛出错误:
/*
* Generate a random nonce. This is used for authentication requests that
* will fail because the user does not exist. The nonce is used to create
* a genuine-looking password challenge for the non-existent user, in lieu
* of an actual stored password.
*/
if (!pg_backend_random(mock_auth_nonce, MOCK_AUTH_NONCE_LEN))
ereport(PANIC,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("could not generate secret authorization token")));
src/backend/utils/misc/backend_random.c
说:
pg_backend_random() function fills a buffer with random bytes. Normally,
it is just a thin wrapper around pg_strong_random(), but when compiled
with --disable-strong-random, we provide a built-in implementation.
因此,PostgreSQL 似乎是建立在一个具有强随机数来源的系统上(OpenSSL 或 /dev/urandom
,如果你不在 Windows 上),但该设施无法正常工作在您当前的系统上。
尝试使用最新的 v10 次要版本(当前为 10.15)——可能已修复错误。
运行
pg_config --configure
检查是否构建了 PostgreSQL--with-openssl
OpenSSL 也使用
/dev/urandom
,因此随机数来源可能有问题;在那里调查
如果都失败了,从源代码构建 PostgreSQL 并使用
配置它./configure --disable-strong-random ...
它运行良好。非常感谢,@Laurenz Albe