Move Solr Core to Another Server
I was need to move solr installation from one server to another. I can not do any reindexing from the beginning because its fairly large collection, about 15 million and I don’t know how much time will it takes to do it from beginning. So I need to move the index data as well.
I do google it and then end up to this question on stackoverflow. The answer is not exactly what I need, but it gave me the idea. You can try making backup on one system, and a restore on the other system.
And then I learn about Solr Index Replication, Backup and Restore.
I use Solr v6.6.0. It’s farly easy, expescially I only install standalone mode.
First, we need to copy the Core configuration directory, usually called conf
to new solr core. This is important because we need same data type and structure for the new server. Then all I need is execute this request in browser.
GET http://localhost:8983/solr/collection-name/replication?command=backup&wt=json
Note that, the backup is running asynchronously in server, and not finished right away, especially if the index data is large. My index data is about 15 million, about 45G, it takes 1 hour in ubuntu server with 16GB Ram.
To get status of the backup, also we can do it by simple GET request
GET http://localhost:8983/solr/collection-name/replication?command=details&wt=json
The json response will looks like this.
{
"responseHeader": {
"status": 0,
"QTime": 1
},
"details": {
"indexSize": "44.67 GB",
"indexPath": "/data/solr/data/collection-name/data/index/",
"commits": [
[
"indexVersion",
1561325531462,
"generation",
749269,
"filelist",[
"segments_g251"
]
]
],
"isMaster": "true",
"isSlave": "false",
"indexVersion": 1561325531462,
"generation": 749269,
"master": {
"replicateAfter": [
"commit"
],
"replicationEnabled": "true",
"replicableVersion": 1561325531462,
"replicableGeneration": 749269
},
"backup": [
"startTime",
"Mon Jun 24 03:10:06 UTC 2019",
"fileCount",
278,
"status",
"success",
"snapshotCompletedAt",
"Mon Jun 24 03:38:28 UTC 2019",
"snapshotName",
null
]
}
}
If the backup is still in progress, then there will no “backup” field. And if a backup failed, it will return somethins like this.
"backup": [
"snapShootException",
"No space left on device"
]
Ya, I experiance “No space left on device” error during the backup for the first time. You know how to fix this.
After backup finished, I get file named snapshot.XXX
in collection data folder. And what I do is move that folder to target server using rsync
rsync -a --stats --progress `snapshot.XXX` user@otherserver:/location/to/new_collection/data
After that, run the the restore command in the new server
GET http://localhost:8983/solr/collection-name/replication?command=restore&location=/location/to/snapshot&wt=json
And run this to get the restore status:
GET http://localhost:8983/solr/collection-name/replication?command=restorestatus&wt=json
The response you will get is similar to this
{
"responseHeader": {
"status": 0,
"QTime": 0
},
"restorestatus": {
"snapshotName": "snapshot.20190624031006850",
"status": "In Progress"
}
}
I wait about an hour to get the “status” change from “In Progress” to “success”.