Centos6.5 (或Linux) 安装Elasticsearch
2017-09-28 19:37
531 查看
一、可以在网上下载对饮的版本:https://github.com/elastic/elasticsearch,本次安装的是5.5.3。
首先保证虚拟机上安装了jdk,jdk的版本只是是1.7或以上
查看本地虚拟机是否已经安装了jdk:yum list installed java*; (yum list install java* 查看库中可以安装的软件),然后用yum 命令安装 yum install java-1.8.0-openjdk* ,用yum命令安装的好处就是不用配置path。感兴趣的可以用安装包安装。
二、将下载的.tar.gz解压,然后进入elasticsearch-5.5.3/config/目录下配置elasticsearch.yml。
三、因为我先暂时配的是单节点,所有就采用默认的方式,如果想自定义,将#号去掉就行。
如果elasticsearch启动报错,这里需要修改,具体问后面再贴出
注意如果不修network.host,默认使用的是localhost,如http://localhost:9200,9200是elasticsearch的默认端口,如果想通过外网访问,则需要将network.host 设置成 0.0.0.0或者部署该elasticsearch服务器的ip地址。
这个跟集群节点布置有关系,如果同一台服务器布置了多个节点,则需要修改 http.port,如 http.port:9201, transport.tcp.port:9301。
四、启动 elasticsearch.
五、出现的问题:
1、
[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter:
Java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMPandCONFIG_SECCOMP_FILTERcompiledinatorg.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]
原因:报了一大串错误,大家不必惊慌,其实只是一个警告,主要是因为你Linux版本过低造成的。
解决方案:
1)、重新安装新版本的Linux系统
2)、警告不影响使用,可以忽略。选择了忽略,装个系统就回到原点了。
2、
ERROR: bootstrap checks failed。
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
原因:无法创建本地文件问题,用户最大可创建文件数太小
解决方案:
切换到root用户,编辑limits.conf配置文件, 添加类似如下内容:
vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
备注:* 代表Linux所有用户名称(比如 hadoop)
保存、退出、重新登录才可生效,ulimit -a可以看到文件打开数已经是65536了
3、
max number of threads [1024] for user [es] likely too low, increase to at least [2048]
原因:无法创建本地线程问题,用户最大可创建线程数太小
解决方案:切换到root用户,进入limits.d目录下,修改90-nproc.conf 配置文件。
vi /etc/security/limits.d/90-nproc.conf
找到如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048
4、
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
原因:最大虚拟内存太小
解决方案:切换到root用户下,修改配置文件sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后重新启动elasticsearch,即可启动成功。
5、
ElasticSearch启动找不到主机或路由
原因:ElasticSearch 单播配置有问题
解决方案:
检查ElasticSearch中的配置文件
vi config/elasticsearch.yml
找到如下配置:
discovery.zen.ping.unicast.hosts:["192.168.**.**:9300","192.168.**.**:9300"]
一般情况下,是这里配置有问题,注意书写格式
6、
bin/elasticsearch-plugin install license
ERROR: Unknown plugin license
原因:ElasticSearch5.0.0以后插件命令已经改变
解决方案:使用最新命令安装所有插件
bin/elasticsearch-plugin install x-pack
7、
ERROR: bootstrap checks failed。system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
8、
head主控页面是可以显示的,但是显示连接失败,或者在url无法外网访问。在elasticsearch 中的elasticsearch.yml中添加以下属性。
Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources ,即跨域访问。这个字段默认为false,在Elasticsearch安装集群之外的一台机上用Sense、Head等监控插件访问Elasticsearch是不允许的。这个字段最早可以追溯到1.4.x版本,而非5.x特有。具体这个http.cors.x字段还有哪些用途和用法:
http.cors.enabled --------- (是否支持跨域,默认为false 。一般设置这两个参数就可以实现跨域:http.cors.enabled : true, http.cors.allow-origin : " *" )
http.cors.allow-origin --------- (当设置允许跨域,默认为*,表示支持所有域名,如果我们只是允许某些网站能访问,那么可以使用正则表达式。比如只允许本地地址。 /https?:\/\/localhost(:[0-9]+)?/)
http.cors.max-age --------- (浏览器发送一个“预检”OPTIONS请求,以确定CORS设置。最大年龄定义多久的结果应该缓存。默认为1728000(20天))
http.cors.allow-methods --------- (允许跨域的请求方式,默认OPTIONS,HEAD,GET,POST,PUT,DELETE)
http.cors.allow-headers --------- (跨域允许设置的头信息,默认为X-Requested-With,Content-Type,Content-Length)
http.cors.allow-credentials --------- (是否返回设置的跨域Access-Control-Allow-Credentials头,如果设置为true,那么会返回给客户端)
六、Elasticsearch 安装插件:
1、head插件安装:
进入 /ES_HOME/elasticsearch/ 路径,在2.0版本以前用一下命令:
2.0以上版本安装:
首先 安装nodejs,npm环境。(安装es-head依赖node npm)
如果yum命令不能安装,则下载nodejs编译后的源码安装。如v5.10版:
https://nodejs.org/dist/v5.10.1/
红色部分是编译好的源码,直接解压就行
简单说就是解压后,在bin文件夹中已经存在node以及npm,如果你进入到对应文件的中执行命令行一点问题都没有,不过不是全局的,所以通过建立软链接的方式将这个设置为全局就好了
然后,就是下在elasticsearch-head
最后,在url中输入:http://localhost:9100/ 就可以看到界面了。
[Reference] https://github.com/mobz/elasticsearch-head
5.0以上的版本,head作为独立服务安装
for Elasticsearch 5.x: site plugins are not supported. Run as a standalone server
安装成功后可以查看效果:
2、ik分词安装:
下一节有专门讲述
【Reference】
[1] http://blog.csdn.net/sinat_28224453/article/details/51134978
[2] http://www.dajiangtai.com/community/18136.do?origin=csdn-geek&dt=1214
[3] http://www.cnblogs.com/ShawnYuki/p/6818677.html
首先保证虚拟机上安装了jdk,jdk的版本只是是1.7或以上
查看本地虚拟机是否已经安装了jdk:yum list installed java*; (yum list install java* 查看库中可以安装的软件),然后用yum 命令安装 yum install java-1.8.0-openjdk* ,用yum命令安装的好处就是不用配置path。感兴趣的可以用安装包安装。
[root@localhost elasticsearch]# ls elasticsearch-5.5.3 elasticsearch-analysis-ik-5.5.3 elasticsearch-5.5.3.tar.gz elasticsearch-analysis-ik-5.5.3.zip
二、将下载的.tar.gz解压,然后进入elasticsearch-5.5.3/config/目录下配置elasticsearch.yml。
三、因为我先暂时配的是单节点,所有就采用默认的方式,如果想自定义,将#号去掉就行。
# ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # #cluster.name: my-application # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # #node.name: node-1 # # Add custom attributes to the node:
如果elasticsearch启动报错,这里需要修改,具体问后面再贴出
#bootstrap.memory_lock: true bootstrap.memory_lock: false 3 bootstrap.system_call_filter: false # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # #network.host: 192.168.0.1 network.host: 0.0.0.0
注意如果不修network.host,默认使用的是localhost,如http://localhost:9200,9200是elasticsearch的默认端口,如果想通过外网访问,则需要将network.host 设置成 0.0.0.0或者部署该elasticsearch服务器的ip地址。
# Set a custom port for HTTP: # #http.port: 9200 4 #transport.tcp.port:9301
这个跟集群节点布置有关系,如果同一台服务器布置了多个节点,则需要修改 http.port,如 http.port:9201, transport.tcp.port:9301。
四、启动 elasticsearch.
[hoojjack@localhost elasticsearch-5.5.3]$ bin/elasticsearch [2017-09-29T10:48:15,620][INFO ][o.e.n.Node ] [] initializing ... ......
五、出现的问题:
1、
[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter:
Java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMPandCONFIG_SECCOMP_FILTERcompiledinatorg.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]
原因:报了一大串错误,大家不必惊慌,其实只是一个警告,主要是因为你Linux版本过低造成的。
解决方案:
1)、重新安装新版本的Linux系统
2)、警告不影响使用,可以忽略。选择了忽略,装个系统就回到原点了。
2、
ERROR: bootstrap checks failed。
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
原因:无法创建本地文件问题,用户最大可创建文件数太小
解决方案:
切换到root用户,编辑limits.conf配置文件, 添加类似如下内容:
vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
备注:* 代表Linux所有用户名称(比如 hadoop)
保存、退出、重新登录才可生效,ulimit -a可以看到文件打开数已经是65536了
3、
max number of threads [1024] for user [es] likely too low, increase to at least [2048]
原因:无法创建本地线程问题,用户最大可创建线程数太小
解决方案:切换到root用户,进入limits.d目录下,修改90-nproc.conf 配置文件。
vi /etc/security/limits.d/90-nproc.conf
找到如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048
4、
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
原因:最大虚拟内存太小
解决方案:切换到root用户下,修改配置文件sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后重新启动elasticsearch,即可启动成功。
5、
ElasticSearch启动找不到主机或路由
原因:ElasticSearch 单播配置有问题
解决方案:
检查ElasticSearch中的配置文件
vi config/elasticsearch.yml
找到如下配置:
discovery.zen.ping.unicast.hosts:["192.168.**.**:9300","192.168.**.**:9300"]
一般情况下,是这里配置有问题,注意书写格式
6、
bin/elasticsearch-plugin install license
ERROR: Unknown plugin license
原因:ElasticSearch5.0.0以后插件命令已经改变
解决方案:使用最新命令安装所有插件
bin/elasticsearch-plugin install x-pack
7、
ERROR: bootstrap checks failed。system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
8、
head主控页面是可以显示的,但是显示连接失败,或者在url无法外网访问。在elasticsearch 中的elasticsearch.yml中添加以下属性。
Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources ,即跨域访问。这个字段默认为false,在Elasticsearch安装集群之外的一台机上用Sense、Head等监控插件访问Elasticsearch是不允许的。这个字段最早可以追溯到1.4.x版本,而非5.x特有。具体这个http.cors.x字段还有哪些用途和用法:
http.cors.enabled --------- (是否支持跨域,默认为false 。一般设置这两个参数就可以实现跨域:http.cors.enabled : true, http.cors.allow-origin : " *" )
http.cors.allow-origin --------- (当设置允许跨域,默认为*,表示支持所有域名,如果我们只是允许某些网站能访问,那么可以使用正则表达式。比如只允许本地地址。 /https?:\/\/localhost(:[0-9]+)?/)
http.cors.max-age --------- (浏览器发送一个“预检”OPTIONS请求,以确定CORS设置。最大年龄定义多久的结果应该缓存。默认为1728000(20天))
http.cors.allow-methods --------- (允许跨域的请求方式,默认OPTIONS,HEAD,GET,POST,PUT,DELETE)
http.cors.allow-headers --------- (跨域允许设置的头信息,默认为X-Requested-With,Content-Type,Content-Length)
http.cors.allow-credentials --------- (是否返回设置的跨域Access-Control-Allow-Credentials头,如果设置为true,那么会返回给客户端)
六、Elasticsearch 安装插件:
1、head插件安装:
进入 /ES_HOME/elasticsearch/ 路径,在2.0版本以前用一下命令:
[root@localhost bin]# ./plugin install mobz/elasticsearch-head -> Installing mobz/elasticsearch-head... Trying https://github.com/mobz/elasticsearch-head/archive/master.zip... Downloading ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................DONE Installed mobz/elasticsearch-head into /opt/elasticsearch-1.4.2/plugins/head
2.0以上版本安装:
首先 安装nodejs,npm环境。(安装es-head依赖node npm)
yum -y install nodejs npm node -v npm -v
如果yum命令不能安装,则下载nodejs编译后的源码安装。如v5.10版:
https://nodejs.org/dist/v5.10.1/
红色部分是编译好的源码,直接解压就行
tar -xzvf node-v5.10.1-linux-x64.tar.gz -C /opt/hoojjack/ cd /opt/hoojjack/ mv node-v5.10.1-linux-x64/ nodejs 4 ln -s /opt/hoojjack/nodejs/bin/node /usr/local/bin 5 ln -s /opt/hoojjack/nodejs/bin/npm /usr/local/bin
简单说就是解压后,在bin文件夹中已经存在node以及npm,如果你进入到对应文件的中执行命令行一点问题都没有,不过不是全局的,所以通过建立软链接的方式将这个设置为全局就好了
然后,就是下在elasticsearch-head
git clone git://github.com/mobz/elasticsearch-head.git cd elasticsearch-head npm install npm run start
最后,在url中输入:http://localhost:9100/ 就可以看到界面了。
[Reference] https://github.com/mobz/elasticsearch-head
5.0以上的版本,head作为独立服务安装
for Elasticsearch 5.x: site plugins are not supported. Run as a standalone server
安装成功后可以查看效果:
2、ik分词安装:
下一节有专门讲述
【Reference】
[1] http://blog.csdn.net/sinat_28224453/article/details/51134978
[2] http://www.dajiangtai.com/community/18136.do?origin=csdn-geek&dt=1214
[3] http://www.cnblogs.com/ShawnYuki/p/6818677.html
相关文章推荐
- linux VMware安装 CentOS6.5 教程
- PXE 安装Linux 网络 自动安装 CentOS6.5 Linux
- Linux(CentOS6.5)下编译Popt报错”GNU gettext is required. The latest version”(gettext已经编译安装,但是没有安装在默认目录)的解决方案
- Linux(centOS6.5)下SVN的安装、配置及开机启动
- 虚拟机 CentOS 6.5 安装搭建 Elasticsearch 6.2.2
- Linux虚机centos6.5安装Vmware Tools步骤
- linux 下安装nodejs,CentOS 6.5 系统
- Linux(centos7.2/6.5)安装oracle12c
- Linux中Python安装与配置(CentOS-6.5:Python-2.7.6)
- Linux(centos6.5)下安装jenkins
- CentOS 6.5结合busybox完成自制Linux系统及远程登录和nginx安装测试
- VM安装Linux(CentOS6.5)及JDK+Tomcat+ MySQL-5.7
- linux(CentOS6.5)下安装Mysql5.6教程
- Hadoop-2.7.2在Linux(centos6.5)上安装配置
- Linux(CentOS6.5)下编译安装Nginx官方最新稳定版(nginx-1.10.0)
- Linux(centOS6.5)下SVN的安装、配置及开机启动
- Centos6.5 linux下安装Redis3.2.9
- [Linux]在CentOS 6.5上安装MySQL
- Linux(CentOS 6.5) 下Nginx 安装
- Linux(CentOS-6.5)安装配置SVN