Re: general fear question about move PGDATA from one Disc to another

Поиск
Список
Период
Сортировка
От Aleksandar Lazic
Тема Re: general fear question about move PGDATA from one Disc to another
Дата
Msg-id 56276d2b20e9e402bdc1bd92911197cb@none.at
обсуждение исходный текст
Ответ на Re: general fear question about move PGDATA from one Disc to another  (Craig Ringer <craig@2ndQuadrant.com>)
Список pgsql-general
Dear Craig,

Am 14-11-2012 00:44, schrieb Craig Ringer:
> On 11/13/2012 11:26 PM, Aleksandar Lazic wrote:
>> Dear listmembers,
>>
>> I need to move
>>
>> /var/lib/postgresql/8.4/main
>>
>> from the / partion to another disc.
>
> If so, you're probably using `pg_wrapper` for cluster management.
> Confirm that with `pg_lsclusters`. If the command exists and it shows
> an
> 8.4 installation with the data directory you mentioned above, then
> you're using pg_wrapper to manage Pg.

pg_lsclusters
Version Cluster   Port Status Owner    Data directory
  Log file
8.4     main      5432 online postgres /var/lib/postgresql/8.4/main
  custom

> pg_wrapper reads
> /etc/postgresql/[version]/[clustername]/postgresql.conf
> to locate the cluster. For example, yours will be
> /etc/postgresql/8.4/main/postgresql.conf . This means you don't have
> to
> edit any init script settings on your system to get Pg to start
> properly
> next boot.

This was also a option for me. I wanted not to much changes in the
system but it
looks that this is the best way.

>> 0.) Mount new pgroot, are there any hints for the mount command?
>>
>>     mount -t ext4 -o noatime,nodiratime,nodev,noexec,nosuid
>> /dev/sde1
>> /pgroot
>>
>>     output from mount
>>
>>     /dev/sde1 on /pgroot type ext4
>> (rw,nosuid,nodev,noexec,noatime,nodiratime,barrier=1,data=ordered)
>
> Unless you add this to fstab as well, the file system won't mount at
> the
> next boot and PostgreSQL will fail to start.

;-) I added this to the fstab, of course.

>> 3.) copy the current /var/lib/postgresql/8.4/main to the new dir as
>> user postgres
>>     cd /var/lib/postgresql/
>>     tar cvf - . | (cd /pgroot/pgdata && tar xvf -)
>
> What an odd way to do the copy. I'd use `cp -aR`, or at least use the
> preserve flag (-p) to tar.

Well it is old fashioned way.

> If you like you can have the new file system (assuming it's dedicated
> to
> just PostgreSQL) mount where the old data directory was, so there's
> no
> change visible in the system.
>
> edit /etc/fstab and add a line like:
>
> UUID=b4d54649-a9b5-4a57-aa22-291791ad7a3c /var/lib/postgresql/ ext4
> defaults,noatime  0 0
>
> Replace the UUID shown with the UUID of your new file system,
> determined
> with the vol_id command on older systems, or blkid on newer ones. Or
> just use the device node for the partition, like /dev/sdx9

I have written the following into the fstab.

/dev/sde1 /var/lib/postgresql ext4
noatime,nodiratime,nodev,noexec,nosuid 0 2

> Make a full pg_dumpall backup.
>
> Now stop all your PostgreSQL clusters with pg_ctlcluster and:
>
> mv /var/lib/postgresql/ mv /var/lib/postgresql.old
> mkdir /var/lib/postgresql
> mount /var/lib/postgresql
> chown postgres:postgres /var/lib/postgresql
> shopt -s dotglob
> cp -aR /var/lib/postgresql.old/* /var/lib/postgresql/
> Start the cluster with pg_ctlcluster

Thanks for the description and explanation.

Best regards
Aleks


В списке pgsql-general по дате отправления:

Предыдущее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: Understanding streaming replication
Следующее
От: Shaun Thomas
Дата:
Сообщение: Re: SSDs - SandForce or not?