elasticsearch安装配置

1: Java安装

1.1 检测是否安装java及java版本

在终端输入java –version,如果未安装java或者版本低于8,请下载java8,在终端输入:

wget http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz?AuthParam=1478501340_5bfa9f75e38b012bb7e871c993104c2f

1.2  解压下载的文件,tar –xvf jdk-8u112-linux-x64.tar.gz

1.3  执行下面语句将解压后的文件夹jdk1.8.0_112 拷贝到/usr/lib/jvm下

cp –r jdk1.8.0_112 /usr/lib/jvm

1.4  配置java环境变量

1) cd ~

2)在.bashrc文件中配置java环境变量。vi .bashrc

export JAVA_HOME = /usr/local/jdk1.8.0

export JRE_HOME = ${JAVA_HOME}/jre

export CLASSPATH = .:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH = ${JAVA_HOME}/bin:$PATH

3)退出并保存。执行 source .bashrc

4)在终端执行java –version,输出以下信息,则完成配置

java version "1.8.0_112"

Java(TM) SE Runtime Environment (build 1.8.0_112-b15)

Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

2: elasticsearch安装

2.1 下载elasticsearch安装包

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

2.2 解压

sha1sum elasticsearch-5.0.0.tar.gz

tar -xzf elasticsearch-5.0.0.tar.gz

2.3 移动到指定文件夹并重命名

mv elasticsearch-5.0.0 /usr/local/elasticsearch

2.4 修改访问elasticsearch的IP及端口

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

找到如下代码段,并取消network.host及http.port所在行的注释,修改IP及端口。

# ---------------------------------- Network -----------------------------------

#

# Set the bind address to a specific IP (IPv4 or IPv6):

#

network.host: 192.168.0.155

#

# 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

3: 启动elasticsearch并解决出现的错误

3.1直接运行bin/elasticsearch文件启动elasticsearch

cd /usr/java/elasticsearch/bin/

./elasticsearch

3.2 遇到问题及解决方案

问题一:Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

#

# There is insufficient memory for the Java Runtime Environment to continue.

解决:增加服务器内存

问题二:can not run elasticsearch as root

解决:https://my.oschina.net/topeagle/blog/591451?fromerr=mzOr2qzZ

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

解决方法:切换到root用户,进入vi /etc/security/limits.conf  ,增加配置(保存后注意切回elsearch用户的时候才能生效,sudo 修改的不能立即生效):

elsearch soft nofile 819200

elsearch hard nofile 819200

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

解决方法:进入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]

解决方法:修改sysctl文件:vi /etc/sysctl.conf ,增加下面配置项:

增加改行配置:vm.max_map_count=655360

保存退出后,执行:

sysctl -p

问题六:另外再配置ES的时候,threadpool.bulk.queue_size 已经变成了thread_pool.bulk.queue_size ,ES_HEAP_SIZE,ES_MAX_MEM等配置都变为ES_JAVA_OPTS这一配置项,如限制内存最大最小为1G:

export ES_JAVA_OPTS="-Xms1g -Xmx1g"

你可能感兴趣的:(elasticsearch安装配置)