RE: Correct Way To Migrate Existing Gerrit Server

4,533 views
Skip to first unread message

phur1234

unread,
Feb 15, 2011, 7:55:04 PM2/15/11
to Repo and Gerrit Discussion
Hi,
We are planning to do a major migration of one of our existing
Gerrit servers to a new server. I am trying to get feedback on the
correct way to do this. I'm also concerned about any potential hard
coded hostname issues I might run into since system hostnames will be
changing.

Please assume Gerrit is installed on the new Server.

1) Shut down Gerrit on production Server A
2) Dump Server A (existing server) MYSQL database to a backup file
3) Copy over backup file to new Server B
4) Restore the backup file to Server B
5) Rsync GIT repos from production Server A to Server B
6) Update the Canonical Web URL on Server with the DNS Alias that
previously pointed to A
7) Start Gerrit on Server B

We recently did a migration from an old server to the a new
system. The intention was to create a new Gerrit server based on an
existing Git repo, but since there were change ids in refs/changes,
we ran into issues. Although that was a different issue, I would like
to get some feedback on whether I am taking the correct approach.

Thanks in advance.

Shawn Pearce

unread,
Feb 16, 2011, 10:10:43 AM2/16/11
to phur1234, Repo and Gerrit Discussion
On Tue, Feb 15, 2011 at 16:55, phur1234 <phur...@gmail.com> wrote:
>    We are planning to do a major migration of one of our existing
> Gerrit servers to a new server. I am trying to get feedback on the
> correct way to do this.  I'm also concerned about any potential hard
> coded hostname issues I might run into since system hostnames will be
> changing.

Nope. The hostnames are all stored in the gerrit.config file. Make
sure that file is correct, and you should be OK.

> Please assume Gerrit is installed on the new Server.
>
> 1) Shut down Gerrit on production Server A
> 2) Dump Server A (existing server) MYSQL database to a backup file
> 3) Copy over backup file to new Server B
> 4) Restore the backup file to Server B
> 5) Rsync GIT repos from production Server A to Server B
> 6) Update the Canonical Web URL on Server with the DNS Alias that
> previously pointed to A
> 7) Start Gerrit on Server B

Yes, as you said in 6, you are updating the canonicalWebURL. I would
also double check the sshd.listenAddress and try to configure it with
the same hostname as the canonicalWebURL as that is the hostname that
Gerrit will advertise to repo upload clients when they try to send a
change for review.

If you use OpenID with providers like Yahoo! or Google Accounts, your
users will lose their account information as a result of changing the
hostname their browser uses to access the site. But if you don't use
OpenID (e.g. you use LDAP or HTTP) then this is a non-issue. Or if you
setup a CNAME from the old host to the new host, and use the CNAME in
the canonicalWebURL you can bypass this.

You may also want to consider copying the ssh host keys from the old
server's $site_path/etc/ directory, so that users don't see the host
key change.

>    We recently did a migration from an old server to the a new
> system.  The intention was to create a new Gerrit server based on an
> existing Git repo, but since there were change ids in  refs/changes,
> we ran into issues.  Although that was a different issue, I would like
> to get some feedback on whether I am taking the correct approach.

This occurs because the refs/changes in the Git repository _MUST_
match the database. Above you are ensuring that by shutting down the
system, dumping the database, restoring it, and rsyncing the Git
repositories. But just taking another Gerrit server's refs/changes/
namespace and copying it over causes all sorts of misbehavior and
errors. Fortunately you aren't doing that. :-)

We've used the above process to move servers several times, I think we
have it down to under 20 minutes these days. :-\

phur1234

unread,
Feb 16, 2011, 11:37:33 PM2/16/11
to Repo and Gerrit Discussion
Shawn,
Thanks for the quick response back. I'm sure that other people
will find this post useful. The one thing that I'm not clear about is
how to migrate the replication set up so it will work without any
modifications (replication to other git servers). Should I copy over
the private/public key of the gerrit user onto the new server to the
new gerrit user? How is this different from the ssh host keys in
$site_path/etc/? On my server, I see private/public rsa and dsa keys
in that directory.

On Feb 16, 7:10 am, Shawn Pearce <s...@google.com> wrote:

Shawn Pearce

unread,
Feb 17, 2011, 1:04:33 PM2/17/11
to phur1234, Repo and Gerrit Discussion
On Wed, Feb 16, 2011 at 20:37, phur1234 <phur...@gmail.com> wrote:
>   Thanks for the quick response back.  I'm sure that other people
> will find this post useful.  The one thing that I'm not clear about is
> how to migrate the replication set up so it will work without any
> modifications (replication to other git servers).  Should I  copy over
> the private/public key of the gerrit user onto the new server to the
> new gerrit user?

Yes, just copy the .ssh/ directory files over. Or generate new keys
and update the replication servers. :-)

>  How is this different from the ssh host keys in
> $site_path/etc/?  On my server, I see private/public rsa and dsa keys
> in that directory.

The host keys are how the server proves to clients that it is the
server they think it is. Clients use this to remember a server they
have spoken with in the past, if they try to connect to that same
server name again but get a different key, they abort screaming about
how a different party has dropped itself into the middle and might be
eavesdropping on the connection.

The client keys in ~/.ssh/ are how the server proves itself to other
servers its connecting to. Same thing, just the other side of the
connection.

> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>

phur1234

unread,
Feb 25, 2011, 12:30:59 AM2/25/11
to Repo and Gerrit Discussion
After reading your reply, it all makes sense to me now :). I forgot
about the Minasshd server which is why the application needs those ssh
keys. I have one more question. The two new servers will have
different site paths (the file system structure will be different on
both servers). Do I need to update the system_config table to update
the new site path. The DB dump will have the old site path in the
system_config table. Thanks a lot.

Phil

On Feb 17, 10:04 am, Shawn Pearce <s...@google.com> wrote:

Shawn Pearce

unread,
Feb 25, 2011, 10:40:09 AM2/25/11
to phur1234, Repo and Gerrit Discussion
On Thu, Feb 24, 2011 at 21:30, phur1234 <phur...@gmail.com> wrote:
> After reading your reply, it all makes sense to me now :).  I forgot
> about the Minasshd server which is why the application needs those ssh
> keys.  I have one more question.  The two new servers will have
> different site paths (the file system structure will be different on
> both servers).  Do I need to update the system_config table to update
> the new site path.  The DB dump will have the old site path in the
> system_config table.  Thanks a lot.

The site_path in system_config is only used if you launch Gerrit from
a web application container like Tomcat or a self-managed Jetty. If
you launch Gerrit with its gerrit.sh script that runs the built-in
Jetty, site_path comes from where the script lives, not the database.

Gopi Kumar

unread,
Sep 17, 2014, 2:52:56 AM9/17/14
to repo-d...@googlegroups.com, phur...@gmail.com
Hi Phur/Shawn,

I tried following the same steps and I don't see any errors during start up. But in the Gerrit UI I dont see data retrieved from my database. I can see git projects, people and all other data except change related details. Can you please let me know if I'm missing out something here.

Steps followed -

1. Shutdown Server A
2. Copied and restored Mysql dump to Server B
3. Copied Git repo dir under Gerrit site to Server B
4. Restarted Server B

Please note these are completely two different servers with their own canonical names, but I want to replicate database and gerrit project details on to other server in case if Server A goes down. I'll test out using same canonical name soon. But before that I want to clarify why change related details are not retrieved from the database and shown in the UI of server B.

Thanks.

Rahul Bhardwaj

unread,
Jun 15, 2015, 5:12:46 AM6/15/15
to repo-d...@googlegroups.com
Hi All,

I face the same thing.

I have a Gerrit server. For disaster recovery i dump 2 things everyday:
1)  Gerrit database (only gerrit db) in Postgresql server
2) $GERRIT_HOME/git/*  repos path

Now one day i decided to restore the latest dumps to an old gerrit  server to see if i see the Latest changes on Gerrit GUI. But sadly i cannot. Gerrit GUI display the old server history  only.

Please please tell me how can i fix this.



Thanks 

Luca Milanesio

unread,
Jun 15, 2015, 6:10:15 AM6/15/15
to Rahul Bhardwaj, repo-d...@googlegroups.com
java -jar $GERRIT_HOME/bin/gerrit.war reindex -d $GERRIT_HOME

This will recreate the Lucene Indexes.

Luca.
 
--
---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rahul bhardwaj

unread,
Jun 16, 2015, 6:42:17 AM6/16/15
to Luca Milanesio, repo-d...@googlegroups.com
Hi thanks for the answer. Is there any documentation where this steps is described. I find lot of difficulty in searching the related solutions.


I will follow this step and will update.


Thanks
Rahul

rahul bhardwaj

unread,
Jun 19, 2015, 3:30:05 AM6/19/15
to Luca Milanesio, repo-d...@googlegroups.com
Hi Luca,

Thanks a lot it worked.


Thanks
Rahul

vista...@gmail.com

unread,
Mar 14, 2017, 4:07:42 AM3/14/17
to Repo and Gerrit Discussion, phur...@gmail.com
Hi,Shawn. How to Solve the issue about key.

When server A is shutadown and new server B is enable,how to update the code which  repo sync from A ago?

vista...@gmail.com

unread,
Mar 14, 2017, 4:46:26 AM3/14/17
to Repo and Gerrit Discussion, phur...@gmail.com
I find the answer.  

Thanks All.

Y. Li

unread,
Jun 27, 2017, 9:56:56 PM6/27/17
to Repo and Gerrit Discussion, phur...@gmail.com
Hi, I met a problem after gerrit migration following the similar way. described in https://groups.google.com/forum/#!topic/repo-discuss/lBFq33kYsE4

URL in gerrit.config are all changed to new server. output message of repo init command shows that client connected to the new server. And projects xml files in manifests directory use the old one as remote fetch url parameters.

Does repo init command get remote fetch url from other place such as git files?

Thanks you

在 2011年2月16日星期三 UTC+8下午11:10:43,Shawn Pearce写道:
Reply all
Reply to author
Forward
0 new messages