在CentOS上迁移PostgreSQL数据需要经过以下几个步骤:
pg_dump
工具来完成这个任务。请确保在运行此命令时使用正确的数据库名称和身份验证信息。sudo pg_dump -U your_username -h your_host -p your_port -Fc your_database_name > backup.dump
scp
、rsync
或其他文件传输工具来完成这个任务。scp backup.dump your_username@your_new_host:/path/to/destination
pg_restore
工具恢复数据库。请确保在运行此命令时使用正确的数据库名称和身份验证信息。sudo pg_restore -U your_username -h your_host -p your_port your_database_name < backup.dump
更新配置文件
在新的服务器上,更新PostgreSQL配置文件(通常位于/etc/postgresql/版本号/main/postgresql.conf
)以匹配原服务器的设置。这可能包括调整内存限制、连接数限制等。
更新监听设置
确保新的PostgreSQL实例允许来自其他服务器的连接。编辑postgresql.conf
文件中的listen_addresses
设置,将其设置为'*'
或特定的IP地址。
listen_addresses = '*'
sudo systemctl restart postgresql
sudo firewall-cmd --permanent --add-service=postgresql
sudo firewall-cmd --reload
psql -U your_username -h your_host -p your_port your_database_name
完成以上步骤后,你应该已经成功地将PostgreSQL数据从旧服务器迁移到了新服务器。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: centos怎么查看用户权限