当前位置: 首页 > 知识库问答 >
问题:

ignite集群与kubernetes集成

容磊
2023-03-14

我是新点燃的。

步骤1:我在两个VM(ubuntu)中安装了Ignite 2.6.0,在一个VM中启动了节点。下面有COMAND。bin/ignite.sh examples/config/example-ignite.xml

步骤2:我的所有配置都在example-default.xml中

步骤3:在其他VM中执行包含datagrid逻辑的client.jar(该VM既是客户机也是节点)。

步骤4:能够在缓存中存储数据。

    null

步骤3:现在我启动了相同的client.jar,它给出了exception(attached)命令来运行client is attached(Kubernetes和Ignite安装在同一个VM(ubuntu)中)

请让我知道Test2中有任何错误。提前谢了。

 <bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <!-- Set to true to enable distributed class loading for examples, default is false. -->
        <property name="peerClassLoadingEnabled" value="true"/>
        <property name="clientMode" value="false"/>

        <!-- Enable task execution events for examples. -->
        <property name="includeEventTypes">
            <list>

                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>


                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
            </list>
        </property>


    <property name="publicThreadPoolSize" value="40"/>
    <property name="systemThreadPoolSize" value="30"/>

     <property name="dataStorageConfiguration">
                 <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
                         <property name="dataRegionConfigurations">
                                 <list>
                                         <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                                         <!-- Custom region name. -->
                                         <property name="name" value="6GB_Region"/>

                                         <!-- 100 MB initial size. -->
                                         <property name="initialSize" value="#{100L * 1024 * 1024}"/>

                                         <!-- 6 GB maximum size. -->
                                         <property name="maxSize" value="#{6L * 1024 * 1024 * 1024}"/>

                                         <!-- Enabling persistence for the region. -->
                                         <property name="persistenceEnabled" value="true"/>
                                         <property name="metricsEnabled" value="true"/>
                                        </bean>
                                 </list>
                         </property>
                 </bean>
    </property>

    <property name="cacheConfiguration">
        <list>
         <bean id="myCacheTemplate" class="org.apache.ignite.configuration.CacheConfiguration">
                 <property name="dataRegionName" value="6GB_Region"/>
                 <property name="name" value="myCache"/>
                <property name="atomicityMode" value="ATOMIC"/>
                 <property name="cacheMode" value="REPLICATED"/>
                 <property name="backups" value="0"/>
                 <property name="copyOnRead" value="false"/>
                                 <property name="rebalanceBatchSize" value="#{1024 * 1024}"/>
                                 <property name="rebalanceThrottle" value="0"/>
                                 <property name="rebalanceThreadPoolSize" value="4"/>
                                <!-- <property name="swapEnabled" value="false"/> 
                                 <property name="startSize" value="#{100 * 1024 * 1024}"/> 
                <property name="evictionPolicy">

                         <bean class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">

                         <property name="maxSize" value="1000000"/>
                         </bean>
                </property>
                <property name="offHeapMaxMemory" value="0"/>-->
         </bean>
         </list>
    </property>


        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <!--
                        Ignite provides several options for automatic discovery that can be used
                        instead os static IP based discovery. For information on all options refer
                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
                    -->
                    <!-- 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.kubernetes.TcpDiscoveryKubernetesIpFinder">
                    <property name="namespace" value="ignite"/>
                    <property name="serviceName" value="ignite"/>
                    <!-- <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>xxx.xxx.xxx.xxx:47500</value>
                                <value>xxx.xxx.xxx.xxx:47500</value>                                
                            </list>
                        </property>
                    </bean>
                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder">
                <property name="namespace" value="ignite"/>
                    </bean>-->
                </property>
            </bean>
        </property>
    </bean>
</beans>
    try (Ignite ignite = Ignition.start("/opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-ignite.xml")) {
    //try (Ignite ignite = Ignition.start("D:\\ApacheIgnite\\apache-ignite-fabric-2.6.0-bin\\examples\\config\\example-ignite.xml")) {


        ignite.cluster().active(true);
        System.out.println(">>> Cache asynchronous API started.");



        // Auto-close cache at the end of the example.
        try (IgniteCache<String, String> cache = ignite.getOrCreateCache("myCache")) {

           Collection<IgniteFuture<?>> futs = new ArrayList<>();

            // Execute several puts asynchronously.
           String key = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
           String value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

           System.out.println("CAME HERE 11"); 

           long put_start_time = System.currentTimeMillis();
           // Execute several puts asynchronously.
           for(int i=0;i<messageCount;i++) {

             futs.add(cache.putAsync(key+String.valueOf(i), value));

           }        
           long put_end_time = System.currentTimeMillis();

           System.out.println("Time taken to put="+(put_end_time-put_start_time)+" Milli Seconds ");

          key = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
          long get_start_time = System.currentTimeMillis();

          // Wait for completion of all futures.
          for (IgniteFuture<?> fut : futs) fut.get();



          // Execute get operation asynchronously and wait for result.
          for(int i=0;i<messageCount;i++) {
              cache.getAsync(key+String.valueOf(i)).listen(new IgniteInClosure<IgniteFuture<String>>() {

                  /**
                 * 
                 */
                private static final long serialVersionUID = -2066693655303313807L;

                @Override
                  public void apply(IgniteFuture<String> fut) {
                      //System.out.println("Get operation completed [value=" + fut.get() + ']');
                  }
              });
          }

          long get_end_time = System.currentTimeMillis();
          System.out.println("Time taken to get="+(get_end_time-get_start_time)+" Milli Seconds ");


          // Get the metrics of all the data regions configured on a node.
          Collection<DataRegionMetrics> regionsMetrics = ignite.dataRegionMetrics();
          System.out.println("----------------------------------Data Region Metrics---------------------------------- ");         
          // Print out some of the metrics.
          for (DataRegionMetrics metrics : regionsMetrics) {

              System.out.println(">>> Memory Region Name: " + metrics.getName());
              System.out.println(">>> Allocation Rate: " + metrics.getAllocationRate());
              System.out.println(">>> Fill Factor: " + metrics.getPagesFillFactor());
              System.out.println(">>> Allocated Size: " + metrics.getTotalAllocatedSize());
              System.out.println(">>> Physical Memory Size: " + metrics.getPhysicalMemorySize());
              System.out.println(">>> Total allocated Size: " + metrics.getTotalAllocatedSize());                 
              System.out.println(">>> Eviction Rate: " + metrics.getEvictionRate());                  
              System.out.println(">>> Off Heap Size: " + metrics.getOffHeapSize());
              System.out.println(">>> Off Heap used Size: " + metrics.getOffheapUsedSize());

          }


          System.out.println("Cached size=="+cache.size(CachePeekMode.ALL));
          ignite.compute().broadcast(()->System.out.println(cache.get("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0")));
          //cache.removeAll();
          cache.clear();
          //cache.removeAllAsync();
          System.out.println("Cached size1=="+cache.size(CachePeekMode.ALL));

        }
        finally {
            // Distributed cache could be removed from cluster only by #destroyCache() call.
            //ignite.destroyCache("myCache");
        }
    }
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: ignite
  namespace: ignite
spec:
  selector:
    matchLabels:
      app: ignite
  serviceName: ignite
  replicas: 2
  template:
    metadata:
      labels:
        app: ignite
    spec:
      serviceAccountName: ignite
      containers:
      - name: ignite
        image: apacheignite/ignite:2.6.0
        env:
        - name: OPTION_LIBS
          value: ignite-kubernetes,ignite-rest-http
        - name: selfLink
          value: file:///opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-default.xml
        - name: IGNITE_QUIET
          value: "false"
        - name: JVM_OPTS
          value: "-Djava.net.preferIPv4Stack=true"
        ports:
        - containerPort: 11211 # JDBC port number.
        - containerPort: 47100 # communication SPI port number.
        - containerPort: 47500 # discovery SPI port number.
        - containerPort: 49112 # JMX port number.
        - containerPort: 10800 # SQL port number.
        - containerPort: 8080 # REST port number.
        - containerPort: 10900 #Thin clients port number.
        volumeMounts:
        - mountPath: "/data/ignite"
          name: ignite-storage
  volumeClaimTemplates:
  - metadata:
      name: ignite-storage
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi

例外情况:

Exception in thread "main" class org.apache.ignite.IgniteException: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH) [springUrl=file:/opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-ignite.xml]
        at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:990)
        at org.apache.ignite.Ignition.start(Ignition.java:355)

Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH) [springUrl=file:/opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-ignite.xml]

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ignite.cfg$child#0' defined in URL [file:/opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-ignite.xml]: Cannot create inner bean 'org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#c038203' of type [org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi] while setting bean property 'discoverySpi'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#c038203' defined in URL 

[file:/opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-default.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#c038203' defined in URL [file:/opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-default.xml]: Cannot create inner bean

[file:/opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-default.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder

其他形式的问题...

  • 名称:无私值:file://opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-default.xml

应仅包含以下内容**

  <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder">
    <property name="namespace" value="ignite"/>
  </bean>

**并存档

try(Ignite Ignite=ignition.start(“/opt/apache-ignite-fabric-2.6.0-bin/examples/config/example-ignite.xml”)包含如下所示的自定义配置

       <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                <property name="namespace" value="ignite"/>
                <property name="serviceName" value="ignite"/>
                <bean 
                    <property name="addresses">
                        <list>
                            <value>xxx.xxx.xxx.xxx:47500</value>
                            <value>xxx.xxx.xxx.xxx:47500</value>                                
                        </list>
                    </property>
                </bean>

@客户端-运行

java-xms5G-xmx15g-xx:+useg1gc-xx:+disableexplicitgc-cp“0-bin/libs/ignite-indexing/lucene-queryparser-5.5.2.jar://opt/apache-ignite-fabric-2.6.0-bin/libs/ignite-indexing/lucene-queryparser-5.5.2.jar://opt/apache-ignite-fabric-2.6.0-bin/libs/ignite-indexing/lucene-core-5.5.2.jar://opt/apache-ignite-indexing/lucene-core-5.5.2.jar://opt/apache-ignite-indexing-2.6.0-bin/libs/ignite-indexing-2.6.0-iGnite-indexing/h2-1.4.195.jar://opt/apache-ignite-frick-2.6.0-bin/libs/ignite-indexing/commons-codec-1.11.jar://opt/apache-ignite-frick-2.6.0-bin/libs/ignite-spring/spring-tx-4.3.16.release.jar://opt/apache-ignite-frick-2.6.0-bin/libs/ignite-spring/spring-jdbc-4.3.16.release.jar://opt/apache-ignite-frick-26.0-bin/libs/ignite-spring/spring-expression-4.3.16.release.jar://opt/apache-ignite-fabric-2.6.0-bin/libs/ignite-spring/spring-core-4.3.16.release.jar://opt/apache-ignite-fabric-2.6.0-bin/libs/ignite-fabric-2.6.0-bin/libs/ignite-spring/spring-context-4.3.16.release.jar://opt/apache-ignite-fabric-2.6.0-bin/libs/ige-spring/spring-aop-4.3.16.release.jar://opt/apache-ignite-frabric-2.6.0-bin/libs/ignite-spring/ignite-spring-2.6.0.jar://opt/apache-ignite-frabric-2.6.0-bin/libs/ignite-spring/commons-logging-1.1.1.jar://opt/apache-ignite-frabric-2.6.0-bin/libs/ignite-spring/commons-logging-2.6.0-bin/libs/option/ignite-kubernetes.jTureSync 1000000

共有1个答案

蓬兴国
2023-03-14

您不能有TCPDiscoveryKubernetesIPFinder地址。因此,系统不能从XML创建它。删除地址部分。

 类似资料:
  • 我最近试图创建一个Apache Ignite集群,对此我还是个新手。在创建它并将旧数据库迁移到Apache Ignite时,我面临着几个问题。 这是目前面临的两个问题,并期待着对此的投入。 感谢和问候

  • 问题内容: 我对SQL(Server2008)的较低层次的了解是有限的,现在我们的DBA对此提出了挑战。让我解释一下这种情况:(我已经提到一些明显的陈述,希望我是对的,但是如果您发现有问题,请告诉我)。 我们有一张桌子,上面放着人们的“法院命令”。创建表(名称:CourtOrder)时,我的创建方式如下: 然后,我将非聚集索引应用于主键(以提高效率)。我的理由是,这是一个唯一字段(主键),应该像我

  • 问题内容: 我的网络中有六台台式机,我想构建两个Kubernetes集群。每台机器都安装了Ubuntu 16.04 LTS。最初,所有机器都是单个集群的一部分。但是,我删除了三台机器以设置另一个集群,并在每台机器上执行以下命令: 此后,我重新启动了每台计算机,并通过设置主节点来进行新集群的设置: 此后,我还安装了法兰绒。成功安装主服务器后,我继续进行kubeadm连接以添加其他两台计算机。添加这些

  • 本系列文档介绍使用二进制部署最新 kubernetes v1.6.2 集群的所有步骤,而不是使用 kubeadm 等自动化方式来部署集群。 在部署的过程中,将详细列出各组件的启动参数,它们的含义和可能遇到的问题。 部署完成后,你将理解系统各组件的交互原理,进而能快速解决实际问题。 所以本文档主要适合于那些有一定 kubernetes 基础,想通过一步步部署的方式来学习和了解系统配置、运行原理的人。

  • 根据用户部署和暴露服务的方式不同,有很多种方式可以用来访问 kubernetes 集群。 最简单也是最直接的方式是使用 kubectl 命令。 其次可以使用 kubeconfig 文件来认证授权访问 API server。 通过各种 proxy 经过端口转发访问 kubernetes 集群中的服务 使用 Ingress,在集群外访问 kubernetes 集群内的 service

  • 本系列文档介绍使用二进制部署最新 kubernetes v1.6.2 集群的所有步骤,而不是使用 kubeadm 等自动化方式来部署集群。