gpt4 book ai didi

docker - 如何将点火数据安装到主机系统

转载 作者:行者123 更新时间:2023-12-02 21:08:54 35 4
gpt4 key购买 nike

我想在docker中运行apache-ignite,并且我能够做到这一点。
但是问题在于,只要我旋转图像并在点燃时创建表,只要容器正在运行,它就会一直停留在该位置。如果我重新启动容器或再次启动点燃图像,则无法获取该数据。我知道每当旋转图像时,它总是创建新的容器。就我而言,如果我要保留数据,则需要提交并推送容器,以便下次启动时可以获取它。

但是有什么办法,我可以在主机系统上存储点火数据,并且每当我启动镜像时,它将在该位置读取/写入数据(短时批量安装)。

任何人都可以分享例子的经验或想法吗?
谢谢。

我将其与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:
  • 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,我也能够保留数据。

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

    谢谢。

    关于docker - 如何将点火数据安装到主机系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56197092/

    35 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com