英杰926

导航

ElasticSearch

ElasticSearch

elasticsearch-6.6.1

下载

https://www.elastic.co/downloads/elasticsearch

elasticsearch-6.6.1.tar.gz

安装

cd /usr/local

rz

tar -xvf elasticsearch-6.6.1.tar.gz

rm elasticsearch-6.6.1.tar.gz

mv elasticsearch-6.6.1 elasticsearch

cd elasticsearch/bin

运行

/usr/local/elasticsearch/bin/elasticsearch

/usr/local/elasticsearch/bin/elasticsearch -d  #后台运行

停止

ps -ef | grep elasticsearch

kill -9 XXXid

验证访问

http://192.168.190.129:9200/

坑1:运行权限问题

如果以root身份运行将会出现问题,是因为elasticsearch是不允许使用root用户启动的,所以我们创建一个新用户,并elasticsearch文件夹赋予这个用户,用这个用户运行:

 

adduser userelasticsearch  #创建用户后/home目录会出现userelasticsearch文件夹

passwd userelasticsearch

chown -R userelasticsearch /usr/local/elasticsearch/ 

#给用户userelasticsearch赋予访问文件夹的权限

su - userelasticsearch  #进入elasticsearch用户,exit退出

坑2:外机访问不到

vim /usr/local/elasticsearch/config/elasticsearch.yml

#在最后添加:

network.host:0.0.0.0

坑3:虚拟内存问题(设置了ip后又出现虚拟内存问题)

root用户

vim /etc/sysctl.conf

#在sysctl.conf的最后添加;262144根据运行错误提示得到。

vm.max_map_count=262144

sysctl -p

坑4:java运行错误(None of the configured nodes are available)

vim /usr/local/elasticsearch/config/elasticsearch.yml

#在最后添加:

cluster.name: my-application

其中红色部分跟java配置文件中的“cluster-name: my-application”红色部分相同

elasticsearch-head

ElasticSearch Head是集群管理、数据可视化、增删查改、查询语句可视化工具。

下载

https://github.com/mobz/elasticsearch-head

elasticsearch-head-master.zip

cd /usr/local

rz

unzip elasticsearch-head-master.zip

rm elasticsearch-head-master.zip

mv elasticsearch-head-master/ elasticsearch-head

 

apt-get install npm

apt-get install nodejs-legacy

npm install -g grunt

npm install -g grunt-cli

 

vim elasticsearch-head/_site/app.js

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

#this.base_uri = …… "http://192.168.190.129:9200";

 

vim elasticsearch-head/Gruntfile.js

connect: {

                        server: {

                                options: {

                                        port: 9100,

                                        base: '.',

                                        keepalive: true,

                                                                      hostname: '*'

                                }

                        }

                }

 

vim elasticsearch/config/elasticsearch.yml

#修改elasticseach的配置文件elasticsearch.yml,添加:

http.cors.enabled: true

http.cors.allow-origin: "*"

 

cd /usr/local/elasticsearch-head/

npm start  #或者运行:grunt server

 

运行有问题

npm install grunt@latest

npm install grunt-cli@latest

npm install grunt-contrib-copy@latest

npm install grunt-contrib-concat@latest

npm install grunt-contrib-uglify@latest

npm install grunt-contrib-clean@latest

npm install grunt-contrib-watch@latest

npm install grunt-contrib-connect@latest

npm install grunt-contrib-jasmine@latest(这个没成功,但也可运行了)

再运行

访问

之前要启动elasticsearch服务

http://192.168.190.129:9100/

posted on 2020-04-12 12:40  英杰926  阅读(121)  评论(0编辑  收藏  举报