Elasticsearch 版本部署中的问题

启动el和head都没错 但现实未连接 修改 

vi Gruntfile.js

修改服务器监听地址(Gruntfile.js)

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

增加这一行:增加hostname属性,设置为*
修改连接地址(app.js)

cd /usr/local/elk/es-head/elasticsearch-head-master/_site

vi app.js

修改head的连接地址:

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
把localhost修改成你es的服务器地址,如:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://172.30.1.45:9200";

Linux 出现-bash: grunt: command not found 错误解决

1、安装grunt

npm install -g grunt-cli
1
2、使用命令

[root@localhost ~]# grunt -version
-bash: grunt: command not found
1
2
3、分析 
如果一些程序没有安装在系统默认的路径(ie /bin/, /usr/bin, /usr/local/bin/ )里面,这个时候普通用户想要调用这些命令,必须设定路径。

[root@localhost ~]# vi ~/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/src/node-v8.2.1-linux-x86/bin

export PATH
--------------------- 
作者:那小子很拽 
来源:CSDN 
原文:https://blog.csdn.net/haoqi9999/article/details/77018585 
版权声明:本文为博主原创文章,转载请附上博文链接!

参考: 
http://www.cnblogs.com/kevingrace/p/5919021.html 
http://www.cnblogs.com/xing901022/p/6030296.html

之前装过2.X版本,里面的elasticsearch-head组件是集成到版本里的,今天装的5.5.2版本,发现没有elasticsearch-head组件,需要单独安装,安装过程中遇到一些错误,特此记录下来

环境

ELK-ncnode01 192.168.96.208 
ELK-ncnode02 192.168.96.209

[root@ELK-ncnode02 ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 
1
2
关闭防火墙和selinux

Elasticsearch安装配置

基础环境安装(ELK-ncnode01和ELK-ncnode02同时操作)
1)下载并安装GPG Key

[root@ELK-ncnode01 ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
1
2)添加yum仓库

[root@ELK-ncnode01 ~]# vi /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
1
2
3
4
5
6
7
8
9
3)安装elasticsearch

[root@ELK-ncnode01 ~]# yum install elasticsearch
1
4)安装相关测试软件 
提前先下载安装epel源:epel-release-latest-7.noarch.rpm,否则yum会报错:No Package…..

[root@ELK-ncnode01 ~]# yum install -y wget
[root@ELK-ncnode01 ~]# wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@ELK-ncnode01 ~]# rpm -ivh epel-release-latest-7.noarch.rpm

[root@ELK-ncnode01 ~]# yum install -y redis nginx java
1
2
3
4
5
安装完java后,检测

[root@ELK-ncnode01 ~]# java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)
1
2
3
4
配置部署(下面先进行elk-node1的配置)
1)配置修改配置文件

[root@ELK-ncnode01 ~]# vi /etc/elasticsearch/elasticsearch.yml  【将里面内容情况,配置下面内容】
cluster.name: longtel                            # 组名(同一个组,组名必须一致)
node.name: ELK-ncnode01                          # 节点名称,建议和主机名一致
path.logs: /var/log/elasticsearch/               # 日志存放的路径
network.host: 0.0.0.0                            # 网络设置
http.port: 9200                                  # 端口
1
2
3
4
5
6
2)启动并查看

[root@ELK-ncnode01 ~]# systemctl start elasticsearch
[root@ELK-ncnode01 ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-08-24 17:33:41 CST; 5s ago
     Docs: http://www.elastic.co
  Process: 8483 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
 Main PID: 8485 (java)
   CGroup: /system.slice/elasticsearch.service
           └─8485 /bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupa...

Aug 24 17:33:41 ELK-ncnode02 systemd[1]: Starting Elasticsearch...
Aug 24 17:33:41 ELK-ncnode02 systemd[1]: Started Elasticsearch.
1
2
3
4
5
6
7
8
9
10
11
12
13
注意:上面可以看出elasticsearch设置的内存最小2g,最大2g

[root@ELK-ncnode02 ~]# netstat -antlp |egrep "9200|9300"
tcp6       0      0 127.0.0.1:9200          :::*                    LISTEN      8485/java           
tcp6       0      0 ::1:9200                :::*                    LISTEN      8485/java           
tcp6       0      0 127.0.0.1:9300          :::*                    LISTEN      8485/java           
tcp6       0      0 ::1:9300                :::*                    LISTEN      8485/java    
1
2
3
4
5
然后通过web访问(访问的浏览器最好用google浏览器)

http://192.168.96.208:19200/

3)通过命令的方式查看数据

[root@ELK-ncnode01 ~]# curl -i -XGET 'http://192.168.96.208:9200/_count?pretty' -d '{"query":{"match_all":{}}}'
HTTP/1.1 200 OK
Warning: 299 Elasticsearch-5.5.2-b2f0c09 "Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header." "Thu, 24 Aug 2017 09:39:49 GMT"
content-type: application/json; charset=UTF-8
content-length: 95

{
  "count" : 0,
  "_shards" : {
    "total" : 0,
    "successful" : 0,
    "failed" : 0
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
4)接下来安装插件,使用插件进行查看~ (下面两个插件要在ELK-ncnode01和ELK-ncnode02上都要安装)

安装elasticsearch-head插件

(请特别注意,此插件的安装和2.X的版本就不同了哦)
第一步,安装git

需要从github上面下载代码,因此先要安装git

yum -y install git
1
安装完成后,就可以直接下载代码了:

git clone git://github.com/mobz/elasticsearch-head.git
1
下载后,修改下777权限(简单粗暴),因为是独立启动head的,所以我把它放到/usr/local/下了,参考:

[root@ELK-ncnode01 local]# chmod 777 elasticsearch-head/
[root@ELK-ncnode01 local]# ls
bin  elasticsearch-head  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@ELK-ncnode01 local]# pwd
/usr/local
1
2
3
4
5
第二步,安装node

由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用npm来安装依赖的包。(npm可以理解为maven)

去官网下载nodejs,https://nodejs.org/en/download/

下载下来的jar包是xz格式的,一般的linux可能不识别,还需要安装xz.

[root@ELK-ncnode01 local]# yum install -y xz
1
然后解压nodejs的安装包:

[root@ELK-ncnode01 local]# xz -d node-v6.11.2-linux-x64.tar.xz 
[root@ELK-ncnode01 local]# ls
bin  elasticsearch-head  etc  games  include  lib  lib64  libexec  node-v6.11.2-linux-x64.tar  sbin  share  src
[root@ELK-ncnode01 local]# tar xvf node-v6.11.2-linux-x64.tar 
1
2
3
4
解压完node的安装文件后,需要配置下环境变量,编辑/etc/profile,添加

[root@ELK-ncnode01 node-v6.11.2-linux-x64]# vi /etc/profile
# set node environment
export NODE_HOME=/usr/local/node-v6.11.2-linux-x64
export PATH=$PATH:$NODE_HOME/bin

[root@ELK-ncnode01 node-v6.11.2-linux-x64]# source /etc/profile
1
2
3
4
5
6
这个时候可以测试一下node是否生效:

[root@ELK-ncnode01 node-v6.11.2-linux-x64]#  echo $NODE_HOME
/usr/local/node-v6.11.2-linux-x64
[root@ELK-ncnode01 node-v6.11.2-linux-x64]# node -v
v6.11.2
[root@ELK-ncnode01 node-v6.11.2-linux-x64]# npm -v
3.10.10
1
2
3
4
5
6
第三步,安装grunt

grunt是一个很方便的构建工具,可以进行打包压缩、测试、执行等等的工作,5.5里的head插件就是通过grunt启动的。因此需要安装一下grunt:

[root@ELK-ncnode01 elasticsearch-head]# npm install  grunt 
npm WARN prefer global [email protected] should be installed with -g
[email protected] /usr/local/elasticsearch-head
└─┬ [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ └─┬ [email protected] 
  │   ├─┬ [email protected] 
  │   │ └── [email protected] 
  │   ├── [email protected] 
  │   ├─┬ [email protected] 
  │   │ ├─┬ [email protected] 
  │   │ │ └── [email protected] 
  │   │ └── [email protected] 
  │   ├── [email protected] 
  │   ├── [email protected] 
  │   ├─┬ [email protected] 
  │   │ ├── [email protected] 
  │   │ ├─┬ [email protected] 
  │   │ │ └── [email protected] 
  │   │ ├── [email protected] 
  │   │ └─┬ [email protected] 
  │   │   ├─┬ [email protected] 
  │   │   │ └── [email protected] 
  │   │   └── [email protected] 
  │   ├── [email protected] 
  │   ├─┬ [email protected] 
  │   │ ├─┬ [email protected] 
  │   │ │ ├── [email protected] 
  │   │ │ └─┬ [email protected] 
  │   │ │   └── [email protected] 
  │   │ └─┬ [email protected] 
  │   │   ├─┬ [email protected] 
  │   │   │ ├── [email protected] 
  │   │   │ ├─┬ [email protected] 
  │   │   │ │ └─┬ [email protected] 
  │   │   │ │   └── [email protected] 
  │   │   │ ├── [email protected] 
  │   │   │ └─┬ [email protected] 
  │   │   │   └── [email protected] 
  │   │   └── [email protected] 
  │   ├─┬ [email protected] 
  │   │ ├─┬ [email protected] 
  │   │ │ └─┬ [email protected] 
  │   │ │   └─┬ [email protected] 
  │   │ │     └── [email protected] 
  │   │ └── [email protected] 
  │   └── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├─┬ [email protected] 
  │ │ ├─┬ [email protected] 
  │ │ │ ├── [email protected] 
  │ │ │ ├── [email protected] 
  │ │ │ ├─┬ [email protected] 
  │ │ │ │ └── [email protected] 
  │ │ │ ├── [email protected] 
  │ │ │ └── [email protected] 
  │ │ └── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ └─┬ [email protected] 
  │   └── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ └── [email protected] 
  └── [email protected] 

npm WARN [email protected] license should be a valid SPDX license expression

[root@ELK-ncnode01 elasticsearch-head]# npm install -g grunt-cli --save        (此处加-g,不加的话会出现各种错误)
/usr/local/node-v6.11.2-linux-x64/bin/grunt -> /usr/local/node-v6.11.2-linux-x64/lib/node_modules/grunt-cli/bin/grunt
/usr/local/node-v6.11.2-linux-x64/lib
└── [email protected] 

[root@ELK-ncnode01 elasticsearch-head]# grunt -version
grunt-cli v1.2.0
grunt v1.0.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
第四步,修改head源码

由于head的代码还是2.6版本的,直接执行有很多限制,比如无法跨机器访问。因此需要用户修改两个地方: 
修改服务器监听地址

目录:/usr/local/elasticsearch-head/Gruntfile.js

connect: {
    server: {
        options: {
            port: 9100,
            hostname: '*',
            base: '.',
            keepalive: true
        }
    }
}
1
2
3
4
5
6
7
8
9
10
增加hostname属性,设置为*

修改连接地址:

目录:/usr/local/elasticsearch-head/_site/app.js

修改head的连接地址:

this.base_uri = this.config.base_uri || this.prefs.get(“app-base_uri”) || “http://localhost:9200“;

把localhost修改成你es的服务器地址,如:

this.base_uri = this.config.base_uri || this.prefs.get(“app-base_uri”) || “http://192.168.96.208:9200“;

第五步,运行head

首先开启5.5 ES。

然后在head目录中,执行npm install 下载以来的包:

npm install

此处会报错如下

解决方法

[root@ELK-ncnode01 elasticsearch-head]# npm install [email protected] --ignore-script
[email protected] /usr/local/elasticsearch-head
└─┬ [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ └─┬ [email protected] 
  │   └─┬ [email protected] 
  │     └── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ ├── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ ├─┬ [email protected] 
  │ │ ├─┬ [email protected] 
  │ │ │ ├── [email protected] 
  │ │ │ └─┬ [email protected] 
  │ │ │   └── [email protected] 
  │ │ └── [email protected] 
  │ ├─┬ [email protected] 
  │ │ ├── [email protected] 
  │ │ ├── [email protected] 
  │ │ ├── [email protected] 
  │ │ └── [email protected] 
  │ ├─┬ [email protected] 
  │ │ ├── [email protected] 
  │ │ ├─┬ [email protected] 
  │ │ │ ├── [email protected] 
  │ │ │ ├── [email protected] 
  │ │ │ ├── [email protected] 
  │ │ │ └─┬ [email protected] 
  │ │ │   └── [email protected] 
  │ │ └─┬ [email protected] 
  │ │   ├── [email protected] 
  │ │   ├── [email protected] 
  │ │   ├── [email protected] 
  │ │   ├─┬ [email protected] 
  │ │   │ └── [email protected] 
  │ │   ├── [email protected] 
  │ │   ├─┬ [email protected] 
  │ │   │ └── [email protected] 
  │ │   ├── [email protected] 
  │ │   └── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  └─┬ [email protected] 
    └── [email protected] 

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] license should be a valid SPDX license expression
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
此处说明npm WARN可以忽略,如果不想看到WARN可如下执行npm install命令时添加 –no-optional

执行如下

[root@ELK-ncnode01 elasticsearch-head]# npm install --no-optional
npm WARN [email protected] license should be a valid SPDX license expression
1
2
还有一个WARN,打开elasticsearch-head目录下的package.json文件,找到license位置,修改为上面这个网站上存在Identifier,就可以了。如图所示,把原来的Apache内容修改为Apache-2.0。具体修改后的内容参考官网上的Identifier数值(防止后续更新,授之于渔了)。

[root@ELK-ncnode01 elasticsearch-head]# vi package.json
"author": "",
"license": "Apache-2.0",
"gitHead": "0c2ac0b5723b493e4454baa7398f386ecb829412",
"readmeFilename": "README.textile",
1
2
3
4
5
再次执行

[root@ELK-ncnode01 elasticsearch-head]# npm install --no-optional
[root@ELK-ncnode01 elasticsearch-head]#
1
2
没有一点毛病了

最后,启动nodejs

grunt server

访问:target:9100

这个时候,访问http://192.168.96.208:9100就可以访问head插件了.

访问http://192.168.96.209:9100也可以

ELK-ncnode02也要做全局的配置
[root@ELK-ncnode02 _site]# vi /etc/elasticsearch/elasticsearch.yml 
cluster.name: longtel
node.name: ELK-ncnode02
path.logs: /var/log/elasticsearch/
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.96.208", "192.168.96.209"]
1
2
3
4
5
6
7
启动服务

[root@ELK-ncnode02 _site]# systemctl restart elasticsearch
[root@ELK-ncnode02 _site]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-08-24 18:39:18 CST; 14h ago
     Docs: http://www.elastic.co
  Process: 10172 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
 Main PID: 10175 (java)
   CGroup: /system.slice/elasticsearch.service
           └─10175 /bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccup...

Aug 24 18:39:18 ELK-ncnode02 systemd[1]: Starting Elasticsearch...
Aug 24 18:39:18 ELK-ncnode02 systemd[1]: Started Elasticsearch.
1
2
3
4
5
6
7
8
9
10
11
12
13
上面的elasticsearch-head组件也要在ELK-ncnode02上安装

后续会继续完善logstash, kibana

—————————年轻的时候最幸福的事情就是拼命工作———————————
--------------------- 
作者:三支烟 
来源:CSDN 
原文:https://blog.csdn.net/qq_36357820/article/details/77539843 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/weixin_40790313/article/details/84023208
今日推荐