目录
elasticsearch-6.3.2 搭建集群环境
/    

elasticsearch-6.3.2 搭建集群环境

安装

1、下载 elasticsearch-6.3.2.tar.gz 并解压

2、创建 elasticsearch 用户,并设置密码

3、使用 chown -R elasticsearch:elasticsearch ./elasticsearch-6.3.2 修改所在用户组

4、修改配置

vim /etc/security/limits.conf

# 最后加上

* hard nofile 65536
* soft nofile 65536
vim /etc/sysctl.conf
# 最后加上

vm.max_map_count=262144

然后注销当前登录用户重新登录,如果还是不行 就重启系统;

使用命令立即生效:sysctl -w vm.max_map_count=262144

5、修改配置文件,copy 三个节点node01、node02、node03,分别将 jvm.options 内存改成256m (这里只是测试使用,生产环境根据需要进行修改)

  • node01 的 elasticsearch.yml

    cluster.name: "gitsilence-cluster"
    
    node.name: master
    
    node.master: true
    
    network.host: 192.168.44.130
    
    http.port: 9200
    
    transport.host: 192.168.44.130
    
    transport.tcp.port: 9300
    
  • node02 的 elasticsearch.yml

    cluster.name: "gitsilence-cluster"
    
    node.name: slave-01
    
    network.host: 192.168.44.130
    
    http.port: 9201
    
    discovery.zen.ping.unicast.hosts: ["192.168.44.130:9300", "192.168.44.130:9301", "192.168.44.130:9302"]
    
    
    transport.host: 192.168.44.130
    
    transport.tcp.port: 9301
    
  • node03 的 elasticsearch.yml

    cluster.name: "gitsilence-cluster"
    
    node.name: slave-02
    
    network.host: 192.168.44.130
    
    http.port: 9202
    
    discovery.zen.ping.unicast.hosts: ["192.168.44.130:9300", "192.168.44.130:9301", "192.168.44.130:9302"]
    
    transport.host: 192.168.44.130
    
    transport.tcp.port: 9302
    

分别启动三个节点

bin/elasticsearch -d 后台启动

jps -l 查看正在运行

访问:http://192.168.44.130:9200/_cat/nodes

192.168.44.130 55 62 0 0.14 0.10 0.19 mdi * master
192.168.44.130 48 62 0 0.14 0.10 0.19 mdi - slave-01
192.168.44.130 48 62 0 0.14 0.10 0.19 mdi - slave-02
{
  "name": "master",
  "cluster_name": "gitsilence-cluster",
  "cluster_uuid": "A4zpMU6rSsuLVt5FfBg0mQ",
  "version": {
    "number": "6.3.2",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "053779d",
    "build_date": "2018-07-20T05:20:23.451332Z",
    "build_snapshot": false,
    "lucene_version": "7.3.1",
    "minimum_wire_compatibility_version": "5.6.0",
    "minimum_index_compatibility_version": "5.0.0"
  },
  "tagline": "You Know, for Search"
}

就此搭建成功,需要测试 一下 索引的创建、查询。

测试

安装 kibana 测试

GET _search
{
  "query": {
    "match_all": {}
  }
}

# 创建user索引
PUT user
{
  "mappings": {
    "_doc": {
      "properties": {
        "name": {
          "type": "keyword"
        },
        "age": {
          "type": "integer"
        },
        "content": {
          "type": "text"
        }
      }
    }
  }
}

# 添加一条数据
PUT user/_doc/1
{
  "name": "zs",
  "age": 15,
  "content": "ni'hao你好 ya呀 m'm密码 "
}

# 查看已经创建的索引
GET _cat/indices

# 查看健康状态
GET _cat/health

标题:elasticsearch-6.3.2 搭建集群环境
作者:gitsilence
地址:https://blog.lacknb.cn/articles/2021/11/02/1635864247557.html