一:安装RPM软件包
rpm --install elasticsearch-6.5.1.rpm
二:修改配置文件
vim /etc/sysconfig/elasticsearch
JAVA_HOME=/home/java/jdk1.8.0_181
三:启动Esearch
service elasticsearch start
四:测试Esearch
curl localhost:9200
{
"name" : "mZJN_QU",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Vl0l04LqRdmutjp3AQBx3Q",
"version" : {
"number" : "6.5.1",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "8c58350",
"build_date" : "2018-11-16T02:22:42.182257Z",
"build_snapshot" : false,
"lucene_version" : "7.5.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
错误:
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
修改:vim /etc/elasticsearch/elasticsearch.yml
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
错误:
max number of threads [1024] for user [elasticsearch] is too low, increase to at least [4096]
修改:/etc/security/limits.conf
elasticsearch soft nproc unlimited
elasticsearch hard nproc unlimited
错误:
memory locking requested for elasticsearch process but memory is not locked
修改:/etc/security/limits.conf
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
https://github.com/medcl/elasticsearch-analysis-ik
下载对应版本elasticsearch-analysis-ik-6.5.1.zip
在/usr/share/elasticsearch/plugin下创建目录ik,把zip放入ik解压重启服务完成安装
yum localinstall kibana-6.5.1-x86_64.rpm
修改 vim /etc/kibana/kibana.yml
server.host: "0.0.0.0"
elasticsearch.url: http://localhost:9200
启动kibana
service kibana start
访问地址 http://192.168.80.114:5601/
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.5.1</version>
</dependency>
https://www.elastic.co/guide/cn/elasticsearch/guide/cn/_indexing_employee_documents.html
GET _count?pretty=true
{
"query": {"match_all": {}}
}
{
"count" : 14022,
"_shards" : {
"total" : 2,
"successful" : 2,
"skipped" : 0,
"failed" : 0
}
}
GET _cat/indices?v
PUT /megacorp/employee/3
{
"first_name" : "Douglas",
"last_name" : "Fir",
"age" : 35,
"about": "I like to build cabinets",
"interests": [ "forestry" ]
}
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "3",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
GET /megacorp/employee/1
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "1",
"_version" : 1,
"found" : true,
"_source" : {
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests" : [
"sports",
"music"
]
}
}