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,恍然大悟。。。

  • 相关阅读:
    前端(移动端)开发沉思录
    我的世界观—学习与世界观
    学习一门新的语言和平台相当于学习一个新的世界观
    股票:格局、模式、结构与策略
    资本市场世界观
    投资的道与术:投资投的是自己的修为
    关心把事情做得正确,而不是关心赚钱--《股票作手回忆录》第十一章--投资股票的道与术
    js字符串截取函数slice()、substring()、substr()
    推荐一个好的Redis GUI 客户端工具
    sometimes-ever js中创建数组,并往数组里添加元素
  • 原文地址:https://www.cnblogs.com/majw/p/6484234.html
Copyright © 2011-2022 走看看