From 660aaac345110237e6a59b59fde62e459022f788 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Tue, 3 Sep 2019 10:03:51 +0200 Subject: [PATCH 1/4] add doc for migration with data move --- docs/multi-instance.md | 84 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/docs/multi-instance.md b/docs/multi-instance.md index 11872a98..a36cbbd1 100644 --- a/docs/multi-instance.md +++ b/docs/multi-instance.md @@ -8,13 +8,89 @@ See [554#issuecomment-496804929](https://github.com/elastic/ansible-elasticsearc If you have single-instances hosts and want to upgrade from previous versions of the role: +### Procedure with datas move + +This procedure will allow you to move your datas to the new standard paths (see [#581](https://github.com/elastic/ansible-elasticsearch/issues/581)): + +1. Stop Elasticsearch before the migration + +2. Migrate your datas to the new standard paths: +``` +# mv /etc/elasticsearch/${ES_INSTANCE_NAME}/* /etc/elasticsearch/ && rm -fr /etc/elasticsearch/${ES_INSTANCE_NAME}/ +mv: overwrite '/etc/elasticsearch/elasticsearch.keystore'? y +# mv /var/lib/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/* /var/lib/elasticsearch/ && rm -fr /var/lib/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ +# ls /var/lib/elasticsearch/ +nodes +# mv /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/* /var/log/elasticsearch/ && rm -fr /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ +# rm -fr /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ +``` + +3. Update playbook (remove `es_conf_dir`, `es_data_dirs`, `es_log_dir`, `es_pid_dir` and `es_instance_name` variables) + +4. Deploy ansible-role + +5. After ansible-role new deployment, you can do some cleanup of old Init file and Default file: + +Example: +``` +$ systemctl stop elasticsearch +$ mv /etc/elasticsearch/${ES_INSTANCE_NAME}/* /etc/elasticsearch/ && rm -fr /etc/elasticsearch/${ES_INSTANCE_NAME}/ +mv: overwrite '/etc/elasticsearch/elasticsearch.keystore'? y +$ mv /var/lib/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/* /var/lib/elasticsearch/ && rm -fr /var/lib/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ +$ ls /var/lib/elasticsearch/ +nodes +$ mv /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/* /var/log/elasticsearch/ && rm -fr /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ +$ rm -fr /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ +$ ansible-galaxy install --force elastic.elasticsearch,7.1.1 +- changing role elastic.elasticsearch from 6.6.0 to 7.1.1 +- downloading role 'elasticsearch', owned by elastic +- downloading role from https://github.com/elastic/ansible-elasticsearch/archive/7.1.1.tar.gz +- extracting elastic.elasticsearch to /home/jmlrt/.ansible/roles/elastic.elasticsearch +- elastic.elasticsearch (7.1.1) was installed successfully +$ ansible-playbook playbook.yml + +... + +TASK [elastic.elasticsearch : Create Directories] +ok: [localhost] => (item=/var/run/elasticsearch) +ok: [localhost] => (item=/var/log/elasticsearch) +changed: [localhost] => (item=/etc/elasticsearch) +ok: [localhost] => (item=/var/lib/elasticsearch) + +TASK [elastic.elasticsearch : Copy Configuration File] +changed: [localhost] + +TASK [elastic.elasticsearch : Copy Default File] +changed: [localhost] + +TASK [elastic.elasticsearch : Copy jvm.options File] +changed: [localhost] + +... + +RUNNING HANDLER [elastic.elasticsearch : restart elasticsearch] +changed: [localhost] + +... + +PLAY RECAP +localhost : ok=26 changed=6 unreachable=0 failed=0 skipped=116 rescued=0 ignored=0 +$ find /etc -name '${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}*' +/etc/default/node1_elasticsearch +/etc/systemd/system/multi-user.target.wants/node1_elasticsearch.service +``` + +### Procedure without datas move + +This procedure will allow you to keep your datas to the old paths: + 1. Override these variables to match previous values: ```yaml -es_conf_dir: /etc/elasticsearch/{{ es_instance_name }} +es_conf_dir: /etc/elasticsearch/${ES_INSTANCE_NAME} es_data_dirs: - - /var/lib/elasticsearch/{{ inventory_hostname }}-{{ es_instance_name }} -es_log_dir: /var/log/elasticsearch/{{ inventory_hostname }}-{{ es_instance_name }} -es_pid_dir: /var/run/elasticsearch/{{ inventory_hostname }}-{{ es_instance_name }} + - /var/lib/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME} +es_log_dir: /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME} +es_pid_dir: /var/run/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME} ``` 2. Deploy ansible-role. **Even if these variables are overrided, Elasticsearch config file and default option file will change, which imply an Elasticsearch restart.** From d0fa9e2f7b0d7b774d696660c8ee9f50498b5ca0 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Wed, 4 Sep 2019 16:51:32 +0200 Subject: [PATCH 2/4] fix typos --- docs/multi-instance.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/multi-instance.md b/docs/multi-instance.md index a36cbbd1..df0c46f0 100644 --- a/docs/multi-instance.md +++ b/docs/multi-instance.md @@ -8,13 +8,13 @@ See [554#issuecomment-496804929](https://github.com/elastic/ansible-elasticsearc If you have single-instances hosts and want to upgrade from previous versions of the role: -### Procedure with datas move +### Procedure with data move -This procedure will allow you to move your datas to the new standard paths (see [#581](https://github.com/elastic/ansible-elasticsearch/issues/581)): +This procedure will allow you to move your data to the new standard paths (see [#581](https://github.com/elastic/ansible-elasticsearch/issues/581)): 1. Stop Elasticsearch before the migration -2. Migrate your datas to the new standard paths: +2. Migrate your data to the new standard paths: ``` # mv /etc/elasticsearch/${ES_INSTANCE_NAME}/* /etc/elasticsearch/ && rm -fr /etc/elasticsearch/${ES_INSTANCE_NAME}/ mv: overwrite '/etc/elasticsearch/elasticsearch.keystore'? y @@ -22,7 +22,7 @@ mv: overwrite '/etc/elasticsearch/elasticsearch.keystore'? y # ls /var/lib/elasticsearch/ nodes # mv /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/* /var/log/elasticsearch/ && rm -fr /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ -# rm -fr /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ +# rm -fr /var/run/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ ``` 3. Update playbook (remove `es_conf_dir`, `es_data_dirs`, `es_log_dir`, `es_pid_dir` and `es_instance_name` variables) @@ -80,9 +80,9 @@ $ find /etc -name '${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}*' /etc/systemd/system/multi-user.target.wants/node1_elasticsearch.service ``` -### Procedure without datas move +### Procedure without data move -This procedure will allow you to keep your datas to the old paths: +This procedure will allow you to keep your data to the old paths: 1. Override these variables to match previous values: ```yaml From 8bf16d8ae85f173cd05b608715ba6fd62fd40d1f Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Wed, 4 Sep 2019 17:04:13 +0200 Subject: [PATCH 3/4] fix another typo --- docs/multi-instance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/multi-instance.md b/docs/multi-instance.md index df0c46f0..a5662769 100644 --- a/docs/multi-instance.md +++ b/docs/multi-instance.md @@ -40,7 +40,7 @@ $ mv /var/lib/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/* /var/lib $ ls /var/lib/elasticsearch/ nodes $ mv /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/* /var/log/elasticsearch/ && rm -fr /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ -$ rm -fr /var/log/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ +$ rm -fr /var/run/elasticsearch/${INVENTORY_HOSTNAME}-${ES_INSTANCE_NAME}/ $ ansible-galaxy install --force elastic.elasticsearch,7.1.1 - changing role elastic.elasticsearch from 6.6.0 to 7.1.1 - downloading role 'elasticsearch', owned by elastic From fb64bd7d1cd88e858614522d84e11dffddfc8041 Mon Sep 17 00:00:00 2001 From: Julien Mailleret Date: Wed, 4 Sep 2019 19:11:49 +0200 Subject: [PATCH 4/4] fix after review --- docs/multi-instance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/multi-instance.md b/docs/multi-instance.md index a5662769..57b62388 100644 --- a/docs/multi-instance.md +++ b/docs/multi-instance.md @@ -27,7 +27,7 @@ nodes 3. Update playbook (remove `es_conf_dir`, `es_data_dirs`, `es_log_dir`, `es_pid_dir` and `es_instance_name` variables) -4. Deploy ansible-role +4. Update ansible-role to new version ([7.1.1](https://github.com/elastic/ansible-elasticsearch/releases/tag/7.1.1) at the time of writing) and deploy ansible-role 5. After ansible-role new deployment, you can do some cleanup of old Init file and Default file: