elasticsearch安装

//如果是在容器里的话,需要容器以特权模式启动,来执行sysctl命令
docker  run -d  --privileged --name centos-es6 -v /home/es6/esoft:/software -p 9202:9200 centos:7 /usr/sbin/init
//进入容器
docker exec -it centos-es6 bash

1、不能以root用户启动,创建es用户,并拿root用户给它授权
chown es /home/elasticsearch -R
2、配置文件elasticsearch.yml中修改配置实现远程访问
修改 network.host 为 本机ip或0.0.0.0,后者比较好
network.host: 192.168.46.137
修改 discovery.zen.ping.unicast.hosts 为 ["0.0.0.0"]
discovery.zen.ping.unicast.hosts: ["0.0.0.0"]
然后重启,重启会报错:
ERROR: [1] bootstrap checks failed
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
此类错误,根据报错提示内容进行相关配置,sysctl.conf配置文件中需要的参数可能不止这一种。
按需修改即可:
vi /etc/sysctl.conf 设置
fs.file-max=655350
保存之后sysctl -p使设置生效
vi /etc/security/limits.conf 新增
* soft nofile 655350
* hard nofile 655350
重新登录服务器,再次启动即可。
或者报错:
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
则对应修改vm.max_map_count=655360

补充:

如需支持跨域则需要在配置文件中增加如下参数配置

#开启跨域访问支持,默认为false
http.cors.enabled: true
#跨域访问允许的域名地址,(允许所有域名)以上使用正则
http.cors.allow-origin: /.*/

3、防火墙要关。
centos7
查看防火墙状态
firewall-cmd --state
临时关闭
systemctl stop firewalld
禁止开机启动
systemctl disable firewalld
4、/etc/hosts中主机名要配好。
5、后台启动:
./bin/elasticsearch -d -p pid

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