Elasticsearch:6.0及其ES-Head插件安装
创始人
2025-01-11 11:36:12
0次

Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎;是目前全文搜索引擎的首选,性能测试我们就不累赘了,网上能搜索到很多性能测试结果,不管老版本还是新版本对Java的兼容很友好。搜索也很高效。那我们今天就介绍下如何安装?

1、下载并解压elasticsearch(Elasticsearch 6.0.0 | Elastic)

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.0.zip unzip elasticsearch-6.0.0.zip

2、配置elasticsearch.yml文件

# 集群的名字 cluster.name: my-application # 节点名字 node.name: node-1 # 数据存储目录(多个路径用逗号分隔) path.data: /opt/elasticsearch/data # 日志目录 path.logs: /opt/elasticsearch/logs #本机的ip地址 network.host: 192.168.1.1 #设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点 discovery.zen.ping.unicast.hosts: ["192.168.1.1"] # 设置节点间交互的tcp端口(集群),(默认9300) transport.tcp.port: 9300 # 监听端口(默认) http.port: 9200 # 增加参数,使head插件可以访问es http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

3、启动ES

cd /opt/elasticsearch ./elasticsearch

4、下载head插件

wget https://github.com/mobz/elasticsearch-head/archive/master.zip unzip master.zip

5、安装node

wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz tar -zxvf node-v4.4.7-linux-x64.tar.gz

配置下环境变量,编辑/etc/profile添加

export NODE_HOME=/opt/nodejs/node-v4.4.7-linux-x64/

export PATH=$PATH:$NODE_HOME/bin

export NODE_PATH=$NODE_HOME/lib/node_modules

:wq 保存

source /etc/profile

6、安装grunt

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

cd /opt/elasticsearch-head  //执行后会生成node_modules npm install -g grunt-cli 

7、修改head插件源码  

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

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

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

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.1.1.:9200"; useradd es chown -R es:es elasticsearch

8、运行head

进入到elasticsearch-head主目录执行:

elastic@xtsadhas001 elasticsearch-head]$ npm install

安装过程中出现错误:

  • Please report this full log at GitHub - Medium/phantomjs: NPM wrapper for installing phantomjs

  • npm ERR! Darwin 15.0.0

  • npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"

  • npm ERR! node v4.4.3

  • npm ERR! npm  v3.10.9

  • npm ERR! code ELIFECYCLE

  • npm ERR! phantomjs-prebuilt@2.1.14 install: `node install.js`

  • npm ERR! Exit status 1

  • npm ERR!

  • npm ERR! Failed at the phantomjs-prebuilt@2.1.14 install script 'node install.js

 解决方案:

//忽略脚本继续进行安装 npm install phantomjs-prebuilt@2.1.14 --ignore-scripts

配置 Gruntfile.js  

hostname: '0.0.0.0',

9.访问 http://yourwebsite:9100

ps -ef | grep elastic ps -ef | grep logstash nohup ./bin/elasticsearch & head nohup grunt server & exit

常见问题

1、root用户启动elasticsearch报错

Elasticsearch为了安全考虑,不让使用root启动,解决方法新建一个用户,用此用户进行相关的操作。如果你用root启动,会出现“java.lang.RuntimeException: can not runelasticsearch as root”错误

2、JVM虚拟机内存不足

错误:“JavaHotSpot(TM) 64-Bit Server VM warning: INFO: error='Cannotallocate memory' (errno=12)”表示内存不足,其配置文件为config目录下的jvm.options,默认为2G,可以修改为1G

3、max_map_count过小

错误“max virtual memory areas vm.max_map_count [65530]is too low, increase to at least [262144]”,max_map_count文件包含限制一个进程可以拥有的VMA(虚拟内存区域)的数量,系统默认是65530,修改成262144。解决方法是修改/etc/sysctl.conf配置文件,添加vm.max_map_count=262144,记得需要重启机器才起作用

4、max file descriptors过小

错误“max file descriptors [65535] for elasticsearchprocess is too low, increase to at least [65536]”,maxfile descriptors为最大文件描述符,设置其大于65536即可。解决方法是修改/etc/security/limits.conf文件,添加“* - nofile65536 * - memlock unlimited”,“*”表示给所有用户起作用

相关内容

热门资讯

玩家爆料开挂app!丹东约战麻... 玩家爆料开挂app!丹东约战麻将多功能开挂app,丹东约战麻将果然真的有开挂app1、下载好丹东约战...
终于清楚辅助软件!丰城棋牌多功... 终于清楚辅助软件!丰城棋牌多功能辅助软件,丰城棋牌本来是真的有辅助软件1、起透看视 丰城棋牌辅助软件...
重大消息透视器方法!科尔沁麻将... 重大消息透视器方法!科尔沁麻将多功能透视器方法,科尔沁麻将本来是有透视器方法科尔沁麻将脚本下载中分为...
分享个大家辅助方法!天津麻将多... 分享个大家辅助方法!天津麻将多功能辅助方法,天津麻将竟然是真的有辅助方法1、很好的工具软件,可以解锁...
带你了解外挂攻略!逍遥皖北棋牌... 带你了解外挂攻略!逍遥皖北棋牌多功能外挂攻略,逍遥皖北棋牌总是是有外挂攻略1、在逍遥皖北棋牌插件功能...
热门推荐透视挂攻略!悠乐汇多功... 热门推荐透视挂攻略!悠乐汇多功能透视挂攻略,悠乐汇切实真的有透视挂攻略;1、全新机制【悠乐汇ai辅助...
推荐一款辅助方法!科尔沁麻将多... 推荐一款辅助方法!科尔沁麻将多功能辅助方法,科尔沁麻将其实真的有辅助方法1、不需要AI权限,帮助你快...
重大来袭开挂攻略!一乐浙江多功... 重大来袭开挂攻略!一乐浙江多功能开挂攻略,一乐浙江一贯是真的有开挂攻略1、让任何用户在无需一乐浙江安...
详细说明作弊器技巧!启东麻将多... 详细说明作弊器技巧!启东麻将多功能作弊器技巧,启东麻将一贯存在有作弊器技巧1、下载好启东麻将透视辅助...
玩家必看科普辅助插件!闲来互娱... 玩家必看科普辅助插件!闲来互娱多功能辅助插件,闲来互娱一贯有辅助插件1、很好的工具软件,可以解锁游戏...