日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

elasticsearch -- head插件

發(fā)布時間:2023/12/20 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 elasticsearch -- head插件 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

2019獨角獸企業(yè)重金招聘Python工程師標準>>>

elasticsearch head插件是一個入門級的elasticsearch前端插件;我們來安裝下;

?

第一步:安裝nodejs??

head插件是nodejs實現(xiàn)的,所以必須先安裝Nodejs

參考:http://blog.java1234.com/blog/articles/354.html

?

第二步:安裝git

我們要用git方式下載head插件

參考:http://blog.java1234.com/blog/articles/353.html

?

第三步:下載以及安裝head插件

打開?https://github.com/mobz/elasticsearch-head?

Running with built in server

  • git clone git://github.com/mobz/elasticsearch-head.git

  • cd elasticsearch-head

  • npm install

  • npm run start

  • open?http://localhost:9100/

?

我們用這種最簡單的方式安裝

?

當然我們安裝的地方是 /usr/local/?

?

第四步:配置elasticsearch,允許head插件訪問

進入elasticsearch config目錄 打開?elasticsearch.yml

最后加上

http.cors.enabled: true

http.cors.allow-origin: "*"

?

第五步:測試

啟動elasticsearch,再進入head目錄,執(zhí)行npm run start 啟動插件

?

說明啟動成功,然后瀏覽器 執(zhí)行?http://192.168.1.110:9100/

內(nèi)部輸入?http://192.168.1.110:9200/?點擊連接 如果右側(cè)輸出黃色背景字體 說明配置完整OK;

?

?

elasticsearch-head插件添加索引

?

?

elasticsearch提供了豐富的http url接口對外提供服務(wù),

這也使得elasticsearch插件特別多,功能也強大;

?

我們今天來講下 用head插件來添加索引

這里有好幾種方式,先講一種原始的,

?

進入主頁,選擇 復合查詢

?

我們以后執(zhí)行操作 都在這里搞;

?

地址欄輸入:http://192.168.1.110:9200/student/

然后點擊“提交請求”,即可;

?

?

右側(cè)返回索引添加成功信息;

我們返回 概要 首頁 點擊 刷新 也能看到新建的索引student

?

這里方式有點索引 這里有更加簡單的方式

?

點擊 索引標簽,

?

點擊“新建索引”,

這里我們輸入索引名稱即可 當然默認分片數(shù)是5 副本數(shù)是1 我們輸入索引名稱student2 分片數(shù)10 副本2

假如單個機器部署的話 副本是沒地方分配的 一般集群都是2臺或者2臺以上機器集群,副本都不存對應(yīng)的分片所以機器的,這樣能保證集群系統(tǒng)的可靠性。

?

我們點擊"OK" 即可輕松建立索引 以及分片數(shù)和副本;

?

回到概要首頁;

?

這里可以清晰的看到索引 以及分片和副本;

?

當然要刪除索引的話

?

點 動作? 然后 刪除 ,即可;

?

比較簡單

?

elasticsearch-head插件添加,修改,刪除文檔

elasticsearch-head插件添加,修改,刪除文檔

?

我們用head插件來實現(xiàn)下添加,修改,刪除文檔操作;

?

首先是添加文檔,這里我們給student索引添加文檔

先進入符合查詢

post方式??http://192.168.1.110:9200/student/first/12/

這里student是索引 first是類別 12是id

假如id沒寫的話 系統(tǒng)也會給我們自動生成一個

假如id本身已經(jīng)存在 那就變成了修改操作;我們一般都要指定下id

?

我們輸入Json數(shù)據(jù),然后點擊提交,右側(cè)顯示創(chuàng)建成功,當然我們可以驗證下json

?

點 數(shù)據(jù)瀏覽,

?

我們可以看到新添加的索引文檔

?

修改文檔的話,

方式和添加一樣,只不過我們一定要指定已經(jīng)存在的id

地址輸入:http://192.168.1.110:9200/student/first/12/

然后修改下數(shù)據(jù),點擊提交:

我們發(fā)現(xiàn) 提示修改成功;

?

數(shù)據(jù)瀏覽里:

?

查詢文檔也有可以通過請求

http://192.168.1.110:9200/student/first/12/?選擇get方式,然后點擊提交

?

刪除文檔?

選擇delete即可;

?

前面我們講過刪除索引的圖形操作方式;

用http url命令也可以

輸入:http://192.168.1.110:9200/student/

選擇delete即可

elasticsearch使用head插件打開和關(guān)閉索引

elasticsearch使用head打開和關(guān)閉索引

?

打開/關(guān)閉索引接口允許關(guān)閉一個打開的索引或者打開一個已經(jīng)關(guān)閉的索引。

關(guān)閉的索引只能顯示索引元數(shù)據(jù)信息,不能夠進行讀寫操作。

?

比如我們新建一個索引student2

我們用 POST?http://192.168.1.110:9200/student2/_close/? 關(guān)閉索引

點擊提交請求;

?

再概要首頁里,可以刷新下 看到student2被關(guān)閉;

變成了灰色;

?

POST?http://192.168.1.110:9200/student2/_open/?打開索引;

點擊提交請求,

回到概要首頁,點擊刷新,

?

又正常了。

elasticsearch head插件 增加索引映射

?

?

elasticsearch head插件 增加索引映射

?

elasticsearch HTTP API 允許你向索引(index)添加文檔類型(type),或者向文檔類型(type)中添加字段(field)。

?

PUT?http://192.168.1.110:9200/student/

{

? ?"mappings":{

? ? ? ?"first":{

? ? ? ? ? ? "properties":{

? ? ? ? ? ? ? ?"name":{"type":"keyword"}

? ? ? ? ? ? ?}

? ? ? ? }

? ?}

}

mapping是映射關(guān)鍵字??properties是添加指定文檔類型的字段的關(guān)鍵字

點擊提交,添加student索引

添加文檔類型first? ??

添加字段name 類型是keyword

(keyword類型適合短詞匯內(nèi)容,比如郵件,姓名,性別等等,text類型適合長文本,可以分詞,比如文章標題,文章內(nèi)容等)

?

PUT?http://192.168.1.110:9200/student/_mapping/third/

{

? ?"properties":{

? ? ? "name2":{"type":"keyword"}

? ? }

}

?

向已經(jīng)存在的索引student添加文檔類型為third,包含字段name2,字段類型是keyword字符串

?

elasticsearch head插件 查詢索引映射關(guān)系

?

elasticsearch head插件 查詢索引映射關(guān)系

?

http://192.168.1.110:9200/student/? GET? 直接加索引名稱即可 能查到所有信息

?

?

?

第二種方式 利用head插件圖形工具:

?

進入概要首頁,選擇索引,然后索引信息,

?

直接顯示索引的映射狀態(tài)信息;

?

elasticsearch-.yml(中文配置詳解)

# ========================?Elasticsearch Configuration?=========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ----------------------------------?Cluster?-----------------------------------
#
# Use a descriptive name for your cluster:
#?集群名稱,默認是elasticsearch
# cluster.name: my-application
#
# ------------------------------------?Node?------------------------------------
#
# Use a descriptive name for the node:
#?節(jié)點名稱,默認從elasticsearch-2.4.3/lib/elasticsearch-2.4.3.jar!config/names.txt中隨機選擇一個名稱
# node.name: node-1
#
# Add custom attributes to the node:
#?
# node.rack: r1
#
# -----------------------------------?Paths?------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#?可以指定es的數(shù)據(jù)存儲目錄,默認存儲在es_home/data目錄下
# path.data: /path/to/data
#
# Path to log files:
#?可以指定es的日志存儲目錄,默認存儲在es_home/logs目錄下
# path.logs: /path/to/logs
#
# -----------------------------------?Memory?-----------------------------------
#
# Lock the memory on startup:
#?鎖定物理內(nèi)存地址,防止elasticsearch內(nèi)存被交換出去,也就是避免es使用swap交換分區(qū)
# bootstrap.memory_lock: true
#
#
#
#?確保ES_HEAP_SIZE參數(shù)設(shè)置為系統(tǒng)可用內(nèi)存的一半左右
# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
# available on the system and that the owner of the process is allowed to use this limit.
#?
#?當系統(tǒng)進行內(nèi)存交換的時候,es的性能很差
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ----------------------------------?Network?-----------------------------------
#
#
#?為es設(shè)置ip綁定,默認是127.0.0.1,也就是默認只能通過127.0.0.1 或者localhost才能訪問
#?es1.x版本默認綁定的是0.0.0.0 所以不需要配置,但是es2.x版本默認綁定的是127.0.0.1,需要配置
# Set the bind address to a specific IP (IPv4 or IPv6):
#
# network.host: 192.168.0.1
#
#
#?為es設(shè)置自定義端口,默認是9200
#?注意:在同一個服務(wù)器中啟動多個es節(jié)點的話,默認監(jiān)聽的端口號會自動加1:例如:9200,9201,9202...
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# ---------------------------------?Discovery?----------------------------------
#
#?當啟動新節(jié)點時,通過這個ip列表進行節(jié)點發(fā)現(xiàn),組建集群
#?默認節(jié)點列表:
#?127.0.0.1,表示ipv4的回環(huán)地址。
# [::1],表示ipv6的回環(huán)地址
#
#?在es1.x中默認使用的是組播(multicast)協(xié)議,默認會自動發(fā)現(xiàn)同一網(wǎng)段的es節(jié)點組建集群,
#?在es2.x中默認使用的是單播(unicast)協(xié)議,想要組建集群的話就需要在這指定要發(fā)現(xiàn)的節(jié)點信息了。
#?注意:如果是發(fā)現(xiàn)其他服務(wù)器中的es服務(wù),可以不指定端口[默認9300],如果是發(fā)現(xiàn)同一個服務(wù)器中的es服務(wù),就需要指定端口了。
# Pass an initial list of hosts to perform discovery when new node is started:
#?
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
# discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
#
#
#
#?通過配置這個參數(shù)來防止集群腦裂現(xiàn)象 (集群總節(jié)點數(shù)量/2)+1
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ----------------------------------?Gateway?-----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#?一個集群中的N個節(jié)點啟動后,才允許進行數(shù)據(jù)恢復處理,默認是1
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ----------------------------------?Various?-----------------------------------
#?在一臺服務(wù)器上禁止啟動多個es服務(wù)
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
#?設(shè)置是否可以通過正則或者_all刪除或者關(guān)閉索引庫,默認true表示必須需要顯式指定索引庫名稱
#?生產(chǎn)環(huán)境建議設(shè)置為true,刪除索引庫的時候必須顯式指定,否則可能會誤刪索引庫中的索引庫。
# Require explicit names when deleting indices:
#

# action.destructive_requires_name: true

?

?

elasticsearch5.5多機集群配置

elasticsearch5.5多機集群配置

?

ELasticsearch 5.5要求JDK版本最低為1.8;

?

配置集群之前? 先把要加群集群的節(jié)點的里的data目錄下的Node目錄 刪除,否則集群建立會失敗。

?

我這邊虛擬機配置了兩臺centos IP分別是 192.168.1.110 和?192.168.1.111 ;

?

分別配置下elasticsearch.yml配置文件

110機器:

# ---------------------------------- Cluster -----------------------------------

#

# Use a descriptive name for your cluster:

#

cluster.name: my-application

#

# ------------------------------------ Node ------------------------------------

#

# Use a descriptive name for the node:

#

node.name: node-1

#

# Add custom attributes to the node:

#

#node.attr.rack: r1

#

# ----------------------------------- Paths ------------------------------------

#

# Path to directory where to store the data (separate multiple locations by comma):

#

#path.data: /path/to/data

#

# Path to log files:

#

#path.logs: /path/to/logs

#

# ----------------------------------- Memory -----------------------------------

#

# Lock the memory on startup:

#

#bootstrap.memory_lock: true

#

# Make sure that the heap size is set to about half the memory available

# on the system and that the owner of the process is allowed to use this

# limit.

#

# Elasticsearch performs poorly when the system is swapping the memory.

#

# ---------------------------------- Network -----------------------------------

#

# Set the bind address to a specific IP (IPv4 or IPv6):

#

network.host: 192.168.1.110

#

# Set a custom port for HTTP:

#

http.port: 9200

#

# For more information, consult the network module documentation.

#

# --------------------------------- Discovery ----------------------------------

#

# Pass an initial list of hosts to perform discovery when new node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

#

discovery.zen.ping.unicast.hosts: ["192.168.1.110"]

#

# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):

#

#discovery.zen.minimum_master_nodes: 3

#

# For more information, consult the zen discovery module documentation.

#

# ---------------------------------- Gateway -----------------------------------

#

# Block initial recovery after a full cluster restart until N nodes are started:

#

#gateway.recover_after_nodes: 3

#

# For more information, consult the gateway module documentation.

#

# ---------------------------------- Various -----------------------------------

#

# Require explicit names when deleting indices:

#

#action.destructive_requires_name: true

http.cors.enabled: true

http.cors.allow-origin: "*"

?

111機器:

# ---------------------------------- Cluster -----------------------------------

#

# Use a descriptive name for your cluster:

#

cluster.name: my-application

#

# ------------------------------------ Node ------------------------------------

#

# Use a descriptive name for the node:

#

node.name: node-2

#

# Add custom attributes to the node:

#

#node.attr.rack: r1

#

# ----------------------------------- Paths ------------------------------------

#

# Path to directory where to store the data (separate multiple locations by comma):

#

#path.data: /path/to/data

#

# Path to log files:

#

#path.logs: /path/to/logs

#

# ----------------------------------- Memory -----------------------------------

#

# Lock the memory on startup:

#

#bootstrap.memory_lock: true

#

# Make sure that the heap size is set to about half the memory available

# on the system and that the owner of the process is allowed to use this

# limit.

#

# Elasticsearch performs poorly when the system is swapping the memory.

#

# ---------------------------------- Network -----------------------------------

#

# Set the bind address to a specific IP (IPv4 or IPv6):

#

network.host: 192.168.1.111

#

# Set a custom port for HTTP:

#

http.port: 9200

#

# For more information, consult the network module documentation.

#

# --------------------------------- Discovery ----------------------------------

#

# Pass an initial list of hosts to perform discovery when new node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

#

discovery.zen.ping.unicast.hosts: ["192.168.1.110"]

#

# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):

#

#discovery.zen.minimum_master_nodes: 3

#

# For more information, consult the zen discovery module documentation.

#

# ---------------------------------- Gateway -----------------------------------

#

# Block initial recovery after a full cluster restart until N nodes are started:

#

#gateway.recover_after_nodes: 3

?

?

?

這里兩臺機器的cluster.name必須一致 這樣才算一個集群

node.name節(jié)點名稱每臺取不同的名稱,用來表示不同的集群節(jié)點

network.host配置成自己的局域網(wǎng)IP

http.port端口就固定9200

discovery.zen.ping.unicast.hosts主動發(fā)現(xiàn)節(jié)點我們都配置成110節(jié)點IP

?

配置完后 重啟es服務(wù);

?

然后head插件我們查看下:

?

說明集群配置OK 。

轉(zhuǎn)載于:https://my.oschina.net/u/1458864/blog/2050766

總結(jié)

以上是生活随笔為你收集整理的elasticsearch -- head插件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。