集群健康检查
http://localhost:9200/_cat/health?v
http://localhost:9200/_cluster/health(推荐)
状态说明
green:正常
yellow: 集群正常 数据正常,部分副本不正常
red: 集群部分正常,数据可能丢失,需要紧急修复
查询节点列表
http://localhost:9200/_cat/nodes?v
查看所有索引
http://localhost:9200/_cat/indices?v
目前 集群中没有任何索引
补充:
curl
-X 指定http的请求方法 有HEAD GET POST PUT DELETE
-d 指定要传输的数据
-H 指定http请求头信息
新增索引
curl -XPUT 'localhost:9201/blog_test?pretty'
curl -XPUT 'localhost:9201/blog?pretty'
删除索引
curl -XDELETE 'localhost:9200/blog_test?pretty'
新增一条记录,并指定为article类型,ID为1
curl -XPUT -H "Content-Type: application/json" 'localhost:9201/blog/article/1?pretty' -d '
{
"title": "冰雪之华王昭君啦啦啦",
"content":"冰雪之华王昭君,昭君出塞"
}'
curl -XPUT -H "Content-Type: application/json" 'localhost:9201/blog/article/2?pretty' -d '
{
"title": "test",
"content":"testsfsdfdsfdsf",
"PV":10
}'
curl -XPUT -H "Content-Type: application/json" 'localhost:9201/blog/article/3?pretty' -d '
{
"title": "test",
"content":"testsfsdfdsfdsf",
"PV":23
}'
空间不够新增失败处理 curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
{
"error" : {
"root_cause" : [
{
"type" : "cluster_block_exception",
"reason" : "blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
}
],
"type" : "cluster_block_exception",
"reason" : "blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
},
"status" : 403
}
ID查询记录
curl -XGET 'localhost:9200/blog/article/1'
curl -XGET 'localhost:9200/blog/article/1?pretty'(美化推荐)
搜索
curl -XGET 'http://localhost:9201/blog/article/_search?q=title:小A'