這裏使用的java 是1.8.0_77的版本.使用的是rpm 安裝包的形式進行部署安裝 。java
配置環境變量node
[root@node1 ~]# cat .bash_profile
export JAVA_HOME=/usr/java/jdk1.8.0_77/ # JAVA_HOME變兩個路徑
export JAVA_BIN=/usr/java/jdk1.8.0_77/bin
export PATH=${JAVA_HOME}bin:$PATH
檢測java環境安裝是否正常linux
[root@node1 ~]# java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
[root@node1 local]# tar -zxvf elasticsearch-6.1.3.tar.gz
[root@node1 local]# ls
bin elasticsearch-6.1.3 elasticsearch-6.1.3.tar.gz etc games include lib lib64 libexec sbin share src
修改配置文件git
node1
[root@node1 local]# cd node1/config/
[root@node1 config]# cat elasticsearch.yml | grep -v "^#"
cluster.name: elasticsearch #集羣的名稱
node.name: node1 #節點的名稱
bootstrap.memory_lock: false #另外一種選擇是在Linux / Unix系統上使用mlockall或在Windows上使用 VirtualLock,以嘗試將進程地址空間鎖定到RAM中,防止任何Elasticsearch 內存被換出。
bootstrap.system_call_filter: false #爲禁用系統調用過濾器false
network.host: 133.1.11.39 #綁定到回送地址
http.port: 9200 #設置對外服務的http端口,默認爲9200
discovery.zen.ping.unicast.hosts: ["133.1.11.39","133.1.11.39:9202","133.1.11.39:9203"]
discovery.zen.minimum_master_nodes: 2
node2
cluster.name: elasticsearch
node.name: node2
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 133.1.11.39
http.port: 9202
discovery.zen.ping.unicast.hosts: ["133.1.11.39","133.1.11.39:9202","133.1.11.39:9203"]
discovery.zen.minimum_master_nodes: 2
node3
cluster.name: elasticsearch
node.name: node3
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 133.1.11.39
http.port: 9203
discovery.zen.ping.unicast.hosts: ["133.1.11.39","133.1.11.39:9202","133.1.11.39:9203"]
discovery.zen.minimum_master_nodes: 2
[root@node1 config]# vim jvm.options
-Xms512m
-Xmx512m
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vim /etc/security/limits.d/90-nproc.conf
* soft nproc 2048
vim /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p
[root@node1 ~]# groupadd es
[root@node1 ~]# useradd es -g es -p es
[root@node1 ~]# chown -R es:es /usr/local/node1
啓動elasticsearchgithub
[root@node1 bin]# ./elasticsearch -d
[root@node1 bin]# curl http://133.1.11.39:9200
{
"name" : "node1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "dJo2cKFfSO-M-qwMF9upjg",
"version" : {
"number" : "6.1.3",
"build_hash" : "af51318",
"build_date" : "2018-01-26T18:22:55.523Z",
"build_snapshot" : false,
"lucene_version" : "7.1.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
[root@node1 ~]# wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.5.0-linux-x64.tar.gz
[root@node1 ~]#tar -zxvf node-v4.5.0-linux-x64.tar.gz -C /usr/local
配置環境變量
export NODE_HOME=/usr/local/node-v4.5.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin/
export NODE_PATH=$NODE_HOME/lib/node_modules
[root@node1 ~]#source /etc/profile
[root@node1 ~]# npm install -g cnpm --registry=https://registry.npm.taobao.org
/usr/local/node-v4.5.0-linux-x64/bin/grunt -> /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt/bin/grunt
grunt@1.0.2 /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt
├── path-is-absolute@1.0.1
├── eventemitter2@0.4.14
├── grunt-known-options@1.1.0
├── rimraf@2.2.8
├── exit@0.1.2
├── iconv-lite@0.4.19
├── coffeescript@1.10.0
├── nopt@3.0.6 (abbrev@1.1.1)
├── glob@7.0.6 (inherits@2.0.3, fs.realpath@1.0.0, once@1.4.0, inflight@1.0.6)
├── findup-sync@0.3.0 (glob@5.0.15)
├── minimatch@3.0.4 (brace-expansion@1.1.11)
├── grunt-cli@1.2.0 (resolve@1.1.7)
├── js-yaml@3.5.5 (esprima@2.7.3, argparse@1.0.10)
├── grunt-legacy-util@1.0.0 (getobject@0.1.0, async@1.5.2, hooker@0.2.3, underscore.string@3.2.3, which@1.2.14, lodash@4.3.0)
├── grunt-legacy-log@1.0.1 (hooker@0.2.3, colors@1.1.2, underscore.string@3.3.4, grunt-legacy-log-utils@1.0.0, lodash@4.17.5)
└── dateformat@1.0.12 (get-stdin@4.0.1, meow@3.7.0)
[root@node1 ~]# npm install -g grunt-cli --registry=https://registry.npm.taobao.org --no-proxy
/usr/local/node-v4.5.0-linux-x64/bin/grunt -> /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt-cli/bin/grunt
grunt-cli@1.2.0 /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt-cli
├── grunt-known-options@1.1.0
├── nopt@3.0.6 (abbrev@1.1.1)
├── resolve@1.1.7
└── findup-sync@0.3.0 (glob@5.0.15
[root@node1 ~]# node -v
v4.5.0
[root@node1 ~]# npm -v
2.15.9
[root@node1 ~]# grunt -version
grunt-cli v1.2.0
[root@node1 ~]# wget https://github.com/mobz/elasticsearch-head/archive/master.zip
[root@node1 ~]# unzip master.zip -d /usr/local/
[root@node1 elasticsearch-head-master]# npm install -g grunt-cli
/usr/local/node-v4.5.0-linux-x64/bin/grunt -> /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt-cli/bin/grunt
grunt-cli@1.2.0 /usr/local/node-v4.5.0-linux-x64/lib/node_modules/grunt-cli
├── grunt-known-options@1.1.0
├── resolve@1.1.7
├── nopt@3.0.6 (abbrev@1.1.1)
└── findup-sync@0.3.0 (glob@5.0.15)
[root@node1 elasticsearch-head-master]# grunt -version
grunt-cli v1.2.0
[root@node1 elasticsearch-head-master]# npm install
中止ElasticSearch web
[root@node1 local]# jps
28516 Jps
12072 Elasticsearch
node1 上面配置
[root@node1 ]# vim config/elasticsearch.yml
# 增長新的參數,這樣head插件能夠訪問es。設置參數的時候:後面要有空格
http.cors.enabled: true
http.cors.allow-origin: "*"
[root@node1 elasticsearch-head-master]# vim Gruntfile.js
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
修改修改鏈接地址:_site/app.js
[root@node1 elasticsearch-head-master]# vim _site/app.js
_node_handler: function(data) {
if(data) {
// this.prefs.set("app-base_uri", this.cluster.base_uri);
this.prefs.set("app-base_uri" )|| "http://133.1.11.39:9200";
if(data.version && data.version.number)
this.cluster.setVersion(data.version.number);
[root@node1 bin]# ./elasticsearch -d #分別啓動3個節點
[root@node1 elasticsearch-head-master]# nohup grunt server &
若是出現集羣沒法連接
請注意刪除node1 下面/usr/local/node1/data 下面的目錄,否則形成數據不統一 不能呢連接head 插件