Elasticsearch集群是怎么搭建的,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
紹興ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書(shū)銷(xiāo)售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書(shū)合作)期待與您的合作!
一:資源
集群: gh-cluster
節(jié)點(diǎn)1:gh-cluster-node-01 10.44.66.2
節(jié)點(diǎn)2:gh-cluster-node-02 10.116.148.103
節(jié)點(diǎn)3:gh-cluster-node-03 10.170.142.108
Elasticsearch:elasticsearch-2.4.4.tar.gz
安裝目錄:/mnt/gh
二:安裝 Elasticsearch
1.創(chuàng)建相關(guān)文件目錄
mkdir -p /mnt/gh/data/logs/elasticsearch
mkdir -p /mnt/gh/data/elasticsearch/{data,work,plugins,scripts}
2.創(chuàng)建新的用戶(hù)
groupadd elsearch
useradd elsearch -g elsearch -p elsearch
3.操作權(quán)限
chown -R elsearch:elsearch /mnt/gh/data/logs/elasticsearch /mnt/gh/data/elasticsearch
4.安裝 Elasticsearch
tar -zxvf elasticsearch-2.4.4.tar.gz
5./etc/security/limits.conf 配置
elsearch soft memlock unlimited
elsearch hard memlock unlimited
6.Elasticsearch 配置
vi /mnt/gh/elasticsearch-2.4.4/config/elasticsearch.yml
點(diǎn)擊(此處)折疊或打開(kāi)
# ======================== 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:
#
cluster.name: gh-cluster
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: gh-cluster-node-01
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
path.data: /mnt/gh/data/elasticsearch/data
#
# Path to log files:
#
path.logs : /mnt/gh/data/logs/elasticsearch
path.plugins: /mnt/gh/data/elasticsearch/plugins
path.scripts: /mnt/gh/data/elasticsearch/scripts
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
bootstrap.memory_lock: true
#
# 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.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 10.44.66.2
#
# 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 ----------------------------------
#
# 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.multicast.enabled: false
discovery.zen.ping_timeout: 120s
discovery.zen.fd.ping_timeout: 120s
discovery.zen.ping.unicast.hosts: ["10.44.66.2", "10.116.148.103", "10.170.142.108"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 2
#
# 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:
#
gateway.recover_after_nodes: 3
gateway.recover_after_time: 30m
gateway.expected_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true
各節(jié)點(diǎn)調(diào)整node-name的配置信息,保證唯一。
四: 在節(jié)點(diǎn)1上面安裝Elasticsearch 插件
1.安裝head插件 監(jiān)控Elasticsearch的運(yùn)行狀態(tài)以及數(shù)據(jù)
./plugin -DproxyPort=4832 -DproxyHost=10.116.4.116 install mobz/elasticsearch-head
紅色部分因?yàn)槭莾?nèi)網(wǎng),用了代理訪問(wèn)外網(wǎng)
2.安裝kopf插件 ---ElasticSearch的管理工具
./plugin -DproxyPort=4832 -DproxyHost=10.116.4.116 install lmenezes/elasticsearch-kopf
五:?jiǎn)?dòng)
以elsearch用戶(hù)啟動(dòng)三個(gè)節(jié)點(diǎn)
/mnt/gh/elasticsearch-2.4.4/bin/elasticsearch
六:驗(yàn)證
1.http://10.44.66.2:9200/
{ "name" : "gh-cluster-node-01", "cluster_name" : "gh-cluster", "cluster_uuid" : "iGovr8lcSW62JdEABzLMyg", "version" : { "number" : "2.4.4", "build_hash" : "fcbb46dfd45562a9cf00c604b30849a6dec6b017", "build_timestamp" : "2017-01-03T11:33:16Z", "build_snapshot" : false, "lucene_version" : "5.5.2" }, "tagline" : "You Know, for Search" }
2.head插件 http://10.44.66.2:9200/_plugin/head/
3.kopf插件 http://10.44.66.2:9200/_plugin/kopf/#!/nodes
七:操作命令
1.檢查集群的狀態(tài)
curl '10.44.66.2:9200/_cat/health?v'
2.檢查節(jié)點(diǎn)的信息
curl '10.44.66.2:9200/_cat/nodes?v'
3.檢查索引信息
curl '10.44.66.2:9200/_cat/indices?v'
4.創(chuàng)建索引
curl -XPUT '10.44.66.2:9200/customer?pretty'
5.往索引中,添加文檔
curl -XPUT '10.44.66.2:9200/customer/external/1?pretty' -d '{"name":"John Doe"}'
6.查看文檔信息
curl -XGET '10.44.66.2:9200/customer/external/1?pretty'
7.查看所有文檔數(shù)量
curl -XGET '10.44.66.2:9200/_count?pretty' -d '{"query":{"match_all":{}}}'
8.刪除索引
curl -XDELETE '10.44.66.2:9200/customer?pretty'
9.隨機(jī)創(chuàng)建文檔信息
curl -XPOST '10.44.66.2:9200/customer/external?pretty' -d '{"name":"Geng Chong"}'
一個(gè) Elasticsearch 請(qǐng)求和任何 HTTP 請(qǐng)求一樣由若干相同的部件組成:
curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' -d '<BODY>'
被 < > 標(biāo)記的部件:
VERB
適當(dāng)?shù)?HTTP 方法 或 謂詞 : GET`、 `POST`、 `PUT`、 `HEAD 或者 `DELETE`。
PROTOCOL
http 或者 https`(如果你在 Elasticsearch 前面有一個(gè) `https 代理)
HOST
Elasticsearch 集群中任意節(jié)點(diǎn)的主機(jī)名,或者用 localhost 代表本地機(jī)器上的節(jié)點(diǎn)。
PORT
運(yùn)行 Elasticsearch HTTP 服務(wù)的端口號(hào),默認(rèn)是 9200 。
PATH
API 的終端路徑(例如 _count 將返回集群中文檔數(shù)量)。Path 可能包含多個(gè)組件,例如:_cluster/stats 和 _nodes/stats/jvm 。
QUERY_STRING
任意可選的查詢(xún)字符串參數(shù) (例如 ?pretty 將格式化地輸出 JSON 返回值,使其更容易閱讀)
BODY
關(guān)于Elasticsearch集群是怎么搭建的問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
文章標(biāo)題:Elasticsearch集群是怎么搭建的
URL分享:http://muchs.cn/article10/pihdgo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、標(biāo)簽優(yōu)化、網(wǎng)站策劃、定制開(kāi)發(fā)、動(dòng)態(tài)網(wǎng)站、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)