1. 程式人生 > 其它 >ElasticSearch-docker配置與入門使用

ElasticSearch-docker配置與入門使用

docker配置

docker pull elasticsearch:7.12.1
docker run -p 9200:9200 -e discovery.type="single-node" --name elasticsearch elasticsearch:7.12.1
#拷貝分詞外掛
docker cp D:\\MyData\\Desktop\\elasticsearch-analysis-ik-7.15.1.zip elasticsearch:/usr/share/elasticsearch/plugins 
# 分詞外掛elasticsearch-analysis-ik拷貝到外掛路徑,解壓--注意要下載es對應版本
cd plugin
mkdir ik
unzip elasticsearch-analysis-ik-7.15.1.zip

Es命令列使用

sh-4.4# curl -Xsh-4.4# curl -X GET "localhost:9200/_cat/health?v" 獲取es健康狀況
epoch      timestamp cluster        status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1635319461 07:24:21  docker-cluster green           1         1      0   0    0    0        0             0                  -                100.0%
sh-4.4# curl -X GET "localhost:9200/_cat/nodes?v"  獲取es伺服器節點列表
ip         heap.percent ram.percent cpu load_1m load_5m load_15m node.role   master name
172.17.0.3           45          97   1    0.00    0.08     0.08 cdfhilmrstw *      4cecefb09b76
sh-4.4# curl -X GET "localhost:9200/_cat/indices?v"  獲取索引列表
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
sh-4.4# curl -X PUT "localhost:9200/test"  新建test索引
sh-4.4# curl -X GET "localhost:9200/_cat/indices?v"
health status index uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   test  ELpWJdz9QEKnqwjmoVmpSg   1   1          0            0       208b           208b
sh-4.4# curl -X DELETE "localhost:9200/test" 刪除索引

PostMan使用Es

  • put-增/改(覆蓋儲存就是修改)

  • delete-刪