一、部署JDK
[root@node1 application]# tar -xf jdk-8u231-linux-x64.tar.gz -C /usr/local/
[root@node1 application]# mv /usr/local/jdk-8u231-linux-x64 /usr/local/jdk/
[root@node1 application]# vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
[root@node1 application]# source /etc/profile.d/java.sh
[root@node1 application]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
二、源码安装ES
[root@node1 application]# tar -xf elasticsearch-6.6.2.tar.gz -C /usr/local/
[root@node1 application]# cd /usr/local/elasticsearch-6.6.2/
[root@node1 elasticsearch-6.6.2]# ls
bin config lib LICENSE.txt logs modules NOTICE.txt plugins README.textile
[root@node1 elasticsearch-6.6.2]# cd config/
[root@node1 config]# cp elasticsearch.yml elasticsearch.yml.bak
[root@node1 config]#
[root@node1 config]# vim elasticsearch.yml
cluster.name: elasticsearch //修改集群名称
node.name: node1 //修改节点名称
network.host: 0.0.0.0 //添加监听的网络地址
http.port: 9200 //监听的端口号;9200为接受用户查询的端口;
9300为集群内部节点各通信的端口;
discovery.zen.ping.unicast.hosts: ["192.168.172.128", "192.168.172.129"]
//申明集群内部的默认节点主机地址
bootstrap.memory_lock: false //禁止使用内存锁
bootstrap.system_call_filter: false
http.cors.enabled: true //允许跨域
http.cors.allow-origin: "*"
xpack.ml.enabled: false
[root@node1 config]# vim /usr/local/elasticsearch-6.6.2/config/jvm.options
-Xms256m
-Xmx256m //调整jvm所使用的的堆大小
[root@node1 config]# groupadd -r elasticsearch
[root@node1 config]# useradd elasticsearch -g elasticsearch //添加elasticsearch用户
[root@node1 config]# vim /etc/sysctl.conf
vm.max_map_count=655360 //修改内核参数,调整用户所拥有的内存权限大小
[root@node1 config]# vim /etc/security/limits.conf
* soft nproc 4096
* hard nproc 4096
* soft nofile 65536
* hard nofile 65536
//修改进程所能打开的文件数大小和最大线程个数
[root@node1 ~]# chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-6.6.2/
[root@node1 ~]# su - elasticsearch
Last login: Tue Nov 26 20:35:34 CST 2019 on pts/0
[elasticsearch@node1 ~]$ /usr/local/elasticsearch-6.6.2/bin/elasticsearch //启动ES
[root@node1 ~]# ss -tunl
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 *:68 *:*
tcp LISTEN 0 128 *:22 *:*
tcp LISTEN 0 100 127.0.0.1:25 *:*
tcp LISTEN 0 128 :::9200 :::*
tcp LISTEN 0 128 :::9300 :::*
tcp LISTEN 0 128 :::22 :::*
tcp LISTEN 0 100 ::1:25 :::*
[root@node1 ~]# curl -XGET 'http://localhost:9200/'
{
"name" : "node1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "kmpQLICnQpKZRut85oGp-w",
"version" : {
"number" : "6.6.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "3bd3e59",
"build_date" : "2019-03-06T15:16:26.864148Z",
"build_snapshot" : false,
"lucene_version" : "7.6.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
//安装成功
[root@node1 ~]# curl -XGET 'http://localhost:9200/_cluster/health?pretty' //查看集群状态
{
"cluster_name" : "my-elk",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 2,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
[root@node1 ~]# curl -XGET 'http://localhost:9200/_cluster/state/nodes?pretty'
//查看集群节点信息
{
"cluster_name" : "my-elk",
"compressed_size_in_bytes" : 11029,
"cluster_uuid" : "kmpQLICnQpKZRut85oGp-w",
"nodes" : {
"xHym7xM8QqipqXWsok4zvw" : {
"name" : "node2",
"ephemeral_id" : "RHwfK8rOQvGQVwjRxMLoXA",
"transport_address" : "192.168.172.129:9300",
"attributes" : {
"xpack.installed" : "true"
}
},
"dvyUVXgIQfa07BkvZW0BGg" : {
"name" : "node1",
"ephemeral_id" : "sIcv6sU2RUe0pmYMeXcbyg",
"transport_address" : "192.168.172.128:9300",
"attributes" : {
"xpack.installed" : "true"
}
}
}
}
[root@node1 ~]# curl -XGET 'http://localhost:9200/_cat/nodes?v' //查看节点详细信息
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.172.129 36 66 0 0.05 0.18 0.18 mdi - node2
192.168.172.128 46 40 0 0.09 0.17 0.13 mdi * node1
三、安装HEAD插件
[root@node2 ~]# wget https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz
--2019-12-01 18:00:24-- https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz
Resolving nodejs.org (nodejs.org)... 104.20.22.46, 104.20.23.46, 2606:4700:10::6814:162e, ...
Connecting to nodejs.org (nodejs.org)|104.20.22.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9366128 (8.9M) [application/x-xz]
Saving to: ‘node-v6.10.2-linux-x64.tar.xz’
100%[=======================================================================>] 9,366,128 276KB/s in 26s
2019-12-01 18:00:52 (348 KB/s) - ‘node-v6.10.2-linux-x64.tar.xz’ saved [9366128/9366128]
[root@node2 ~]# xz -d node-v6.10.2-linux-x64.tar.xz
[root@node2 ~]# tar xf node-v6.10.2-linux-x64.tar
[root@node2 ~]# mv node-v6.10.2-linux-x64.tar /usr/local/node
[root@node2 ~]# vim /etc/profile
export NODE_HOME=/usr/local/node
export PATH=$PATH:$NODE_HOME/bin
[root@node2 ~]# source /etc/profile
[root@node2 ~]# node -v
v6.10.2
[root@node2 ~]# npm -v
3.10.10
[root@node2 ~]# git clone https://github.com/mobz/elasticsearch-head.git
Cloning into 'elasticsearch-head'...
remote: Enumerating objects: 77, done.
remote: Counting objects: 100% (77/77), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 4337 (delta 38), reused 45 (delta 17), pack-reused 4260
Receiving objects: 100% (4337/4337), 2.51 MiB | 73.00 KiB/s, done.
Resolving deltas: 100% (2411/2411), done.
[root@node2 ~]# cd elasticsearch-head/
[root@node2 elasticsearch-head]# npm install -g grunt --registry=https://registry.npm.taobao.org
/usr/local/node/bin/grunt -> /usr/local/node/lib/node_modules/grunt/bin/grunt
/usr/local/node/lib
[root@node2 elasticsearch-head]# npm install
[root@node2 elasticsearch-head]# vim Gruntfile.js
server: {
options: {
hostname: '192.168.172.129',
port: 9100,
base: '.',
keepalive: true
}
}
[root@node2 elasticsearch-head]# vim _site/app.js
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.172.129:9200";
[root@node2 elasticsearch-head]# node_modules/grunt/bin/grunt server &