1

1、安装JDK8

2、创建用户

创建bigdata 用户组

groupadd bigdata

创建用户es,并修改密码

useradd es
passwd es

将es用户添加到bigdata组

 usermod -G bigdata es

visudo 权限设置

找到root ALL=(ALL) ALL一行,添加es用户,如下。

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
es      ALL=(ALL)       ALL

切换用户

su es

3、ElasticSearch 6.x 软件包下载

官网: https://www.elastic.co/produc...
下载:

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

解压:

tar -zxf elasticsearch-6.4.2.tar.gz

4、修改配置

修改elasticsearch.yml

vi config/elasticsearch.yml

修改host和port

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.70.4
#
# Set a custom port for HTTP:
#
http.port: 9200

修改/etc/sysctl.conf

添加

vm.max_map_count=262144

使用修改生效

sysctl -p

修改文件/etc/security/limits.conf

添加以下内容

* hard nofile 65536
* soft nofile 65536

* soft nproc 2048
* hard nproc 4096

5、ElasticSearch启动与停止

直接启动

bin/elasticsearch

停止
ctrl+c

后台启动

 bin/elasticsearch -d

验证

jps

61562 Jps
61503 Elasticsearch

浏览器 :http://hserver3:9200/

clipboard.png

6、问题解决

1. 权限问题

Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file logs/gc.log due to Permission denied

Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.AccessDeniedException: /home/es/elasticsearch-6.4.2/config/elasticsearch.keystore
Likely root cause: java.nio.file.AccessDeniedException: /home/es/elasticsearch-6.4.2/config/elasticsearch.keystore

解决方法:
因为第一次启动不小心用了root启动,导致用root生成了对应的文件。切换es账号之后,没有对应文件的权限导致,删除相关的东西即可。

2. max number of threads [1024]

ERROR: [2] bootstrap checks failed
[1]: max number of threads [1024] for user [es] is too low, increase to at least [4096]
[2]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

解决:

ulimit -a

max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
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.

* hard nproc 4096
* soft nproc 4096
*          soft    nproc     4096
root       soft    nproc     unlimited

3. system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

原因:
这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。

解决:

在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

kyle
23 声望4 粉丝