Elasticsearch 叢集搭建
一:資源
叢集: gh-cluster
節點1:gh-cluster-node-01 10.44.66.2
節點2:gh-cluster-node-02 10.116.148.103
節點3:gh-cluster-node-03 10.170.142.108
Elasticsearch:elasticsearch-2.4.4.tar.gz
安裝目錄:/mnt/gh
二:安裝 Elasticsearch
1.建立相關檔案目錄
mkdir -p /mnt/gh/data/logs/elasticsearch
mkdir -p /mnt/gh/data/elasticsearch/{data,work,plugins,scripts}
2.建立新的使用者
groupadd elsearch
useradd elsearch -g elsearch -p elsearch
3.操作許可權
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
各節點調整node-name的配置資訊,保證唯一。
四: 在節點1上面安裝Elasticsearch 外掛
1.安裝head外掛 監控Elasticsearch的執行狀態以及資料
./plugin -DproxyPort=4832 -DproxyHost=10.116.4.116 install mobz/elasticsearch-head
紅色部分因為是內網,用了代理訪問外網
2.安裝kopf外掛 ---ElasticSearch的管理工具
./plugin -DproxyPort=4832 -DproxyHost=10.116.4.116 install lmenezes/elasticsearch-kopf
五:啟動
以elsearch使用者啟動三個節點
/mnt/gh/elasticsearch-2.4.4/bin/elasticsearch
六:驗證
1.
2.head外掛 _plugin/head/
3.kopf外掛 _plugin/kopf/#!/nodes
七:操作命令
1.檢查叢集的狀態
curl '10.44.66.2:9200/_cat/health?v'
2.檢查節點的資訊
curl '10.44.66.2:9200/_cat/nodes?v'
3.檢查索引資訊
curl '10.44.66.2:9200/_cat/indices?v'
4.建立索引
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.檢視所有文件數量
curl -XGET '10.44.66.2:9200/_count?pretty' -d '{"query":{"match_all":{}}}'
8.刪除索引
curl -XDELETE '10.44.66.2:9200/customer?pretty'
9.隨機建立文件資訊
curl -XPOST '10.44.66.2:9200/customer/external?pretty' -d '{"name":"Geng Chong"}'
一個 Elasticsearch 請求和任何 HTTP 請求一樣由若干相同的部件組成:
curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' -d '<BODY>'
被 < > 標記的部件:
VERB
適當的 HTTP 方法 或 謂詞 : GET`、 `POST`、 `PUT`、 `HEAD 或者 `DELETE`。
PROTOCOL
http 或者 https`(如果你在 Elasticsearch 前面有一個 `https 代理)
HOST
Elasticsearch 叢集中任意節點的主機名,或者用 localhost 代表本地機器上的節點。
PORT
執行 Elasticsearch HTTP 服務的埠號,預設是 9200 。
PATH
API 的終端路徑(例如 _count 將返回叢集中文件數量)。Path 可能包含多個元件,例如:_cluster/stats 和 _nodes/stats/jvm 。
QUERY_STRING
任意可選的查詢字串引數 (例如 ?pretty 將格式化地輸出 JSON 返回值,使其更容易閱讀)
BODY
一個 JSON 格式的請求體 (如果請求需要的話)
叢集: gh-cluster
節點1:gh-cluster-node-01 10.44.66.2
節點2:gh-cluster-node-02 10.116.148.103
節點3:gh-cluster-node-03 10.170.142.108
Elasticsearch:elasticsearch-2.4.4.tar.gz
安裝目錄:/mnt/gh
二:安裝 Elasticsearch
1.建立相關檔案目錄
mkdir -p /mnt/gh/data/logs/elasticsearch
mkdir -p /mnt/gh/data/elasticsearch/{data,work,plugins,scripts}
2.建立新的使用者
groupadd elsearch
useradd elsearch -g elsearch -p elsearch
3.操作許可權
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
點選(此處)摺疊或開啟
-
# ======================== 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
四: 在節點1上面安裝Elasticsearch 外掛
1.安裝head外掛 監控Elasticsearch的執行狀態以及資料
./plugin -DproxyPort=4832 -DproxyHost=10.116.4.116 install mobz/elasticsearch-head
紅色部分因為是內網,用了代理訪問外網
2.安裝kopf外掛 ---ElasticSearch的管理工具
./plugin -DproxyPort=4832 -DproxyHost=10.116.4.116 install lmenezes/elasticsearch-kopf
五:啟動
以elsearch使用者啟動三個節點
/mnt/gh/elasticsearch-2.4.4/bin/elasticsearch
六:驗證
1.
{ "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外掛 _plugin/head/
3.kopf外掛 _plugin/kopf/#!/nodes
七:操作命令
1.檢查叢集的狀態
curl '10.44.66.2:9200/_cat/health?v'
2.檢查節點的資訊
curl '10.44.66.2:9200/_cat/nodes?v'
3.檢查索引資訊
curl '10.44.66.2:9200/_cat/indices?v'
4.建立索引
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.檢視所有文件數量
curl -XGET '10.44.66.2:9200/_count?pretty' -d '{"query":{"match_all":{}}}'
8.刪除索引
curl -XDELETE '10.44.66.2:9200/customer?pretty'
9.隨機建立文件資訊
curl -XPOST '10.44.66.2:9200/customer/external?pretty' -d '{"name":"Geng Chong"}'
一個 Elasticsearch 請求和任何 HTTP 請求一樣由若干相同的部件組成:
curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' -d '<BODY>'
被 < > 標記的部件:
VERB
適當的 HTTP 方法 或 謂詞 : GET`、 `POST`、 `PUT`、 `HEAD 或者 `DELETE`。
PROTOCOL
http 或者 https`(如果你在 Elasticsearch 前面有一個 `https 代理)
HOST
Elasticsearch 叢集中任意節點的主機名,或者用 localhost 代表本地機器上的節點。
PORT
執行 Elasticsearch HTTP 服務的埠號,預設是 9200 。
PATH
API 的終端路徑(例如 _count 將返回叢集中文件數量)。Path 可能包含多個元件,例如:_cluster/stats 和 _nodes/stats/jvm 。
QUERY_STRING
任意可選的查詢字串引數 (例如 ?pretty 將格式化地輸出 JSON 返回值,使其更容易閱讀)
BODY
一個 JSON 格式的請求體 (如果請求需要的話)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28624388/viewspace-2138064/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ElasticSearch 7.8.1叢集搭建Elasticsearch
- Elasticsearch 5.3 叢集搭建Elasticsearch
- Elasticsearch使用系列-Docker搭建Elasticsearch叢集ElasticsearchDocker
- ElasticSearch7.6叢集搭建Elasticsearch
- elasticsearch-6.7.1叢集搭建Elasticsearch
- Elasticsearch(ES)叢集的搭建Elasticsearch
- Elasticsearch6.2叢集搭建Elasticsearch
- 搭建 ElasticSearch 6.1.3分散式叢集Elasticsearch分散式
- ELK叢集搭建(ElasticSearch Logstash Kinaba)Elasticsearch
- 手把手教你搭建一個 Elasticsearch 叢集Elasticsearch
- Elasticsearch高階之-叢集搭建,資料分片Elasticsearch
- Elasticsearch 第九篇:叢集配置與搭建Elasticsearch
- Elasticsearch之叢集。Elasticsearch
- Elasticsearch叢集搭建教程及生產環境配置Elasticsearch
- CentOS7 上搭建多節點 Elasticsearch叢集CentOSElasticsearch
- Docker Elasticsearch 叢集配置DockerElasticsearch
- ElasticSearch 分散式叢集Elasticsearch分散式
- Docker部署ElasticSearch叢集DockerElasticsearch
- Elasticsearch 叢集規劃Elasticsearch
- Elasticsearch跨叢集同步Elasticsearch
- ES 31 - 從0開始搭建Elasticsearch生產叢集Elasticsearch
- 搭建zookeeper叢集(偽叢集)
- 叢集搭建
- (三)docker-Elasticsearch 叢集DockerElasticsearch
- Elasticsearch叢集升級指引Elasticsearch
- elasticsearch如何設計叢集Elasticsearch
- elasticsearch(三)---分散式叢集Elasticsearch分散式
- 解剖 Elasticsearch 叢集 - 之一Elasticsearch
- zookeeper叢集及kafka叢集搭建Kafka
- Redis系列:搭建Redis叢集(叢集模式)Redis模式
- redis叢集搭建Redis
- nacos 叢集搭建
- kafka叢集搭建Kafka
- Ambari叢集搭建
- 搭建ELK叢集
- RabbitMQ叢集搭建MQ
- HBASE叢集搭建
- zookeeper 叢集搭建