大数据学习31:Elasticsearch 6.0 和 Elasticsearch header 安装记录

来源:互联网 发布:js post 跨域解决方案 编辑:程序博客网 时间:2024/05/17 19:18

Elasticsearch 6.0 和 Elasticsearch header 安装记录

------------------------------hosts文件151.101.0.133  raw.githubusercontent.com192.30.255.112  github.com54.231.40.211  github-production-release-asset-2e65be.s3.amazonaws.com54.235.82.130  artifacts.elastic.co34.208.205.7  npmjs.org151.101.72.162  registry.npmjs.org104.20.22.46  nodejs.org-----------------------------
调一下时间ntpdate 202.108.6.95

一、elasticsearch 6.0 单机安装
a)创建elkuser用户

[root@hadoop001 ~]# useradd elkuser#elasticsearch 只能用非 root 启动[root@hadoop001 elk]# chown -R elkuser.elkuser elasticsearch-6.0.0/ [root@hadoop001 software]# java -versionjava version "1.8.0_45"Java(TM) SE Runtime Environment (build 1.8.0_45-b14)Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

b)解压

[root@hadoop001 elk]# tar -xzvf elasticsearch-6.0.0.tar.gz 

c)创建相关目录

[root@hadoop001 elk]# cd elasticsearch-6.0.0/[root@hadoop001 elasticsearch-6.0.0]# lltotal 236drwxr-xr-x.  2 root root   4096 Dec  2 15:09 bindrwxr-xr-x.  2 root root   4096 Nov 11 02:42 configdrwxr-xr-x.  2 root root   4096 Nov 11 02:42 lib-rw-r--r--.  1 root root  11358 Nov 11 02:39 LICENSE.txtdrwxr-xr-x. 14 root root   4096 Nov 11 02:42 modules-rw-r--r--.  1 root root 193097 Nov 11 02:42 NOTICE.txtdrwxr-xr-x.  2 root root   4096 Nov 11 02:42 plugins-rw-r--r--.  1 root root   9326 Nov 11 02:39 README.textile[root@hadoop001 elasticsearch-6.0.0]# mkdir data logs[root@hadoop001 elasticsearch-6.0.0]# cd config/[root@hadoop001 config]# ll total 16-rw-rw----. 1 root root 2854 Nov 11 02:40 elasticsearch.yml-rw-rw----. 1 root root 2672 Nov 11 02:40 jvm.options-rw-rw----. 1 root root 5091 Nov 11 02:40 log4j2.properties

d)进行配置:

[root@hadoop001 config]# vi elasticsearch.yml cluster.name: wxk_clusternode.name: node-11path.data: /opt/software/elk/elasticsearch-6.0.0/datapath.logs: /opt/software/elasticsearch-6.0.0/logsnetwork.host: 192.168.137.11# ----------------------------------- Memory -----------------------------------## Lock the memory on startup:#bootstrap.memory_lock: falsebootstrap.system_call_filter: false最后配置这个:否则head无法连接elasticsearchhttp.cors.enabled: truehttp.cors.allow-origin: "*"

e)开始启动

[root@hadoop001 elk]# chown -R elkuser.elkuser elasticsearch-6.0.0/ [elkuser@hadoop001 elasticsearch-6.0.0]$ bin/elasticsearch

这里报错,需要修改Linux相关配置:

ERROR: [3] bootstrap checks failed[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536][2]: max number of threads [1024] for user [elkuser] is too low, increase to at least [4096][3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]vm.max_map_count 不低于 262144vm.max_map_count 表示虚拟内存大小,它是一个内核参数。elasticsearch 默认要求  vm.max_map_count 不低于 262144。[root@hadoop001 ~]# sysctl -w vm.max_map_count=262144[root@hadoop001 ~]# echo "vm.max_map_count=262144" >> /etc/sysctl.conf[root@hadoop001 ~]# sysctl -pnofile 不低于 65536[root@hadoop001 ~]# nofile 表示进程允许打开的最大文件数。elasticsearch 进程要求可以打开的最大文件数不低于 65536。[root@hadoop001 ~]# echo "* soft nofile 65536" >> /etc/security/limits.conf[root@hadoop001 ~]# echo "* hard nofile 131072" >> /etc/security/limits.confnproc 不低于 2048nproc 表示最大线程数。elasticsearch 要求最大线程数不低于 2048。[root@hadoop001 ~]# echo "elkuser soft nproc 4096" >> /etc/security/limits.conf[root@hadoop001 ~]# echo "elkuser hard nproc 4096" >> /etc/security/limits.conf[elkuser@hadoop001 elasticsearch-6.0.0]$ ulimit -u  4096[root@hadoop001 ~]# reboot

f)再次启动

[elkuser@hadoop001 elasticsearch-6.0.0]$ bin/elasticsearch

发现正常。
使用 get 进行测试

[root@hadoop001 elasticsearch-head-master]# curl -XGET '192.168.137.11:9200/?pretty'{  "name" : "node-11",  "cluster_name" : "wxk_cluster",  "cluster_uuid" : "Gj-aXikKTj2A6WyBQJsqSQ",  "version" : {    "number" : "6.0.0",    "build_hash" : "8f0685b",    "build_date" : "2017-11-10T18:41:22.859Z",    "build_snapshot" : false,    "lucene_version" : "7.0.1",    "minimum_wire_compatibility_version" : "5.6.0",    "minimum_index_compatibility_version" : "5.0.0"  },  "tagline" : "You Know, for Search"}

control c 中断后

[elkuser@hadoop001 elasticsearch-6.0.0]$ bin/elasticsearch -d  使他在后台运行

二、elasticsearch header 单机安装
a) 下载head插件文件:

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

或者

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)解压

[root@hadoop001 elk]# pwd /opt/software/elk[root@hadoop001 elk]# ll total 39392-rw-r--r--. 1 root root 28017602 Nov 26 18:50 elasticsearch-6.0.0.tar.gzdrwxr-xr-x. 6 root root     4096 Sep 15 09:32 elasticsearch-head-master-rw-r--r--. 1 root root   921421 Nov 26 23:45 elasticsearch-head-master.zip-rw-r--r--. 1 root root 11387108 Nov 27 00:20 node-v8.9.1-linux-x64.tar.xz[root@hadoop001 elk]# unzip elasticsearch-head-master.zip [root@hadoop001 elk]# xz -d node-v8.9.1-linux-x64.tar.xz [root@hadoop001 elk]# tar -xvf node-v8.9.1-linux-x64.tar 

解压后:

[root@hadoop001 elk]# ll total 12drwxr-xr-x. 7 root root 4096 Nov 11 02:42 elasticsearch-6.0.0drwxr-xr-x. 6 root root 4096 Sep 15 09:32 elasticsearch-head-masterdrwxrwxr-x. 6  500  500 4096 Nov  8 04:56 node-v8.9.1-linux-x64

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

vim /etc/profile:export NODE_HOME=/opt/software/elk/node-v8.9.1-linux-x64export PATH=$NODE_HOME/bin:$PATH 

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

e) 查看当前head插件目录下有无node_modules/grunt目录:
没有:执行命令创建:npm install grunt –save

[root@hadoop001 elasticsearch-head-master]# npm install grunt --savenpm notice created a lockfile as package-lock.json. You should commit this file.npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression+ grunt@1.0.1added 92 packages in 46.817s

f)修改服务器监听地址:Gruntfile.js
vi Gruntfile.js 在第93行添加:

hostname:’*’

g)修改连接地址:_site/app.js

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

h) 安装grunt:
grunt是基于Node.js的项目构建工具,可以进行打包压缩、测试、执行等等的工作,head插件就是通过grunt启动

npm install -g grunt-cli

i) 安装head插件:
npm install 或者
使用重定向安装:npm install -g cnpm –registry=https://registry.npm.taobao.org

[root@hadoop001 elasticsearch-head-master]# npm install 

这里要提前配置好hosts,其实只要下载包完成就可以了,有个单独的进度条下载文件的特别慢,我中断了,后面也没有问题。

报错1:

[root@hadoop001 elasticsearch-head-master]# npm install npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expressionnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

解决方法:

vi package.json 修改"license": "Apache-2.0"

warnings其实可以不用管

报错2:

[root@hadoop001 elasticsearch-head-master]# grunt server Loading "Gruntfile.js" tasks...ERROR>> SyntaxError: Unexpected identifierWarning: Task "server" not found. Use --force to continue.Aborted due to warnings.

检查 Gruntfile.js
查看server 那里

connect: {    server: {        options: {            port: 9100,            base: '.',            keepalive: true // 这里添加完了以后没加逗号分隔,修改后正常启动            hostname: '0.0.0.0'

j)启动 grunt server

[root@hadoop001 elasticsearch-head-master]# grunt server (node:2235) ExperimentalWarning: The http2 module is an experimental API.Running "connect:server" (connect) taskWaiting forever...Started connect web server on http://localhost:9100

后台运行:

nohup grunt server &

这样就可以连接elasticsearch 了。

这里写图片描述

原创粉丝点击