简体   繁体   English

在辅助卷上的 AWS EC2 CentOS 7 中安装 Postgresql

[英]Installing Postgresql in AWS EC2 CentOS 7 on secondary volume

My AWS EC2 has two volumes, primary and secondary, with the secondary volume being larger.我的 AWS EC2 有两个卷,主卷和辅助卷,辅助卷更大。 I am looking to install Postgres on this EC2.我希望在此 EC2 上安装 Postgres。 As the database gets used, I anticipate it will overrun the size of the primary volume.随着数据库的使用,我预计它会超出主卷的大小。 So,所以,

1 - How can I install it such that the database sits on the secondary volume? 1 - 如何安装它以使数据库位于辅助卷上? I am referencing this article for installation.我正在参考这篇文章进行安装。 Particularly, the following command installs it on the primary volume:特别是,以下命令将其安装在主卷上:

sudo yum install postgresql postgresql-server postgresql-devel postgresql- contrib postgresql-docs

2 - Is is advisable to install it on the secondary volume? 2 - 建议将其安装在辅助卷上吗? If no, why?如果没有,为什么?

Thanks.谢谢。

1 - How can I install it such that the database sits on the secondary volume? 1 - 如何安装它以使数据库位于辅助卷上?

see the documentation, basically you can initialize a database on any folder https://www.postgresql.org/docs/13/app-initdb.html请参阅文档,基本上您可以在任何文件夹https://www.postgresql.org/docs/13/app-initdb.html上初始化数据库

Example:例子:

initdb -D /mnt/data

2 - Is is advisable to install it on the secondary volume? 2 - 建议将其安装在辅助卷上吗? If no, why?如果没有,为什么?

Sure, it's easier to maintain and resize a non-root volume.当然,维护和调整非根卷的大小更容易。

Regardless that with AWS you could consider running the AWS RDS, where a lot of maintenance tasks (eg storage auto-scaling) is offloaded to AWS无论使用 AWS,您都可以考虑运行 AWS RDS,其中许多维护任务(例如存储自动缩放)被卸载到 AWS

The standard pattern I see for this is to install postres db the normal way to the normal place, and then setting the pg data directory to a mountpoint on a different volume.我看到的标准模式是以正常方式将 postres db 安装到正常位置,然后将 pg 数据目录设置为不同卷上的挂载点。 This differentiates the postgres application files (which would be on the same volume as the rest of the OS filesystem) from the postgres data (which would be on the secondary).这将 postgres 应用程序文件(与操作系统文件系统的 rest 在同一卷上)与 postgres 数据(在辅助文件上)区分开来。 It can be advisable for a few reasons - isolating db data disk usage from system disk usage is a good one.出于几个原因,这是可取的——将数据库数据磁盘使用与系统磁盘使用隔离是一个很好的方法。 Another reason is to be able to scale throughput and size independently and see usage independently.另一个原因是能够独立扩展吞吐量和大小并独立查看使用情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM