Managing the repository is the most import issue in Elasticsearch backup management. Due to its native distributed architecture, the snapshot and the restore are designed in a cluster style.
During a snapshot, the shards are copied to the defined repository. If this repository is local to the nodes, the backup data is spread across all the nodes. For this reason, it's necessary to have shared repository storage if you have a multimode cluster.
A common approach is to use a Network File System (NFS), as it's very easy to set up and it's a very fast solution (also, standard Windows Samba shares can be used.)
We have a network with the following nodes:
192.168.1.30
(where we will store the backup data)192.168.1.40
192.168.1.50
192.168.1.51
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
The following instructions are for standard Debian or Ubuntu distributions: they can be easily changed for other Linux distribution.
To create an NFS shared repository, we need to execute the following steps on the NFS server:
nfs-kernel-server
package) on the host server. On the host server 192.168.1.30
we will execute:sudo apt-get update sudo apt-get install nfs-kernel-server
sudo mkdir /mnt/shared-directory
nobody
and group nogroup
. These are a special reserved user/group in Linux operating systems that do not need any special permission to run things:sudo chown -R nobody:nogroup /mnt/shared-directory
/etc/exports
file (sudo nano /etc/exports
) and add the following line containing the directory to be shared and space-separated client IP lists:/mnt/shared-directory 192.168.1.40(rw,sync,no_subtree_check) 192.168.1.50(rw,sync,no_subtree_check) 192.168.1.51(rw,sync,no_subtree_check)
sudo exportfs -a
sudo service nfs-kernel-server start
After the NFS server is up-and-running, we need to configure the clients. We'll repeat the following steps on every Elasticsearch node:
sudo apt-get update sudo apt-get install nfs-common
sudo mkdir /mnt/nfs sudo mount 192.168.1.30:/mnt/shared-directory /mnt/nfs
/etc/fstab
file, so that it will be mounted at the next boot:sudo nano /etc/fstab
192.168.1.30:/mnt/shared-directory /mnt/nfs/ nfs auto,noatime,nolock,bg,nfsvers=4,sec=krb5p,intr,tcp,actimeo =1800 0 0
config/elasticsearch.yml
) path.repo
in this way: path.repo: /mnt/nfs/
curl -XPUT 'http://192.168.1.40:9200/_snapshot/my_repository' - d '{ "type": "fs", "settings": { "location": "/ mnt/nfs/my_repository", "compress": true } }'
NFS is a distributed filesystem protocol that is very common in the Unix world, and which allows you to mount remote directories on your server. The mounted directories look like the local directory of the server, and therefore, by using NFS, multiple servers can write to same directory.
This is very handy if you need to do a shared backup: all the nodes will write/read from the same shared directory.
3.145.175.253