SQL數據同步到ELK(二)- Elastic Search 安裝

開篇廢話

沒錯,前面扯了一堆SQL SERVER,其實我連Elastic Search根本沒動手玩過(是否是與時代有點脫節了?),那今天我就準備嘗試安裝一個ELK的簡單集羣出來(這個集羣是使用個人小米筆記本建立了兩個虛擬機,虛擬出來的一個集羣,沒錢買阿里雲)html

虛擬機的操做系統實CentOS 7 64位,不一樣的Linux版本可能略有差別~node

直接安裝Elastic Search

安裝Master Node

本文也是參考官網文檔進行安裝,你們能夠直接看官網文檔,通常來講,比較新一些。linux

官方文檔:https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-install.htmlgit

1)找個合適的文件夾下載安裝包:github

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-linux-x86_64.tar.gz

友情提示,若是下載速度比較慢,能夠拿迅雷這類軟件下載好,上傳到服務器,迅雷這類軟件在下載這種熱門資源的時候,仍是有速度上的提高的。npm

2)解壓下載下來的文件bootstrap

本文的版本號均爲7.2.0,安裝不一樣的版本時,靈活應變就行。瀏覽器

tar -xvf elasticsearch-7.2.0-linux-x86_64.tar.gz

3)修改配置文件服務器

進入解壓後的elasticsearch-7.2.0 文件夾中的config文件夾,並修改elasticsearch.yml 文件中的配置:cors

cluster.name: jax-elk-group1
node.name: master
node.master: true
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: ["master"]

此時咱們在elasticsearch-7.2.0文件夾下執行

./bin/elasticsearch

因爲我虛擬機內存不夠大的緣由,他會拋個異常:

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

對於第一個報錯ELK官網是這麼解釋的:

是因爲Elasticsearch須要使用大量的文件描述符或文件句柄,用完文件描述符多是災難性的,也有可能致使數據丟失,須要確保將運行Elasticsearch的用戶能打開文件描述符數量的限制增長到65,536或更高。

官網連接在這裏:https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html

官網解決方案的連接:https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html#limits.conf

然而,我照官網作了以後,並無論什麼用,最終找到了一篇文章:

http://www.kxtry.com/archives/1635

首先第一個問題,須要修改文件etc/security/limits.conf中的一些配置:

執行命令:

sudo vi /etc/security/limits.conf

像文件最後添加內容:

* soft nofile 65536

* hard nofile 131072 (貌似只添加這句就行)

* soft nproc 2048

* hard nproc 4096

而後退出當前的終端從新鏈接進入,這步很是重要,不從新進不起做用的~

第二個問題須要修改/etc/sysctl.conf中的一些配置:

執行命令:

sudo vi /etc/sysctl.conf

向文件最後添加記錄:

vm.max_map_count=655360

保存並退出後執行命令:

sudo sysctl -p

這步跟上面退出終端從新進入同樣重要,不執行這個配置不會生效的。

執行完這兩步,而後從新執行就能夠啓動成功了~

./bin/elasticsearch

能夠在新開一個終端執行下面命令來驗證安裝的成果:

curl http://服務器ip:9200/

此時若是安裝的沒問題,會打印相似下面的內容:

{
  "name" : "master",
  "cluster_name" : "jax-elk-group1",
  "cluster_uuid" : "NtmpxdwtRQOiT8sv8bJrvg",
  "version" : {
    "number" : "7.2.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "508c38a",
    "build_date" : "2019-06-20T15:54:18.811730Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

若是你想在後臺啓動elastic search進程,那麼能夠在啓動時加個 -d參數:

./bin/elasticsearch –d

到此爲止,咱們的Master節點(主節點)就安裝完畢了

安裝Slave node

接下來,咱們再次來安裝一臺Slave節點(從節點),而且跟咱們當前的Master節點組成一個Elastic search集羣。

Slave節點的大部分步驟和Master節點是同樣的,惟一的區別在於elasticsearch.yml 文件中的配置。

cluster.name: jax-elk-group1
node.name: node-01
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*" cluster.initial_master_nodes: ["master"]
discovery.zen.ping.unicast.hosts: ["192.168.154.135"]

配置的時候,須要注意如下幾點:

  • cluster.name 必定要跟Master節點配置的同樣
  • node.name 是一個惟一標識,必定不要跟Master節點配置的同樣,各個不一樣的Salve也不要重複
  • discovery.zen.ping.unicast.hosts中的IP列表是集羣中其餘節點的IP地址列表

到這裏爲止,咱們整個集羣都安裝完成了

使用ElasticSearch-Head可視化界面

默認咱們只能經過命令行或者Http的方式來操做Elastic Search,elasticsearch-head 則是一款開源的ElasticSearch管理界面,它的項目主頁爲:https://github.com/mobz/elasticsearch-head

使用起來也很是簡單:

  1. 下載他的源碼,不論是使用Clone仍是直接使用Github的download zip功能
  2. 執行命令:npm install 還原npm依賴,(依賴於Node.js和npm)
  3. 還原完成後,執行npm start命令啓動項目
  4. 瀏覽器中打開http://localhost:9100/
  5. 修改瀏覽器中最上方的鏈接地址(默認是http://localhost:9200

image

該項目能夠在任意一臺能訪問到ElasticSearch的機器上安裝,裝在你的本地機器也能夠哦~

ELK的安裝就介紹到這裏嘍~更多的ELK的知識,還須要多多探索哦~

相關文章
相關標籤/搜索