apache ignite 中的本机数据持久性不起作用

问题描述 投票:0回答:1

我在 docker 容器中运行 ignite,我想实现本机持久性,这样如果我删除或停止 ignite 容器,在重新启动容器后我想访问以前的数据。为此,我安装了一个 ignite 卷,将其连接到主机目录,并在 ignite-config.xml 中给出该卷的路径以实现数据持久性。我还在 ignite-config.xml 中将 dataPersistenceEnabled 设置为 true。

这是我的 ignite-config.xml:


  <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans.xsd">

          <!-- Ignite Configuration -->
          <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">

              <!-- Data Storage Configuration -->
              <property name="dataStorageConfiguration">
                  <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
                      <!-- Enable Native Persistence -->
                      <property name="defaultDataRegionConfiguration">
                          <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                              <property name="persistenceEnabled" value="true"/>
                          </bean>
                      </property>
                      <!-- Define the path where data, indexes, and WAL files will be stored -->
                      <property name="storagePath" value="/opt/ignite/persistence"/>
                  </bean>
              </property>
          
          </bean>
      </beans>

这是我的 docker run 命令:

docker run -d --name ignite-container `
  -p 10800:10800 -p 47100:47100 -p 47500:47500 -p 49112:49112 `
  -v C:/Users/ArchanaAnand/Desktop/ignite-config/persistence:/opt/ignite/persistence `
  -v C:/Users/ArchanaAnand/Desktop/ignite-config/ignite-config.xml:/opt/ignite/apache-ignite/config/ignite-config.xml `
  -e IGNITE_CONFIG_URI=file:///opt/ignite/apache-ignite/config/ignite-config.xml `
  apacheignite/ignite

我将 ignite-config.xml 放在 default-config.xml 所在的同一容器文件夹中。运行容器后我们可以在容器中看到ignite-config文件。

这是我运行的Python文件:

      from pyignite import Client

        client = Client()
        with client.connect('127.0.0.1', 10800):   

            #  create a cache.
            cache = client.create_cache('my cache')


            cache.put(1, 'Hello, Ignite!')
            cache.put(2, 'Apache Ignite is awesome!')


            value1 = cache.get(1)
            value2 = cache.get(2)

            print(value1)
            print(value2)


            client.close()

当我在终端中运行这个 python 文件时,我确实得到了输出,正在容器中创建持久性文件夹,但我的持久性容器文件夹和持久性主机目录中都没有写入任何内容。

我是新手,找不到问题所在,我应该更改配置文件中的某些内容吗?

caching ignite data-persistence apacheignite
1个回答
0
投票

尝试将 IGNITE_CONFIG_URI 替换为 CONFIG_URI,值得考虑的是,默认情况下具有 PDS 的集群在启动后不会被激活为 IN-MEM,您需要激活它,这可以在客户端中通过添加以下行来完成: client.get_cluster( ).set_state(ClusterState.ACTIVE)

© www.soinside.com 2019 - 2024. All rights reserved.