ElasticsearchのCentos 7へのインストールと構成

7389 ワード

Java環境のインストール
ここではyum方式でインストールし、ネットワークが必要であることを前提としています.
yum install java-1.8.0-openjdk

インストール完了、javaバージョンの表示
[root@localhost ~]# java -version 
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

Elasticsearchのインストール
Elasticsearchのインストールはとても简単で、ダウンロードして解凍してすぐ、ここでwgetを使ってダウンロードして、もちろんホームページを通じてダウンロードすることができますhttps://www.elastic.co/downlo...あ、またコピー.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz

/usr/local/に解凍
tar -zxvf elasticsearch-5.6.3.tar.gz -C /usr/local/

Elasticsearchの実行
Elasticsearchはスーパーユーザーrootを使用して実行できないことを要求しているので、testuserアカウントを作成します.
#   testuser  
adduser testuser
#     
passwd testuser

次にtestuserユーザーelasticsearchディレクトリへの権限を与えます.
chown -R testuser /usr/local/elasticsearch-5.6.3/

elasticsearchディレクトリに切り替え、testuserユーザーで実行
cd /usr/local/elasticsearch-5.6.3/
su testuser

elasticsearchを実行し、バックグラウンドで-dを追加したい場合は
[testuser@localhost elasticsearch-5.6.3]$ ./bin/elasticsearch
[2017-10-31T16:07:09,445][INFO ][o.e.n.Node               ] [] initializing ...
[2017-10-31T16:07:09,662][INFO ][o.e.e.NodeEnvironment    ] [oDFU6c3] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [45.4gb], net total_space [49.9gb], spins? [unknown], types [rootfs]
[2017-10-31T16:07:09,662][INFO ][o.e.e.NodeEnvironment    ] [oDFU6c3] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-10-31T16:07:09,663][INFO ][o.e.n.Node               ] node name [oDFU6c3] derived from node ID [oDFU6c3UT6ORC2p0CKBeLA]; set [node.name] to override
[2017-10-31T16:07:09,663][INFO ][o.e.n.Node               ] version[5.6.3], pid[11484], build[1a2f265/2017-10-06T20:33:39.012Z], OS[Linux/3.10.0-514.26.2.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_151/25.151-b12]
[2017-10-31T16:07:09,664][INFO ][o.e.n.Node               ] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch-5.6.3]
[2017-10-31T16:07:10,723][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [aggs-matrix-stats]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [ingest-common]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [lang-expression]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [lang-groovy]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [lang-mustache]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [lang-painless]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [parent-join]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [percolator]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [reindex]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [transport-netty3]
[2017-10-31T16:07:10,724][INFO ][o.e.p.PluginsService     ] [oDFU6c3] loaded module [transport-netty4]
[2017-10-31T16:07:10,725][INFO ][o.e.p.PluginsService     ] [oDFU6c3] no plugins loaded
[2017-10-31T16:07:12,622][INFO ][o.e.d.DiscoveryModule    ] [oDFU6c3] using discovery type [zen]
[2017-10-31T16:07:13,133][INFO ][o.e.n.Node               ] initialized
[2017-10-31T16:07:13,133][INFO ][o.e.n.Node               ] [oDFU6c3] starting ...
[2017-10-31T16:07:13,306][INFO ][o.e.t.TransportService   ] [oDFU6c3] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2017-10-31T16:07:13,318][WARN ][o.e.b.BootstrapChecks    ] [oDFU6c3] max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2017-10-31T16:07:16,372][INFO ][o.e.c.s.ClusterService   ] [oDFU6c3] new_master {oDFU6c3}{oDFU6c3UT6ORC2p0CKBeLA}{olaY-n5LTpCUpzrhU3joVw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-10-31T16:07:16,398][INFO ][o.e.h.n.Netty4HttpServerTransport] [oDFU6c3] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2017-10-31T16:07:16,399][INFO ][o.e.n.Node               ] [oDFU6c3] started
[2017-10-31T16:07:17,242][INFO ][o.e.g.GatewayService     ] [oDFU6c3] recovered [0] indices into cluster_state

errorがない場合は正常に動作します
新しい端末を開きcurlでアクセス
[root@localhost ~]# curl 'http://localhost:9200/?pretty' 
{
  "name" : "oDFU6c3",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "v2mGsAuuTsqIzzm8CZcW5w",
  "version" : {
    "number" : "5.6.3",
    "build_hash" : "1a2f265",
    "build_date" : "2017-10-06T20:33:39.012Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"
}

その他の構成
Elasticsearch ipアドレスの指定
esのプロファイルの編集
[testuser@localhost elasticsearch-5.6.3]$ vim ./config/elasticsearch.yml

networkを見つけたhost:1行、#番号を除去し、次のように変更します.
network.host: [_local_, 172.30.6.1]

172.30.6.1は指定されたipアドレスであり、複数であってもよい.
これでブラウザで開くことができます
http://172.30.6.1:9200/?pretty
発生する可能性のある問題
問題1
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

max_map_countの値は、1つのプロセスで最も使用可能なメモリマッピング領域(memory map areas)を指し、mallocを呼び出すとmmap/mprotectによって生成されます.
解決策:
rootユーザーに切り替えて構成/etc/sysctlを変更します.conf
su root
vim /etc/sysctl.conf

に参加
vm.max_map_count=655360

次に有効にします
sysctl -p

問題2
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

ファイルの記述が低すぎる
解決策:
rootユーザー変更/etc/security/limitsに切り替えます.conf
su root
vim /etc/security/limits.conf

に参加
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096 

問題3
supervisorを使用して起動すると、ログを表示しても次のエラーが表示されます.
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

解決策:
rootユーザーに切り替えてvim/etc/supervisordを変更します.d/elasticsearch.conf
[supervisord]
minfds=65536
minprocs=32768

[program:es]
process_name=%(program_name)s_%(process_num)02d
directory=/usr/local/elasticsearch-5.6.3/
command=/usr/local/elasticsearch-5.6.3/bin/elasticsearch
;autostart=true
autorestart=false
user=testuser
numprocs=1

テキストhttps://www.tech1024.cn/origi...