掲示板

Merge Two Lifreay Databases

thumbnail
7年前 に Doyle Briley によって更新されました。

Merge Two Lifreay Databases

New Member 投稿: 6 参加年月日: 15/07/20 最新の投稿
Does anyone know of a tool to merge the liferay (lportal) databases from two seperate liferay instances? We are setting up a liferay instance dedicated to one client and have another instance for our remaining clients. Down the road we are looking into combining these two instances and I am curious if there is a tool or code already written that would allow the two database to be merged.

Thanks in advance for any help or insight to solving this issue!
thumbnail
7年前 に Jorge Díaz によって更新されました。

RE: Merge Two Lifreay Databases

Liferay Master 投稿: 753 参加年月日: 14/01/09 最新の投稿
You can have a lot of problems if you mix two different databases in one, because each database has its own counters.
So after mixing them, you can have different objects with same id.

In order to avoid that, you can export/import using LAR files
thumbnail
7年前 に Doyle Briley によって更新されました。

RE: Merge Two Lifreay Databases

New Member 投稿: 6 参加年月日: 15/07/20 最新の投稿
Hi Andrew,

Thanks for the quick reply.

I am not sure I understand, how does that prevent problems like duplicate id's from causing issues? For example, in the first instance we may have a user Bob with an id of 1005. In the second instance we may have a user Jane with the same id, 1005. When we try to merge the two user_ tables for theses instances it seems only one of these id's would be allowed. We need some programmatic way to reassign/remap all of the liferay objects from one instance to the other. I am sure you realize how interrelated the items in the liferay (lportal) database are (user, contact, group, organization, etc.) and mapping those manually would not be an easy task.

My suspicion is that there isn't a reasonable way to do this and we will end up having to manually recreate everything for the new client in the existing instance and losing some information along the way.

Thank you!
thumbnail
7年前 に Olaf Kock によって更新されました。

RE: Merge Two Lifreay Databases

Liferay Legend 投稿: 6396 参加年月日: 08/09/23 最新の投稿
Doyle Briley:
My suspicion is that there isn't a reasonable way to do this and we will end up having to manually recreate everything for the new client in the existing instance and losing some information along the way.


You're pointing out exactly Jorge's objections - and I'd second them: Don't just merge the database. (To that guy posting with Andrew's account: Who are you and what have you done to Andrew? He'd never suggest writing to the database in a publicly quotable place)

For the content: Use export/import through LAR files.
For users: If you're on EE, you might want to try Liferay mimicing an LDAP server - there's a VLDAP plugin on marketplace that publishes Liferay's user database through LDAP - install this on one of your systems and configure the other to use this LDAP and import the users. If you have a significant amount of users and groups it might be a well understood method to deal with them. If they're not very structured, you might get away with a custom export/import routine that just dumps information out of one database into a csv-file, then reads this into the other. Naturally, this would use Liferay's API (UserLocalService, RoleLocalService, UserGroupLocalService etc) to read/write the data. If you're more or less "just" after the user accounts, it might be quick. If you need more: It depends on what you're more familiar with: API or LDAP (and if LDAP covers all you need)
thumbnail
7年前 に Jorge Díaz によって更新されました。

RE: Merge Two Lifreay Databases (回答)

Liferay Master 投稿: 753 参加年月日: 14/01/09 最新の投稿
Hi all,

There is one situation that maybe it is safe to join databases:
- If you have one unique Liferay installation with more than one database using sharding, the database counters are shared
- So perhaps you can join shards databases into a single database, but I haven't tested it!

But in case if you have more than one Liferay installations, each one with its own database, you cannot join databases, as you will have different objects with same id.

About exporting/importing users, there are some applications in marketplace:
- https://web.liferay.com/es/marketplace/-/mp/application/61081811
- https://web.liferay.com/es/marketplace/-/mp/application/33064852
thumbnail
7年前 に Doyle Briley によって更新されました。

RE: Merge Two Lifreay Databases

New Member 投稿: 6 参加年月日: 15/07/20 最新の投稿
Hi Jorge,

While it may not be a complete solution, I believe the User Export Import Plugin may be a step in the right direction. I may be able to use it to export the information I need and then re-ID, increment the counters in the counter table and re-import. I will definitely test this in a non-production environment first.

Thank you!
thumbnail
7年前 に Andrew Jardine によって更新されました。

RE: Merge Two Lifreay Databases

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hey Doyle,

It totally doesn't! That was a boner answer I gave ... as Olaf has pointed out. Clearly that one was not thought through. In fact, it is such bad advice that as soon as I hit Publish here? I am deleting that post to both save further embarrassment (lol) and to make sure that anyone too lazy to read beyond my post doesn't use it as a solution! emoticon

I hang my head in shame! Please forgive me Liferay.
thumbnail
7年前 に Olaf Kock によって更新されました。

RE: Merge Two Lifreay Databases

Liferay Legend 投稿: 6396 参加年月日: 08/09/23 最新の投稿
Andrew Jardine:
I hang my head in shame! Please forgive me Liferay.


You are forgiven, now that you gained back control over your account.

I forgot to take a screenshot for blackmailing you anyway emoticon