美文网首页
elasticsearch 7.X安装

elasticsearch 7.X安装

作者: 劈山菜刀 | 来源:发表于2020-06-03 09:45 被阅读0次

    下载安装包后解压

    tar -zxvf elasticsearch.tar.gz 
    

    修改config文件夹下elasticsearch.yml 文件

    #集群的名称
    cluster.name: es6
    #节点名称,其余两个节点分别为node-2 和node-3
    node.name: node-1
    #指定该节点是否有资格被选举成为master节点,默认是true,es是默认集群中的第一台机器为master,如果这台机挂了就会重新选举master
    node.master: true
    #允许该节点存储数据(默认开启)
    node.data: true
    #索引数据的存储路径
    path.data: /usr/local/elk/elasticsearch/data
    #日志文件的存储路径
    path.logs: /usr/local/elk/elasticsearch/logs
    #设置为true来锁住内存。因为内存交换到磁盘对服务器性能来说是致命的,当jvm开始swapping时es的效率会降低,所以要保证它不swap
    bootstrap.memory_lock: true
    #绑定的ip地址
    network.host: 0.0.0.0
    #设置对外服务的http端口,默认为9200
    http.port: 9200
    # 设置节点间交互的tcp端口,默认是9300 
    transport.tcp.port: 9300
    #Elasticsearch将绑定到可用的环回地址,并将扫描端口9300到9305以尝试连接到运行在同一台服务器上的其他节点。
    #这提供了自动集群体验,而无需进行任何配置。数组设置或逗号分隔的设置。每个值的形式应该是host:port或host
    #(如果没有设置,port默认设置会transport.profiles.default.port 回落到transport.tcp.port)。
    #请注意,IPv6主机必须放在括号内。默认为127.0.0.1, [::1]
    discovery.zen.ping.unicast.hosts: ["192.168.3.101:9300", "192.168.3.102:9300", "192.168.3.103:9300"]
    #如果没有这种设置,遭受网络故障的集群就有可能将集群分成两个独立的集群 - 分裂的大脑 - 这将导致数据丢失
    discovery.zen.minimum_master_nodes: 2
    

    为了安全不允许使用root用户启动,创建elasticsearch 账户
     1、创建用户:elasticsearch

    [root@hza~]# adduser elasticsearch
    

    2、创建用户密码,需要输入两次

    [root@hza~]# passwd elasticsearch
    

    3、将对应的文件夹权限赋给该用户

    [root@hza~]# chown -R elasticsearch elasticsearch7.X
    

    4、切换至elasticsearch用户

    [root@hza~]# su elasticsearch
    

    进入elasticsearch/bin 目录启动

    ./elasticsearch -d
    

    启动会有如下提示jdk版本问题 不要管

    future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_211/jre] does not meet this requirement
    

    启动报错

    /bin/elasticsearch-env: line 116: syntax error near unexpected token `<' 
    

    解决方法
    把 elasticsearch-env 文件中前置行的脚本内容遵循改为:

    set +o posix
    

    继续启动又遇到报错

    ERROR: [3] bootstrap checks failed
    [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
    [2]: memory locking requested for elasticsearch process but memory is not locked
    [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    

    解决方法
    编辑 /etc/sysctl.conf,追加以下内容:

    * soft nofile 65536
    * hard nofile 65536
    * soft nproc 32000
    * hard nproc 32000
    * hard memlock unlimited
    * soft memlock unlimited
    

    编辑 /etc/sysctl.conf,追加以下内容:

    vm.max_map_count=655360
    

    保存后root账户执行

    sysctl -p
    

    OK 切换至 elasticsearch账户启动成功

    相关文章

      网友评论

          本文标题:elasticsearch 7.X安装

          本文链接:https://www.haomeiwen.com/subject/akbpzhtx.html