Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

add doc for migration with data move #605

Merged
merged 5 commits into from
Sep 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 80 additions & 4 deletions docs/multi-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
jmlrt marked this conversation as resolved.
Show resolved Hide resolved

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
Copy link
Contributor

@Conky5 Conky5 Sep 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps explicitly call out to use the new ansible role here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ansible Galaxy command to install the new version of the role is in the example below: https://github.com/elastic/ansible-elasticsearch/pull/605/files#diff-05d70e203a6d81fe483f4556abe6750dR44

Is it what you expect?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the example is what I expect, but there is not a step in the instructions that mentions updating the role or using the new role in step 4 here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in fb64bd7


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}/
jmlrt marked this conversation as resolved.
Show resolved Hide resolved
$ 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.**
Expand Down