安裝ElasticSearch-RPM

Architecture: x86-64

內存: 2GB

Operating System: Alibaba Cloud Linux 3 (Soaring Falcon)

Kernel: Linux 5.10.134-15.al8.x86_64

elasticsearch-8.9.0

--

 

序章

elastic.io 官網:elasticsearch

https://www.elastic.co/cn/elasticsearch

下載頁面:

https://www.elastic.co/downloads/elasticsearch

240316 最新版本:8.12.2

 

官文:

Elastic Installation and Upgrade Guide

https://www.elastic.co/guide/en/elastic-stack/current/index.html

Installing the Elastic Stack

https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html

Network requirements:一些端口,確保不要被佔用。

Default port    Component
3002

Enterprise Search

5044

Elastic Agent → Logstash
Beats → Logstash

5601

Kibana
Elastic Agent → Fleet
Fleet Server → Fleet

8220

Elastic Agent → Fleet Server
APM Server

9200-9300

Elasticsearch REST API

9300-9400

Elasticsearch node transport and communication

9600-9700

Logstash REST API

 

Install Elasticsearch with RPM
https://www.elastic.co/guide/en/elasticsearch/reference/8.12/rpm.html

該文檔的目錄:

Import the Elasticsearch GPG Key
Installing from the RPM repository
Download and install the RPM manually
Start Elasticsearch with security enabled
    Reconfigure a node to join an existing cluster
Enable automatic creation of system indices
Running Elasticsearch with systemd
Check that Elasticsearch is running
Configuring Elasticsearch
Connect clients to Elasticsearch
Directory layout of RPM
    Security certificates and keys
Next steps

其中,Download and install the RPM manually 的命令如下:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.12.2-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.12.2-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-8.12.2-x86_64.rpm.sha512 
sudo rpm --install elasticsearch-8.12.2-x86_64.rpm

更多信息請查看官文。

 

注,wget 的速度不是太快,下載 500MB+ 的 RPM 需要 近半小時(資訊後發現,可以通過 阿里雲鏡像下載,超快)。

 

注,Installing from the RPM repository 的方式 未嘗試。

 

阿里雲鏡像:elasticsearch

爲了更快的下載速度。

網址:

https://developer.aliyun.com/mirror/elasticstack/

下載地址:https://mirrors.aliyun.com/elasticstack/

 

安裝步驟

注意,安裝前確保主機有足夠的內存,至少2GB

 

安裝步驟很簡單🀄

 

說明,安裝全程使用 root 賬號——所以,命令沒有使用 sudo

說明,啓動 ElasticSearch 使用的是其 自帶的 JDK

 

下載

進入 阿里雲的 elasticsearch 鏡像下載地址:

https://mirrors.aliyun.com/elasticstack/

選擇需要安裝的版本:elasticsearch-8.9.0-x86_64.rpm

複製 該 rpm文件的地址:

https://mirrors.aliyun.com/elasticstack/yum/elastic-8.x/8.9.0/elasticsearch-8.9.0-x86_64.rpm

登錄 ECS,使用 wget 命令下載:速度 十幾MBPS,快太多了。

下載完畢:

-rw-r--r-- 1 root root 605947433 Jul 25  2023 elasticsearch-8.9.0-x86_64.rpm

 

安裝&啓動

使用命令:

# rpm --install elasticsearch-8.9.0-x86_64.rpm

安裝完畢,顯示如下信息:

此時,安裝成功,不過,服務還沒有啓動。ben發佈於博客園

 

注意,上面給 內置賬號 elastic(默認) 生成了密碼:

The generated password for the elastic built-in superuser is : RF+C=orFFKtC49rHeNWn

下面 測試時會用到。

 

還需執行(官文還要加 sudo):

systemctl daemon-reload
systemctl enable elasticsearch.service

啓動、停止 ES 服務:

systemctl start elasticsearch.service
systemctl stop elasticsearch.service

 

注意,啓動前,檢查主機的 內存(memory) 夠不夠!(free 命令

free 是 1166080(1.1GB),夠了。

ben發佈於博客園

啓動 ES 服務:

# sudo systemctl start elasticsearch.service

啓動後,使用 ps 命令檢查 服務是否啓動:

# ps -ef | grep elas

可以看到 3個 Java進程:

文字版:

/usr/share/elasticsearch/jdk/bin/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=/usr/share/elasticsearch/bin/elasticsearch -Dcli.libs=lib/tools/server-cli -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/etc/elasticsearch -Des.distribution.type=rpm -cp /usr/share/elasticsearch/lib/*:/usr/share/elasticsearch/lib/cli-launcher/* org.elasticsearch.launcher.CliToolLauncher -p /var/run/elasticsearch/elasticsearch.pid --quiet

 

/usr/share/elasticsearch/jdk/bin/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -Djava.security.manager=allow -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j2.formatMsgNoLookups=true -Djava.locale.providers=SPI,COMPAT --add-opens=java.base/java.io=org.elasticsearch.preallocate -XX:+UseG1GC -Djava.io.tmpdir=/tmp/elasticsearch-8240227414755309209 --add-modules=jdk.incubator.vector -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError -XX:HeapDumpPath=/var/lib/elasticsearch -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,level,pid,tags:filecount=32,filesize=64m -Xms943m -Xmx943m -XX:MaxDirectMemorySize=494927872 -XX:G1HeapRegionSize=4m -XX:InitiatingHeapOccupancyPercent=30 -XX:G1ReservePercent=15 -Des.distribution.type=rpm --module-path /usr/share/elasticsearch/lib --add-modules=jdk.net --add-modules=org.elasticsearch.preallocate -m org.elasticsearch.server/org.elasticsearch.bootstrap.Elasticsearch

 

/usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

說明,這裏的 java 命令是 elasticsearch 自帶的。

說明,第二個進程 設置了 943MB 的內存。

 

啓動後,檢查內存:大爲減少!

top命令查看:

 

測試

找到 上面 安裝過程中產生的密碼,執行 官方文檔 下面的命令 即可:

curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200 

$ELASTIC_PASSWORD 改爲 RF+C=orFFKtC49rHeNWn

執行後返回:

說明,一定要認真看 官方文檔。

 

進一步學習

官文:Quick start

https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started.html

發佈博文時是 8.12 的。

 

其它

查看 rpm 安裝後的位置

執行命令:

# rpm -qpl elasticsearch-8.9.0-x86_64.rpm | more

 

---END---

ben發佈於博客園

本文鏈接:

https://www.cnblogs.com/luo630/p/18077518

ben發佈於博客園

參考資料

1、

 

ben發佈於博客園

ben發佈於博客園

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章