1. 程式人生 > >apache Ignite 實戰+資料遷移部署

apache Ignite 實戰+資料遷移部署

1,因mysql壓力需求,採用apache Ignite做快取前置,考慮不影響現有業務邏輯下,apache Ignite昨為查詢主庫,mysql不變,所以以mysql為持久層,php寫個載入啟動,mysql表比較多,手寫配置檔案不符合場景,決定用php寫啟動應用程式碼
2,配置檔案(說明:採用純快取不切實際,200多萬資料好用1G記憶體,配置持久化

<?xml version="1.0" encoding="UTF-8"?>
			<!--
			  Licensed to the Apache Software Foundation (ASF) under one or more
			  contributor license agreements.  See the NOTICE file distributed with
			  this work for additional information regarding copyright ownership.
			  The ASF licenses this file to You under the Apache License, Version 2.0
			  (the "License"); you may not use this file except in compliance with
			  the License.  You may obtain a copy of the License at

				   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">
				<!--
					Alter configuration below as needed.
				-->
				<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
					<!-- Enabling ODBC. -->
					<property name="odbcConfiguration">
					  <bean class="org.apache.ignite.configuration.OdbcConfiguration"/>
					</property>
					<!--慢客戶端列隊限制-->
				  <property name="communicationSpi">
					<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
					  <property name="slowClientQueueLimit" value="1000"/>
					</bean>
				  </property>
					<!--<property name="memoryConfiguration">
					  <bean class="org.apache.ignite.configuration.MemoryConfiguration">
						<property name="defaultMemoryPolicySize" value="#{1L * 1024 * 1024 * 1024}"/>
					  </bean>
					</property>-->
					  <!-- Enabling Apache Ignite native persistence. -->
					  <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>
					<!-- Configuring cache. -->
					<property name="cacheConfiguration">
					  <list>
						<bean class="org.apache.ignite.configuration.CacheConfiguration">
						  <property name="name" value="PUBLIC"/>
						  <!--<property name="sqlFunctionClasses" value="com.example.SqlFunc"/>-->
						  <property name="cacheMode" value="PARTITIONED"/>
						  <property name="atomicityMode" value="TRANSACTIONAL"/>
						  <property name="writeSynchronizationMode" value="FULL_SYNC"/>
						 </bean>
					</list>
					</property>
					<property name="discoverySpi">
                        <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
						<property name="localPort" value="47500"/>
						<property name="localPortRange" value="20"/>
                          <property name="ipFinder">
                            <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                              <property name="multicastGroup" value="224.0.0.100"/>
                              <property name="addresses">
								  <list>
									<value>139.236.17.64:47500..47509</value>
									<value>139.241.231.73:47500..47509</value>
								  </list>
							  </property>
                            </bean>
                           </property>
						</bean>
					 </property>             
				 </bean>
			</beans>

3,啟動ignite
4,啟用叢集命令
/opt/tmp/apache-ignite-fabric-2.6.0-bin/bin/control.sh --activate
5,程式碼建立表,載如資料庫
6,單臺服務查詢效能遠不如單臺mysql,同樣的資料量同樣的sql,場景不同吧,不符合需求,以致詳情的沒動力貼了。