我想在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'.]
答案 0 :(得分:2)
@Update 您好,经过大量RnD处理后,我能够解决此问题。下面是我做的配置1. docker-compose.yml
# !/usr/bin/python
from gurobipy import *
# Create the model to be used in the terminal
m = Model("777x Optimization")
# Name and Create the variables
x1 = m.addVar(name="First-Class Seat Pitch [in]")
x2 = m.addVar(name="First-Class Seat Width [in]")
x3 = m.addVar(name="First-Class Seat Thickness [in]")
x4 = m.addVar(name="Premium-Economy Seat Pitch [in]")
x5 = m.addVar(name="Premium-Economy Seat Width [in]")
x6 = m.addVar(name="Premium-Economy Seat Thickness [in]")
x7 = m.addVar(name="Number of First-Class Rows")
x8 = m.addVar(name="Number of Premium-Economy Rows")
x9 = m.addVar(name="Number of First-Class Seats Per Row")
x10 = m.addVar(name="Number of Premium-Economy Seats per Row")
# Set objective: f(x1,x2,x3,x4,x5,x6,x7,x8)
obj = x7*x9*(x1+x2+x3) + x8*x10*(x4+x5+x6)
m.setObjective(obj, GRB.MINIMIZE)
# Add constraints
m.addConstr((x7*x1*x2)+(x4*x5*x8) <= 342625, "Area Constraint")
m.addConstr(1512*x8 + 5410*x7 >= 202182, "Ticket Revenue Constraint")
m.addConstr(0.25*x5 + 0.35*x6 +0.4*x4 >= 18.6975, "Premium-Economy Comfort Level Constraint")
m.addConstr(0.25*x2 + 0.35*x3 +0.4*x1 >= 29.16, "First-Class Economy Comfort Constraint")
m.addConstr(x8 - 1.4*x7 >= 0 , "Ratio of First Class to Economy Class Seats Constraint")
m.addConstr(x1 >= 57, "Minimum First-Class Pitch Constraint")
m.addConstr(x2 >= 25, "Minimum First-Class Width Constraint")
m.addConstr(x3 >= 3, "Minimum First-Class Thickness Constraint")
m.addConstr(x4 >= 36, "Minimum Premium-Economy Pitch Constraint")
m.addConstr(x5 >= 18.5, "Minimum Premium-Economy Width Constraint")
m.addConstr(x6 >= 1.5, "Minimum Premium-Economy Thickness Constraint")
m.addConstr(x9*x2 <= 233.04, "Seats Per Aisle Constraint First-Class")
m.addConstr(x10*x5 <= 233.04, "Seats Per Aisle Constraint Premium-Economy")
m.optimize()
for v in m.getVars():
print('%s %g' % (v.varName, v.x))
print('Obj: %g' % obj.getValue())
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:
我将docker-compose.yml和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>
通过使用 ignite-persistence-1:/ opt / ignite / ,即使停止或关闭docker-compose,我也能够保留数据。
我希望这也会对其他人有所帮助。
谢谢。