Elasticsearch5安装以及部署Head插件

请看完再动手,两篇文章都是找来的,合并在一起了,前半部分是参考,我是按照后半部分做的,而且执行中间也有坑。

Elasticsearch5.X及 head插件 安装说明:

1、下载elasticsearch安装文件:

a) 下载官方源码:

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

b) 解压压缩文件

tar -zxvf elasticsearc-5.0.0.tar.gz

c) 修改es配置文件:elasticsearch.yml

cluster.name: kd-cluster //集群名称,所有主机相同的集群名称用于发现集群节点

node.name: node01 //节点名称

node.master: true //该节点是否用做管理节点

node.data: true //该节点是否用做数据节点

node.attr.rack: r1

path.data: 数据存储路径(文件夹)

path.logs: 日志存储路径(文件夹)

bootstrap.memory_lock: false

network.host: 172.16.8.229 //节点ip地址

http.cors.enabled: true //head插件的配置

http.cors.allow-origin: "*" //head插件的配置

http.port: 9200 //集群访问端口

discovery.zen.ping.unicast.hosts: ["node01"] //配置了互信的话这个位置可以使用节点名称(一般节点名成和计算机名称的相同的)。未配置互信的话使用主机ip,用于发现管理节点。

discovery.zen.minimum_master_nodes: 1 //集群最大管理节点数(防止脑裂的配置)

gateway.recover_after_nodes: 1

*******************如果是虚拟机一台复制的多台ES服务器,需要手工删除复制出来的机器上的目录elasticsearch/data/,否则会提示node id相同而无法加入集群

d) 修改主机配置

vi /etc/security/limits.conf :

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

vi /etc/security/limits.d/90-nproc.conf :

* soft nproc 2048

vi /etc/sysctl.conf :

vm.max_map_count=655360

并执行命令:sysctl -p

重启计算机。

2、下载elasticseatch-head插件:

a) 下载head插件文件:

https://github.com/mobz/elasticsearch-head(下载后上传到服务器)

git clone git://github.com/mobz/elasticsearch-head.git(git下载)

b) 下载Node.js:

wget https://nodejs.org/dist/v4.6.1/node-v4.6.1-linux-x64.tar.gz(linux命令直接下载)

https://nodejs.org/dist/(官方网站下载后上传到服务器)

c) 配置node.js环境变量:

vim /etc/profile:

export PATH=/data/elasticsearch/node-v4.6.1-linux-x64/bin:$PATH(根据实际情况添加,路径和格式参照本机环境)

执行source /etc/profile使环境变量生效

(修改profile文件需要root权限,使环境生效的命令在当前es集群使用用户下执行)

d) 查看当前head插件目录下有无node_modules/grunt目录:

没有:执行命令创建:npm install grunt --save

e) 安装head插件:

npm install

或者使用重定向安装:npm install -g cnpm --registry=https://registry.npm.taobao.org

f) 安装grunt:

npm install -g grunt-cli

g) 编辑Gruntfile.js

文件93行添加hostname:’0.0.0.0’

h) 检查head根目录下是否存在base文件夹

没有:将 _site下的base文件夹及其内容复制到head根目录下

i) 启动grunt server:

在head下运行grunt server -d启动head插件

j) 访问head插件:

http://localhost:9100(启动后会有提示:Started connect web server on http://localhost:9100)

--------------------------5.5 安装HEAD详细步骤------------------

1、git下载软件包

yum -y install git
git clone git://github.com/mobz/elasticsearch-head.git

备注:安装包不要放到elasticsearch/plugins目录下

2、node安装

http://www.cnblogs.com/shhnwangjian/p/6559732.html

2.1、下载编译好的文件

1
2
3
yum -y install wget
cd /usr/local/src/
wget http://nodejs.org/dist/v6.9.4/node-v6.9.4-linux-x64.tar.gz

2.2、解压

1
tar -xvf node-v6.9.4-linux-x64.tar.gz

2.3、查看版本信息

1
2
cd /usr/local/src/node-v6.9.4-linux-x64/bin
./node -v

2.4、设置全局

1
2
ln -s /usr/local/src/node-v6.9.4-linux-x64/bin/node /usr/local/bin/node
ln -s /usr/local/src/node-v6.9.4-linux-x64/bin/npm /usr/local/bin/npm

或者设置NODE_HOME环境变量

1
2
export NODE_HOME=/usr/local/src/node-v6.9.14-linux-x64
export PATH=$NODE_HOME/bin:$PATH

2.5、淘宝镜像cnpm安装  https://npm.taobao.org/

1
2
3
npm install -g cnpm --registry=https://registry.npm.taobao.org
ln -s /usr/local/src/node-v6.9.4-linux-x64/bin/cnpm /usr/local/bin/cnpm
cnpm -v

3、安装grunt和grunt-cli

1
2
npm install -g grunt-cli
npm install -g grunt

*****切记验证一下在任何目录下执行grunt是否可以找到命令。 

我反正没有找到,于是最后加了连接搞定的:ln -s /usr/local/es/elasticsearch-head/node_modules/grunt/bin/grunt /usr/local/bin/grunt

4、修改Elasticsearch配置文件,加入

/etc/elasticsearch/elasticsearch.yml

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

5、修改Gruntfile.js

elasticsearch-head/Gruntfile.js

                connect: {
                        server: {
                                options: {
                                        hostname: ‘0.0.0.0‘,
                                        port: 9100,
                                        base: ‘.‘,
                                        keepalive: true
                                }
                        }
                }

增加hostname属性,设置为0.0.0.0

6、修改app.js

elasticsearch-head/_site/app.js

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://10.10.83.163:9200";

把localhost修改成ES的服务器地址,如上面10.10.83.163

7、运行head

进入elasticsearch-head 目录

npm install 

***我在centos 7平台上安装过程中出现以下错误:

1.由于是最新的elasticsearch-head,可能由此提示node版本可能不对,于是我把node从6.9.4换成最新的8.4.0,然后重新做了一遍

2.提示“tar (child): bzip2: Cannot exec: No such file or directory”,于是通过yum安装了bzip2

3.然后死活安装不了phantomjs,估计是安装脚本问题,于是单独安装了npm install phantomjs-prebuilt@2.1.14 --ignore-scripts,最后再npm install通过

启动

grunt server

页面访问:http://10.10.83.163:9100

8、后台启动elasticsearch-head

nohup grunt server &

如果想关闭head插件,查找进程命令:

ps aux|grep grunt

x-pack安全模块(security机制)

1、修改Elasticsearch配置文件

/etc/elasticsearch/elasticsearch.yml

http.cors.allow-headers: Authorization

2、页面访问

http://10.10.83.163:9100/?auth_user=elastic&auth_password=changeme

原文地址:https://www.cnblogs.com/floodwater/p/7371949.html