Native data persistence in apache ignite not working

62 views Asked by At

I am running ignite in a docker container, I want to implement native persistence so that if I remove or stop the ignite container, after restarting the container I want to access the previous data. For this I am mounting an ignite volume, connecting it to a host directory and giving the path of the volume in ignite-config.xml for data persistence. And I also gave dataPersistenceEnabled true in ignite-config.xml.

This is my 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>

This is my docker run command:

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

I am putting ignite-config.xml in the same container folder where default-config.xml exists. And after running the container we can see the ignite-config file in the container.

This is the python file that I run:

      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()

When I run this python file in terminal, I do get the output, the persistence folder is being created in the container, but nothing is written in my persistence container folder nor in my persistence host directory.

I am new to this and can't find what is going wrong, should I change something in the config file?

1

There are 1 answers

0
nao On

try replacing IGNITE_CONFIG_URI with CONFIG_URI and it's worth considering that a cluster with PDS by default will not be activated as IN-MEM after startup, you need to activate it, this can be done in the client by adding the line: client.get_cluster().set_state(ClusterState.ACTIVE)