当前位置: 首页> 游戏> 网游 > 想开一家客服外包公司_标签在线设计平台_网络营销概述ppt_seo网络推广经理招聘

想开一家客服外包公司_标签在线设计平台_网络营销概述ppt_seo网络推广经理招聘

时间:2025/7/13 8:45:06来源:https://blog.csdn.net/qq_73797346/article/details/143985870 浏览次数:0次
想开一家客服外包公司_标签在线设计平台_网络营销概述ppt_seo网络推广经理招聘

官方链接:https://www.elastic.co/guide/en/elasticsearch/reference/7.17/index.html

1 索引的创建

1.1 创建一个简单的索引

1.创建一个简单的索引zhiyong18-zhiyong

  • -X:指定http方法为PUT
  • 默认是1分片,1副本

==提示:==也可以使用postman图形化软件实现操作

[root@elk91~]# curl -X PUT "http://10.0.0.91:9200/zhiyong18-zhiyong"
{"acknowledged":true,"shards_acknowledged":true,"index":"zhiyong18-zhiyong"}
[root@elk91~]# echo $?
0

1.2 创建索引时指定分片

1.创建索引时指定为3分片

PUT 10.0.0.92:9200/three-shard{"settings": {"number_of_shards": 3}
}

返回结果:200 OK

{"acknowledged": true,"shards_acknowledged": true,"index": "three-shard"
}

2.查看这条索引的信息

{"three-shard": {"aliases": {},"mappings": {},"settings": {"index": {"routing": {"allocation": {"include": {"_tier_preference": "data_content"}}},"number_of_shards": "3","provided_name": "three-shard","creation_date": "1731520141526","number_of_replicas": "1","uuid": "n8A_adczSMev00wj4vD9kw","version": {"created": "7172299"}}}}
}

1.3 创建索引时指定副本

指定为3分片和3副本

PUT 10.0.0.92:9200/three-replica{"settings": {"number_of_shards": 3,"number_of_replicas": 3}
}

2 索引的查看

提示:索引名称以 . 开头表示隐藏索引。

2.1 查看单条索引

查看上一步创建的索引

curl -X GET "10.0.0.91:9200/zhiyong18-zhiyong

在这里插入图片描述

输出为json格式,在linux命令行不明显,需要额外美化

{"zhiyong18-zhiyong": {"aliases": {},"mappings": {},"settings": {"index": {"routing": {"allocation": {"include": {"_tier_preference": "data_content"}}},"number_of_shards": "1","provided_name": "zhiyong18-zhiyong","creation_date": "1731516873526","number_of_replicas": "1","uuid": "dY-XygcfSNWqcsA6GiCYAw","version": {"created": "7172299"}}}}
}
  • 索引名称zhiyong18-zhiyong

  • 别名(Aliases):空("aliases": {}

  • 映射(Mappings):空("mappings": {}

  • 设置(Settings)

    • index.routing.allocation.include._tier_preference: data_content,该索引的路由会根据 _tier_preference 规则被分配到数据内容节点
    • number_of_shards: 1索引设置了 1 个分片
    • umber_of_replicas: 1
    • provided_name: zhiyong18-zhiyong
    • creation_date: 1731516873526,创建时间,时间戳
    • uuid: dY-XygcfSNWqcsA6GiCYAw,该索引的唯一标识符
  • version: (版本)

    • created: 71722997172299 对应 Elasticsearch 7.17.22 版本

2.2 查看所有索引

[root@elk91~]# curl -X GET "http://10.0.0.91:9200/_cat/indices"
green open .geoip_databases  iKrxOYj1SQ2ycYmmPA17OQ 1 1 35 0 67.2mb 33.6mb
green open zhiyong18-zhiyong dY-XygcfSNWqcsA6GiCYAw 1 1  0 0   454b   227b

2.3 查看索引表头信息

?v可以显示索引的标头信息

[root@elk91~]# curl -X GET "http://10.0.0.91:9200/_cat/indices?v"
health status index             uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .geoip_databases  iKrxOYj1SQ2ycYmmPA17OQ   1   1         35            0     67.2mb         33.6mb
green  open   zhiyong18-zhiyong dY-XygcfSNWqcsA6GiCYAw   1   1          0            0       454b           227b
healthstatusindexuuidprirepdocs.countdocs.deletedstore.sizepri.store.size
greenopen.geoip_databasesOeOOSf30ThmAX-IzPVLcLQ1133061.4mb30.7mb
greenopenzhiyong18-zhiyongEQlFTFj5QqSMgbaJ8zGZ5Q1100452b226b

多个分片

3个分片,每个分片一个副本,所以这个索引还是1个副本

在这里插入图片描述

3 索引的修改

3.1 修改索引的分片数量

1.把1分片改为2分片

health status index                    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .geoip_databases         yn6pNHvZRSyVzRDaHUn3cg   1   1         37            0     70.6mb         35.3mb
green  open   three-replica-become-two ybf1MbgPQO-1ZyTOz1DPxg   1   2          0            0       681b           227b

2.把原有的1分片修改为2片

PUT 10.0.0.92:9200/three-replica-become-two/_settings
{"number_of_replicas": 2
}

3.查看验证

health status index                    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .geoip_databases         yn6pNHvZRSyVzRDaHUn3cg   1   1         37            0     70.6mb         35.3mb
green  open   three-replica-become-two ybf1MbgPQO-1ZyTOz1DPxg   1   2          0            0       681b           227b

3.2 修改索引的副本数量

1.查看索引副本为3,现在改为2

health status index                    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .geoip_databases         yn6pNHvZRSyVzRDaHUn3cg   1   1         37            0     70.6mb         35.3mb
yellow open   three-replica-become-two ybf1MbgPQO-1ZyTOz1DPxg   1   3          0            0       681b           227b
PUT 10.0.0.92:9200/three-replica-become-two/_settings{"number_of_replicas": 2
}

2.再次查看索引状态为绿色。主分片和副本数量正好为3

health status index                    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .geoip_databases         yn6pNHvZRSyVzRDaHUn3cg   1   1         37            0     70.6mb         35.3mb
green  open   three-replica-become-two ybf1MbgPQO-1ZyTOz1DPxg   1   2          0            0       681b           227b

4 索引的删除

==提示:==用通配符删除多条索引非常危险,可以禁用掉通配符,编辑elasticsearch.yml,设置 action.destructive_requires_name: true ,在执行破坏性的操作时就必须指定操作对象的名字。

1.查看索引three-replica-become-two

health status index                    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .geoip_databases         yn6pNHvZRSyVzRDaHUn3cg   1   1         37            0     70.6mb         35.3mb
green  open   three-replica-become-two ybf1MbgPQO-1ZyTOz1DPxg   1   2          0            0       681b           227b

2.删除指定索引

DELETE 10.0.0.92:9200/three-replica-become-two

3.查看索引是否存在

GET 10.0.0.92:9200/three-replica-become-two
{"error": {"root_cause": [{"type": "index_not_found_exception","reason": "no such index [three-replica-become-two]","resource.type": "index_or_alias","resource.id": "three-replica-become-two","index_uuid": "_na_","index": "three-replica-become-two"}],"type": "index_not_found_exception","reason": "no such index [three-replica-become-two]","resource.type": "index_or_alias","resource.id": "three-replica-become-two","index_uuid": "_na_","index": "three-replica-become-two"},"status": 404
}

温馨提示:*可以匹配索引名称;这样意味着可以删除多个一zhiyong18开头的索引,非常危险。不过在elasticsearch.yml配置文件中提供了禁用删除统配符的配置。

# 批量删除
DELETE 10.0.0.91:9200/zhiyong18*

5 索引的开启和关闭

当不想写入数据时,但又想保留数据可以把索引给关闭,以停止数据的写入。

索引被关闭后就处于close状态,关闭后的索引不能检索数据

  • 关闭:
POST 10.0.0.93:9200/index-name/_close
  • 开启:
POST 10.0.0.93:9200/index-name/_open

当然也可以在kibana上关闭索引

关键字:想开一家客服外包公司_标签在线设计平台_网络营销概述ppt_seo网络推广经理招聘

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: