elasticsearch head

1.安裝Elasticsearch

(略)

2.下載elasticsearch-head

下載地址

3.安裝grunt

npm install -g grunt-cli

4.解壓elasticsearch-head

cd 到解壓后的目錄下,執行 npm install

5.修改elasticsearch.yml 配置文件

新增

http.cors.enabled: true
http.cors.allow-origin: "*"

6.修改elasticsearch-head-master/Gruntfile.js文件

connect: {
        server: {
            options: {
                hostname: '192.168.9.108',
                port: 9100,
                base: '.',
                keepalive: true
            }
        }
    }

7. 在elasticsearch-head-master目錄下啟動elasticsearch-head

運行命令
grunt server

8.通過瀏覽器連接http://192.168.9.108:9100/

image.png

9.新加節點,看看效果

bootstrap.memory_lock: false
cluster.name: elasticsearch_zhang
http.port: 9200
node.data: true
node.ingest: true
node.master: true
node.max_local_storage_nodes: 1
node.name: DESKTOP-V8P04QS
path.data: C:\Users\user\Elastic\Elasticsearch\data
path.logs: C:\Users\user\Elastic\Elasticsearch\logs
transport.tcp.port: 9300
network.host: [_local_, 192.168.9.101]
discovery.zen.ping.unicast.hosts: ["192.168.9.108:9300"]

啟動節點后,瀏覽器查看


image.png

10.執行批量插入后,節點變化

from elasticsearch import Elasticsearch
from datetime import datetime

es = Elasticsearch(hosts=["192.168.9.108"])

s = es.bulk(
    index="website",
    doc_type="blog",
    body=[
        # {action: metadata}
        {"create": {"_id": 8}},
        # {request body}
        {
            "title": "created using es.bulk",
            "date": datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
            "text": "try to write a doc to es"
        },
        # {action: metadata}
        {"create": {"_id": 19}},
        # {request body}
        {
            "title": "created using es.bulk",
            "date": datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
            "text": "try to write a doc to es"
        }
    ]
)
image.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容