Re: how to create multiple databases running in different dirs

Поиск
Список
Период
Сортировка
Искать

Re: how to create multiple databases running in different dirs

От:
Rob Sargent <robjsargent@gmail.com>
Дата:
On 06/30/2014 05:58 PM, frank ernest wrote:
Hi, I'm new to postgresql and sql in general. I desired to write a program in C that used an sql data base for IPC and because multiple copies of my program might run on the same machine I wanted a way to ensure that only one copy of each multithreaded program got one database but I'm uncertain how to go about this. As the program might be run several different times and each time it should only get the data base from it's predisesor I can't use the pid as a unique data base name. I thought that I might start multiple pgsql instances but somehow that seems wrong. Any ideas?
 
Thanks, David
 
Is each runtime instance of your application to have a new, empty database?  No data from any other run of the application?

Re: how to create multiple databases running in different dirs

От:
John R Pierce <pierce@hogranch.com>
Дата:
On 6/30/2014 4:58 PM, frank ernest wrote:
> Hi, I'm new to postgresql and sql in general. I desired to write a 
> program in C that used an sql data base for IPC and because multiple 
> copies of my program might run on the same machine I wanted a way to 
> ensure that only one copy of each multithreaded program got one 
> database but I'm uncertain how to go about this. As the program might 
> be run several different times and each time it should only get the 
> data base from it's predisesor I can't use the pid as a unique data 
> base name. I thought that I might start multiple pgsql instances but 
> somehow that seems wrong. Any ideas?

how would an instance of your program know what to connect to, or which 
previous instance its 'predecessor' was ?

normally, you have ONE database for a given set of applications, and all 
the applications share the same database tables and such.


-- 
john r pierce                                      37N 122W
somewhere on the middle of the left coast


Re: how to create multiple databases running in different dirs

От:
John R Pierce <pierce@hogranch.com>
Дата:
On 7/1/2014 7:19 AM, Rémi Cura wrote:
>
> If it is so your desire, you could also have multiple server on the 
> same machine (althought on different port).
> This way each server would have its own repository.

which still doesn't answer the question, how would an instance of his 
program know which database (port) to connect to?



-- 
john r pierce                                      37N 122W
somewhere on the middle of the left coast


Re: how to create multiple databases running in different dirs

От:
John R Pierce <pierce@hogranch.com>
Дата:

> > how would an instance of your program know what to connect to, or which
> > previous instance its 'predecessor' was ?
> > normally, you have ONE database for a given set of applications, and all
> > the applications share the same database tables and such.
>
> That's the problem, is there some way to tell pgsql "Go to dir X, open 
> your data base Y and prepare for connections at adress Z and port P"? 
> And could pgsql accept multiple connections on the same address and 
> port? I was thinking of using my pID but that would change and if I 
> used a user created string then if I started only on a single instace 
> of pgsql and pointed it to it's databases the user might get the 
> strings duplicated and that would be no good. I also thought of naming 
> each database with a name generated by using the uuid library but I'm 
> not sure which would be best.

why directory, address and port?   why not just 'open database X' ?    
this still doesn't answer my question, HOW do you determine which 
database a given instance of your program is supposed to connect to?

yes, postgres supports many different connections to the same address 
and port, either to the same database or different databases.   
relational databases are totally built around concurrent transactional 
operations.

there's no such thing as 'directory', all database tables are stored in 
the database server's private storage, the client app has no need to 
know where this is.  There /is/ a concept of 'tablespaces', these are 
used when you want to put different tables on different file systems, 
typically used for very large scale databases, and/or when you have 
different performance tiers of storage.


> No, the dynamically generated content is to be dropped (drop table 
> dynamic_content;) but the rest is to be preserved. The idea is to 
> create a database of a file system but the files contain no data, I 
> only want their metadata and I will add a few additional metadta 
> values to each file.

using TRUNCATE SOME_TABLE  would likely make more sense, that deletes 
all the data in table SOME_TABLE, without actually deleting the table 
definition, so you can then proceed to insert new data into it.

I really don't understand what you mean by 'a database of a file 
system'.   I'm beginning to suspect you don't understand how SQL 
databases work.




-- 
john r pierce                                      37N 122W
somewhere on the middle of the left coast


Re: how to create multiple databases running in different dirs

От:
Rémi Cura <remi.cura@gmail.com>
Дата:
Hey,
postgres already takes care of multiple client writting/reading,
so you don't really need to be afraid of concurrency (for most of the stuff)

If it is so your desire, you could also have multiple server on the same machine (althought on different port).
This way each server would have its own repository.

Cheers,
Rémi-C


2014-07-01 4:59 GMT+02:00 John R Pierce <pierce@hogranch.com>:
On 6/30/2014 4:58 PM, frank ernest wrote:
Hi, I'm new to postgresql and sql in general. I desired to write a program in C that used an sql data base for IPC and because multiple copies of my program might run on the same machine I wanted a way to ensure that only one copy of each multithreaded program got one database but I'm uncertain how to go about this. As the program might be run several different times and each time it should only get the data base from it's predisesor I can't use the pid as a unique data base name. I thought that I might start multiple pgsql instances but somehow that seems wrong. Any ideas?

how would an instance of your program know what to connect to, or which previous instance its 'predecessor' was ?

normally, you have ONE database for a given set of applications, and all the applications share the same database tables and such.


--
john r pierce                                      37N 122W
somewhere on the middle of the left coast



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: how to create multiple databases running in different dirs

От:
John W Higgins <wishdev@gmail.com>
Дата:
Afternoon Frank,

I believe what you might wish to look at is a single database with a set of schemas[1] which would separate your data in a logical way. You could have a single connection url and then each individual connection could create a schema (or reuse if you wish), set the search path (first example here [2]) and populate the schema (if needed) within your single database 

That would give you your desired isolation but within a simple framework that is PostgreSQL friendly.

John



On Wed, Jul 2, 2014 at 4:24 PM, frank ernest <doark@mail.com> wrote:
> how would an instance of your program know what to connect to, or which
> previous instance its 'predecessor' was ?
> normally, you have ONE database for a given set of applications, and all
> the applications share the same database tables and such.

That's the problem, is there some way to tell pgsql "Go to dir X, open your data base Y and prepare for connections at adress Z and port P"? And could pgsql accept multiple connections on the same address and port? I was thinking of using my pID but that would change and if I used a user created string then if I started only on a single instace of pgsql and pointed it to it's databases the user might get the strings duplicated and that would be no good. I also thought of naming each database with a name generated by using the uuid library but I'm not sure which would be best.
 
If I choose to have multiple servers running on the same machine how would my program start them?
 
> Is each runtime instance of your application to have a new, empty
> database? No data from any other run of the application?
 
No, the dynamically generated content is to be dropped (drop table dynamic_content;) but the rest is to be preserved. The idea is to create a database of a file system but the files contain no data, I only want their metadata and I will add a few additional metadta values to each file.
 
Thanks, David
 

how to create multiple databases running in different dirs

От:
"frank ernest" <doark@mail.com>
Дата:
Hi, I'm new to postgresql and sql in general. I desired to write a program in C that used an sql data base for IPC and because multiple copies of my program might run on the same machine I wanted a way to ensure that only one copy of each multithreaded program got one database but I'm uncertain how to go about this. As the program might be run several different times and each time it should only get the data base from it's predisesor I can't use the pid as a unique data base name. I thought that I might start multiple pgsql instances but somehow that seems wrong. Any ideas?

 

Thanks, David

 

Re: how to create multiple databases running in different dirs

От:
"frank ernest" <doark@mail.com>
Дата:
> how would an instance of your program know what to connect to, or which
> previous instance its 'predecessor' was ?

> normally, you have ONE database for a given set of applications, and all
> the applications share the same database tables and such.


That's the problem, is there some way to tell pgsql "Go to dir X, open your data base Y and prepare for connections at adress Z and port P"? And could pgsql accept multiple connections on the same address and port? I was thinking of using my pID but that would change and if I used a user created string then if I started only on a single instace of pgsql and pointed it to it's databases the user might get the strings duplicated and that would be no good. I also thought of naming each database with a name generated by using the uuid library but I'm not sure which would be best.

 

If I choose to have multiple servers running on the same machine how would my program start them?

 

> Is each runtime instance of your application to have a new, empty
> database? No data from any other run of the application?

 

No, the dynamically generated content is to be dropped (drop table dynamic_content;) but the rest is to be preserved. The idea is to create a database of a file system but the files contain no data, I only want their metadata and I will add a few additional metadta values to each file.

 

Thanks, David

 
FAQ