Skip to content

aisuhua/elasticsearch-ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elasticsearch-ansible

使用 ansible 以简单的方式搭建 elasticsearch 集群。

安装

git clone [email protected]:aisuhua/elasticsearch-ansible.git
cd elasticsearch-ansible

# 按需修改 inventory 、安装目录、用户等信息
vim hosts.yaml

ansible-playbook playbook.yaml

卸载

ansible-playbook remove.yaml

测试

# 查看集群健康状态
$ curl https://172.31.96.151:19201/_cat/health -k -u elastic -p
Enter host password for user 'elastic':
1725539414 12:30:14 es1 green 3 3 68 34 0 0 0 0 - 100.0%

# 查看集群节点
$ curl https://172.31.96.151:19201/_cat/nodes -k -u elastic -p
Enter host password for user 'elastic':
172.31.96.151 57 94 28 0.31 1.14 3.47 cdfhilmrstw - node3-es1
172.31.96.151 59 94 28 0.31 1.14 3.47 cdfhilmrstw * node1-es1
172.31.96.151 60 94 28 0.31 1.14 3.47 cdfhilmrstw - node2-es1

特点

  • 可离线安装
  • 支持在单机上安装多个不同版本的集群
  • 卸载简单,方便来回测试
  • 自带 100 年 SSL 证书,可简单替换成自签名证书
  • 定制简单,该 role 保持了简单
  • 支持安装插件、重置内置用户密码(builtin) 、新增和删除 keystore

备份

使用快照功能(snapshot)将索引备份到 S3,如已安装 Kibana,则可在 dev tools 执行以下语句

# 创建 s3 类型的 repo
PUT _snapshot/s3repo
{
  "type" : "s3",
  "settings" : {
    "bucket" : "test",
    "path_style_access" : "true",
    "base_path" : "/es1",
    "endpoint" : "192.168.88.61:19000",
    "protocol" : "http"
  }
}

# 创建快照策略
PUT _slm/policy/daily-snapshots
{
  "name": "<daily-snap-{now/d}>",
  "schedule": "0 30 20 * * ?",
  "repository": "s3repo",
  "config": {
    "feature_states": [],
    "include_global_state": true
  },
  "retention": {
    "expire_after": "7d",
    "max_count": 7
  }
}

# 创建索引保留策略
PUT _ilm/policy/applog
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_age": "1d",
            "max_primary_shard_size": "50gb"
          }
        }
      },
      "delete": {
        "min_age": "7d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

参考

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages