GVKun编程网logo

centos 编译安装 elasticsearch(centos 编译安装)

20

在这篇文章中,我们将带领您了解centos编译安装elasticsearch的全貌,包括centos编译安装的相关情况。同时,我们还将为您介绍有关(centos7)安装elasticsearch6.4

在这篇文章中,我们将带领您了解centos 编译安装 elasticsearch的全貌,包括centos 编译安装的相关情况。同时,我们还将为您介绍有关(centos7)安装elasticsearch6.4.2、CentOS 5.6 安装 Elasticsearch 5.0、centos 6.5 elasticsearch 5.1 安装、CentOS 6.7 安装ElasticSearch2.0.0的知识,以帮助您更好地理解这个主题。

本文目录一览:

centos 编译安装 elasticsearch(centos 编译安装)

centos 编译安装 elasticsearch(centos 编译安装)

1. 编译安装

引用: https://www.cnblogs.com/liuxiaoming123/p/8126330.html

引用: https://blog.csdn.net/gan_ke/article/details/79553131

2. 外网访问

引用: https://blog.csdn.net/buzaiqq/article/details/67637731

3. 虚拟内存过小

引用: https://blog.csdn.net/qq_21387171/article/details/53577115

引用: https://blog.csdn.net/jiankunking/article/details/65448030

(centos7)安装elasticsearch6.4.2

(centos7)安装elasticsearch6.4.2

(centos7)安装elasticsearch6.4.2

环境

centos7 虚拟机

java 1.8

步骤

  1. 下载
    https://www.elastic.co/downloads/elasticsearch

  2. 解压安装
    解压后,移动到 /usr/local/elasticsearch (个人习惯)

  3. 修改配置
    /usr/local/elaticsearch/configelasticsearch.yml 文件中 可配置 访问权限,默认是只能在本机访问,其他机子都不能访问,就算开了防火墙都不行,里面可配置 port 默认是 9200。 如果只有本地可以访问,尝试修改配置文件 elasticsearch.yml 中network.host(注意配置文件格式不是以 # 开头的要空一格, : 后要空一格)
    network.host: 0.0.0.0

  4. 启动服务
    我的虚拟机报了一系列的错误,首先是,默认不允许使用root用户去启动,这个你可以有两种解决办法:1. 老实用其他非root 用户去启动es 2.修改配置,是其能使用root 启动
    其中错误的问题,详细的错误问题,可以查看这篇博客https://www.jianshu.com/p/4c6f9361565b
    基本上解决了我的问题。

    根据上面的博文,总结一下解决办法。
    ERROR: bootstrap checks failed

    1. vi /etc/security/limits.conf 
      添加如下内容:
       soft nofile 65536
       hard nofile 131072
       soft nproc 2048
       hard nproc 4096
      
    2. vi /etc/security/limits.d/90-nproc.conf 
      修改文件内容为
      soft nproc 2048
      
    3. vi /etc/sysctl.conf 
      添加下面配置:
      vm.max_map_count=655360
      
    4. 执行 sysctl -p

    5. 重启es

    max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]

    1. 执行下面命令

      ulimit -n 65536
      

参考文献

https://www.jianshu.com/p/4c6f9361565b

本文同步分享在 博客"suveng"(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

CentOS 5.6 安装 Elasticsearch 5.0

CentOS 5.6 安装 Elasticsearch 5.0

0. 操作系统:CentOS release 5.6 i686 athlon i386 GNU/Linux

1. 安装 java jdk1.8 (参考:Centos 6.5 安装java及设置默认jdk版本)
2. 下载安装包:elasticsearch-5.0.0.tar.zip


注:此为虚拟机测试,以下系统资源配置会较低。


解压文件

# tar zxvf elasticsearch-5.0.0.tar.gz
# mv elasticsearch-5.0.0 /usr/local/elasticsearch
# mkdir -p /usr/local/elasticsearch/{data,logs}

配置 es 参数文件 (Important Elasticsearch configuration)
# vi /usr/local/elasticsearch/config/elasticsearch.yml
# 注意冒号后有空格
http.port: 9200
node.name: node-1
cluster.name: es_cluster
network.host: 192.168.1.222
bootstrap.memory_lock: false
path.data: /usr/local/elasticsearch/data
path.logs: /usr/local/elasticsearch/logs

配置足够内存 (Set JVM heap size via jvm.options)
# vi /usr/local/elasticsearch/config/jvm.options
-xms512M
-Xmx512M

配置环境变量
# vi /etc/profile  
export ES_HOME=/usr/local/elasticsearch
 
# source /etc/profile

添加独立用户,并启动服务
# groupadd elsearch
# useradd elsearch -g elsearch
# chown -R elsearch:elsearch /usr/local/elasticsearch
# su elsearch
# cd /usr/local/elasticsearch/bin
# ./elasticsearch

可能错误(一)
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 [elsearch] likely too low,increase to at least [2048]
max virtual memory areas vm.max_map_count [65530] likely too low,increase to at least [262144]


解决:修改配置
# https://www.elastic.co/guide/en/elasticsearch/reference/master/setting-system-settings.html

# vi /etc/security/limits.conf		#永久设置
elsearch               soft    nofile           65536
elsearch               hard    nofile           65536
elsearch               soft    nproc            2048
elsearch               hard    nproc            2048

# ulimit -n 65536			#临时设置,重启无效
# ulimit -u 2048
# ulimit -a

# vi /etc/sysctl.conf			#永久设置
vm.max_map_count=262144

# sysctl -w vm.max_map_count=262144	#临时设置,重启无效
# sysctl -a | grep "vm.max_map_count"

可能错误(二)
Java HotSpot(TM) Server VM warning: INFO: os::commit_memory(0xcc000000,469762048,0) Failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) Failed to map 469762048 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/elasticsearch/bin/hs_err_pid7598.log


解决:修改足够的内存

# vi /usr/local/elasticsearch/config/jvm.options
-xms512M
-Xmx512M

# vi /usr/local/elasticsearch/bin/elasticsearch
# ES_JAVA_OPTS="-xms512m -Xmx512m" $ES_HOME/bin/elasticsearch

正常启动服务状态
[2017-01-07T12:18:21,508][INFO ][o.e.n.Node               ] [node-1] initializing ...
[2017-01-07T12:18:21,814][INFO ][o.e.e.nodeenvironment    ] [node-1] using [1] data paths,mounts [[/ (/dev/sda2)]],net usable_space [11gb],net total_space [17.7gb],spins? [possibly],types [ext3]
[2017-01-07T12:18:21,816][INFO ][o.e.e.nodeenvironment    ] [node-1] heap size [505.6mb],compressed ordinary object pointers [unkNown]
[2017-01-07T12:18:21,849][INFO ][o.e.n.Node               ] [node-1] version[5.0.0],pid[16529],build[253032b/2016-10-26T04:37:51.531Z],OS[Linux/2.6.18-238.el5/i386],JVM[Oracle Corporation/Java HotSpot(TM) Server VM/1.8.0_111/25.111-b14]
[2017-01-07T12:18:30,971][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-expression]
[2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-groovy]
[2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2017-01-07T12:18:30,974][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2017-01-07T12:18:30,974][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty3]
[2017-01-07T12:18:30,975][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2017-01-07T12:18:30,976][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2017-01-07T12:18:55,728][INFO ][o.e.n.Node               ] [node-1] initialized
[2017-01-07T12:18:55,728][INFO ][o.e.n.Node               ] [node-1] starting ...
[2017-01-07T12:18:59,185][INFO ][o.e.t.TransportService   ] [node-1] publish_address {192.168.1.222:9300},bound_addresses {192.168.1.222:9300}
[2017-01-07T12:18:59,277][INFO ][o.e.b.BootstrapCheck     ] [node-1] bound or publishing to a non-loopback or non-link-local address,enforcing bootstrap checks
[2017-01-07T12:19:03,447][INFO ][o.e.c.s.ClusterService   ] [node-1] new_master {node-1}{8x-utN34QFqJmeeIhrTGjA}{euJKK9YNSSueCM__ko6O8Q}{192.168.1.222}{192.168.1.222:9300},reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-01-07T12:19:03,636][INFO ][o.e.h.HttpServer         ] [node-1] publish_address {192.168.1.222:9200},bound_addresses {192.168.1.222:9200}
[2017-01-07T12:19:03,636][INFO ][o.e.n.Node               ] [node-1] started
[2017-01-07T12:19:03,637][INFO ][o.e.g.GatewayService     ] [node-1] recovered [0] indices into cluster_state
[2017-01-07T12:23:04,309][INFO ][o.e.m.j.JvmGcMonitorService] [node-1] [gc][young][248][9] duration [723ms],collections [1]/[1s],total [723ms]/[1.7s],memory [72.1mb]->[37mb]/[505.6mb],all_pools {[young] [51.2mb]->[172.8kb]/[51.2mb]}{[survivor] [6.3mb]->[4.7mb]/[6.3mb]}{[old] [14.4mb]->[32.3mb]/[448mb]}
[2017-01-07T12:23:04,310][WARN ][o.e.m.j.JvmGcMonitorService] [node-1] [gc][248] overhead,spent [723ms] collecting in the last [1s]

浏览器打开网址:http://192.168.1.222:9200/ (出现当前集群节点信息)
{
  "name" : "node-1","cluster_name" : "es_cluster","cluster_uuid" : "3DUO7WigT9m0pqMz-QlR4g","version" : {
    "number" : "5.0.0","build_hash" : "253032b","build_date" : "2016-10-26T04:37:51.531Z","build_snapshot" : false,"lucene_version" : "6.2.0"
  },"tagline" : "You KNow,for Search"
}


参考:Installing Elasticsearch

Elasticsearch 权威指南(中文版)

centos 6.5 elasticsearch 5.1 安装

centos 6.5 elasticsearch 5.1 安装

添加普通用户

useradd tommy

passwd tommy

[root@localhost home]# useradd tommy
[root@localhost home]# passwd tommy
Changing password for user tommy.
New password: 
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.

赋予root权限

vi /etc/sudoers

添加 tommy ALL=(ALL) ALL

[root@localhost home]# chmod -w /etc/sudoers
[root@localhost home]# vi /etc/sudoers
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
tommy   ALL=(ALL)       ALL


安装jdk

 

安装elasticsearch

unzip elasticsearch-5.1.1.zip

[tommy@localhost ~]$ unzip elasticsearch-5.1.1.zip

 

配置

$ vi config/elasticsearch.yml

[tommy@localhost elasticsearch-5.1.1]$ vi config/elasticsearch.yml

打开network.host设置为当前ip

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.1.107
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#

 

启动

cd elasticsearch-5.1.1/bin/

./elasticsearch

[tommy@localhost ~]$ cd elasticsearch-5.1.1/bin/
[tommy@localhost bin]$ ./elasticsearch

遇到如下错误

[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2016-12-31T10:04:16,049][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2016-12-31T10:04:16,050][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty3]
[2016-12-31T10:04:16,051][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2016-12-31T10:04:16,063][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2016-12-31T10:04:31,693][INFO ][o.e.n.Node               ] [node-1] initialized
[2016-12-31T10:04:31,696][INFO ][o.e.n.Node               ] [node-1] starting ...
[2016-12-31T10:04:33,025][INFO ][o.e.t.TransportService   ] [node-1] publish_address {192.168.1.107:9300}, bound_addresses {192.168.1.107:9300}
[2016-12-31T10:04:33,054][INFO ][o.e.b.BootstrapCheck     ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max number of threads [1024] for user [tommy] is too low, increase to at least [2048]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2016-12-31T10:04:33,157][INFO ][o.e.n.Node               ] [node-1] stopping ...
[2016-12-31T10:04:33,340][INFO ][o.e.n.Node               ] [node-1] stopped
[2016-12-31T10:04:33,340][INFO ][o.e.n.Node               ] [node-1] closing ...
[2016-12-31T10:04:33,454][INFO ][o.e.n.Node               ] [node-1] closed

设置 max file descriptors (linux能够打开的最大文件句柄数)

在 /etc/security/limits.conf 文件最后添加

* hard nofile 65536
* soft nofile 65536

[root@localhost home]# echo ''* hard nofile 65536'' >> /etc/security/limits.conf 
[root@localhost home]# echo ''* soft nofile 65536'' >> /etc/security/limits.conf

注意是 >>  千万不要少打一个 > 

设置 max number of threads (linux允许每个用户的最大线程数)

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

# Default limit for number of user''s processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     2048
root       soft    nproc     unlimited

设置 vm.max_map_count (限制一个进程可以拥有的VMA(虚拟内存区域)的数量)

echo 262144 > /proc/sys/vm/max_map_count

sysctl -p

[root@localhost home]# echo 262144 > /proc/sys/vm/max_map_count

退出再次ssh到服务器启动elasticsearch

遇到如下错误

[tommy@localhost bin]$ ./elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x000000008a660000, 1973026816, 0) failed; error=''Cannot allocate memory'' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1973026816 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/tommy/elasticsearch-5.1.1/bin/hs_err_pid24402.log

设置elasticsearch jvm配置

vi config/jvm.options (调整jvm参数)

################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms1g
-Xmx1g

 

Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/tommy/elasticsearch-5.1.1/data/my-application]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?

在 elasticsearch-5.1.1/data/nodes/0 目录下有一个 node.lock

rm -rf node.lock 即可 

 

以守护模式启动

$ bin/elasticsearch -d

./bin/elasticsearch -d -p pid

查看日志

tail -100f logs/xxx.log (节点名)

[tommy@localhost elasticsearch-5.1.1]$ tail -100f logs/elasticsearch.log

杀死进程

kill `cat pid`

测试连接

[tommy@localhost ~]$ curl -XGET ''192.168.1.107:9200''
{
  "name" : "node-1",
  "cluster_name" : "my-application",
  "cluster_uuid" : "KMX4Y_skRByI3wYxvYCp5Q",
  "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"
}

 

 

CentOS 6.7 安装ElasticSearch2.0.0

CentOS 6.7 安装ElasticSearch2.0.0

“是不是所有的麻雀,都会在冬天里死去;是不是所有的人们都在金钱里丧失着良知;是不是只有穷苦的孩子才能唱出最美的歌;是不是只有漂泊的人们才懂得生活的苦涩。”——《涩》

1. jdk的安装配置

首先是要安装jdk的,
最初采用命令yum install java安装的java并没有javac,其实我也并不清楚具体是哪些包,所以开启任性模式——反正我不管,就把1.7.0版本相关的全都装上吧……

yum list java* yun install java-1.7.0-openjdk*

然后需要设置一下JAVA_HOME环境变量,那么问题来了,刚才安装的jdk路径在哪?

rpm -qa | grep java

看一眼,然后发现有个包叫java-1.7.0-openjdk-1.7.0.91-2.6.2.2.el6_7.x86_64

rpm -ql java-1.7.0-openjdk-1.7.0.91-2.6.2.2.el6_7.x86_64

于是列出了一大串路径,在其中找到了/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91.x86_64/jre/bin,cd到这个目录下发现嗯,javac啊,java都有,就是它了。下面配置JAVA_HOME环境变量

vim /etc/profile

在尾部加上

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91.x86_64 export CLAsspATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin

:wq退出vim编辑器,然后source /etc/profile就行了。

2. ElasticSearch的安装配置

这里使用yum方式来安装 ES的官方网站上有说明: https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html 首先下载并安装公钥

rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

配置一下yum源

vim /etc/yum.repos.d/elasticsearch.repo

elasticsearch.repo内容:

[elasticsearch-2.x] name=Elasticsearch repository for 2.x packages baseurl=http://packages.elastic.co/elasticsearch/2.x/centos gpgcheck=1 gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch enabled=1

然后yum makecache更新一下缓存,

yum install elasticsearch

安装elasticsearch完毕。

之后我们需要将ElasticSearch作为一个服务来运行,具体参考这里 https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-service.html

sudo /sbin/chkconfig --add elasticsearch sudo service elasticsearch start

至此为止,elasticsearch服务就启动了,访问一下9200端口

curl -X GET localhost:9200 { "name" : "Hindsight Lad","cluster_name" : "elasticsearch","version" : { "number" : "2.0.0","build_hash" : "de54438d6af8f9340d50c5c786151783ce7d6be5","build_timestamp" : "2015-10-22T08:09:48Z","build_snapshot" : false,"lucene_version" : "5.2.1" },"tagline" : "You KNow,for Search" }

关于centos 编译安装 elasticsearchcentos 编译安装的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于(centos7)安装elasticsearch6.4.2、CentOS 5.6 安装 Elasticsearch 5.0、centos 6.5 elasticsearch 5.1 安装、CentOS 6.7 安装ElasticSearch2.0.0的相关信息,请在本站寻找。

本文标签: