postgresql - 在azure容器实例上部署Postgres数据库?

标签 postgresql azure azure-container-instances

我正在尝试在 azure 容器实例上部署 PostgresDatabase。 要使用绑定(bind)安装在docker上部署(因为Azure容器实例仅支持绑定(bind)安装),我使用以下命令,并将其部署在docker上。 docker run -d -p 5434:5432 --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -e PGDATA=/var/lib/postgresql/data/pgdata -v /home/ubuntu/volum:/var/lib/postgresql/data postgres

如果我在 Azure 容器实例上进行类似的部署

az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name postgreariesdb25-1 \
    --location eastus \
    --image postgres \
    --dns-name-label $ACI_DNS_LABEL \
    --environment-variables POSTGRES_PASSWORD=mysecretpassword PGDATA=/var/lib/postgresql/data/pgdata  \
    --ports 5432  \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /var/lib/postgresql/data

我在 Azure 容器的日志中收到以下消息

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
2020-11-24 05:23:39.218 UTC [85] FATAL:  data directory "/var/lib/postgresql/data/pgdata" has wrong ownership
2020-11-24 05:23:39.218 UTC [85] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data/pgdata"
running bootstrap script ... 

卷挂载需要在容器重启时有数据。

最佳答案

这是将 Azure 文件共享安装到 Azure 容器实例时的一个已知错误。目前不支持更改挂载点的归属。如果您不想使用其他服务,则需要创建一个脚本将数据移动到挂载点,并且挂载点应该是镜像中不存在的新文件夹。对你来说,镜像中存在挂载点/var/lib/postgresql/data,并且包含Postgresql所依赖的文件,那么这个点就不能作为挂载点。

关于postgresql - 在azure容器实例上部署Postgres数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64980940/

相关文章:

azure - 使用 Docker compose 时的 az 容器 exec

sql - 如何更新 Rails 中的序列并在我的对象中获取结果值?

python - 使用 Python (psycopg2) 在 PostgreSQL 中的通知不起作用

azure - 从 Python SDK 启动容器实例 - 权限问题

Azure 上的 Java Web 应用程序 + mySQL 应用程序内

azure - 使用 Azure Devops 将文件添加到构建输出的最佳方法是什么

Azure 容器实例在启动时更改环境变量

sql - 有没有办法优化 SQL 选择中的子查询数组?

postgresql - jsonb_path_query 按子顺序

javascript - 使用 Android 应用程序中的自定义 API 将数据发布到 Windows Azure 移动服务 Mysql 表