wangJiaLun-go

王加伦的技术分享

0%

centos7安装elasticsearch

centos7安装elasticsearch

  • 解压 tar -zxvf elasticsearch-6.4.3.tar.gz

  • 修改配置文件,默认不支持远程连接

    1
    2
    3
    4
    5
    cluster.name: es6
    node.name: node0
    path.data: /usr/local/elasticsearch-6.4.3/data
    path.logs: /usr/local/elasticsearch-6.4.3/logs
    network.host: 0.0.0.0
  • ElasticSearch 可以接收脚本执行,默认不支持root用户启动

    • 添加专门用户useradd elastic
    • 修改解压后elasticsearch文件夹所属用户chown -R elastic:elastic elasticsearch-6.4.3
    • 切换用户su elsearch后台启动./elasticsearch -d
  • 启动后会占用两个端口

    • 9200 是ES节点与外部通讯使用的端口, 是http协议的RESTful接口.
    • 9300 是ES节点之间通讯使用的端口, 是tcp通讯端口,集群间和TCPclient都走的9300。(java程序中使用ES时,在配置文件中要配置该端口)

中文分词

  • 下载地址https://github.com/medcl/elasticsearch-analysis-ik/releases

    wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.3/elasticsearch-analysis-ik-6.4.3.zip

    解压到/plugins/ik下面

图形化界面 kibana

  • 官网地址https://www.elastic.co/cn/downloads/past-releases#kibana

    wget https://artifacts.elastic.co/downloads/kibana/kibana-6.4.3-linux-x86_64.tar.gz

问题及处理

  • 线程数不够

    • 错误日志

      1
      2
      ERROR: [2] bootstrap checks failed
      [1]: max number of threads [3000] for user [elastic] is too low, increase to at least [4096]
    • vi /etc/security/limits.conf

      1
      2
      3
      4
      * soft nofile 65536
      * hard nofile 65536
      * soft nproc 65536
      * hard nproc 65536
  • max_map_count too low

    • 错误日志

      1
      2
      ERROR: [1] bootstrap checks failed
      [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    • vi /etc/sysctl.conf

      1
      vm.max_map_count = 655360