搭建Elasticsearch环境

1.下载安装包

可以从这下载https://blog.csdn.net/weixin_37281289/article/details/101483434

2.解压

 tar -zxvf elasticsearch-7.6.0-linux-x86_64.tar.gz

3.新建用户

useradd elasticsearch
passwd  elasticsearch
chown -R elasticsearch /usr/local/es/elasticsearch-7.6.0 赋权

4.修改配置文件

cluster.name: elasticsearch
node.name: node-1
path.data: /usr/local/elasticsearch/elasticsearch-7.6.0/data
path.logs: /usr/local/elasticsearch/elasticsearch-7.6.0/logs
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]

5.进入elasticsearch用户

su elasticsearch

6.启动

cd /usr/local/es/elasticsearch-7.6.0/bin
./elasticsearch

7.会报一系列错误

1)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 4096
* hard nproc 4096
​
备注:* 代表Linux所有用户名称(比如 hadoop)
需要保存、退出、重新登录才可生效。
​
2)max number of threads [1024] for user [es] likely too low, increase to at least [4096]
原因:无法创建本地线程问题,用户最大可创建线程数太小
解决方案:同上

​
3)max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
原因:最大虚拟内存太小
每次启动机器都手动执行下。
root用户执行命令:
[root@localhost ~]# sysctl -w vm.max_map_count=262144
查看修改结果命令:sysctl -a|grep vm.max_map_count  看是否已经修改
永久性修改策略:
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
​
4)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.4.1默认bootstravelap.system_call_filter为travelue进行检测,所以导致检测失败,失败后直接导致ES不能启动。
详见 :https://github.com/elastic/elasticsearch/issues/22899
​
解决方法:在elasticsearch.yml中新增配置
bootstrap.system_call_filter,设为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

5) os::commit_memory(0x00000000c5330000, 986513408, 0) failed; 
​vi ../config/jvm.options
修改
-Xms256m
-Xmx256m

6)future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk/jdk1.8.0_231/jre] does not meet this requirement
不用管 会向下兼容

7)es:ccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SEC
/usr/local/es/elasticsearch-7.6.0/config/elasticsearch.yml追加
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

8.开放端口号

发现输入 ip:9200还是访问不了 开放端口

/sbin/iptables -I INPUT -p tcp --dport 9200 -j ACCEPT

10.成功

11.设置后台启动

./elasticsearch -d

猜你喜欢

转载自blog.csdn.net/qq_20143059/article/details/106327576
今日推荐