[es]install

ouyida3ouyida3 117 9月14日 发布

elastic 下载
https://www.elastic.co/cn/dow...
Version: 7.9.1
Release date: September 04, 2020

logstash
https://www.elastic.co/cn/dow...
Version: 7.9.1

kibana
https://www.elastic.co/cn/dow...
https://www.elastic.co/guide/...

https://www.cnblogs.com/cheyu...

启动:
/data/webapp/log/elasticsearch-5.4.3/bin/elasticsearch
后台机器: nohup elasticsearch &
如果不想写日志到nohup.out 再重定向一下。
日志:
/data/webapp/log/elasticsearch-5.4.3/logs

看端口
netstat -antp |grep 9200

访问
curl http://127.0.0.1:9200/

[webapp@kafka-2 elasticsearch-5.4.3]$ curl http://127.0.0.1:9200/
{
"name" : "zyB1cBo",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "GaS-Wxy4T-OTkZVBPO5ylA",
"version" : {

"number" : "5.4.3",
"build_hash" : "eed30a8",
"build_date" : "2017-06-22T00:34:03.743Z",
"build_snapshot" : false,
"lucene_version" : "6.5.1"

},
"tagline" : "You Know, for Search"
}

curl -i -XGET 'localhost:9200/_count?pretty'

74机器设置跳转:,再用chrome访问:
http://127.0.0.1:9200/

es命令
https://www.cnblogs.com/zhang... 很好

curl -H "Content-Type: application/json" -XPUT http://localhost:9200/zy2index/product/p1 -d '{
"name":"mac",
"price":20000,
"description":"test",
"attr":["computer","产品"]
}'

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"json_parse_exception","reason":"Invalid UTF-8 start byte 0xb2n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@7f939ce5; line: 5, column: 22]"}},"status":400}
解决:
改.bash_profile为utf8
乱码后台日志会报错。其余后台日志没东西。

after

{"_index":"zy2index","_type":"product","_id":"p1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}

查询:
curl -XGET http://localhost:9200/zy2index/product/p1?pretty
不要?pretty就是前面没空格

查部分
curl -XGET http://localhost:9200/zy2index/product/p1?_source=name,price&pretty

修改
curl -H "Content-Type: application/json" -XPOST http://localhost:9200/zy2index/product/p1/_update?pretty -d '{"doc":
{"name":"mac2",
"price":2000,
"description":"test2",
"attr":["computer","product"]}
}'

必须是/index/type/id,这样。缺一不可。type或者id错了都是返回found=false,
curl -XGET http://localhost:9200/zy2index/product/aa?pretty
{
"_index" : "zy2index",
"_type" : "product",
"_id" : "aa",
"found" : false
}

如果index错了:
curl -XGET http://localhost:9200/zy2inde/produc/aa?pretty
{
"error" : {

"root_cause" : [
  {
    "type" : "index_not_found_exception",
    "reason" : "no such index",
    "resource.type" : "index_expression",
    "resource.id" : "zy2inde",
    "index_uuid" : "_na_",
    "index" : "zy2inde"
  }
],
"type" : "index_not_found_exception",
"reason" : "no such index",
"resource.type" : "index_expression",
"resource.id" : "zy2inde",
"index_uuid" : "_na_",
"index" : "zy2inde"

},
"status" : 404
}

索引库
curl -XGET http://localhost:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open zy2index j30b30u4RjukFgjhsfzbtQ 5 1 1 0 5.4kb 5.4kb
yellow open testindex K_oNsyh-R_yBEX4BdIE0nQ 5 1 0 0 650b 650b

建索引,已存在会报错。也可不建,直接插数据。
curl -XPUT http://localhost:9200/zy2index

curl -XPUT http://localhost:9200/testindex
{"acknowledged":true,"shards_acknowledged":true}

删除数据?错了吧。不是xput
curl -H "Content-Type: application/json" -XPUT http://localhost:9200/zy2index/product/p3 -d '{
"name":"mac2",
"price":2000,
"description":"prod",
"attr":["computer","prod"]
}'

curl -XDELETE http://localhost:9200/zy2index/product/p3?pretty
成功删。

curl -XDELETE http://localhost:9200/testindex/product/p1?pretty
啥也没删。

curl -XDELETE http://localhost:9200/testindex?pretty
{
"acknowledged" : true
}
成功删了。

elasticsearch-head
要不docker,要不npm。74机器装不了

评论
载入中...