如何将点燃数据挂载到主机系统

How to mount ignite data to host system

我想在 docker 中 运行 apache-ignite,我可以做到。 但问题是,每当我旋转图像并在 ignite 中创建表时,只要该容器处于 运行ning 状态,它就会一直存在。如果我重新启动容器或再次启动点燃图像,我没有得到该数据。我知道每当我们旋转图像时,它总是会创建新容器。在我的例子中,如果我想保留数据,那么我需要提交并推送容器,以便下次启动时我会得到它。

但是有什么方法可以让我在主机系统上存储 Ignite 数据,每当我启动映像时,它都会 read/write 该位置上的数据(简称卷安装)。

任何人都可以分享经验或想法并举例说明吗? 谢谢

我将它与 docker-compose 一起使用,下面是我的 docker-compose.yml 文件。

version: "3.7"
services:
  ignite:
    image: apacheignite/ignite
    environment:
      - IGNITE_QUIET=false
    volumes:
      - "./ignite-main.xml:/opt/ignite/apache-ignite/config/default-config.xml"
    ports:
      - 11211:11211
      - 47100:47100
      - 47500:47500
      - 49112:49112

如果我 运行 docker-compose up 命令然后我得到以下错误。

Recreating ignite-test_ignite_1 ... done
Attaching to ignite-test_ignite_1
ignite_1  | Ignite Command Line Startup, ver. 2.7.0#20181130-sha1:256ae401
ignite_1  | 2018 Copyright(C) Apache Software Foundation
ignite_1  | 
ignite_1  | class org.apache.ignite.IgniteException: Failed to instantiate Spring XML application context [springUrl=file:/opt/ignite/apache-ignite/config/default-config.xml, err=Line 1 in XML document from URL [file:/opt/ignite/apache-ignite/config/default-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 31; cvc-elt.1: Cannot find the declaration of element 'property'.]

@Update 您好,经过大量的 RnD 我能够解决这个问题。下面是我做的配置 1. docker-compose.yml

version: "3.5"
    services:
      ignite:
        image: apacheignite/ignite
        environment:
          - IGNITE_QUIET=false

        volumes:
          - ignite-persistence-1:/opt/ignite/
          - "./ignite_1.xml:/opt/ignite/apache-ignite/config/default-config.xml"

        ports:
          - 11211:11211
          - 47100:47100
          - 47500:47500
          - 49112:49112

        deploy:
          replicas: 1
          restart_policy:
            condition: on-failure
            delay: 30s
            max_attempts: 10
            window: 180s

    volumes:
      ignite-persistence-1:
  1. ignite_1.xml 用于数据持久化

               http://www.apache.org/licenses/LICENSE-2.0

          Unless required by applicable law or agreed to in writing, software
          distributed under the License is distributed on an "AS IS" BASIS,
          WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          See the License for the specific language governing permissions and
          limitations under the License.
        -->
        <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">
           <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
              <!-- Enabling Apache Ignite Persistent Store. -->
              <property name="dataStorageConfiguration">
                 <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
                    <property name="defaultDataRegionConfiguration">
                       <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                          <property name="persistenceEnabled" value="true" />
                       </bean>
                    </property>
                 </bean>
              </property>
              <property name="workDirectory" value="/opt/ignite/apache-ignite/data" />
              <!-- Explicitly configure TCP discovery SPI to provide a list of initial nodes. -->
              <property name="discoverySpi">
                 <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                    <property name="ipFinder">
                       <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
                       <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
                       <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                          <property name="addresses">
                             <list>
                                <!-- In distributed environment, replace with actual host IP address. -->
                                <value>127.0.0.1:47500..47502</value>
                             </list>
                          </property>
                       </bean>
                    </property>
                 </bean>
              </property>
           </bean>
        </beans>

我将 docker-compose.yml 和 ignite_1.xml 保存在同一目录中,并从该目录打开终端并执行以下命令。

docker-compose up

通过使用 ignite-persistence-1:/opt/ignite/ 即使我停止或关闭 docker-compose 我也能够保留数据.

我希望这对其他人也有帮助。

谢谢。