03_ElasticSearchのダウンロードとインストール

概要

ElasticSearchはJavaで開発されており、jdk環境が必須であり、少なくともjre環境が必要です

1 エラスティックサーチをダウンロード

最新バージョンは、ElasticSearch 公式 Web サイト (https://www.elastic.co/cn/downloads/elasticsearch) からダウンロードする必要があります。

他のバージョンについては、Elastic Chinese コミュニティ (アドレス: https://elasticsearch.cn/download) を参照してください。
バージョンに注意してください。バージョンが異なるとまったく異なります。自分に合ったバージョンを選択してください。

2. インストール

Java プログラムの起動方法は環境によって異なりますが、解凍後に特別なインストールは必要なく、bin ディレクトリを見つけてコマンドを使用して起動するだけです。

ここに画像の説明を挿入します

2.1 環境変数を構成して、毎回 bin ディレクトリに移動する代わりにコマンドを使用して後で起動しやすくする

私は他人のスクリーンショットを撮るために Mac を使用していますが、Baidu Bar を使用する方が簡単です。

vim ~/.bash_profile 

コンテンツを追加します:

自己的解压目录
ES_HOME=/Users/XXX/java/es/elasticsearch-7.17.3 
PATH=$PATH:$ES_HOME/bin
export ES_HOME

設定はターミナル上で実行できますが、
通常はelasticsearchコマンドを使用するはずですが、簡単にするためにesコマンドに変更しました。

es
在后端启动
es -d 

起動後、
localhost:9200に直接アクセスします。

端末を閉じるとMacの環境変数が有効にならない問題

~/.bash_profile で環境変数を設定します。設定した環境変数は、ターミナルを再起動するたびに有効になるわけではありません。

$source ~/.bash_profile を再実行する必要があります。

これは、zsh が ~/.zshrc ファイルをロードし、「.zshrc」ファイルに環境変数が定義されていないためです。

解決:

私たち ~/.zshrc

~/.zshrc ファイルの最後に次の行を追加します。

ソース ~/.bash_profile

やっと

ソース ~/.zshrc

問題は解決したので、2 つのファイル .bash_profile と .zshrc の違いは何ですか?

.bash_profile によって変更された環境変数は、現在のウィンドウでのみ有効であり、ソースする必要があります。.zshrc は、win によって開始される環境変数と同等です。問題を解決するには、ソース更新 .bash_profile コマンドを .zshrc に追加できます。

クラスタ構成

学習を始めたばかりの場合は、クラスターを構成する必要はなく、スタンドアロンのマシンで学習できます。とにかくクラスターにはさまざまな問題があります。ここでは設定ファイルのみを記述します。問題が発生した場合は、 Baidu に移動し、独自の解凍ファイルを数分間コピーし、 config の下で変更します


# Use a descriptive name for your cluster:
##集群名称,节点之间要保持一致
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# #节点名称,集群内要唯一
node.name: node-1
node.master: true
node.data: true
#
# 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.
# node-01
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
# #ip 地址
network.host: 10.0.72.59
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
# #http 端口
http.port: 1001
#tcp 监听端口
transport.tcp.port: 9301
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features. 
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html


discovery.seed_hosts: ["localhost:9301", "localhost:9302","localhost:9303"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#集群内的可以被选为主节点的节点列表
cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#跨域配置
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"







クラスターが正常に起動するかどうかを確認します。
GET http://127.0.0.1:1001/_cluster/health
GET http://127.0.0.1:1002/_cluster/health
GET http://127.0.0.1:1003/_cluster/health
Return結果:

{
    
    
    "cluster_name": "my-application",
    "status": "green",
    "timed_out": false,
    "number_of_nodes": 3,
    "number_of_data_nodes": 3,
    "active_primary_shards": 0,
    "active_shards": 0,
    "relocating_shards": 0,
    "initializing_shards": 0,
    "unassigned_shards": 0,
    "delayed_unassigned_shards": 0,
    "number_of_pending_tasks": 0,
    "number_of_in_flight_fetch": 0,
    "task_max_waiting_in_queue_millis": 0,
    "active_shards_percent_as_number": 100.0
}

status フィールドは、現在のクラスターが全体として正常に動作しているかどうかを示します。その3色には次のような意味があります。

緑: すべてのプライマリ シャードとレプリカ シャードが正常に実行されています。
黄色: すべてのプライマリ シャードは正常に実行されていますが、すべてのレプリカ シャードが正常に実行されているわけではありません。
赤: 正しく実行されていないプライマリ シャードがあります。

メモリ設定ファイル jvm.options を構成する

ファイルパス:/var/huaxing/elasticsearch-7.4.2/config

メモリ容量が少ない場合は、デフォルトの構成を変更します。 -Xms1g -Xmx1g は、-Xms512m -Xmx512m になります。

Supongo que te gusta

Origin blog.csdn.net/wufagang/article/details/132918997
Recomendado
Clasificación