## 1. ElasticSearch 和 Kibana 在 Linux服务器启动
需要切换到非root用户启动
[root@localhsot bin] useradd es
[root@localhsot bin] su es
[es@localhsot bin] # ./elasticsearch
[es@localhsot bin] # ./kibana
## 2.若启动时报Permission Denied,需要赋文件夹权限给es用户
[root@localhsot bin] chown -R es /apps/elasticsearch /apps/kibana
不建议 --allow-root
建议 使用root创建一个普通用户,再使用普通用户启动
## 3. 启动成功后可以在浏览器进行验证浏览
## 4. 挂载启动
[es@localhsot bin] # nohup ./elasticsearch &
[es@localhsot bin] # nohup ./kibana &
## 5. 关闭进程
# 1) ElasticSearch - grep 应用名
[es@localhsot bin] #ps aux|grep elastic
# 2) Kibana - grep 端口号
[es@localhsot bin] #ps aux|grep 5601
[es@localhsot bin] # kill -9 xxx
## 6. ES启动参数配置文件 --- [../config/elasticsearch.yml 配置文件]
# 忽略掉geoip下载
ingest.geoip.downloader.enabled: false
# 单机本地磁盘空间较小。(磁盘空间不足,配置了集群的话,索引会不健康)
cluster.routing.allocation.disk.threshold_enabled: false
# 外网部署,有防火墙
systemctl status firewalld
firewall-cmd --query-port=9200/tcp
ElasticSearch:
# 启动后访问9200网址无返回信息
# 查着日志显示
# [2024-03-26T14:20:05,905][WARN ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [yanfayibu1] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.16.81.43:9200, remoteAddress=/172.16.81.43:52442}
# application.yml
xpack相关的配置true都改成false
# 安装分词器
#1) 在es/plugin文件夹下,解压完成后需要将zip文件删除,否则无法启动es
#2) 分词器安装完成后,需要将kibana先停止,然后再启动es,否则es也无法启动
kibana:
# 会影响后期集群,可一并改了
# xpack.reporting.roles.enabled
# kibana.yml 配置修改,否则无法完全启动成功
server.host: 172.16.81.43
# 改称中文
i18n.locale: "zh-CN"
Kibana进程截图
一、ES高性能配置讲解
二、ES 简单示例
# Click the Variables button, above, to create your own variables.
PUT es_business_file_txt
{
"mappings": {
"properties": {
"fileId":{
"type": "keyword"
},
"sysCode":{
"type": "keyword"
},
"branchId":{
"type": "keyword"
},
"batchNo":{
"type": "keyword"
},
"fileName":{
"type": "text",
"analyzer": "ik_max_word"
},
"fileType":{
"type": "keyword"
},
"billCode":{
"type": "keyword"
},
"createdBy":{
"type": "text",
"analyzer": "ik_max_word"
},
"createTime":{
"type": "date"
},
"REMARK":{
"type": "text",
"analyzer": "ik_max_word"
},
"annotation":{
"type": "text",
"analyzer": "ik_max_word"
},
"label":{
"type": "text",
"analyzer": "ik_max_word"
}
}
}
, "settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
PUT es_business_file_txt
{
"mappings": {
"properties": {
"fileId":{
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"sysCode":{
"type": "text"
},
"branchId":{
"type": "text"
},
"batchNo":{
"type": "text"
},
"fileName":{
"type": "text",
"analyzer": "ik_max_word"
},
"fileType":{
"type": "text"
},
"billCode":{
"type": "text"
},
"createdBy":{
"type": "text",
"analyzer": "ik_max_word"
},
"createTime":{
"type": "date"
},
"REMARK":{
"type": "text",
"analyzer": "ik_max_word"
},
"annotation":{
"type": "text",
"analyzer": "ik_max_word"
},
"label":{
"type": "text",
"analyzer": "ik_max_word"
}
}
}
, "settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
# json形式index
PUT es_business_file_json
{
"mappings": {
"properties": {
"objectFiled":{
"type": "object"
},
"jsonField":{
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"nestedFiled":{
"type": "nested"
}
}
},
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
PUT es_business_file_json/_create/1
{
"objectFiled": {"objFiled1": "objValue1"},
"jsonField": "{\"jsonFiled1\": \"jsonValue1\"}",
"nestedFiled": {"objFiled2": "objValue2"}
}
PUT es_business_file_json/_create/2
{
"objectFiled": {"Filed1": "object Value1", "Filed1_2": "object1_2 Value1_2 你很好"},
"jsonField": "{\"Filed2\": \"json Value2\", \"Filed2_2\": \"object2_2 Value2_2 你很好 很好\"}",
"nestedFiled": {"Filed3": "nested Value3", "Filed3_2": "object3_2 Value3_2 你很好很好很好"}
}
PUT es_business_file_json/_create/3
{
"objectFiled": {"Filed3_1": "object Value1", "Filed3_2": "object1_2 Value1_2 你很好3", "field3_3": {"Filed3_1": "早上好 早上很好3 object hello 1"}},
"nestedFiled": {"Filed3_3": "nested Value3", "Filed3_2": "object3_2 Value3_2 你很好很好很好 3", "field3_3": {"Filed3_1": "早上好 早上很好3 object hello 3"}}
}
# json格式存储
PUT es_business_file_txt/_create/1{
"fileId": "你很好很好很好",
"fileName": "你很好",
"billCode": "你真很好很好",
"REMARK": "{"bookName"}"
}
GET _analyze
{
"analyzer": "ik_max_word",
"text": ["大大"]
}
GET es_business_file/_search
{
"query":{
"multi_match":{
"query":"你好",
"fields":["billCode"]
}
}
}
PUT es_business_file_txt/_create/1
{
"fileId": "你很好很好很好",
"fileName": "你很好",
"billCode": "你真很好很好"
}
# json格式存储
PUT es_business_file_txt/_create/1{
"fileId": "你很好很好很好",
"fileName": "你很好",
"billCode": "你真很好很好",
"REMARK": "{"bookName"}"
}
POST es_business_file/_doc
{
"fileId": "CCC"
}
POST es_business_file/_update/2
{
"doc": {
"fileId": "BBB",
"fileName": "你很好",
"billCode": "你很好很好"
}
}
DELETE es_business_file/_doc/NpZzS4cBX2TbHzC0yFEL
GET es_business_file/_search
{
"query":{
"match_all":{}
},
"from":0,
"size":100,
"sort":{
"createTime":"desc"
}
}
GET es_business_file/_search
{
"query":{
"bool" : {
"must" : [
{
"match" : {
"fileName" : {
"query" : "大",
"operator" : "OR",
"prefix_length" : 0,
"max_expansions" : 50,
"fuzzy_transpositions" : true,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"boost" : 1.0
}
}
}
],
"filter" : [
{
"terms" : {
"sysCode" : [
"epcb"
],
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"from":0,
"size":100,
"sort":{
"createTime":"desc"
}
}