Elasticsearch7.3 学习笔记2-安装与配置

一、jdk的安装
1.下载jdk
.JDK下载地址:点击直达官网下载请添加链接描述
《Elasticsearch7.3 学习笔记2-安装与配置》
2.解压并安装
tar -zxvf jdk-11.0.4_linux-x64_bin.tar.gz
mkdir -p /usr/local/jdk/
mv jdk-11.0.4 /usr/local/jdk/
3.配置环境变量
vi /etc/profile
export JAVA_HOME=/usr/local/jdk/jdk-11.0.4
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
4.编译
source /etc/profile
5.查看
java -version
《Elasticsearch7.3 学习笔记2-安装与配置》
二、es安装并配置
1.下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.0-linux-x86_64.tar.gz
2.解压
tar -zxvf elasticsearch-7.3.0-linux-x86_64.tar.gz

  1. 新建账号并授权
    Elasticsearch #要求不能使用超级用户root运行,所以我们建立一个测试账号
    groupadd testes

            useradd testesuser -g testes -p 123456
    
            然后,给testesuser用户elasticsearch目录的授权。
    
            chown -R testesuser:testes /usr/local/es/
            切换至elasticsearch目录,并以testesuser用户运行
    
            su testesuser
            这个用户专门用来给es操作的,如启动,暂停等。。。
    4.启动服务
         在es安装目录下进入bin文件夹
         运行elasticsearch,如果想后台运行后面加 -d,es默认会启动http 9200端口,tcp 9300端口
     5.防火墙添加
         firewall-cmd --zone=public --add-port=9200/tcp --permanent
         firewall-cmd --zone=public --add-port=9300/tcp --permanent
         firewall-cmd --reload
    6.测试
       方法1  直接通过浏览器测试

    《Elasticsearch7.3 学习笔记2-安装与配置》
    方法2 curl 测试
    curl http://localhost:9200
    《Elasticsearch7.3 学习笔记2-安装与配置》
    三、目录结构说明
    • home目录 :使用$ES_HOME表示
    • bin/ : 位置 $ES_HOME/bin,包含了elasticsearch和elasticsearch-plugin等脚本
    • conf/ :位置 $ES_HOME/config,包含了 配置文件 elasticsearch.yml 和 log4j2.properties,使用 path.conf 指定
    • data/ :位置 $ES_HOME/data,包含了每个index/shard的数据文件,可以指定多个位置,使用 path.data 指定
    • logs/ : 位置 $ES_HOME/logs,使用 path.logs 指定
    • plguins/ : 位置$ES_HOME/plugins
    • repo/ :使用 path.repo指定,没有默认位置,表示共享文件系统repository的位置。可以指定多个位置。
    • script/ :位置$ES_HOME/scripts,使用 path.scripts 指定。

四、启动服务报错解决
1.curl端口报错
. curl http://192.168.43.96:9200 拒绝连接

默认是通过127.0.0.1启动的 ,需要修改配置文件
《Elasticsearch7.3 学习笔记2-安装与配置》
network.host: 192.168.43.96
http.port: 9200
2.ERROR: bootstrap checks failed
max file descriptors [10240] for elasticsearch process likely too low, increase to at least [65536]
切换到root用户
vi /etc/security/limits.conf
#添加如下内容:

  • soft nofile 65536
  • hard nofile 131072
  • soft nproc 4096
  • hard nproc 4096
    修改/etc/sysctl.conf
    #添加下面配置:
    vm.max_map_count=655360
    执行命令:

    sysctl -p

    注意:如果仍然提示异常

    max file **

    max number **

    max virtual **

    可根据提示调整上述文件参数大小即可解决。
    sysctl –p 执行此命令保存后执行
    3.the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
    修改XX-nproc.conf (不同机器XX不一样,可先到 cd /etc/security/limits.d/ 查看下)

    vi /etc/security/limits.d/20-nproc.conf
    *          soft    nproc     4096(改为4096,原来为1024)
    在 elasticsearch.yml中添加配置项:bootstrap.system_call_filter为false:
    bootstrap.memory_lock: false
    bootstrap.system_call_filter: false
    cluster.initial_master_nodes: ["node-1"]
    原文作者:w0rdyyp
    原文地址: https://blog.51cto.com/2262805/2441988
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞