Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Database migration in postgresql production environment

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Because the existing pg environment is overloaded, the current database needs to be migrated to the new environment.

If the amount of data is small, you can use method 1.

Method 1:

Pgsql migrates the database to a new library in different network segments, and the new database environment master-slave high-availability environment has been configured.

First back up the old library

$pg_dump-U peimsmdata-d peimsm > peimsm.sql

Compress

$tar-zcf peimsm.tar.gz peimsm.sql

Transfer the file to the new environment and extract it

$tar-xzf peimsm.tar.gz

Import database

$psql-U peimsmdata-d peimsm < peimsm.sql

But in fact, the amount of data is 50 to 60 million, more than 50 GB, so using the above method will be very time-consuming, so use the following method

Method 2:

The new and old environment is in a network segment

First stop the corresponding business of the old database, and then stop the database service and keepalived service

Then compile postgresql in the main library environment

Clean up the archive file before the latest file in the pg_archive directory using the following command

$pg_archivecleanup. / filename

Transfer all files under the / data/pg_data directory in the old environment to the / data/pg_data directory in the new environment, modify the configuration file, and start the service.

Master-slave synchronization data

...

Configure according to the master-slave configuration document, etc.

Referenc

Https://help.aliyun.com/document_detail/26157.html#h3-url-4

Https://blog.csdn.net/qq_36408250/article/details/80652518

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report