elasticsearch install

elasticsearch cluster install

  1. elasticsearch安装

    1
    2
    3
    4
    5
    6
    7
    [root@10 ~]# cd /mnt/ops/app/
    [root@10 app]# tar xzf elasticsearch-2.3.3.tar.gz
    [root@10 app]# mv elasticsearch-2.3.3 /mnt/app/elasticsearch
    [root@10 app]# chown -R wisdom.wisdom /mnt/app/elasticsearch

    [root@10 app]# mkdir -p /mnt/{data,log}/elasticsearch
    [root@10 app]# chown -R wisdom.wisdom mkdir -p /mnt/{data,log}/elasticsearch
  2. elasticsearch web插件安装

    1
    2
    [root@10 app]# /mnt/app/elasticsearch/bin/plugin install mobz/elasticsearch-head
    [root@10 app]# chown -R wisdom.wisdom /mnt/app/elasticsearch
  3. elasticsearch cluster 配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    [root@10 app]# cp /mnt/app/elasticsearch/config/{elasticsearch.yml,elasticsearch.yml.bak}

    //cluster-1:
    [root@10 app]# cat > /mnt/app/elasticsearch/config/elasticsearch.yml <<EOF
    > cluster.name: ssp
    > node.name: 10.0.3.40
    > path.data: /mnt/data/elasticsearch
    > path.repo: /mnt/ops/elasticsearch
    > path.logs: /mnt/log/elasticsearch
    > bootstrap.mlockall: true
    > network.host: 0.0.0.0
    > http.port: 9200
    > transport.tcp.port: 9300
    > transport.tcp.compress: true
    > gateway.recover_after_nodes: 2
    > node.max_local_storage_nodes: 1
    > action.destructive_requires_name: true
    > action.auto_create_index: true
    > action.disable_delete_all_indices: true
    > index.number_of_shards: 5
    > index.number_of_replicas: 1
    > discovery.zen.ping.multicast.enabled: false
    > discovery.zen.fd.ping_timeout: 100s
    > discovery.zen.ping.timeout: 100s
    > discovery.zen.minimum_master_nodes: 2
    > discovery.zen.ping.unicast.hosts: ["10.0.3.40:9300","10.0.3.41:9300","10.0.3.42:9300"]
    > EOF

    //cluster-2:
    [root@10 app]# cat > /mnt/app/elasticsearch/config/elasticsearch.yml <<EOF
    > cluster.name: ssp
    > node.name: 10.0.3.41
    > path.data: /mnt/data/elasticsearch
    > path.repo: /mnt/ops/elasticsearch
    > path.logs: /mnt/log/elasticsearch
    > bootstrap.mlockall: true
    > network.host: 0.0.0.0
    > http.port: 9200
    > transport.tcp.port: 9300
    > transport.tcp.compress: true
    > gateway.recover_after_nodes: 2
    > node.max_local_storage_nodes: 1
    > action.destructive_requires_name: true
    > action.auto_create_index: true
    > action.disable_delete_all_indices: true
    > index.number_of_shards: 5
    > index.number_of_replicas: 1
    > discovery.zen.ping.multicast.enabled: false
    > discovery.zen.fd.ping_timeout: 100s
    > discovery.zen.ping.timeout: 100s
    > discovery.zen.minimum_master_nodes: 2
    > discovery.zen.ping.unicast.hosts: ["10.0.3.40:9300","10.0.3.41:9300","10.0.3.42:9300"]
    > EOF

    //cluster-3:
    [root@10 app]# cat > /mnt/app/elasticsearch/config/elasticsearch.yml <<EOF
    > cluster.name: ssp
    > node.name: 10.0.3.42
    > path.data: /mnt/data/elasticsearch
    > path.repo: /mnt/ops/elasticsearch
    > path.logs: /mnt/log/elasticsearch
    > bootstrap.mlockall: true
    > network.host: 0.0.0.0
    > http.port: 9200
    > transport.tcp.port: 9300
    > transport.tcp.compress: true
    > gateway.recover_after_nodes: 2
    > node.max_local_storage_nodes: 1
    > action.destructive_requires_name: true
    > action.auto_create_index: true
    > action.disable_delete_all_indices: true
    > index.number_of_shards: 5
    > index.number_of_replicas: 1
    > discovery.zen.ping.multicast.enabled: false
    > discovery.zen.fd.ping_timeout: 100s
    > discovery.zen.ping.timeout: 100s
    > discovery.zen.minimum_master_nodes: 2
    > discovery.zen.ping.unicast.hosts: ["10.0.3.40:9300","10.0.3.41:9300","10.0.3.42:9300"]
    > EOF
  4. elasticsearch 启动参数

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    [root@10 app]# vim /mnt/app/elasticsearch/bin/elasticsearch
    ES_HEAP_SIZE=4g

    或者:

    [root@10 app]# cat > /mnt/app/elasticsearch/config/jvm.options <<EOF
    > -Xms4g
    > -Xmx4g
    > –XX:+UseG1GC
    > -XX:+UseStringDeduplication
    > -XX:+DisableExplicitGC
    > -XX:+AlwaysPreTouch
    > -server
    > -Djava.awt.headless=true
    > -Dfile.encoding=UTF-8
    > -Djna.nosys=true
    > -Dio.netty.noUnsafe=true
    > -Dio.netty.noKeySetOptimization=true
    > -Dlog4j.shutdownHookEnabled=false
    > -Dlog4j2.disable.jmx=true
    > -Dlog4j.skipJansi=true
    > -XX:+HeapDumpOnOutOfMemoryError
    > EOF
  5. elasticsearch 启动

    1
    2
    [root@10 app]# su - wisdom
    [wisdom@10 ~]$ /mnt/app/elasticsearch/bin/elasticsearch -d -p /mnt/data/elasticsearch/elasticsearch.pid
  6. 查看集群

    1
    2
    3
    4
    5
    6
    //浏览器中查看集群
    http://{IP}:9200/_plugin/head

    //命令输出
    curl '10.0.3.40:9200/_cat/health?v'
    curl '10.0.3.40:9200/_cat/nodes?v'