linux 安裝 ES 8.0 和 kibana 8.0 爬米共坑
下載
根據自己的硬體選擇合適的安裝包進行下載,我這邊是 linux x86 版本:
- Elasticsearch 8.0.0 :https://www.elastic.co/downloads/past-releases/elasticsearch-8-0-0
- Kibana 8.0.0:https://www.elastic.co/downloads/past-releases/kibana-8-0-0
Elasticsearch
解壓
將下載好的壓縮包進行解壓,可以的到資料夾
elasticsearch-8.0.0
修改 elasticsearch.yml
cluster.name: qjfy
node.name: node-1
bootstrap.memory_lock: true
network.host: localhost
http.port: 9400
配置
這裡就是一些常見的配置,建立非 root 使用者,修改目錄所有使用者,修改系統設定等等,這裡不贅述。
啟動
切換自己建立的非 root 使用者,我這裡是 es ,然後在 ES 主目錄下命令列啟動:
./bin/elasticsearch
稍等片刻,出現以下資訊,分別是:
-
8.x 自動開啟了安全設定,給出了 elastic 使用者的初始密碼,可以使用命令進行修改
bin/elasticsearch-reset-password -u elastic -i
-
另外給出了 HTTP CA 證書
-
如果需要安裝 kibana (下面的章節會講到),我們只需要啟動 kibana 點選給出的網址之後將這裡給出的一長串 token 拷貝進去即可,切記只有 30 分鐘有效,如果超時,執行命令重新生成即可,執行命令即可返回一長串新的 token
./bin/elasticsearch-create-enrollment-token -s kibana
-
如果想要其他節點加入叢集,按照以下的操作進行即可
Elasticsearch security features have been automatically configured! ✅ Authentication is enabled and cluster connections are encrypted. ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`): OxhN+dqEpl+MR_UaVUgV ℹ️ HTTP CA certificate SHA-256 fingerprint: d5f97e829d095c89a8eeb03df6b17792a9e073e5a85448258697b647da7a752b ℹ️ Configure Kibana to use this cluster: • Run Kibana and click the configuration link in the terminal when Kibana starts. • Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes): eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxMjcuMC4wLjE6OTIwMCIsIls6OjFdOjkyMDAiXSwiZmdyIjoiZDVmOTdlODI5ZDA5NWM4OWE4ZWViMDNkZjZiMTc3OTJhOWUwNzNlNWE4NTQ0ODI1ODY5N2I2NDdkYTdhNzUyYiIsImtleSI6IjJSZ1Z5SUVCVkFIZWZJc3JCZXd2OmQ1MUtlN0ZpUnRLYk56SU9Dd2lURGcifQ== ℹ️ Configure other nodes to join this cluster: • On this node: ⁃ Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`. ⁃ Uncomment the transport.host setting at the end of config/elasticsearch.yml. ⁃ Restart Elasticsearch. • On other nodes: ⁃ Start Elasticsearch with `bin/elasticsearch --enrollment-token <token>`, using the enrollment token that you generated.
回看 elasticsearch.yml
我們開啟一個新的終端,再看配置檔案 elasticsearch.yml (如下所示),可以發現上面的部分是我們自己配置的內容,下面的部分系統自動給我們寫入了一些 “SECURITY AUTO CONFIGURATION” 配置,這些內容就是系統自動預設為我們開啟了 HTTP API 客戶端連線開啟加密,叢集間加密傳輸和身份驗證、自動加入叢集等配置。這些在以前都是需要手動配置的,現在自動生成倒也方便。
cluster.name: qjfy
node.name: node-1
bootstrap.memory_lock: true
network.host: localhost
http.port: 9400
#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically
# generated to configure Elasticsearch security features on 04-07-2022 07:19:54
#
# --------------------------------------------------------------------------------
# Enable security features
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12
# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["node-1"]
#----------------------- END SECURITY AUTO CONFIGURATION -------------------------
瀏覽器檢視
在瀏覽器中輸入以下網址,並且將賬號和密碼輸入即可看到成功部署的介面:
https://localhost:9400
Kibana
解壓
將下載好的壓縮包進行解壓,可以的到資料夾
kibana-8.0.0
修改 kibana.yml
server.port: 5601
server.host: "localhost"
elasticsearch.hosts: ["http://localhost:9400"]
配置 kibana
這裡也是常見的建立非 root 使用者、修改目錄所屬使用者等操作,不做贅述。
啟動
這裡如果我們直接啟動 kibana ,會爆錯(如下),因為 kibana 預設是在能開啟瀏覽器的作業系統上執行的,linux 一般沒有瀏覽器無法進行到這一步,所以沒有正確的許可權去安全訪問上面已經有了安全配置的 elasticsearch :
[ERROR][elasticsearch-service] Unable to retrieve version information from Elasticsearch nodes.
這是一個大坑,我在這裡耗了兩天的時間,因為現在網上的文件都是說因為 elasticsearch.yml 的安全配置關掉,這簡直就是沒腦子的人才想的出來的辦法,這麼做的話雖然能啟動 kibana ,但是 elasticsearch 豈不是在公網果奔了,肯定不是這麼改的,我在網上找了各種辦法,最後在這裡找到了解決辦法,詳情看網頁:
https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-stack-security.html#stack-start-with-security
我們在沒有瀏覽器的 linux 伺服器上,想要 kibana 能連線到 elasticsearch ,要先通過以下命令列,將上面生成的 enrollment token 傳入 kibana 中,如果超時重新生成一個即可:
bin/kibana-setup --enrollment-token eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxMjcuMC4wLjE6OTIwMCIsIls6OjFdOjkyMDAiXSwiZmdyIjoiZDVmOTdlODI5ZDA5NWM4OWE4ZWViMDNkZjZiMTc3OTJhOWUwNzNlNWE4NTQ0ODI1ODY5N2I2NDdkYTdhNzUyYiIsImtleSI6IjJSZ1Z5SUVCVkFIZWZJc3JCZXd2OmQ1MUtlN0ZpUnRLYk56SU9Dd2lURGcifQ==
然後終端會列印如下資訊,表示 kibana 連線 elasticsearch 安全配置成功:
Kibana configured successfully!
To start Kibana run:
bin/kibana
這時候我們正常執行 kibana 即可啟動,然後在瀏覽器中輸入網址 http://localhost:5601 ,還有 elastic 賬戶和對應的密碼即可正常進入 kibana 介面。
回看 kibana.yml
和 elasticsearch.yml 一樣,後半部分都是系統自動新增的安全配置
- linux 安裝 ES 8.0 和 kibana 8.0 爬米共坑
- ES 8.0 及其生態配置過程一條龍服務
- 2022 年中紀
- leetcode 1048. Longest String Chain(python)
- leetcode 1354. Construct Target Array With Multiple Sums(python)
- leetcode 2311. Longest Binary Subsequence Less Than or Equal to K(python)
- leetcode 2304. Minimum Path Cost in a Grid(python)
- leetcode 2303. Calculate Amount Paid in Taxes(python)
- 帶你輕鬆入門 Bert
- leetcode 1332. Remove Palindromic Subsequences(python)
- leetcode 3. Longest Substring Without Repeating Characters (python)
- leetcode 2296. Design a Text Editor (python)
- leetcode 2293. Min Max Game(python)
- leetcode 1584. Min Cost to Connect All Points(python)
- leetcode 318. Maximum Product of Word Lengths(python)
- 沙灘 美女才是夏天的正確開啟方式
- leetcode 2275. Largest Combination With Bitwise AND Greater Than Zero (python)
- leetcode 2258. Escape the Spreading Fire(python)
- leetcode 2257. Count Unguarded Cells in the Grid(python)
- leetcode 2273. Find Resultant Array After Removing Anagrams(python)