ElasticSearch5.6.3下載安裝步驟

一、ElasticSearch5.6.3下載安裝步驟

說明:ElasticSearch的運行不能用root執行,自己用useradd命令新建一個用戶如下所示:

sueradd chen
passwd chen 然後根據提示輸入密碼即可

下載地址:https://www.elastic.co/downloads/elasticsearch 下載最新的安裝包並解壓、然後執行、命令如下:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz

tar -zxvf elasticsearch-5.6.3
cd elasticsearch-5.6.3
./bin/elasticsearch

執行之前就得修改配置文件:vim config/elasticsearch.yml

vim config/elasticsearch.yml 

修改方法參考如下:

cluster.name: elk_test.cluster
node.name: node-01
node.master: true
node.data: true
network.host: 192.168.0.153
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.0.153","192.168.0.154","192.168.0.155"]
#discovery.zen.ping.multicast.enabled: true
discovery.zen.minimum_master_nodes: 2

http.cors.enabled: true
http.cors.allow-origin: "*"

解釋說明:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false 一看就知道是關於內用訪問的方面的配置

cluster.name 集羣名字,同一個集羣中使用相同名字,單機就隨意
node.name: node-01 節點名字
node.master: 是否爲集羣的master機器
node.data: true 是否作爲數據節點
network.host: 192.168.0.153 這個不用自然是配置ip地址的
http.port: 9200 端口號,不配置的話默認9200
discovery.zen.ping.unicast.hosts: [“192.168.0.153”,”192.168.0.154”,”192.168.0.155”] 這個就是配置集羣的時候要用的到了,[]中填上集羣中其他集羣的ip的地址,如果是master的話請把所有salve的機器地址填上
discovery.zen.minimum_master_nodes: 2 關於這個值配置多少合適的話大家去搜一下,自己權衡一下集羣,這裏我用了3臺機器模擬集羣,所以填上2。
http.cors.enabled: true 這個參數的設置和下面一個配置就關於ip的訪問策略了,如果你發現其他ip地址訪問不了就有可以這參數沒有配置
http.cors.allow-origin: “*”

如果你碰到錯誤不要慌下面有解決方法:
- 1、max file descriptor
[1]: max file descriptors [4096] 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]
解決方法,請用root權限修改,修改完記得重啓elasticsearch和使用配置參數在環境裏面生效(重新登錄用戶):(如果還有錯誤請把數字再設置大一點)

vi /etc/security/limits.conf 

*  soft  nofile  65536

*  hard  nofile  131072

*  soft  nproc  2048

*  hard  nproc 4096
2、max number of threads
max number of threads [1024] for user [user] is too low, increase to at least [2048]
解決方法: (* 表示對所有用戶有效)
vi /etc/security/limits.d/90-nproc.conf 
#修改內容如下
*  soft  nproc  1024

3、在elasticsearch.yml中配置bootstrap.system_call_filter爲false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

4、錯誤:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
臨時設置:sudo sysctl -w vm.max_map_count=262144
永久修改:
修改/etc/sysctl.conf 文件,添加 “vm.max_map_count”設置
並執行:sysctl -p

二、集羣安裝、
這裏使用三臺機器模擬ElasticSearch集羣,這三臺的ip地址是如下:

"192.168.0.153"
"192.168.0.154"
"192.168.0.155"

上面我已近在192.168.0.153機器安裝了好了ElasticSearch,剩下的就是分別按照上面的方法在154和155這兩臺機器上安裝好ElasticSearch,然後只需要把配置文件elasticsearch.yml略作修改即可,讀者自動對比上面

192.168.0.154的配置

cluster.name: elk_test.cluster
node.name: node-04

node.master: true
node.data: true

network.host: 0.0.0.0
http.port: 9200

discovery.zen.ping.unicast.hosts: ["192.168.0.153"]
#discovery.zen.ping.multicast.enabled: true

http.cors.enabled: true
http.cors.allow-origin: "*"

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

192.168.0.155的配置

cluster.name: elk_test.cluster
node.name: node-05

node.master: false
node.data: true

network.host: 0.0.0.0
http.port: 9200

discovery.zen.ping.unicast.hosts: ["192.168.0.153"]
#discovery.zen.ping.multicast.enabled: true

http.cors.enabled: true
http.cors.allow-origin: "*"

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

補充:修改的地方大家對比一下就很清楚了,如果配置更多臺機器,上面方法照搬即可。

三、head插件的安裝

說明:5.6版本好像不能再用/bin/plugin -install mobz/elasticsearch-head安裝了,步驟好像有點複雜,不過不打緊,按照下面安裝步驟即可:
- 1、下載head插件
在github上 https://github.com/mobz/elasticsearch-head/archive/master.zip下載插件,命令如下:

wget https://github.com/mobz/elasticsearch-head/archive/master.zip
unzip
cd elasticsearch-head-master
2、安裝node
於head插件本質上還是一個nodejs的工程,因此需要安裝node,使用npm來安裝依賴的包 可以去官網下載https://nodejs.org/en/download/安裝包安裝。
我投簡單是直接用yum命令安裝。
yum安裝node.js :參考地址:https://github.com/nodesource/distributions
centos6.x安裝
curl -sL -o /etc/yum.repos.d/khara-nodejs.repo https://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-6/khara-nodejs-epel-6.repo
yum install -y nodejs nodejs-npm
centos7.x安裝
curl -sL -o /etc/yum.repos.d/khara-nodejs.repo https://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-7/khara-nodejs-epel-7.repo
yum install -y nodejs nodejs-npm

源碼安裝方法如下:

yum -y install gcc make gcc-c++ openssl-devel wget
下載源碼及解壓:
wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
tar -zvxf node-v0.10.26.tar.gz
編譯及安裝:
cd node-v0.10.26
make && make install
驗證是否安裝配置成功:
node -v
3、安裝grunt
grunt是一個很方便的構建工具,可以進行打包壓縮、測試、執行等等的工作,5.6裏的head插件就是通過grunt啓動的。因此需要安裝一下grunt:
cd elasticsearch-head-master
npm install -g grunt-cli  //執行後會生成node_modules文件夾
npm install 

5.0以上,elasticsearch-head 不能放在elasticsearch的 plugins、modules 目錄下,否則elasticsearch啓動會報錯

修改vim Gruntfile.js文件:增加hostname屬性,設置爲*

connect: {
    server: {
        options: {
            port: 9100,
            hostname: '*',
            base: '.',
            keepalive: true
        }
    }
}

修改 vim _site/app.js 文件:修改head的連接地址:
this.base_uri = this.config.base_uri || this.prefs.get(“app-base_uri”) || “http://localhost:9200“;
修改成ElasticSearch的機器地址
this.base_uri = this.config.base_uri || this.prefs.get(“app-base_uri”) || “http://192.168.0.153:9200“;

修改完成你就可以啓動head插件了:在 elasticsearch-head-master下啓動服務

cd  elasticsearch-head-master
grunt server &  #後臺啓動

訪問地址:http://192.168.0.153:9100
如果你在瀏覽器中訪問不了http://192.168.0.153:9100/請檢查防火牆是否關閉。
下面看一我的集羣信息:
這裏寫圖片描述

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