zoukankan      html  css  js  c++  java
  • (1.5)es集群部署运维【最佳实践】

     【1】安装启动ES 集群

    (1.1)集群架构规划

    OS   ES version Ip node.name Role cluster.name es basedir
    CentOS Linux release 7.8.2003 (Core) elasticsearch-7.14.1

    192.168.175.132:9200

    cluster:192.168.175.132:9301

    node_1

    node.master=true

    node.data=true

    es_cluster1 /data/es/es_9200
    CentOS Linux release 7.8.2003 (Core) elasticsearch-7.14.1

    192.168.175.129:9200

    cluster:192.168.175.132:9301

    node_2

    node.data=true

    node.master=true

    es_cluster1 /data/es/es_9200
    CentOS Linux release 7.8.2003 (Core) elasticsearch-7.14.1

    192.168.175.129:9200

    cluster:192.168.175.132:9301

    node_3

    node.data=true

    node.master=true

    es_cluster1 /data/es/es_9200

    (1.2)前置目录、账户、信息等准备工作

    不明白的地方请参考:

      (0.1)elasticsearch安装

      (0.10)elasticsearch分布式集群基本搭建(centos7.x + elaticsearch7.11.1)

    jdk如果不配置,没有 JAVA_HOME,则自动使用 es 包中自带的 JDK,这里我就没有安装jdk

    mkdir -p /data/software
    cd /data/software
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-linux-x86_64.tar.gz
    groupadd elk
    useradd elk -g elk
    tar -zxf elasticsearch-7.14.1-linux-x86_64.tar.gz
    mkdir -p /data/es/
    mv elasticsearch-7.14.1 /data/es/es_9200
    echo 'vm.max_map_count=2655350'>> /etc/sysctl.conf
    echo 'vm.swappiness=1'>>/etc/sysctl.conf
    cat <<eof>> /etc/security/limits.conf
    elk soft nproc 65535
    elk hard nproc 65535
    elk soft nofile 65535
    elk hard nofile 65535
    elk soft stack 65535
    elk hard stack 65535
    elk hard memlock unlimited  #锁定内存页
    elk soft memlock unlimited  #需要退出重登会话生效
    eof
    sysctl -p
    #
    /data/es/es_9200/data # 默认数据目录,同目录的 logs 放日志
    mkdir -p /data/es/es_9200/{es_data,es_logs}
    chown -R elk:elk /data/es
    #参考启动命令 su -l elk -c "/data/es/es_9200/bin/elasticsearch -d -p /tmp/es_9200.pid"

    (1.3)配置文件 elasticsearch.yml

    cp -r /data/es/es_9200/config/elasticsearch.yml /data/es/es_9200/config/elasticsearch.yml.bak
    cat <<eof > /data/es/es_9200/config/elasticsearch.yml
    #-----cluster-----
    cluster.name: es_cluster1 #集群名称
      #gateway.recover_after_nodes: 3 #至少恢复3个节点及以上,集群节点才可以被访问
    
    #-----node-----
    node.name: node_1  #节点名称,其他两个节点分别改成 node_2 node_3
    node.master: true  #该是否可被选举为主节点
    node.data: true    #该节点是否可成为数据节点
    node.max_local_storage_nodes: 5  #集群最大逻辑存储节点数
    transport.port: 9301 #集群内部通信端口
    
    #-----data and log------
    path.data: es_data  #生产环境建议把这2个和解压文件夹分离,避免升级丢失数据
    path.logs: es_logs
    
    #-----memory-----
    bootstrap.memory_lock: true  #启动锁定内存页,这样就可以避免内存压力从而导致es的内存页被释放掉或被存到交换内存
    
    #-----network-----
    network.host: 0.0.0.0  # 网关地址,0.0.0.0为不限制
    http.port: 9200
    
    discovery.seed_hosts: ["192.168.175.132:9301", "192.168.175.147:9301", "192.168.175.148:9301"]
    cluster.initial_master_nodes: ["node_1", "node_2", "node_3"]
    
    #-----http requests-----
    bootstrap.system_call_filter: false
    http.cors.allow-origin: "*"
    http.cors.enabled: true
    http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
    http.cors.allow-credentials: true
    
    #-----es operation-----
      #action.destructive_requires_name: true  #删除索引时是否必须要实际索引名,避免批量删除
    eof

    (1.4)启动es、查阅(9200)

    3个机器配置文件都弄好之后,启动es

    
    
    echo 'su -l elk -c "/data/es/es_9200/bin/elasticsearch -d -p /tmp/es_9200.pid"'>>/etc/rc.local
    su -l elk -c "/data/es/es_9200/bin/elasticsearch -d -p /tmp/es_9200.pid"
    #kill -F /tmp/es_9200.pid

    #查阅
    curl localhost:9200
    curl localhost:9200/_cat/health?v

    (1.5)整合UI监控,es-head(9100)

    参考:(0.4)ElasticSearch7整合es-head,ES配置密码

    (1)下载前置依赖:https://nodejs.org/en/download/

    cd /data/software
    wget https://nodejs.org/dist/v14.17.6/node-v14.17.6-linux-x64.tar.xz
    tar -Jxf  node-v14.17.6-linux-x64.tar.xz
    echo "export PATH=${PATH}:`pwd`/bin">> /etc/profile
    source /etc/profile

    (2)下载es-head插件:https://github.com/mobz/elasticsearch-head

    # git clone https://github.com/mobz/elasticsearch-head.git
    cd /data/software wget https://github.com/mobz/elasticsearch-head/archive/master.zip unzip master.zip cd elasticsearch-head-master

    #如果报错,则运行下面那个,如果下面那个也报错,则检查Yum源 npm
    install
    npm install phantomjs-prebuilt@2.1.16 --ignore-scripts
    # run software
    nohup npm run start &
    echo "
    nohup npm run start &">>/etc/rc.local

    (1.5)整合UI,cerebro(参考就行,不怎么会用,9000)

    cerebro官网:https://github.com/lmenezes/cerebro

    装一个就可以了,我装在了 192.168.175.132 机器上 也就是 node_1

    cd /data/software
    
    wget https://github.com/lmenezes/cerebro/releases/download/v0.9.4/cerebro-0.9.4.tgz
    
    tar -zxf cerebro-0.9.4.tgz
    cd /data/software/cerebro-0.9.4/bin && nohup ./cerebro &
    echo 'cd /data/software/cerebro-0.9.4/bin && nohup ./cerebro &' >>/etc/rc.local

    访问:http://192.168.175.132:9000

    输入任意集群节点信息

      

     效果:

      

       

      

       

    (1.6)整合kibana(5601)

    1》依然装在 192.16.175.132 上面吧

    cd /data/software
    wget https://artifacts.elastic.co/downloads/kibana/kibana-7.14.1-linux-x86_64.tar.gz
    tar -zxf kibana-7.14.1-linux-x86_64.tar.gz

    2》修改配置文件

    vim /data/software/kibana-7.14.1-linux-x86_64/config/kibana.yml

    server.port: 5601
    server.host: "0.0.0.0"
    elasticsearch.hosts: ["http://192.168.175.132:9200", "http://192.168.175.147:9200" ,"http://192.168.175.148:9200"]

    其他的默认值就好了

    3》启动:

    su -l elk -c"nohup /data/software/kibana-7.14.1-linux-x86_64/bin/kibana >/data/software/kibana-7.14.1-linux-x86_64/kibana.log &"
    
    echo 'su -l elk -c"nohup /data/software/kibana-7.14.1-linux-x86_64/bin/kibana >/data/software/kibana-7.14.1-linux-x86_64/kibana.log &"' >>/etc/rc.local

    4》连接使用

    http://192.168.175.132:5601/

  • 相关阅读:
    undefined reference to `sqrt' 问题
    linux上开发minigui的配置过程
    linxu select 返回值
    Unix/Linux C静态库的使用
    ubuntu 默认pdf阅读器乱码
    文件锁使用原理及其方法
    fileno函数与ftruncate函数
    Linux下select函数的使用
    unix linux 文件锁
    iOS 基础笔试题
  • 原文地址:https://www.cnblogs.com/gered/p/15234851.html
Copyright © 2011-2022 走看看