elasticsearch 6.x (二) linux部署 kibana x-pack 安装
大家好,我是烤鴨:? ?
環境:
? ?? ? ?linux Cent OS 7.3
????????elasticsearch-6.2.4
1. 下載elasticsearch?
????https://www.elastic.co/downloads/elasticsearch
上面的網址直接下載的話,實在太慢了。官方還提供了另一種方式。
https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-targz.html?
如圖。
2.? 啟動及常見問題
? ? 異常1:org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root.????
????? ?2.1? 創建es用戶和用戶組es,指定密碼es,賦予權限。(/opt/elasticsearch/為es安裝目錄)
groupadd es useradd es -g es -p es chown -R es.es /opt/elasticsearch/????? ? 2.2? 切換es用戶訪問成功
su - es ./elasticsearch-6.2.4/bin/elasticsearch? ? ? ? ?上一張啟動成功的圖:
?????????
?????????2.3? 常見異常:
?異常2 :?bound or publishing to a non-loopback address, enforcing bootstrap checks
????????????????ERROR: [2] bootstrap checks failed
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]? ???
????? ? ??2.4???修改? ?limits.conf
vim /etc/security/limits.conf????????? 最后一行加:
* soft nofile 65536 * hard nofile 131072????????此文件修改后需要重新登錄用戶,才會生效。
? ? ? ? 2.5? 編輯權限
vim /etc/security/limits.d/xx-nproc.conf最下面加上兩行:
* soft nproc 2048 * soft nproc 4096????? ?2.6? 修改配置文件
vi /etc/sysctl.conf sysctl -p如圖:
????????
????????2.7? 切換es用戶,重新啟動
su - es cd /opt/elasticsearch/elasticsearch-6.2.4/bin ./elasticsearch????? ? 后臺啟動:
./elasticsearch -d????????成功如圖:? ? ? ?
????????
????????2.8? ?測試訪問
????? ? 阿里云的服務器需要在安全組配置,端口開放才可以訪問。
????? ?
????? ? 2.9? yml配置
????? ? 可以看出來,上面的啟動端口不是8200和8300,分享一下yml配置說明。? ??
# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # cluster.name: yxd-es # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: node-1 # # 設置充當master節點,默認為true # node.master: true?? # # 設置不充當data節點,默認為true # node.data: true # # Add custom attributes to the node: # #node.attr.rack: r1 # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # path.data: ../data????#數據目錄 # # Path to log files: # path.logs: ../logs????#日志目錄 # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #設置為true來鎖住內存。因為內存交換到磁盤對服務器性能來說是致命的,當jvm開始swapping時es的效率會降低,所以要保證它不swap #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # network.host: 192.168.1.1????(服務器內網ip) network.bind_host: 192.168.1.1 (服務器內網ip) # # Set a custom port for HTTP: # http.port: 9303????#設置對外服務的http端口,默認為9200 transport.tcp.port: 9393???# 設置節點間交互的tcp端口,默認是9300???# transport.publish_host: 127.0.0.1?????# 發布集群中要連接到的節點的主機地址。默認為transport.host(如果設置)或network.publish_host# transport.bind_host: 127.0.0.1 #將傳輸服務綁定到的主機地址。默認為transport.host(如果設置)或network.bind_host # transport.publish_port: 9300????# 與此節點通信時,群集中其他節點應使用的端口。當群集節點位于代理或防火墻之后并且transport.tcp.port不能從外部直接尋址時很有用。默認為通過分配的實際端口 transport.tcp.port# # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # #這提供了自動集群體驗,而無需進行任何配置。數組設置或逗號分隔的設置。每個值的形式應該是host:port或host?? #(如果沒有設置,port默認設置會transport.profiles.default.port 回落到transport.tcp.port)。?? #請注意,IPv6主機必須放在括號內。默認為127.0.0.1, [::1]?? discovery.zen.ping.unicast.hosts: ["內網ip:9393"] # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # #discovery.zen.minimum_master_nodes: # # For more information, consult the zen discovery module documentation. # # ---------------------------------- Gateway ----------------------------------- # # Block initial recovery after a full cluster restart until N nodes are started: # #gateway.recover_after_nodes: 3 # # For more information, consult the gateway module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true? ? 2.10? 調整jvm內存
vim /opt/elasticsearch/elasticsearch-6.2.4/config/jvm.options????#默認是1g官方建議對jvm進行一些修改,不然很容易出現OOM,參考官網改參數配置最好不要超過內存的50%? ??
-Xms1g -Xmx1g??? ? 2.11? 更多關于多節點配置yml
????? ? 請參考:????https://blog.csdn.net/qq_34021712/article/details/79342668
?????????配置文件中給出了三種配置高性能集群拓撲結構的模式,如下:?
????????????# 1. 如果你想讓節點從不選舉為主節點,只用來存儲數據,可作為數據節點?
????????????#?node.master: true?
????????????#?node.data: false
????????????#?node.ingest: true
????????????# 2. 如果想讓節點成為主節點,且不存儲任何數據,并保有空閑資源,可作為協調器?
????????????#?node.master:true?
????????????#?node.data:false?
????????????#?node.ingest:false?
????????????# 3. 如果想讓節點既不稱為主節點,又不成為數據節點,那么可將他作為攝取節點,從節點中獲取數據,生成搜索結果等?
????????????#?node.master: false?
????????????#?node.data: false?
????????????#?node.ingest: true
????????????# 4. 僅作為協調器?
????????????#?node.master: false?
????????????#?node.data: false
????????????#?node.ingest: false
3.? ? x-pack安裝
????? 官方安裝網址:???
????????https://www.elastic.co/cn/downloads/x-pack
????? ? 就按照官方的來就行。
bin/elasticsearch-plugin install x-pack????????
????? ? 3.1? 啟動訪問,會提示輸入用戶名密碼就成功了。
./bin/elasticsearch????????
????? ? 3.2? ? 初始化x-pack用戶名,密碼
bin/x-pack/setup-passwords auto????????用戶名? ?和? 密碼 如圖:
????????
4.? ? kibana和x-pack安裝
????????官方安裝網址:? ?? ?https://www.elastic.co/cn/downloads/kibana
????? ? 4.1? ? wget方式安裝
?????????4.2? ? 修改配置文件/config/kibana.xml
elasticsearch.url: "http://xxxxx:9303"????????#es的ipelasticsearch.username: "elastic"elasticsearch.password: "changme"server.host: "127.0.0.1"??#kibana的啟動ip??server.port: 9399????#kibana的啟動端口????? ? 4.3? ?啟動(9399端口)
./bin/kibana? ?????
????? ? 4.4? ?訪問,用戶名,密碼就是剛才elastic的用戶名和密碼
????? ? 首頁:
????? ? 4.5? kibana的x-pack安裝
cd /opt/elasticsearch/kibana/kibana-6.2.4-linux-x86_64 bin/kibana-plugin install x-pack????????4.3? ?帶x-pack啟動
????????
????????可以看到比剛才多了monitoring選項,可以檢測es的節點等情況。
????????過期時間是一個月以后。快要過期的話,就再去注冊x-pack,每次注冊可以使用一年。
????? ? 注冊網址:????https://register.elastic.co/xpack_register
ps:
1.? ? 關于集群多節點配置x-pack。每個節點都需要安裝x-pack。但是kibana只需要安裝一次。
2.? ? x-pack的密碼修改。(需要指定content-type)
? ? 如果忘記elastic用戶的密碼,可以再創建一個用戶超級角色的用戶(用戶admin,密碼admin1)
bin/x-pack/users useradd admin -p admin1 -r superuser? ? 上面的請求改一下:
curl -H "Content-Type: application/json" -XPUT -u admin -p '內網ip:9303/_xpack/security/user/elastic/_password' -d '{ "password" : "密碼"}'會彈出讓你輸入密碼:輸入admin1就可以完成密碼修改了。
更多關于elasticsearch 6.x內容:
? ? 1.? ?elasticsearch 6.x 部署 windows入門(一) spingboot連接
????????
總結
以上是生活随笔為你收集整理的elasticsearch 6.x (二) linux部署 kibana x-pack 安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 1、Canvas的基本用法
- 下一篇: 安装 openSUSE Leap 42.