序文
Elasticsearchは、Luceneベースの検索サーバーです。これは、RESTful Webインターフェースに基づいて、分散マルチユーザー機能を備えた全文検索エンジンを提供します。ElasticsearchはJava言語で開発され、Apacheライセンスの条件の下でオープンソースとしてリリースされています。これは人気のあるエンタープライズ検索エンジンです。Elasticsearchはクラウドコンピューティングで使用され、リアルタイム検索、安定性、信頼性、高速性、インストールと使用の容易さを実現します。公式クライアントは、Java、.NET(C#)、PHP、Python、Apache Groovy、Ruby、およびその他の多くの言語で利用できます。
公式ウェブサイト:https://www.elastic.co/cn/elasticsearch/
前提
JDKをインストールします https://blog.csdn.net/javanbme/article/details/111573731
インストール手順
1.インストールディレクトリを入力します
cd /usr/local
2.ソースコードをダウンロードします
公式ウェブサイトからダウンロード:https://www.elastic.co/guide/en/elasticsearch/reference/7.6/targz.html
方法1:リンク:https ://pan.baidu.com/s/1fSwBOKStOW9R38xEHnMXCAパスワード:c9noダウンロード後、上記のディレクトリに配置します
方法2:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz
3.インストールパッケージを解凍します
tar -zxvf elasticsearch-7.6.2-linux-x86_64.tar.gz
4.名前を変更します
mv elasticsearch-7.6.2/ elasticsearch
5.構成ファイルを変更します
cd elasticsearch/config/
esインストールディレクトリの下のconfigフォルダーに移動し、elasticsearch.ymlファイルを変更します
vi elasticsearch.yml
英語の入力状態で、iを押して挿入モードに入り、次の構成を変更します
cluster.name: test-elastic
node.name: node-1
path.data: /usr/local/elasticsearch/data
path.logs: /usr/local/elasticsearch/logs
bootstrap.system_call_filter: false
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: ["node-1"]
escを押して次のように入力します :wqを 保存して終了します
6.目次を完成させます
mkdir -p /usr/local/elasticsearch/data
7.セキュリティの問題により、elasticsearchではrootユーザーを直接実行できないため、新しいユーザーを作成します
useradd elk
passwd elk
パスワードを2回入力します(カスタム)elk
8.ユーザーに権限を割り当てます
chown -R elk:elk /usr/local/elasticsearch
9.ファイアウォールポート(9200)を開きます
10.ユーザーを切り替えてESを開始します(初期インストールが成功したかどうかを確認します)
cd
su elk
cd /usr/local/elasticsearch
bin/elasticsearch &
11. x-park(パスワードアクセス)を設定します
サーバーで実行する
curl -H "Content-Type:application/json" -XPOST http://127.0.0.1:9200/_xpack/license/start_trial?acknowledge=true
12.構成を追加します
esインストールディレクトリの下のconfigフォルダーに移動し、elasticsearch.ymlファイルを変更します
cd /usr/local/elasticsearch/config/
vi elasticsearch.yml
英語入力状態でiを押して挿入モードに入り、次の構成を追加します
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
escを押して次のように入力します :wqを 保存して終了します
13.esを再起動します
esプロセスを見つける
ps -ef|grep "elastic"
プロセスを強制終了します(PIDを見つけます。上の画像の私のプロセスは27543です)
kill -9 27543
プロセスを強制終了した後、コマンドを開始して上記の10番目のステップを実行します
14.一連のパスワードを設定します
cd /usr/local/elasticsearch/
bin/elasticsearch-setup-passwords interactive
パスワードを2021adminに設定し、コピーして貼り付けるだけです
15.パスワードを変更する場合は、次のコマンドを実行します(無視できます)。
サーバーで実行する
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
16.CA証明書を生成します
esディレクトリに入り、次のコマンドを実行します。[Y / N]が表示されたら、yと入力し、Enterキーを押します。
パスワードを見つけたら直接入力してください!
不十分な権限の入力を求められた場合chmod660 / usr / local / elasticsearch / config / certs /
bin/elasticsearch-certutil ca --ca-dn "CN=WolfBolin Elatic CA" --out /usr/local/elasticsearch/config/certs/wolfbolin-elastic-ca.p12
bin/elasticsearch-certutil cert -ca /usr/local/elasticsearch/config/certs/wolfbolin-elastic-ca.p12 --out /usr/local/elasticsearch/config/certs/wolfbolin-elastic-certificates.p12
17.CA構成を追加します
cd /usr/local/elasticsearch/config/
vi elasticsearch.yml
英語入力状態でiを押して挿入モードに入り、次の構成を追加します
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/wolfbolin-elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/wolfbolin-elastic-certificates.p12
escを押して次のように入力します :wqを 保存して終了します
18.再起動
上記の手順13を繰り返します
19.訪問
url:9200
ユーザー名とパスワードを入力しますelastic / 2021admin
展開
安装Kibana:https://blog.csdn.net/javanbme/article/details/114888089
質問集
1.情報:os :: commit_memory(0x00000000ca660000、899284992、0)が失敗しました。error = 'スペースが足りません'(errno = 12)
メモリが不足しているため、構成ファイルのESディレクトリ/config/jvm.optionsを512mに変更します
cd /usr/local/elasticsearch/config/
vi jvm.options
以下を変更します
-Xms512m
-Xmx512m
2.根本原因の可能性:java.nio.file.AccessDeniedException:/usr/local/elasticsearch/config/elasticsearch.keystore
rootユーザーを切り替えて権限を追加する
chown -R elk:elk /usr/local/elasticsearch
3.最大仮想メモリ領域vm.max_map_count [65530]が低すぎるため、少なくとも[262144]に増やします。
仮想メモリを変更する
vim /etc/sysctl.conf
以下を追加します
vm.max_map_count = 262144
保存後に実行する
sysctl -p
4. java.lang.RuntimeException:elasticsearchをrootとして実行できません
esユーザーに切り替えて開始します
su elk