一、环境
linux-node1 192.168.127.201
linux-node2 192.168.127.202
centos7.3 elasticsearch6.4 logstash6.4 kibana6.4
二、原理
三、安装
1、elasticsearch和elasticsearch-head安装
[root@linux-node1 ~]# rpm -ivh jdk-8u171-linux-x64.rpm
[root@linux-node1 ~]# vim /etc/profile
JAVA_HOME=/usr/java/jdk1.8.0_171-amd64/
JRE_HOME=/usr/java/jdk1.8.0_171-amd64/jre/
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME:$JRE_HOME/bin:$CALSS_PATH/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
[root@linux-node1 ~]# java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
[root@linux-node1 ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
[root@linux-node1 ~]# vim /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
[root@linux-node1 ~]# yum install elasticsearch -y
[root@linux-node1 ~]# mkdir -p /data/es-data/
[root@linux-node1 ~]# chown -R elasticsearch.elasticsearch /data
[root@linux-node1 ~]# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: suffergtf #####集群的名字
node.name: linux-node1 #######节点名字
path.data: /data/es-data ######数据存储目录
path.logs: /var/log/elasticsearch ######日志目录
bootstrap.memory_lock: true #####锁定交换内存使用
network.host: 192.168.127.201 #####本机IP地址
http.port: 9200
transport.tcp.port: 9300 ############设置节点交互的tcp端口
discovery.zen.ping.unicast.hosts: ["192.168.127.201"] ####集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点
[root@linux-node1 ~]# vim /etc/systemd/system.conf #####修改如下行,即可解决error报错
DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity
[root@linux-node1 elasticsearch]# vim /etc/security/limits.conf #####添加如下行,即可解决warn警告
# allow user 'elasticsearch' mlockall
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
[root@linux-node1 ~]# systemctl start elasticsearch
[root@linux-node1 ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2018-08-31 12:40:09 CST; 25min ago
Docs: http://www.elastic.co
Main PID: 885 (java)
CGroup: /system.slice/elasticsearch.service
├─885 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMS...
└─938 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
8月 31 12:40:09 linux-node1 systemd[1]: Started Elasticsearch.
8月 31 12:40:09 linux-node1 systemd[1]: Starting Elasticsearch...
8月 31 12:40:10 linux-node1 elasticsearch[885]: Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMark...ase.
Hint: Some lines were ellipsized, use -l to show in full.
[root@linux-node1 ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 757/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 834/master
tcp6 0 0 :::9200 :::* LISTEN 885/java
tcp6 0 0 :::9300 :::* LISTEN 885/java
tcp6 0 0 :::22 :::* LISTEN 757/sshd
tcp6 0 0 ::1:25 :::* LISTEN 834/master
udp 0 0 127.0.0.1:323 0.0.0.0:* 498/chronyd
udp6 0 0 ::1:323 :::* 498/chronyd
[root@linux-node1 ~]# curl -i -XGET http://192.168.127.201:9200
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 490
{
"name" : "linux-node1",
"cluster_name" : "suffergtf",
"cluster_uuid" : "PhW_6QKzSkmxEZY7JqIdUA",
"version" : {
"number" : "6.4.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "595516e",
"build_date" : "2018-08-17T23:18:47.308994Z",
"build_snapshot" : false,
"lucene_version" : "7.4.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
elasticsearch-head插件
[root@linux-node2 tools]# wget https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz
[root@linux-node1 tools]# ls
jdk-8u171-linux-x64.rpm node-v6.10.2-linux-x64.tar.xz
[root@linux-node1 tools]# xz -d node-v6.10.2-linux-x64.tar.xz
[root@linux-node1 tools]# tar -xf node-v6.10.2-linux-x64.tar -C /application/
[root@linux-node1 node-v6.10.2-linux-x64]# vim /etc/profile ####添加如下环境变量
export NODE_HOME=/application/node-v6.10.2-linux-x64/
export PATH=$PATH:$NODE_HOME/bin
[root@linux-node1 node-v6.10.2-linux-x64]# source /etc/profile
[root@linux-node1 node-v6.10.2-linux-x64]# node -v
v6.10.2
[root@linux-node1 node-v6.10.2-linux-x64]# npm -v
3.10.10
[root@linux-node1 tools]# ls
elasticsearch-head-master.zip jdk-8u171-linux-x64.rpm node-v6.10.2-linux-x64.tar
[root@linux-node1 tools]# unzip elasticsearch-head-master.zip
[root@linux-node1 tools]# ls
elasticsearch-head-master elasticsearch-head-master.zip jdk-8u171-linux-x64.rpm node-v6.10.2-linux-x64.tar
[root@linux-node1 tools]# mv elasticsearch-head-master /application/
[root@linux-node1 tools]# cd /application/elasticsearch-head-master/
[root@linux-node1 elasticsearch-head-master]# npm install -g grunt --registry=https://registry.npm.taobao.org
/application/node-v6.10.2-linux-x64/bin/grunt -> /application/node-v6.10.2-linux-x64/lib/node_modules/grunt/bin/grunt
/application/node-v6.10.2-linux-x64/lib
└─┬ grunt@1.0.3
├── coffeescript@1.10.0
├─┬ dateformat@1.0.12
│ ├── get-stdin@4.0.1
│ └─┬ meow@3.7.0
│ ├─┬ camelcase-keys@2.1.0
│ │ └── camelcase@2.1.1
│ ├── decamelize@1.2.0
│ ├─┬ loud-rejection@1.6.0
│ │ ├─┬ currently-unhandled@0.4.1
│ │ │ └── array-find-index@1.0.2
│ │ └── signal-exit@3.0.2
│ ├── map-obj@1.0.1
│ ├── minimist@1.2.0
│ ├─┬ normalize-package-data@2.4.0
│ │ ├── hosted-git-info@2.7.1
│ │ ├─┬ is-builtin-module@1.0.0
│ │ │ └── builtin-modules@1.1.1
│ │ ├── semver@5.5.1
│ │ └─┬ validate-npm-package-license@3.0.4
│ │ ├─┬ spdx-correct@3.0.0
│ │ │ └── spdx-license-ids@3.0.0
│ │ └─┬ spdx-expression-parse@3.0.0
│ │ └── spdx-exceptions@2.1.0
│ ├── object-assign@4.1.1
│ ├─┬ read-pkg-up@1.0.1
│ │ ├─┬ find-up@1.1.2
│ │ │ ├── path-exists@2.1.0
│ │ │ └─┬ pinkie-promise@2.0.1
│ │ │ └── pinkie@2.0.4
│ │ └─┬ read-pkg@1.1.0
│ │ ├─┬ load-json-file@1.1.0
│ │ │ ├── graceful-fs@4.1.11
│ │ │ ├─┬ parse-json@2.2.0
│ │ │ │ └─┬ error-ex@1.3.2
│ │ │ │ └── is-arrayish@0.2.1
│ │ │ ├── pify@2.3.0
│ │ │ └─┬ strip-bom@2.0.0
│ │ │ └── is-utf8@0.2.1
│ │ └── path-type@1.1.0
│ ├─┬ redent@1.0.0
│ │ ├─┬ indent-string@2.1.0
│ │ │ └─┬ repeating@2.0.1
│ │ │ └─┬ is-finite@1.0.2
│ │ │ └── number-is-nan@1.0.1
│ │ └── strip-indent@1.0.1
│ └── trim-newlines@1.0.0
├── eventemitter2@0.4.14
├── exit@0.1.2
├─┬ findup-sync@0.3.0
│ └── glob@5.0.15
├─┬ glob@7.0.6
│ ├── fs.realpath@1.0.0
│ ├─┬ inflight@1.0.6
│ │ └── wrappy@1.0.2
│ ├── inherits@2.0.3
│ └── once@1.4.0
├─┬ grunt-cli@1.2.0
│ └── resolve@1.1.7
├── grunt-known-options@1.1.1
├─┬ grunt-legacy-log@2.0.0
│ ├── colors@1.1.2
│ ├─┬ grunt-legacy-log-utils@2.0.1
│ │ └─┬ chalk@2.4.1
│ │ ├─┬ ansi-styles@3.2.1
│ │ │ └─┬ color-convert@1.9.3
│ │ │ └── color-name@1.1.3
│ │ ├── escape-string-regexp@1.0.5
│ │ └─┬ supports-color@5.5.0
│ │ └── has-flag@3.0.0
│ ├── hooker@0.2.3
│ └── lodash@4.17.10
├─┬ grunt-legacy-util@1.1.1
│ ├── async@1.5.2
│ ├── getobject@0.1.0
│ ├─┬ underscore.string@3.3.4
│ │ ├── sprintf-js@1.1.1
│ │ └── util-deprecate@1.0.2
│ └─┬ which@1.3.1
│ └── isexe@2.0.0
├─┬ iconv-lite@0.4.24
│ └── safer-buffer@2.1.2
├─┬ js-yaml@3.5.5
│ ├─┬ argparse@1.0.10
│ │ └── sprintf-js@1.0.3
│ └── esprima@2.7.3
├─┬ minimatch@3.0.4
│ └─┬ brace-expansion@1.1.11
│ ├── balanced-match@1.0.0
│ └── concat-map@0.0.1
├─┬ mkdirp@0.5.1
│ └── minimist@0.0.8
├─┬ nopt@3.0.6
│ └── abbrev@1.1.1
├── path-is-absolute@1.0.1
└── rimraf@2.6.2
[root@linux-node1 elasticsearch-head-master]# npm install
[root@linux-node1 elasticsearch-head-master]# npm install grunt --save
[root@linux-node1 elasticsearch-head-master]# grunt -version
grunt-cli v1.2.0
grunt v1.0.1
[root@linux-node1 elasticsearch-head-master]# vim /application/elasticsearch-head-master/Gruntfile.js
90 connect: {
91 server: {
92 options: {
93 hostname: '192.168.127.201', ####添加改行
94 port: 9100,
95 base: '.',
96 keepalive: true
97 }
98 }
99 }
[root@linux-node1 elasticsearch-head-master]# vim /application/elasticsearch-head-master/_site/app.js
4351 init: function(parent) {
4352 this._super();
4353 this.prefs = services.Preferences.instance();
4354 this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.127.201:9200"; #####修改该内容
4355 if( this.base_uri.charAt( this.base_uri.length - 1 ) !== "/" ) {
4356 // XHR request fails if the URL is not ending with a "/"
4357 this.base_uri += "/";
4358 }
[root@linux-node1 elasticsearch-head-master]# vim /etc/elasticsearch/elasticsearch.yml ###添加如下行
http.cors.enabled: true
http.cors.allow-origin: "*"
[root@linux-node1 elasticsearch-head-master]# /application/elasticsearch-head-master/node_modules/grunt/bin/grunt server
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://192.168.127.201:9100
2、logstash安装
[root@linux-node1 ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
[root@linux-node1 ~]# vim /etc/yum.repos.d/logstash.repo[logstash-6.x]
name=Elastic repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
[root@linux-node1 ~]# yum install logstash -y
3、kibana
[root@linux-node1 logstash]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
[root@linux-node1 logstash]# vim /etc/yum.repos.d/kibana.repo[kibana-6.x]
name=Kibana repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
[root@linux-node1 logstash]# yum install kibana -y
[root@linux-node1 logstash]# vim /etc/kibana/kibana.yml
server.port: 5601
server.host: "192.168.127.201"
server.name: "linux-node1"
elasticsearch.url: "http://192.168.127.201:9200"
kibana.index: ".kibana"