elasticsearch安装

elasticsearch 下载安装

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.16.tar.gz
tar -zxvf elasticsearch-5.6.16.tar.gz
cd elasticsearch-5.6.16
bin/elasticsearch

测试

image.png

相关配置

ls  config/
elasticsearch.yml  jvm.options  jvm.options.bakup  log4j2.properties  scripts
  • elasticsearch.yml es 配置
  • jvm.options jvm配置
  • log4j2.properties 日志配置

elasticsearch常用配置
elasticsearch.yml关键配置说明: cluster.name 集群名称,这个名字一样的话就说明是同一个集群 node.name 节点名称,标识一个集群中的不同节点 network.host/http.port 网络地址和端口,用于http和tranport服务使用 path.data 数据存储地址 path.log 日志存储地址

elasticsearch 本地集群配置

cp config/jvm.options config/jvm.options.bakup
sed -i "s/-Xms2g/-Xms1g/g" config/jvm.options
sed -i "s/-Xmx2g/-Xmx1g/g" config/jvm.options

启动集群,后台执行(这里采用动态加载配置)

./bin/elasticsearch -Ehttp.port=9200 -Epath.data=node1 -d
./bin/elasticsearch -Ehttp.port=8200 -Epath.data=node2 -d
./bin/elasticsearch -Ehttp.port=7200 -Epath.data=node3 -d

启动模式
如果集群节点的http通信和节点间通信使用http.host和transport.host在es的配置如果是 localhost , 则es会判断为开发模式,外网会自动判断为生产模式。 开发模式会以warning方式提示,检查配置的异常。 生产模式会以error方式提示,检查配置的异常,并且退出。

查看进程

$ jps
6688 Main
12657 Elasticsearch
12786 Jps
12374 Elasticsearch
12523 Elasticsearch

测试

image.png

查看集群

image.png

* 代表主节点

查看集群状态

$ curl http://127.0.0.1:9200/_cluster/stats | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1715  100  1715    0     0   139k      0 --:--:-- --:--:-- --:--:--  152k
{
    "_nodes": {
        "failed": 0,
        "successful": 3,
        "total": 3
    },
    "cluster_name": "elasticsearch",
    "indices": {
        "completion": {
            "size_in_bytes": 0
        },
        "count": 0,
        "docs": {
            "count": 0,
            "deleted": 0
        },
        "fielddata": {
            "evictions": 0,
            "memory_size_in_bytes": 0
        },
        "query_cache": {
            "cache_count": 0,
            "cache_size": 0,
            "evictions": 0,
            "hit_count": 0,
            "memory_size_in_bytes": 0,
            "miss_count": 0,
            "total_count": 0
        },
        "segments": {
            "count": 0,
            "doc_values_memory_in_bytes": 0,
            "file_sizes": {},
            "fixed_bit_set_memory_in_bytes": 0,
            "index_writer_memory_in_bytes": 0,
            "max_unsafe_auto_id_timestamp": -9223372036854775808,
            "memory_in_bytes": 0,
            "norms_memory_in_bytes": 0,
            "points_memory_in_bytes": 0,
            "stored_fields_memory_in_bytes": 0,
            "term_vectors_memory_in_bytes": 0,
            "terms_memory_in_bytes": 0,
            "version_map_memory_in_bytes": 0
        },
        "shards": {},
        "store": {
            "size_in_bytes": 0,
            "throttle_time_in_millis": 0
        }
    },
    "nodes": {
        "count": {
            "coordinating_only": 0,
            "data": 3,
            "ingest": 3,
            "master": 3,
            "total": 3
        },
        "fs": {
            "available_in_bytes": 165570379776,
            "free_in_bytes": 178363269120,
            "total_in_bytes": 250438021120
        },
        "jvm": {
            "max_uptime_in_millis": 450790,
            "mem": {
                "heap_max_in_bytes": 3113877504,
                "heap_used_in_bytes": 776754256
            },
            "threads": 158,
            "versions": [
                {
                    "count": 3,
                    "version": "1.8.0_191",
                    "vm_name": "OpenJDK 64-Bit Server VM",
                    "vm_vendor": "Oracle Corporation",
                    "vm_version": "25.191-b12"
                }
            ]
        },
        "network_types": {
            "http_types": {
                "netty4": 3
            },
            "transport_types": {
                "netty4": 3
            }
        },
        "os": {
            "allocated_processors": 24,
            "available_processors": 24,
            "mem": {
                "free_in_bytes": 448393216,
                "free_percent": 2,
                "total_in_bytes": 24727228416,
                "used_in_bytes": 24278835200,
                "used_percent": 98
            },
            "names": [
                {
                    "count": 3,
                    "name": "Linux"
                }
            ]
        },
        "plugins": [],
        "process": {
            "cpu": {
                "percent": 0
            },
            "open_file_descriptors": {
                "avg": 304,
                "max": 306,
                "min": 304
            }
        },
        "versions": [
            "5.6.16"
        ]
    },
    "status": "green",
    "timestamp": 1553465419846
}

_cat命令列表

$ curl http://127.0.0.1:9200/_cat
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates

你可能感兴趣的:(elasticsearch安装)