zoukankan      html  css  js  c++  java
  • CentOS 7/8 部署Elasticsearch集群

    首先要安装JDK,参考 https://www.cnblogs.com/dotqin/p/13560419.html

    环境说明:三台百度云服务器,内网IP分别为: 192.168.32.36、192.168.32.37、192.168.32.38, 不开放公网IP访问

    分别在三台服务器上执行以下操作:

    1.创建目录及下载解压(下载速度很慢)

    cd /usr/local/
    mkdir elasticsearch
    cd elasticsearch
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.1-linux-x86_64.tar.gz
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.1-linux-x86_64.tar.gz.sha512
    yum install perl-Digest-SHA
    shasum -a 512 -c elasticsearch-7.9.1-linux-x86_64.tar.gz.sha512
    tar -xzf elasticsearch-7.9.1-linux-x86_64.tar.gz
    mkdir -p /data/elasticsearch/data
    mkdir -p /data/elasticsearch/logs

    2.设置用户和权限

    groupadd elasticsearch
    useradd elasticsearch -g elasticsearch
    chown -R elasticsearch:elasticsearch /usr/local/elasticsearch/
    chown -R elasticsearch:elasticsearch /data/elasticsearch/

    3.编辑配置文件

    cd /usr/local/elasticsearch/elasticsearch-7.9.1/config
    vim elasticsearch.yml
    # 添加或修改以下内容
    cluster.name: elsearch-cluster
    node.name: node-1 # 每台不一样
    path.data: /data/elasticsearch/data
    path.logs: /data/elasticsearch/logs
    bootstrap.memory_lock: true
    network.host: 192.168.32.36 # 每台不一样
    http.port: 9200
    discovery.seed_hosts: ["192.168.32.36", "192.168.32.37", "192.168.32.38"]
    cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
    
    vim jvm.options
    # 修改以下内容 建议为服务器内存的一半
    -Xms8g
    -Xmx8g

    4.设置一些其他参数

    echo "elasticsearch - nofile 65535" >> /etc/security/limits.conf
    echo "elasticsearch soft memlock unlimited" >> /etc/security/limits.conf
    echo "elasticsearch hard memlock unlimited" >> /etc/security/limits.conf
    echo "vm.swappiness=1" >> /etc/sysctl.conf
    echo "vm.max_map_count=262144" >> /etc/sysctl.conf
    设置完成后需要重启

    5.添加到服务管理

    vim /usr/lib/systemd/system/elasticsearch.service
    # 添加以下内容
    [Unit]
    Description=elasticsearch-7.9.1 service
    After=syslog.target network.target
    
    [Service]
    Restart=always
    RestartSec=1 Type
    =forking TimeoutSec=120 User=elasticsearch Environment=JAVA_HOME=/usr/local/java/jdk1.8.0_261 LimitMEMLOCK=infinity ExecStart=/usr/local/elasticsearch/elasticsearch-7.9.1/bin/elasticsearch -d -p /usr/local/elasticsearch/elasticsearch-7.9.1/elsearch.pid ExecStop=/usr/bin/pkill -F /usr/local/elasticsearch/elasticsearch-7.9.1/elsearch.pid [Install] WantedBy=multi-user.target

    6.设置服务生效及开机自启动

    systemctl daemon-reload
    systemctl enable elasticsearch.service

    7.启动elasticsearch

    systemctl start elasticsearch
    systemctl status elasticsearch
  • 相关阅读:
    jmeter如何引用自己编写的java文件编译的jar包
    Vue+Django REST framework 打造生鲜电商项目(学习笔记二)
    mysql笔试题
    面试遇到的问题
    Idea中maven项目pom文件中已引入testng但项目文件中无法引入@Test
    记录一次TestNg+MyBatis中的SqlSession出现的问题,问题虽然解决了但尚未明白问题原因
    PyMySQL的基本操作
    MySQL循环语句
    Vue父子组件和非父子组件间的通信
    Python的静态方法和类成员方法
  • 原文地址:https://www.cnblogs.com/dotqin/p/13635368.html
Copyright © 2011-2022 走看看