zoukankan      html  css  js  c++  java
  • snapshot(持续更新中)

    首先先了解一下官网中提到的如何backup your elasticsearch

    https://www.elastic.co/guide/en/elasticsearch/guide/current/backing-up-your-cluster.html

    知识点

    1.关于repository的几种类型。

    (来自官网)To use this functionality, you must first create a repository to save data. There are several repository types that you may choose from:

    • Shared filesystem, such as a NAS
    • Amazon S3
    • HDFS (Hadoop Distributed File System)
    • Azure Cloud

    下面截图是来自kopf这个插件,url在上面没有提到,其他的都能对上

    总结一下:fs---->Shared filesystem

         s3---->Amazon S3

         hdfs--->HDFS (Hadoop Distributed File System)

           azure--->Azure Cloud

    下面是google的一篇不错的关于snapshot es的 java 代码。

    https://dzone.com/articles/how-use-elasticsearch-snapshot

    下面是我自己写的代码

    String repositoryPath = "E:\snapshot";
                boolean compress = true;
                String repositoryType = "fs";
                // es 2.4
                Settings setting = Settings.builder()
                        .put("location", repositoryPath)
                        .put("compress", compress).build();
                PutRepositoryResponse putRepositoryResponse = clusterAdminClient.preparePutRepository(defaultRepositoryName)
                        .setType(repositoryType).setSettings(setting)
                        .execute().actionGet();
                if (putRepositoryResponse.isAcknowledged()) {
                    System.out.println(defaultRepositoryName + " have been created");
                    
                    repositoryMetaDataList = clusterAdminClient.prepareGetRepositories(defaultRepositoryName).get().repositories();
                    System.out.println(repositoryMetaDataList.size());
                }

    Exception in thread "main" RepositoryVerificationException[[hippo_Repository] [VMYox38PS9qXN3hYhf588Q, 'RemoteTransportException[[node-hippo3][10.12.198.242:9300][internal:admin/repository/verify]]; nested: RepositoryVerificationException[[hippo_Repository] a file written by master to the store [/opt/hippo/snapshot/E:snapshot] cannot be accessed on the node [{node-hippo3}{VMYox38PS9qXN3hYhf588Q}{10.12.198.242}{10.12.198.242:9300}{master=true}]. This might indicate that the store [/opt/hippo/snapshot/E:snapshot] is not shared between this node and the master node or that permissions on the store don't allow reading files written by the master node];'], [EZQYXYKcTtuDCgjr17_M6g, 'RemoteTransportException[[node-hippo1][10.12.198.240:9300][internal:admin/repository/verify]]; nested: RepositoryVerificationException[[hippo_Repository] a file written by master to the store [/opt/hippo/snapshot/E:snapshot] cannot be accessed on the node [{node-hippo1}{EZQYXYKcTtuDCgjr17_M6g}{10.12.198.240}{10.12.198.240:9300}{master=false}]. This might indicate that the store [/opt/hippo/snapshot/E:snapshot] is not shared between this node and the master node or that permissions on the store don't allow reading files written by the master node];']]]
        at org.elasticsearch.repositories.RepositoriesService$VerifyingRegisterRepositoryListener$1.onResponse(RepositoriesService.java:440)
        ......

    一开始我以为,这个repositoryPath应该是绝对路径,从报错看到设置的应该是相对路径(开头不能是/,直接输入文件夹名字就好了),那么绝对的文件夹位置在哪里设置的,google了一下,发现在elasticsearch.yml中有个变量path.repo,恍然大悟。。。

  • 相关阅读:
    小程序40001错误
    【2020-06-07】把心思放在赚钱上就对了
    【2020-06-05】下点功夫,看清题目,并做好选择
    【2020-06-04】人生十三信条
    【2020-06-03】顺境时也需要放空
    【2020-06-02】我感染别人的同时,也加强了自己的信念
    【2020-06-01】信息的吸收源自压力
    【一句日历】2020年6月
    【2020-05-30】向风、向雨、向阳光去讨教
    【2020-05-29】爱眼前的一切
  • 原文地址:https://www.cnblogs.com/majw/p/6484234.html
Copyright © 2011-2022 走看看