一安装,

在你可以从 elasticsearch.org\/download 下载最新版本的Elasticsearch。tar文件。

一、用户设置

如果已经是普通用户登录可跳过此步骤。

ElasticSearch默认是不能使用root用户进行启动的,所以需要先添加一个普通用户,并使用普通用户身份安装ElasticSearch。

1.添加一个用户,无任何提示则表示成功添加。

[root@localhost soft]# adduser king

2.设置用户密码,需要输入两次。其中提示无效的密码可以不用管,是因为密码太简单,不符合安全要求。

[root@localhost soft]# passwd king
更改用户 king 的密码 。
新的 密码:
无效的密码: 过于简单化/系统化
无效的密码: 过于简单
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。

3.在根目录下创建一个文件夹soft,并将拥有者更改为king,使用ls -al /soft命令查看此时/soft文件夹的拥有者。

[root@localhost /]# mkdir /soft
[root@localhost /]# chown king /soft
[root@localhost /]# ls -al /soft
drwxr-xr-x. 2 king root 4096 9月 3 01:58 .
dr-xr-xr-x. 26 root root 4096 9月 3 01:58 ..

一个点代表当前目录,两个点代表上级目录,可以看到当前目录的拥有者已经是king了。

二、安装jdk1.8

如果已经安装jdk1.8可跳过此步骤

ElasticSearch是基于Java开发的,所以要先安装jdk环境。

1.使用yum安装openjdk1.8,使用yum search jdk1.8搜索安装包

[root@localhost elasticsearch-5.5.2]$ yum search jdk
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
# 会有很多版本的jdk,只展示我们要安装的这个版本

2.安装openjdk1.8

[root@localhost ~]# yum install java-1.8.0-openjdk.x86_64

安装完成后输入java命令,有相应输出就说明安装成功了。

3.至此之前,我们都是使用root身份来操作的,下面使用如下命令切换到king用户。

[root@localhost /]# su king
[king@localhost /]$ cd /soft
[king@localhost soft]$

这时就以king用户身份登录了,我们使用cd命令进入/soft目录,然后进行接下来的操作。

三、下载ElasticSearch并安装

1.首先到官网下载最新版本的ElasticSearch的zip压缩包,也可以复制下载地址在终端中使用wget命令直接下载到CentOS中。例如在终端中执行以下命令:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.0.tar.gz

下载过程可能比较慢,可以使用自己电脑下载后使用ftp工具上传到/soft目录。

2.下载完成后,解压elasticsearch-6.0.0.tar.gz

tar -vxf elasticsearch-6.0.0.tar.gz

解压完成后内容如下

[king@localhost soft]$ ls
elasticsearch-6.0.0  elasticsearch-6.0.0.tar.gz

3.进入elasticsearch-5.5.2,并启动elasticsearch

[king@localhost soft]$ cd elasticsearch-6.0.0
[king@localhost elasticsearch-6.0.0]$ sh ./bin/elasticsearch
## 会有一堆日志输出,还报了一个异常java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ ...不过这个异常不影响启动,是因为我们的内核版本太低了,新版本系统应该没这个问题。

4.让启动不提示这个异常可以在config/elasticsearch.yml添加如下两行内容,其中:号后面要加上一个空格,因为这是yaml文件的格式要求,yaml是一种新的属性文件的写法,更简洁,不懂的可以自行查查。

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

5..这时重新启动,不会提示任何错误了。新打开一个窗口,输入curl localhost:9200,如果有以下输出则说明启动成功。

[king@localhost ~]$ curl localhost:9200
{
"name" : "ZGws7ZX",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "yeYDTLbNQ--rmDXMi2xO-g",
"version" : {
"number" : "5.5.2",
"build_hash" : "b2f0c09",
"build_date" : "2017-08-14T12:33:14.154Z",
"build_snapshot" : false,
"lucene_version" : "6.6.0"
},
"tagline" : "You Know, for Search"
}

6.在centos6下面启动Elasticsearch的时候提示如下错误:

unable to load JNA native support library, native methods will be disabled.
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/linux-x86/libjnidispatch.so) not found

详细错误:

flying-bird@flyingbird:~/elk$ ./elasticsearch-5.5.2/bin/elasticsearch -p my_cluster/node1_pid -Epath.conf=./my_cluster/node1/config
[2017-08-28T20:39:04,823][WARN ][o.e.b.Natives ] unable to load JNA native support library, native methods will be disabled.
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/linux-x86/libjnidispatch.so) not found in resource path (...)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:962) ~[jna-4.4.0.jar:4.4.0 (b0)]
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:922) ~[jna-4.4.0.jar:4.4.0 (b0)]
at com.sun.jna.Native.<clinit>(Native.java:190) ~[jna-4.4.0.jar:4.4.0 (b0)]
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_05]
at java.lang.Class.forName(Class.java:259) ~[?:1.8.0_05]
at org.elasticsearch.bootstrap.Natives.<clinit>(Natives.java:45) [elasticsearch-5.5.2.jar:5.5.2]
...
[2017-08-28T20:39:04,829][WARN ][o.e.b.Natives ] cannot check if running as root because JNA is not available
[2017-08-28T20:39:04,829][WARN ][o.e.b.Natives ] cannot install system call filter because JNA is not available
[2017-08-28T20:39:04,830][WARN ][o.e.b.Natives ] cannot register console handler because JNA is not available
[2017-08-28T20:39:04,832][WARN ][o.e.b.Natives ] cannot getrlimit RLIMIT_NPROC because JNA is not available
[2017-08-28T20:39:04,832][WARN ][o.e.b.Natives ] cannot getrlimit RLIMIT_AS beacuse JNA is not available
[2017-08-28T20:39:04,992][INFO ][o.e.n.Node ] [node1] initializing ...

centos6环境

解决办法

附 其他尝试

https://github.com/java-native-access/jna下载jna-jna-5.0.0.zip,使用jna-jna-5.0.0/dist/linux-x86.jar 
和jna-jna-5.0.0/lib/native/linux-x86.jar,均不可用。

最后比较前面wget的文件,和jna-jna-5.0.0中所有的jar,发现这个文件和dist/jna.jar完全一样。

四、CentOS下RPM安装ElasticSearch

二、下载ElasticSearch

cd /data/software/
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.3.2/elasticsearch-2.3.2.rpm

三、安装ElasticSearch

rpm -ivh elasticsearch-2.3.2.rpm

四、设置开机自启动

service elasticsearch start
chkconfig elasticsearch on

五、注意:

rpm安装后,执行错误会放在log文件中,屏幕不输出,一般在/var/log/elasticsearch

五、外网访问设置

细心的同学也许发现第一章验证是用的“localhost:9200”,如果换成“IP:9200”,则浏览器与curl都无法进行访问,那么如何让外网访问呢?网上查了一下,需要修改config目录下elasticsearch.yml文件,修改network.host为“0.0.0.0”,然后进行启动成功,外网就可以访问啦。但是很遗憾,在我的机器还出现了其他错误,具体如下所示:

通过上面的错误信息,想到需要修改config目录下elasticsearch.yml文件,修改discovery.zen.ping.unicast.hosts为“[“0.0.0.0”]”,然后再次启动,发现没有报错信息(注意防火墙对于端口的限制),同时远程浏览器访问也正常,如下图所示:

1、错误

linux下启动报错BindTransportException[Failed to bind to [9300-9400]解决办法

Exception in thread "main" BindTransportException[Failed to bind to [9300-9400]]; nested: ChannelException[Failed to bind to: /192.168.0.1:9400]; nested: BindException[Cannot assign requested address];
Likely root cause: 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)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

打开配置文件elasticsearch.yml 将 network.host: 192.168.0.1 修改为本机IP 0.0.0.0

通过root用户启动elasticsearch并且在后台运行

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

启动elasticsearch 报如下错误:

[2017-05-10T10:04:50,648][WARN ][o.e.b.JNANatives         ] unable to install syscall filter:

java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed

at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:363) ~[elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:638) ~[elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:215) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:99) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:204) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:360) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:58) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.cli.Command.main(Command.java:88) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.3.2.jar:5.3.2]

解决方法:

修改elasticsearch.yml 添加一下内容

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

问题一:警告提示

[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_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
at org.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版本,就不会出现此类问题了。

问题二:ERROR: bootstrap checks failed

max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]

解决:切换到root用户,编辑limits.conf 添加类似如下内容

vi /etc/security/limits.conf

添加如下内容:

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

问题三:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]

解决:切换到root用户,进入limits.d目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 2048

问题四: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

问题五:max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

解决:修改切换到root用户修改配置limits.conf 添加下面两行

命令:vi /etc/security/limits.conf

*        hard    nofile           65536
*        soft    nofile           65536
切换到es的用户。

然后,重新启动elasticsearch,即可启动成功。

六、后台运行

最后还有一个小问题,如果你在服务器上安装Elasticsearch,而你想在本地机器上进行开发,这时候,你很可能需要在关闭终端的时候,让Elasticsearch继续保持运行。最简单的方法就是使用nohup。先按Ctrl + C,停止当前运行的Elasticsearch,改用下面的命令运行Elasticsearch

nohup./bin/elasticsearch&

这样,你就可以放心地关闭服务器终端,而不用担心Elasticsearch也跟着关闭了。

Elasticsearch在centos6中的安装的更多相关文章

  1. 在centos6中编译安装httpd-2.4/搭建LAMP

    首先确保centos6安装平台安装一下环境: #yum groupinstall "Development  Tools" "Server Platform Develo ...

  2. ElasticSearch之Windows中环境安装

    ElasticSearch 说明 本章,我们主要以在 Windows 中对ElasticSearch 安装进行介绍! 1. 下载 ElasticSearch 这里我们下载的版本为7.17.4为例进行介 ...

  3. 分布式搜索引擎Elasticsearch在CentOS7中的安装

    1. 概述 随着企业业务量的不断增大,业务数据随之增加,传统的基于关系型数据库的搜索已经不能满足需要. 在关系型数据库中搜索,只能支持简单的关键字搜索,做不到分词和统计的功能,而且当单表数据量到达上百 ...

  4. ElasticSearch(二)CentOs6.4下安装ElasticSearch

    一.准备工作 Elastic 需要 Java 8 环境.如果你的机器还没安装 Java,先需要安装java环境,同时还注意要保证环境变量JAVA_HOME正确设置. 链接:https://pan.ba ...

  5. centos6中安装新版 Elasticsearch 7.x

    es出新版了,虽然公司里还是用的老版本,但是本地还是有必要自己安装了玩玩 下载地址:https://www.elastic.co/cn/downloads/elasticsearch 那么一般来说还是 ...

  6. CentOS-6.4-minimal版中源代码安装MySQL-5.5.38

    完整版见https://jadyer.github.io/2014/09/29/centos-install-mysql/ /** * CentOS-6.4-minimal版中源代码安装MySQL-5 ...

  7. Apache源码包在LINUX(CENTOS6.8)中的安装(出现问题及解决)

    任务:在CENT6.8系统中安装Apache(版本为:httpd-2.4.41) 前提:由于源码包必须先编译后安装,所以必须先安装编译器:gcc 理论步骤: 1.检测gcc软件包,如果不存在则进行安装 ...

  8. CentOS6.5 mini安装到VirtualBox虚拟机中

    下载Oracle VM VirtualBox 下载下来安装 下载镜像 http://archive.kernel.org/centos-vault/6.5/isos/i386/CentOS-6.5-i ...

  9. 桌面图形化安装的CentOS6.7中默认安装的yum不能正常使用

    使用rpm -qa|grep yum,可以发现有好多关于yum的安装插件等东西... 从里面将的一些东西删除掉,只留下下面三个即可,其余的全部删除掉rpm -e yum-plugin-security ...

随机推荐

  1. win10 nodejs指定ionic版本安装(npm方式)

    步骤1 node-v6.11.3-x64.msi 下载安装node-v6.11.3-x64.msi, 安装完成后利用cmd通过npm安装 ionic cordova cmd npm install - ...

  2. Disruptor学习笔记(一):基本原理和概念

    一.Disruptor基本原理 在多线程开发中,我们常常遇到这样一种场景:一些线程接受用户请求,另外一些线程处理这些请求.比如日志处理中的日志输入和告警.这种典型的生产者消费者场景十分常见,而生产者消 ...

  3. Codeforces 788A Functions again - 贪心

    Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian super ...

  4. Problem F: 等式

    Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 104  Solved: 22[Submit][Status][Web Board] Descriptio ...

  5. Go第三篇之大话容器

    Go语言数组 数组(Array)是一段固定长度的连续内存区域 在 Go 语言中,数组从声明时就确定,使用时可以修改数组成员,但是数组大小不可变化 Go 语言数组的声明 数组的写法如下: var 数组变 ...

  6. git如何生成指定两个commit之间的补丁

    答:git format-patch <base commit id>..<latest commit id> 如git log输出以下内容: commit 2222222 y ...

  7. 客户端向服务端请求连接是出现"ssh : Connection refused"原因有哪些

    注意:服务端的sshd服务已经正常开启 (可以正常进行连接) 1.在服务端负载比较高的情况下客户端请求连接时会出现连接被拒绝的情况

  8. junit中test注解测试使用案列解析一

    本文原创,转载请注明出处 在写代码的过程中,只想测试部分代码,调试一小段功能有没有通的情况下,可以用该方法: 以下为在项目中测试一个小功能的案例,在此记录一下, /**     * <解析查询磁 ...

  9. 【TCP/IP详解 卷一:协议】TCP定时器 小结

    前言 在有关TCP的章节中,介绍了四种定时器,它们体现了TCP的可靠性,其中最重要的 就是重传定时器了,剩下的定时器都是为了解决TCP的理解上的一些问题而设置的. 四种定时器: 2MSL定时器,出现在 ...

  10. Linux-Ubuntu14.04下mongodb安装部署

    mongo 下载:https://www.mongodb.com/download-center/community?jmp=nav 创建目录,将下载的文件放在如下位置 xxx@ubuntu:/usr ...