Git Product home page Git Product logo

elasticsearch's Introduction

本工具使用ansible playbook部署高可用的Elasticsearch集群。

使用方法:

一、准备资源

请按照inventory格式修改对应资源

[master]
10.10.90.100 hostname=es-master-01 role=master heap_size=16g
10.10.90.101 hostname=es-master-02 role=master heap_size=16g
10.10.90.102 hostname=es-master-03 role=master heap_size=16g
[client]
10.10.90.103 hostname=es-client-01 role=client heap_size=16g
10.10.90.104 hostname=es-client-02 role=client heap_size=16g
10.10.90.105 hostname=es-client-03 role=client heap_size=16g
[hot]
10.10.90.106 hostname=es-data-hot-01 role=data heap_size=32g
10.10.90.107 hostname=es-data-hot-02 role=data heap_size=32g
10.10.90.108 hostname=es-data-hot-03 role=data heap_size=32g
[hot:vars]
type=hot

[cold]
10.10.90.109 hostname=es-data-cold-01 role=data heap_size=32g
10.10.90.110 hostname=es-data-cold-02 role=data heap_size=32g
10.10.90.111 hostname=es-data-cold-03 role=data heap_size=32g
[cold:vars]
type=cold

[es:children]
master
client
hot
cold

二、使用方法

2.1、安装ansible

在控制端机器执行以下命令安装ansible

yum -y install ansible
pip install netaddr

2.2、部署集群

先执行格式化磁盘并挂载目录。如已经自行格式化磁盘并挂载,请跳过此步骤。

ansible-playbook fdisk.yml -i inventory -l data -e "disk=/dev/sdb dir=/data"

安装elasticsearch

ansible-playbook es.yml -i inventory

如启用了TLS,请使用以下命令为elasticsearch生成密码

自动生成密码

/usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto

手动指定密码

/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive

2.3、扩容master节点

扩容elasticsearch的master节点前,请确认{{ssl_dir}}目录中存在elasticsearch证书。

扩容时,请不要在inventory文件master组中保留旧服务器信息。

ansible-playbook es.yml -i inventory -l master

2.4、扩容client节点

扩容时,请不要在inventory文件master组中保留旧服务器信息。

ansible-playbook es.yml -i inventory -l client

2.5、扩容data节点

扩容时,请不要在inventory文件hot或cold组中保留旧服务器信息。

扩容普通数据节点

ansible-playbook es.yml -i inventory -l data

扩容热数据节点

ansible-playbook es.yml -i inventory -l hot

扩容冷数据节点

ansible-playbook es.yml -i inventory -l cold

2.5、替换集群证书

生成证书

ansible-playbook es.yml -i inventory -t cert

拷贝证书

ansible-playbook es.yml -i inventory -t dis_certs

重启服务

ansible -i inventory all -m systemd -a "name=elasticsearch state=restarted"

2.6、升级elasticsearch版本

在升级之前请关闭logstash等写es的应用,并禁用分片分配。在升级完成再进行开启。

停止elasticsearch服务

ansible -i inventory all -m systemd -a "name=elasticsearch state=stopped"

安装新版本

ansible-playbook es.yml -i inventory -t install_es
  • 如有安装插件,在先进行插件升级

启动服务

ansible -i inventory all -m systemd -a "name=elasticsearch state=started"

elasticsearch's People

Contributors

kubeop avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.