我有一个PostgreSQL数据库,里面有我的树莓派上的一些感官数据。它在postgres:12-alpine
标签上运行,还没有自动更新。在更新之前,我得到了以下版本字符串:
('PostgreSQL 12.3 on arm-unknown-linux-musleabihf, compiled by gcc (Alpine 9.3.0) 9.3.0, 32-bit',)
在我注意到它有点过时后,我提取了带有以下版本字符串的最新图像:
('PostgreSQL 12.6 on arm-unknown-linux-musleabihf, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 32-bit',)
这是有效的,但我注意到,当使用NOW()
时,新插入的传感器数据得到了2038年的时间戳。用Alpine解决这个问题似乎很复杂,也许也是一个Alpine问题。我已经遇到了由他们的musl用法引起的问题。由于普通图像不会太大(109MB对62MB(,我切换到常规postgres:12
图像。
由于容器是用正常的Debian映像启动的,因此启动失败:
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | 2021-03-31 17:00:05.213 UTC [1] LOG: starting PostgreSQL 12.3 on arm-unknown-linux-musleabihf, compiled by gcc (Alpine 9.3.0) 9.3.0, 32-bit
postgres_1 | 2021-03-31 17:00:05.214 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2021-03-31 17:00:05.214 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2021-03-31 17:00:05.226 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2021-03-31 17:00:11.083 UTC [1] LOG: startup process (PID 20) was terminated by signal 11: Segmentation fault
postgres_1 | 2021-03-31 17:00:11.084 UTC [1] LOG: aborting startup due to startup process failure
postgres_1 | 2021-03-31 17:00:14.480 UTC [1] LOG: database system is shut down
pms_postgres_1 exited with code 1
与Debian图像相同的问题:
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | 2021-03-31 17:11:19.733 UTC [1] LOG: starting PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on arm-unknown-linux-gnueabihf, compiled by gcc (Debian 8.3.0-6) 8.3.0, 32-bit
postgres_1 | 2021-03-31 17:11:19.738 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2021-03-31 17:11:19.738 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2021-03-31 17:11:19.752 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2021-03-31 17:11:28.520 UTC [1] LOG: startup process (PID 27) was terminated by signal 11: Segmentation fault
postgres_1 | 2021-03-31 17:11:28.520 UTC [1] LOG: aborting startup due to startup process failure
postgres_1 | 2021-03-31 17:11:35.024 UTC [1] LOG: database system is shut down
pms_postgres_1 exited with code 1
它也不适用于最新的12.6版本。我假设问题是,我从Alpine切换到Debian,并用pull更新了PostgreSQL版本。因此Alpine上的PSQL12.3在Debian上升级为PSQL12.6。
为什么会出现分段错误,以及如何修复?
我的docker-compose.yml
:
version: '2.4'
volumes:
#postgres-data_new:
postgres-data:
services:
postgres:
image: postgres:12.6
#image: postgres:12.3-alpine
#image: postgres:12-alpine
restart: always
volumes:
- postgres-data:/var/lib/postgresql/data
- ./create-tables.sql:/docker-entrypoint-initdb.d/create-tables.sql
environment:
POSTGRES_PASSWORD: xx
POSTGRES_DB: xxx
ports:
- 5432:5432
create-tables.sql
只是创建了一个非常基本的度量数据表:
create table if not exists sensors(
id SERIAL PRIMARY KEY,
soilMoisture NUMERIC NOT NULL,
temp NUMERIC NOT NULL,
dateTime timestamp NOT NULL
);
问题似乎是主机上的libseccomp版本过时:需要libseccomp2.4.2或更新版本和Docker到19.03.9或更新版本。但我的RPI距离回购只有2.3.3:
# dpkg -l | grep libseccomp
ii libseccomp2:armhf 2.3.3-4 armhf high level interface to Linux seccomp filter
有两种方法可以解决此问题,,但仅适用于具有新容量的新容器。我仍然无法从卷中获取现有的数据库。
#1手动安装新版本并绕过包管理器
至少在回购更新之前。我想这将在一段时间后发生,然后我们可以再次使用复星提供的版本。
wget http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb
sudo dpkg -i libseccomp2_2.5.1-1_armhf.deb
#2在docker-compose.yml
中禁用它作为解决方法
security_opt:
- seccomp:unconfined
但这将降低主机对容器中恶意代码的安全性,因此更新库似乎是一个更安全的解决方案。