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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容