es部署

系统环境:CentOS 7.3
组件包:

2. ES部署【以下操作均在/soft目录下执行】

创建soft文件夹,进入soft文件夹进行部署操作 mkdir -p /soft cd /soft

JDK安装

  1. 安装Java环境

    上传jdk-8u92-linux-x64.rpm至当前虚拟机

    rpm -ivh jdk-8u92-linux-x64.rpm

  2. 配置环境变量

    cd /etc/profile

  3. 修改配置文件

    #set java environment
        export JAVA_HOME=/usr/java/jdk1.8.0_92/
        export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
        export PATH=$PATH:$JAVA_HOME/bin
  4. 使配置文件生效

    source /etc/profile

ElasticSearch安装

  1. 安装elasticsearch

    上传elasticsearch-2.4.0.rpm至当前虚拟机

    rpm -ivh elasticsearch-2.4.0.rpm

  2. 修改配置文件

    vim /etc/elasticsearch/elasticsearch.yml

    # ======================== Elasticsearch Configuration =========================
    #
    # NOTE: Elasticsearch comes with reasonable defaults for most settings.
    #       Before you set out to tweak and tune the configuration, make sure you
    #       understand what are you trying to accomplish and the consequences.
    #
    # The primary way of configuring a node is via this file. This template lists
    # the most important settings you may want to configure for a production cluster.
    #
    # Please see the documentation for further information on configuration options:
    # <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
    #
    # ---------------------------------- Cluster -----------------------------------
    #
    # Use a descriptive name for your cluster:
    #
     node.master: true    #节点属性
     node.data: true      #节点属性,master节点:master为true,data为false;data节点:master为false,data为true;client节点:两者都为false。
     cluster.name: XXX    #集群名称
    #
    # ------------------------------------ Node ------------------------------------
    #
    # Use a descriptive name for the node:
    #
     node.name: XXX   #节点名称
    #
    # Add custom attributes to the node:
    #
    # node.rack: r1
    #
    # ----------------------------------- Paths ------------------------------------
    #
    # Path to directory where to store the data (separate multiple locations by comma):
    #
     path.data: /data1/es/data   #索引数据的存储路径
    #
    # Path to log files:
    #
     path.logs: /data1/es/logs  #日志存储路径
    
     path.repo: ["/data1/es/backups"]
    #
    # ----------------------------------- Memory -----------------------------------
    #
    # Lock the memory on startup:
    #
    # bootstrap.memory_lock: true
    #
    # Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
    # available on the system and that the owner of the process is allowed to use this limit.
    #
    # Elasticsearch performs poorly when the system is swapping the memory.
    #
    # ---------------------------------- Network -----------------------------------
    #
    # Set the bind address to a specific IP (IPv4 or IPv6):
    #
     network.host: 10.201.81.186  #设置绑定的ip地址
    #
    # Set a custom port for HTTP:
    #
     http.port: 9200      #设置对外服务的http端口,默认为9200
    #
    # For more information, see the documentation at:
    # <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
    #
    # --------------------------------- Discovery ----------------------------------
    #
    # Pass an initial list of hosts to perform discovery when new node is started:
    # The default list of hosts is ["127.0.0.1", "[::1]"]
    #
     discovery.zen.ping.unicast.hosts: ["10.201.81.186", "10.201.81.187"]    #设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点。
    
     
    #
    # Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
    #
     cluster.routing.allocation.disk.watermark.low: "90%" #es所占数据盘容量的最大百分比
     http.enabled: true    #head插件是否可在浏览器中查看
     http.cors.enabled: true
     http.cors.allow-origin: "*"
     bootstrap.memory_lock: true
     discover.zen.ping_timeout: 120s   #超时ping
     discovery.zen.minimum_master_nodes: 1
    #
    # For more information, see the documentation at:
    # <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
    #
    # ---------------------------------- Gateway -----------------------------------
    #
    # Block initial recovery after a full cluster restart until N nodes are started:
    #
    # gateway.recover_after_nodes: 3
    #
    # For more information, see the documentation at:
    # <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
    #
    # ---------------------------------- Various -----------------------------------
    #
    # Disable starting multiple nodes on a single system:
    #
    # node.max_local_storage_nodes: 1
    #
    # Require explicit names when deleting indices:
    #
    # action.destructive_requires_name: true

    配置文件详解

    1. 集群名称:
        cluster.name: XXX
    2. 节点名称,es启动时会自动创建节点名称,但你也可进行配置:
        node.name: "XXX"
    3. 是否作为主节点,每个节点都可以被配置成为主节点,默认值为true:
        node.master: true
    4. 是否存储数据,即存储索引片段,默认值为true:
        node.data: true
             master和data同时配置会产生一些奇异的效果:
        1) 当master为false,而data为true时,会对该节点产生严重负荷;
        2) 当master为true,而data为false时,该节点作为一个协调者;
        3) 当master为false,data也为false时,该节点就变成了一个负载均衡器。
        你可以通过连接http://localhost:9200/_cluster/health或者http://localhost:9200/_cluster/nodes,或者使用插件http://localhost:9200/plugin/head来查看集群状态。
            
    5. 设置一个索引的碎片数量,默认值为5:
        index.number_of_shards: 5
    6. 设置一个索引可被复制的数量,默认值为1:
        index.number_of_replicas: 1
        当你想要禁用公布式时,你可以进行如下设置:
        index.number_of_shards: 1
        index.number_of_replicas: 0
        这两个属性的设置直接影响集群中索引和搜索操作的执行。假设你有足够的机器来持有碎片和复制品,那么可以按如下规则设置这两个值:
        1) 拥有更多的碎片可以提升索引执行能力,并允许通过机器分发一个大型的索引;
        2) 拥有更多的复制器能够提升搜索执行能力以及集群能力。
               对于一个索引来说,number_of_shards只能设置一次,而number_of_replicas可以使用索引更新设置API在任何时候被     增加或者减少。
    7. bind_host和publish_host可以一起设置:
         network.host: 192.168.0.1
    8. 可以定制该节点与其他节点交互的端口:
        transport.tcp.port: 9300
    9. 可以为Http传输监听定制端口:
        http.port: 9200
    10. 设置内容的最大长度:
        http.max_content_length: 100mb
    11. 禁止HTTP
        http.enabled: false
    12. 网关允许在所有集群重启后持有集群状态,集群状态的变更都会被保存下来,当第一次启用集群时,可以从网关中读取到状态,默认网关类型(也是推荐的)是local:
        gateway.type: local
    13. 允许在N个节点启动后恢复过程:
        gateway.recover_after_nodes: 1
    14. 设置初始化恢复过程的超时时间:
        gateway.recover_after_time: 5m
    15. 设置该集群中可存在的节点上限:
        gateway.expected_nodes: 2
    16. 设置复苏时的吞吐量,默认情况下是无限的:
        indices.recovery.max_size_per_sec: 0
    17. 设置一个集群中主节点的数量,当多于三个节点时,该值可在2-4之间:
        discovery.zen.minimum_master_nodes: 1
    18. 设置ping其他节点时的超时时间,网络比较慢时可将该值设大:
        discovery.zen.ping.timeout: 120s
    19. 禁止当前节点发现多个集群节点,默认值为true:
        discovery.zen.ping.multicast.enabled: false
    20. 设置新节点被启动时能够发现的主节点列表(主要用于不同网段机器连接):
        discovery.zen.ping.unicast.hosts: ["host1", "host2", "host3"]
     
  3. 重载修改过的配置文件

    sudo systemctl daemon-reload

  4. 启动es + 设置开机自启

    sudo systemctl enable elasticsearch

    sudo systemctl start elasticsearch

sshfs安装

上传fuse-libs-2.9.2-7.el7.x86_64.rpm、fuse-sshfs-2.5-1.el7.rf.x86_64.rpm至虚拟机上 rpm -ivh fuse-libs-2.9.2-7.el7.x86_64.rpm rpm -ivh fuse-sshfs-2.5-1.el7.rf.x86_64.rpm --force --nodeps

ES插件安装

把ES插件包上传至虚拟机 unzip ES.zip cp -rp /soft/ES/* /usr/share/elasticsearch/plugins/

建立连接

hb.case.criminal.1230_20180125为数据【所有节点均执行此步骤】

sshfs root@192.168.0.1:/soft/backup_XX_20191111/ /data1/es/backups/ -o allow_other

创建仓储

backup_xxgengxin2_20180224为仓储名【仅该data节点执行此步骤】

curl -XPUT http://192.168.0.2:9200/_snapshot/backup_XX_20191112 -d '{"type": "fs","settings":{"compress": true,"location": "/data1/es/backups"}}'

数据恢复

backup_xxgengxin2_20180224仓储名 snapshot_backup_XX_201911124【仅该data节点执行此步骤】

curl -XPOST http://192.168.0.2:9200/_snapshot/backup_XX_20191112/snapshot_20180125/_restore

 

posted @ 2019-11-12 15:08  冷锋灬  阅读(327)  评论(0)    收藏  举报