LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 11-01-2012, 02:49 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
postgresql - how to replicate database/tablespace with a shared iscsi volume


Hi!

I'm experimenting/documenting the process of setting up a cluster with pacemaker.

I have these two virtual machines sharing an iSCSI volume. I have set up a partition in that volume. I have formatted the partition and can mount it in both servers (manually, one at a time, not using pacemaker yet).

Next step would be to create the tablespace using that partition and then create the database using that separate tablespace. I can do it in one of the servers but then my question is: how can I make the other server start using the tablespace/database that were created on the first server? Just so that you have no doubts:
- I will stop postgres on the first server
- I will umount the partition
- I will mount the partition on the second server
- What's next so that postgres on the second server can see that tablespace/database?

Thanks in advance.
 
Old 11-01-2012, 03:33 PM   #2
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
This is hackish but I think could work, what do you think?

On the first server, I create the tablespace and the database (using the tablespace).. leaving the database empty for the moment.

I shutdown postgres on the first server
I umount on the forst server
I mount on the second server
I delete everyting from the tablespace mountpoint
I create the tablespace on the second server
I create the database using the new tablespace.

Now, I shutdown postgres, umount on the second server
I mount and start postgres on the first server. It should "think" there were no changes on the tablespace and I should be able to switch to the second server as well, am I right?
 
Old 11-01-2012, 04:03 PM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
Nope... that didn't work.

After I had recreated the empty database on the second server, I noticed that the directory names that were present at the root of that fs I set up for the tablespace were not the same:

When I just mounted the FS on the second server (before deleting everything so that I could recreate the tablespace/database):
Code:
$ sudo ls -l /var/lib/postgresql/sanos/
total 8
drwx------ 2 postgres postgres 4096 2012-11-01 16:04 16388
-rw------- 1 postgres postgres    4 2012-11-01 15:39 PG_VERSION
Then I deleted everything and proceeded to create the tablespace/database:
Code:
$ sudo ls -l /var/lib/postgresql/sanos/
total 8
drwx------ 2 postgres postgres 4096 2012-11-01 16:22 16386
-rw------- 1 postgres postgres    4 2012-11-01 16:22 PG_VERSION
16388 vs 16386. Anyway, I shutdown postgres on the second server, umounted. Mounted on the first server, started postgres on the first server.

Code:
$ sudo /etc/init.d/postgresql-8.4 start
 * Starting PostgreSQL 8.4 database server                                                                                                                                   [ OK ] 
$ sudo -u postgres psql sanos
psql: FATAL:  database "sanos" does not exist
DETAIL:  The database subdirectory "pg_tblspc/16387/16388" is missing.
End of story.
 
Old 11-01-2012, 04:16 PM   #4
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
SO the only way to pull this off is by sharing data_directory (as set in postgresql.conf)?
 
  


Reply

Tags
iscsi, pacemaker, postgresql, san, tablespace


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to refresh shared file system on shared logical volume created in NAS back-end Kaustuv Linux - Enterprise 3 08-13-2011 06:48 AM
which /dev is which iscsi volume td3201 Linux - Server 1 12-31-2008 01:40 PM


All times are GMT -5. The time now is 05:52 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration