GVKun编程网logo

无法在Ubuntu上将ElasticSearch作为服务运行(ubuntu无法安装essential)

8

以上就是给各位分享无法在Ubuntu上将ElasticSearch作为服务运行,其中也会对ubuntu无法安装essential进行解释,同时本文还将给你拓展ElasticsearchCentOS6.

以上就是给各位分享无法在Ubuntu上将ElasticSearch作为服务运行,其中也会对ubuntu无法安装essential进行解释,同时本文还将给你拓展Elasticsearch CentOS6.5下安装ElasticSearch6.2.4+elasticsearch-head+Kibana、Elasticsearch ubuntu 14.04 安装 note to self、elasticsearch-Ubuntu-拒绝连接、Elasticsearch作为图像服务器与Apache等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

无法在Ubuntu上将ElasticSearch作为服务运行(ubuntu无法安装essential)

无法在Ubuntu上将ElasticSearch作为服务运行(ubuntu无法安装essential)

我试图按照正常的安装指南启动和运行ElasticSearch 。

Macbook上的一切运行正常,但是我试图在Ubuntu 11.04服务器上做同样的事情。

运行/usr/local/elasticsearch/bin/elasticsearch -f正常,我得到了回应curlhttp://localhost:9200

但是,这是我尝试将ElasticSearch作为服务启动时得到的(我已经安装了服务包装器):

$ rcelasticsearch startStarting ElasticSearch...Waiting for ElasticSearch.............................WARNING: ElasticSearch may have failed to start.

果然rcelasticsearch status说不了ElasticSearch is not running本地主机:9200。

任何想法可能是什么问题?

编辑:服务日志显示:

Launching a JVM...JVM exited while loading the application.Error occurred during initialization of VMCould not reserve enough space for object heap

答案1

小编典典

服务器实例没有足够的内存来存储默认的ElasticSearch服务包装器设置。为了解决这个问题,我编辑/usr/local/elasticsearch/bin/service/elasticsearch.confES_HEAP_SIZE从1024
更改为512

Elasticsearch CentOS6.5下安装ElasticSearch6.2.4+elasticsearch-head+Kibana

Elasticsearch CentOS6.5下安装ElasticSearch6.2.4+elasticsearch-head+Kibana

CentOS6.5下安装ElasticSearch6.2.4
(1)配置JDK环境

配置环境变量

export JAVA_HOME="/opt/jdk1.8.0_144"

export PATH="$JAVA_HOME/bin:$PATH"

export CLASSPATH=".:$JAVA_HOME/lib"

(2)安装ElasticSearch6.2.4

下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-2-4

启动报错:

 

解决方式:


bin/elasticsearch -Des.insecure.allow.root=true


 

或者修改bin/elasticsearch,加上ES_JAVA_OPTS属性:

 


ES_JAVA_OPTS="-Des.insecure.allow.root=true"


 

再次启动:

这是出于系统安全考虑设置的条件。由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考 虑,建议创建一个单独的用户用来运行ElasticSearch。

如果没有普通用户就要创建一个普通用户组和普通用户,下面介绍一下怎么创建用户组和普通用户

创建用户组和用户:

 


groupadd esgroup

useradd esuser -g esgroup -p espassword


 

更改elasticsearch文件夹及内部文件的所属用户及组:

 


cd /opt

chown -R esuser:esgroup elasticsearch-6.2.4


 

切换用户并运行:

su esuser

./bin/elasticsearch

再次启动显示已杀死:

 

需要调整JVM的内存大小:

vi bin/elasticsearch

ES_JAVA_OPTS="-Xms512m -Xmx512m"

再次启动:启动成功

如果显示如下类似信息:

 


[INFO ][o.e.c.r.a.DiskThresholdMonitor] [ZAds5FP] low disk watermark [85%] exceeded on [ZAds5FPeTY-ZUKjXd7HJKA][ZAds5FP][/opt/elasticsearch-6.2.4/data/nodes/0] free: 1.2gb[14.2%], replicas will not be assigned to this node


 

需要清理磁盘空间。

 


后台运行:./bin/elasticsearch -d

测试连接:curl 127.0.0.1:9200


 

会看到一下JSON数据:


[root@localhost ~]# curl 127.0.0.1:9200
{
"name" : "rBrMTNx",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "-noR5DxFRsyvAFvAzxl07g",
"version" : {
"number" : "5.1.1",
"build_hash" : "5395e21",
"build_date" : "2016-12-06T12:36:15.409Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
},
"tagline" : "You Know, for Search"
}



实现远程访问:
需要对config/elasticsearch.yml进行 配置:
network.host: hadoop-001

再次启动报错:Failed to load settings from [elasticsearch.yml]

这个错就是参数的冒号前后没有加空格,加了之后就好,我找了好久这个问题;

后来在一个外国网站找到了这句话.

 

Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ElasticsearchParseException[malformed, expected end of settings but encountered additional content starting at line number: [3], column number: [1]]; nested: ParserException[expected ''<document start>'', but found BlockMappingStart

 in ''reader'', line 3, column 1:

    node.rack : r1

    ^

];

Likely root cause: expected ''<document start>'', but found BlockMappingStart

 in ''reader'', line 3, column 1:

    node.rack : r1

 

这个是行的开头没有加空格,fuck!

Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ScannerException[while scanning a simple key

 in ''reader'', line 11, column 2:

     discovery.zen.ping.unicast.hosts ... 

     ^

 

参数冒号后加空格,或者是数组中间加空格

例如:

# discovery.zen.minimum_master_nodes: 3

 

再次启动

还是报错

max file descriptors [4096] for elasticsearch process is too low

 

处理第一个错误:

vim /etc/security/limits.conf //文件最后加入

esuser soft nofile 65536

esuser hard nofile 65536

esuser soft nproc 4096

esuser hard nproc 4096

 

处理第二个错误:

进入limits.d目录下修改配置文件。

vim /etc/security/limits.d/20-nproc.conf
修改为 esuser soft nproc 4096

 

注意重新登录生效!!!!!!!!

处理第三个错误:

vim /etc/sysctl.conf

vm.max_map_count=655360

执行以下命令生效:
sysctl -p

关闭防火墙:systemctl stop firewalld.service

启动又又又报错

 

system call filters failed to install; check the logs and fix your configuration or disable sys

 

直接在

config/elasticsearch.yml  末尾加上一句


bootstrap.system_call_filter: false

再次启动成功!

 


安装Head插件


Head是elasticsearch的集群管理工具,可以用于数据的浏览和查询

(1)elasticsearch-head是一款开源软件,被托管在github上面,所以如果我们要使用它,必须先安装git,通过git获取elasticsearch-head

(2)运行elasticsearch-head会用到grunt,而grunt需要npm包管理器,所以nodejs是必须要安装的

nodejs和npm安装:

http://blog.java1234.com/blog/articles/354.html

git安装


yum install -y git


 

 

(3)elasticsearch5.0之后,elasticsearch-head不做为插件放在其plugins目录下了。
使用git拷贝elasticsearch-head到本地

cd ~

git clone git://github.com/mobz/elasticsearch-head.git

(4)安装elasticsearch-head依赖包

[root@localhost local]# npm install -g grunt-cli

[root@localhost _site]# cd /usr/local/elasticsearch-head/

[root@localhost elasticsearch-head]# cnpm install

(5)修改Gruntfile.js

[root@localhost _site]# cd /usr/local/elasticsearch-head/

[root@localhost elasticsearch-head]# vi Gruntfile.js

在connect-->server-->options下面添加:hostname:’*’,允许所有IP可以访问

(6)修改elasticsearch-head默认连接地址
[root@localhost elasticsearch-head]# cd /usr/local/elasticsearch-head/_site/

[root@localhost _site]# vi app.js

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

(7)配置elasticsearch允许跨域访问

打开elasticsearch的配置文件elasticsearch.yml,在文件末尾追加下面两行代码即可:

http.cors.enabled: true

http.cors.allow-origin: "*"

(8)打开9100端口

[root@localhost elasticsearch-head]# firewall-cmd --zone=public --add-port=9100/tcp --permanent

重启防火墙

[root@localhost elasticsearch-head]# firewall-cmd --reload

(9)启动elasticsearch

(10)启动elasticsearch-head

 


[root@localhost _site]# cd ~/elasticsearch-head/

[root@localhost elasticsearch-head]# node_modules/grunt/bin/grunt server  或者 npm run start


 

(11)访问elasticsearch-head

关闭防火墙:systemctl stop firewalld.service

浏览器输入网址:hadoop-001:9100/

 

 

安装Kibana
Kibana是一个针对Elasticsearch的开源分析及可视化平台,使用Kibana可以查询、查看并与存储在ES索引的数据进行交互操作,使用Kibana能执行高级的数据分析,并能以图表、表格和地图的形式查看数据

(1)下载Kibana
https://www.elastic.co/downloads/kibana

(2)把下载好的压缩包拷贝到/soft目录下

(3)解压缩,并把解压后的目录移动到/user/local/kibana

(4)编辑kibana配置文件

[root@localhost /]# vi /usr/local/kibana/config/kibana.yml

 

将server.host,elasticsearch.url修改成所在服务器的ip地址

 


 

server.port: 5601 //监听端口

server.host: "hadoo-001" //监听IP地址,建议内网ip

elasticsearch.url: "http:/hadoo-001" //elasticsearch连接kibana的URL,也可以填写192.168.137.188,因为它们是一个集群

 


 

(5)开启5601端口

Kibana的默认端口是5601

开启防火墙:systemctl start firewalld.service

开启5601端口:firewall-cmd --permanent --zone=public --add-port=5601/tcp

重启防火墙:firewall-cmd –reload

(6)启动Kibana

[root@localhost /]# /usr/local/kibana/bin/kibana

浏览器访问:http://192.168.137.188:5601

 

安装中文分词器

一.离线安装

(1)下载中文分词器
https://github.com/medcl/elasticsearch-analysis-ik

下载elasticsearch-analysis-ik-master.zip

(2)解压elasticsearch-analysis-ik-master.zip

unzip elasticsearch-analysis-ik-master.zip

(3)进入elasticsearch-analysis-ik-master,编译源码

mvn clean install -Dmaven.test.skip=true

(4)在es的plugins文件夹下创建目录ik

(5)将编译后生成的elasticsearch-analysis-ik-版本.zip移动到ik下,并解压

(6)解压后的内容移动到ik目录下

二.在线安装

./elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip

Elasticsearch ubuntu 14.04 安装 note to self

Elasticsearch ubuntu 14.04 安装 note to self

jdk版本: jdk-7u51-linux-x64.gz

elasticsearch版本: elasticsearch-1.3.2.deb

安装java环境

重命名为default-java,目录位置 /usr/lib/jvm/,因为es启动脚本在这个位置找java,所以就直接改成这样了

deploy@db01:~$ mv jdk1.7.0_51/ default-java
deploy@db01:~$ sudo mv default-java/ /usr/lib/jvm/

.profile配置, 使deploy 用户部署,添加到deploy下的.profile就可以

export JAVA_HOME=/usr/lib/jvm/default-java
export PATH=$PATH:$JAVA_HOME/bin:~/bin

elasticsearch安装

deploy@db01:~$ sudo dpkg -i elasticsearch-1.3.2.deb
deploy@db01:~$ sudo /etc/init.d/elasticsearch start

添加到默认启动:

deploy@db01:~/es$  sudo update-rc.d elasticsearch defaults 95 10

测试

图片描述

安装head插件,可选

使用root用户安装的,.profile也要配置java

root@db01:/usr/share/elasticsearch# bin/plugin -install mobz/elasticsearch-head

查看地址

http://121.40.85.12:9200/_plugin/head/

分词使用ansj

Notice: 使用最新1.x.1

安装:

./bin/plugin -u http://maven.ansj.org/org/ansj/elasticsearch-analysis-ansj/1.x.1/elasticsearch-analysis-ansj-1.x.1-release.zip -i ansj

配置文件示例

https://gist.github.com/lidashuang/12029bf6525475d722b6''点击预览

重启

deploy@db01:/etc/elasticsearch$ sudo service elasticsearch restart

信息

主目录:  /usr/share/elasticsearch
配置文件: /etc/elasticsearch/elasticsearch$.yml
日志文件:  /var/log/elasticsearch/elasticsearch.log

elasticsearch-Ubuntu-拒绝连接

elasticsearch-Ubuntu-拒绝连接

我已经在Ubuntu 14.04上安装了弹性2.2。我保留了elastic的默认初始设置,并且该实例可从localhost:9200到达该系统的弹性实例。

现在,当我尝试使用服务器的IP / DNS名称通过其他系统通过以下方式进行操作时:

curl -XGET "http://<IP_ADDRESS_UBUNTU_SERVER>:9200"

我收到如下错误:

Failed to connect to <IP_ADDRESS_UBUNTU_SERVER> port 9200: Connection refused

我尝试更改elasticsearch.yml文件中的几个参数并将其设置为:

network.host: 0.0.0.0http.port: 9200

但这并不能解决问题。我设置了与拒绝连接相同的错误。实际上设置上述参数并尝试使用localhost:9200从服务器进行访问也会产生连接超时错误。

现在需要配置什么,以便可以从外部访问此弹性实例?

编辑:我试图将Ubuntu服务器的IP地址设置为network.host,但在日志文件中看到以下错误:

BindTransportException[Failed to bind to [9300-9400]]; nested: ChannelException[Failed to bind to: /10.173.1.176:9400]; nested: BindException[Cannot assign requested address];        at org.elasticsearch.transport.netty.NettyTransport.bindToPort(NettyTransport.java:477)        at org.elasticsearch.transport.netty.NettyTransport.bindServerBootstrap(NettyTransport.java:439)        at org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:320)        at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)        at org.elasticsearch.transport.TransportService.doStart(TransportService.java:170)        at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)        at org.elasticsearch.node.Node.start(Node.java:252)        at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:221)        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:287)        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /10.173.1.176:9400        at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:272)        at org.elasticsearch.transport.netty.NettyTransport$1.onPortNumber(NettyTransport.java:459)        at org.elasticsearch.common.transport.PortsRange.iterate(PortsRange.java:69)        at org.elasticsearch.transport.netty.NettyTransport.bindToPort(NettyTransport.java:455)        ... 9 moreCaused by: java.net.BindException: Cannot assign requested address        at sun.nio.ch.Net.bind0(Native Method)        at sun.nio.ch.Net.bind(Net.java:433)        at sun.nio.ch.Net.bind(Net.java:425)        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)        at org.jboss.netty.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)        at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391)        at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315)        at org.jboss.netty.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42)        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)        at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

答案1

小编典典

这是由于配置文件中的错误引起的。我没有遵守YAML指南,却盲目地遵循弹性帮助文档。

网络和端口必须以YML格式指定,如下所示:

network:  host: 0.0.0.0http:  port: 9200

此后,重新启动弹性服务。如果出现问题,请参考弹性日志文件,并检查实例是否绑定到上述IP和端口9200。您还可以检查侦听IP /端口(netstat -l
-n)。必须有一个像这样的条目:

tcp 0 0 0.0.0.0:9200 0.0.0.0:* LISTEN

希望这对您有所帮助,并祝您搜索愉快。

Elasticsearch作为图像服务器与Apache

Elasticsearch作为图像服务器与Apache

我使用elasticsearch查询股票报价。我的浏览器调用了弹性簇,该簇返回<img>标签内的URL列表。然后,浏览器调用图像(相关报价的股票图表)。这些图像位于单独的Apache
2 http服务器上。这两台服务器都是相同的Centos四核2.0Ghz,16GB RAM,1Tb HD。

通过阅读以前的SO帖子,似乎可以在Elasticsearch中存储base64图像。

有没有人在elasticsearch中创建过生产图像服务器,或者将基准与静态Web服务器进行了比较?就我而言,图像为80到150 kb

我的具体问题是(1)将文档映射中的图像作为二进制和弹性回复base64图像而不是<img>标签,然后再调用Apache
会更快吗?(2)Elasticsearch作为图像服务器是否可以与静态Nginx或Apache图像服务器媲美?

答案1

小编典典

Elasticsearch是一个 搜索引擎 (除其他外),擅长为您的数据提供快速搜索。它 不是内容服务器

我将图像存储在ES中的唯一原因是是否需要搜索类似图像。对于您的情况,您似乎愿意使用Elasticsearch作为内容服务器来检索图像,最好将其存储在内容传送网络(CDN)中,就像现在使用第二个Apache服务器一样。

但实际上,如果您有少量的股票报价文件,即没有数百万个,则可以在ES中将图像的base64存储在ES中。

最好的办法是始终尝试一下,看看集群如何处理它。也许对于您的特定用例来说完全可以。只是您将在ES上增加额外的负载,这并不是要一开始就处理的。

例如,如果您返回十个结果,您的响应将从几KB增长到至少1
MB,并且您的用户将需要等待该传输完成才能看到一些结果,而如果您将图像存储在其他位置,您至少可以非常快速地向用户显示结果,并让浏览器以异步方式处理图像检索,而无需关心它。

关于无法在Ubuntu上将ElasticSearch作为服务运行ubuntu无法安装essential的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于Elasticsearch CentOS6.5下安装ElasticSearch6.2.4+elasticsearch-head+Kibana、Elasticsearch ubuntu 14.04 安装 note to self、elasticsearch-Ubuntu-拒绝连接、Elasticsearch作为图像服务器与Apache的相关知识,请在本站寻找。

本文标签: