1 安装
服务器IP: 10.0.1.11/12/13
拷贝安装包到服务器/usr/local/
unzip elasticsearch-6.2.3.zip
mv elasticsearch-6.2.3 /usr/local/elasticsearch
2 配置
cd /usr/local/elasticsearch
vi config/elasticsearch.yml
修改如下配置
cluster.name: ies
# 分别为node-1,node-2,node-3
node.name: node-1
path.data: /data/es/data
path.logs: /data/es/logs
# 本机IP地址,分别为11,12,13
network.host: 10.0.1.11
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.0.1.11", "10.0.1.12", "10.0.1.13"]
3 用户创建
useradd esuser
passwd esuser
chown -R esuser:esuser /usr/local/elasticsearch
mkdir -p /data/es/logs
mkdir -p /data/es/data
chown -R esuser:esuser /data/es
4 调优
4.1 修改jvm.options
vi config/jvm.options
-Xms2g
-Xmx2g
4.2 用户最大进程数等调优
初次启动时常见报错
[1]: max number of threads [1024] for user [hadoop] is too low, increase to at least [2048]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
·max number of threads
vim /etc/security/limits.conf
* soft nproc 65536
* hard nproc 65536
* soft nofile 65536
* hard nofile 65536
vim /etc/security/limits.d/90-nproc.conf
soft nproc 2048
·vm.max_map_count
vi /etc/sysctl.conf
vm.max_map_count=262144
sysctl -p
·system call filters
vim elasticsearch.yml
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
5 基础知识整理
启动:
su - esuser
cd /usr/local/elasticsearch
bin/elasticsearch -d
停止:
jps | grep Elasticsearch | cut -c 1-6 | xargs kill -9
查询集群基础信息:
curl localhost:9200
Node & Cluster
单个 Elastic 实例称为一个节点node,n个节点构成一个集群cluster。
[esuser@jf-vra-app0832 elasticsearch-5.2.1]$ curl -X GET "10.237.120.248:9200/_cat/nodes"
10.237.120.248 10 53 0 0.00 0.01 0.05 mdi * node-1
10.237.120.249 10 54 0 0.00 0.01 0.05 mdi - node-2
10.237.120.250 9 98 0 0.00 0.04 0.05 mdi - node-3
[esuser@jf-vra-app0832 elasticsearch-5.2.1]$ curl -X GET "10.237.120.248:9200/_cat/nodes?v"
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
10.237.120.248 10 53 0 0.00 0.01 0.05 mdi * node-1
10.237.120.249 10 54 0 0.00 0.01 0.05 mdi - node-2
10.237.120.250 9 98 0 0.00 0.03 0.05 mdi - node-3
查询主节点
[esuser@jf-vra-app0832 elasticsearch-5.2.1]$ curl -XGET 'http://10.237.120.248:9200/_cat/master?v'
id host ip node
YY69UzouQaGjw0-SGiP2Lw 10.237.120.248 10.237.120.248 node-1
查询集群健康状态
[esuser@jf-vra-app0832 elasticsearch-5.2.1]$ curl -XGET 'http://10.237.120.248:9200/_cat/health?v'
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1552548481 15:28:01 ies green 3 3 0 0 0 0 0 0 - 100.0%
[esuser@jf-vra-app0832 elasticsearch-5.2.1]$ curl -XGET 'http://10.237.120.248:9200/_cluster/health?pretty'
{
"cluster_name" : "ies",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
curl -XGET 'http://192.168.205.155:9200/_cluster/state/nodes?pretty'
{
"cluster_name" : "ies", #集群名字
"nodes" : {
"YY69UzouQaGjw0-SGiP2Lw" : { #ID值
"name" : "node-1", #node名字
"ephemeral_id" : "ecMo1O_7TqSyR1tFRKYGFA", #id
"transport_address" : "10.237.120.248:9300", #集群通讯地址
"attributes" : { }
},
"ZkZ_fMzhR7W5YPTTndObYg" : {
"name" : "node-2",
"ephemeral_id" : "FPeUdN6dRhCP1vxac4UzxA",
"transport_address" : "10.237.120.249:9300",
"attributes" : { }
},
"tzuvu86aTI23wjiHOHqYbw" : {
"name" : "node-3",
"ephemeral_id" : "PpZbuwiDQr6gafEsFmMLDg",
"transport_address" : "10.237.120.250:9300",
"attributes" : { }
}
}
}
查询index:
Elastic 数据管理的顶层单位就叫做 Index(索引)。它是单个数据库的同义词。每个 Index (即数据库)的名字必须是小写。
curl -X GET 'http://localhost:9200/_cat/indices?v'
Document:
Index 里面单条的记录称为 Document(文档)。许多条 Document 构成了一个 Index。
{
"user": "Nic",
"title": "Enginer",
"desc": "DBA"
}
Type
虚拟的逻辑分组,用来过滤 Document。
curl 'localhost:9200/_mapping?pretty=true'