1.安装

官网

找到对应版本的es进行下载上传服务器。或者找到下载链接使用linux远程wget下载。

jdk需要先安装好。

2.修改配置

默认配置
cluster.name: datacenter
node.name: node-1
http.port: 9200
transport.tcp.port: 9300

其中还可以配置允许自动创建索引

action.auto_create_index: ".security*,.monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*"
集群配置增加
discovery.zen.ping.unicast.hosts: ["192.168.152.128", "192.168.152.129"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 2

发现无法加入节点,可以尝试删除data目录的所有文件试试。复制的节点不能有原来的垃圾数据。

3.启动

不能使用root用户启动。当然也不能安装到/root目录,一切换用户就没有权限访问了。

如果没用用户先创建用户。

useradd es

安装目录赋权

chown -R es:es /data/elasticsearch-6.3.0

切换用户bin目录下启动

-d参数表示后台运行

./elasticsearch
坑点
  1. ERROR: [2] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

第一个:调节并发连接数。

vim /etc/security/limits.conf
# End of file
* soft nofile 655360
* hard nofile 655360
root soft nofile 100001
root hard nofile 100002

第二个:错误表示修改虚拟内存大小。

修改:vim /etc/sysctl.conf 增加配置:vm.max_map_count=655360 配置生效:sysctl -p 配置查看:sysctl -a

  1. [max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

    或者 max number of threads is too low 之类的意思是线程数不够。

修改非root用户线程不限制。

vi /etc/security/limits.d/20-nproc.conf

*          soft    nproc     unlimited
root       soft    nproc     unlimited
  1. 报错提示内存不足:

    Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)

    修改配置 jvm.options,把默认的4g内存下调到1g。

    -Xms1g
    -Xmx1g
    

4.测试启动

curl  127.0.0.1:9200

或则设置好防火墙端口后web页面直接请求。

1553346121339.png

一步到位命令,执行完重启机器

systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalldulimit -c unlimited
ulimit -SHn 65536
echo "ulimit -SHn 65536" >>/etc/rc.local
echo "* soft nofile unlimited" >>/etc/security/limits.conf
echo "* hard nofile unlimited" >>/etc/security/limits.conf
echo "* soft nproc unlimited" >>/etc/security/limits.d/90-nproc.conf
echo "* hard nproc unlimited" >>/etc/security/limits.d/90-nproc.conf
echo "vm.max_map_count = 655360" >>/etc/sysctl.conf
/sbin/sysctl -p
上次更新时间: 2024/5/7 05:59:02