elasticsearch 安裝和安裝plugin

  • 1122
  • 0

這邊有他的官網, 有心的朋友這邊自己參考囉.
https://www.elastic.co/

這邊簡單紀錄一下安裝的過程.
選擇的版本 6.5.3
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-5-3

 1. 下載

$ curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.3.tar.gz
$ tar xvf elasticsearch-6.5.3.tar.gz

2. 設定JAVA_OPS , 請自己斟酌調整自己需要的.

$ ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch 
$ ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch 

3. 設定proxy, 請自己斟酌調整自己需要的.

$ sudo ES_JAVA_OPTS="-Dhttp.proxyHost=host_name -Dhttp.proxyPort=port_number -Dhttps.proxyHost=host_name -Dhttps.proxyPort=https_port_number" bin/elasticsearch-plugin install analysis-icu

4. 設定檔

$ vim ${ES_HOME}\config\elasticsearch.yml

-------------------
action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*
network.host: 0.0.0.0
xpack.security.enabled: true

這邊是我自己用的設定. 

5. 安裝plugin, 這邊用的是atlassian的security 套件 buckler.
有興趣的可以自行參考這篇.

$ cd ${ES_HOME}/bin
// elasticsearch-plugin install -b ${URL}
$ ./elasticsearch-plugin install -b https://packages.atlassian.com/maven/com/atlassian/elasticsearch/buckler-plugin/2.0.1/buckler-plugin-2.0.1-6.5.3.zip?_ga=2.214153363.509132461.1559635773-1426541265.1559635773

6. 手動建立資料夾 buckler 在 elasticsearch/config/ 中.

7. 手動建置設定檔

$ vim ${ES_HOME}/config/buckler.yml


auth.basic.http.enabled: true
auth.basic.username: <username>
auth.basic.password: <password>

8. 安裝成service

$ sudo vim /usr/lib/systemd/systen/elasticsearch.service
    
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target

[Service]
RuntimeDirectory=elasticsearch
PrivateTmp=true
Environment=ES_HOME=/usr/share/elasticsearch
Environment=ES_PATH_CONF=${path.conf}
Environment=PID_DIR=/var/run/elasticsearch
EnvironmentFile=-${path.env}

WorkingDirectory=/usr/share/elasticsearch

User=elasticsearch
Group=elasticsearch

ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet

# StandardOutput is configured to redirect to journalctl since
# some error messages may be logged in standard output before
# elasticsearch logging system is initialized. Elasticsearch
# stores its logs in /var/log/elasticsearch and does not use
# journalctl by default. If you also want to enable journalctl
# logging, you can simply remove the "quiet" option from ExecStart.
StandardOutput=journal
StandardError=inherit

# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65535

# Specifies the maximum number of processes
LimitNPROC=4096

# Specifies the maximum size of virtual memory
LimitAS=infinity

# Specifies the maximum file size
LimitFSIZE=infinity

# Disable timeout logic and wait until process is stopped
TimeoutStopSec=0

# SIGTERM signal is used to stop the Java process
KillSignal=SIGTERM

# Send the signal only to the JVM rather than its control group
KillMode=process

# Java process is never killed
SendSIGKILL=no

# When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

# Built for ${project.name}-${project.version} (${project.name})

Daemon-reload

$ sudo systemctl daemon-reload
$ sudo systemctl list-units|grep elastic
 elasticsearch.mount
 elasticsearch.service
$ sudo systemctl enable elasticsearch
$ sudo systemctl start elasticsearch

啟用完成.