Ignite Persistence 모드를 적용하자!

Karim·2021년 11월 12일
3

Ignite 운영

목록 보기
4/7
post-thumbnail

1. Version

💬

  • OS : CentOS Linux release 7.8.2003(Core)
  • Ignite : 2.11.0
  • Docker : 19.03.13

2. 설치 전 확인사항

💬

  • 작성자는 docekr로 ignite를 올렸다~
  • ignite로 Persistence가 적용된 xml를 잡고 올리는 방법을 아래 링크에 들어가면 있다.!!

🔖 ignite docker로 설치

3. Persistence란

💬

  • Default는 Persistence 모드가 적용되어 있지 않다.
  • Default는 ignite를 재기동 하면 안에 데이터가 살아지는 휘발성 인 메모리 플랫폼이다.
    !!!비 휘발성으로 사용하고 싶다면 Persistence모드를 사용하면 된다.!!!

💬 Persistence 모드를 사용하게 되면

  • 모든 데이터를 디스크에 저장하고 처리를 위해 최대한 많은 데이터를 RAM에 로드 한다.

    EX)
    100개의 데이터가 있으면 RAM에는 20개 정도의 데이터를 로드할 수 있는 용량이 있으면,
    디스크에 100를 저장하고 RAM에는 그 중 20개만 캐시되서 사용합니다.

  • 각 파티션을 디스크의 별도 파일에 저장한다.

4. Persistence 옵션 적용

💬 Persistence 적용

  • config 위치로 가서 default-config.xml 파일에 적용한다.
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">

    <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>
</bean>

💬 영구 저장소 dir 구성

  • Persistence 옵션이 활성화되면 노드는 사용자 데이터, 인덱스 및 wal 파일을 {IGNITE_WORK_DIR}/db dir에 저장한다.

5. 적용 후 작업 에러 및 해결방법

💬 sql시 에러

  • create 문으로 table을 생성 하려고 하자 마자 errer가 발생했다. ㅜㅜ
  • Can not perform the operation because the cluster is inactive. Note, that the cluster is considered inactive by default if Ignite Persistent Store is used to let all the nodes join the cluster. To activate the cluster call Ignite.active(true).
    클러스터가 비활성화되어 작업을 수행할 수 없습니다. Ignite Persistent Store를 사용하여 모든 노드가 클러스터에 가입하도록 하는 경우 클러스터는 기본적으로 비활성 상태로 간주됩니다. 클러스터를 활성화하려면 Ignite.active(true)를 호출하십시오.
  • single로 구축했는데 Persistent를 사용하려면 클러스터를 활성화 해줘야 한다고 한다.
[07:56:00,000][SEVERE][client-connector-#85][JdbcRequestHandler] Failed to execute SQL query [reqId=211, req=JdbcQueryExecuteRequest [schemaName=PUBLIC, pageSize=1024, maxRows=0, sqlQry=CREATE TABLE City ( id LONG PRIMARY KEY, name VARCHAR), args=Object[] [], stmtType=ANY_STATEMENT_TYPE, autoCommit=true, partResReq=false, explicitTimeout=false, super=JdbcRequest [type=2, reqId=211]]]
class org.apache.ignite.IgniteException: Can not perform the operation because the cluster is inactive. Note, that the cluster is considered inactive by default if Ignite Persistent Store is used to let all the nodes join the cluster. To activate the cluster call Ignite.active(true).
        at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.checkClusterState(IgniteH2Indexing.java:1087)
        at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.querySqlFields(IgniteH2Indexing.java:1135)
        at org.apache.ignite.internal.processors.query.GridQueryProcessor$2.applyx(GridQueryProcessor.java:2847)
        at org.apache.ignite.internal.processors.query.GridQueryProcessor$2.applyx(GridQueryProcessor.java:2843)
        at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
        at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:3407)
        at org.apache.ignite.internal.processors.query.GridQueryProcessor.lambda$querySqlFields$3(GridQueryProcessor.java:2863)
        at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuerySafe(GridQueryProcessor.java:2901)
        at org.apache.ignite.internal.processors.query.GridQueryProcessor.querySqlFields(GridQueryProcessor.java:2837)
        at org.apache.ignite.internal.processors.query.GridQueryProcessor.querySqlFields(GridQueryProcessor.java:2795)
        at org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.executeQuery(JdbcRequestHandler.java:640)
        at org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.doHandle(JdbcRequestHandler.java:310)
        at org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:250)
        at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:204)
        at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:55)
        at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
        at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
        at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
        at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

💬 해결 방법

  • control.sh 파일이 있는 bin dir로 이동한다.
  • control.sh --activate 명령어를 실행한다.
    ./control.sh --activate
/opt/ignite/apache-ignite/bin # ./control.sh --activate
Control utility [ver. 2.11.0#20210911-sha1:8f3f07d3]
2021 Copyright(C) Apache Software Foundation
User: root
Time: 2021-11-12T08:17:18.215
Command [ACTIVATE] started
Arguments: --activate
--------------------------------------------------------------------------------
Command deprecated. Use --set-state instead.
Cluster activated
Command [ACTIVATE] finished with code: 0
Control utility has completed execution at: 2021-11-12T08:17:18.547
Execution time: 332 ms

💬 activate 적용 후 테이블 생성

[08:21:21,006][INFO][exchange-worker-#79][time] Started exchange init [topVer=AffinityTopologyVersion [topVer=1, minorTopVer=2], crd=true, evt=DISCOVERY_CUSTOM_EVT, evtNode=53d1d351-9c3a-45a0-83b9-7f9fd0f17e65, customEvt=DynamicCacheChangeBatch [id=99c39231d71-790217ad-65e2-4a9d-831a-bd576112997b, reqs=ArrayList [DynamicCacheChangeRequest [cacheName=SQL_PUBLIC_CITY1, hasCfg=true, nodeId=53d1d351-9c3a-45a0-83b9-7f9fd0f17e65, clientStartOnly=false, stop=false, destroy=false, disabledAfterStart=false]], exchangeActions=ExchangeActions [startCaches=[SQL_PUBLIC_CITY1], stopCaches=null, startGrps=[SQL_PUBLIC_CITY1], stopGrps=[], resetParts=null, stateChangeRequest=null], startCaches=false], allowMerge=false, exchangeFreeSwitch=false]
[08:21:21,122][INFO][exchange-worker-#79][GridCacheProcessor] Started cache [name=SQL_PUBLIC_CITY1, id=357057985, dataRegionName=default, mode=PARTITIONED, atomicity=ATOMIC, backups=0, mvcc=false]
[08:21:21,138][INFO][exchange-worker-#79][GridDhtPartitionsExchangeFuture] Finished waiting for partition release future [topVer=AffinityTopologyVersion [topVer=1, minorTopVer=2], waitTime=0ms, futInfo=NA, mode=DISTRIBUTED]
[08:21:21,141][INFO][exchange-worker-#79][GridDhtPartitionsExchangeFuture] Finished waiting for partitions release latch: ServerLatch [permits=0, pendingAcks=HashSet [], super=CompletableLatch [id=CompletableLatchUid [id=exchange, topVer=AffinityTopologyVersion [topVer=1, minorTopVer=2]]]]
[08:21:21,141][INFO][exchange-worker-#79][GridDhtPartitionsExchangeFuture] Finished waiting for partition release future [topVer=AffinityTopologyVersion [topVer=1, minorTopVer=2], waitTime=0ms, futInfo=NA, mode=LOCAL]
[08:21:21,226][INFO][exchange-worker-#79][GridDhtPartitionsExchangeFuture] finishExchangeOnCoordinator [topVer=AffinityTopologyVersion [topVer=1, minorTopVer=2], resVer=AffinityTopologyVersion [topVer=1, minorTopVer=2]]
[08:21:21,273][INFO][exchange-worker-#79][GridDhtPartitionsExchangeFuture] Finish exchange future [startVer=AffinityTopologyVersion [topVer=1, minorTopVer=2], resVer=AffinityTopologyVersion [topVer=1, minorTopVer=2], err=null, rebalanced=true, wasRebalanced=true]
[08:21:21,279][INFO][exchange-worker-#79][GridCacheProcessor] Finish proxy initialization, cacheName=SQL_PUBLIC_CITY1, localNodeId=53d1d351-9c3a-45a0-83b9-7f9fd0f17e65
[08:21:21,279][INFO][exchange-worker-#79][GridDhtPartitionsExchangeFuture] Completed partition exchange [localNode=53d1d351-9c3a-45a0-83b9-7f9fd0f17e65, exchange=GridDhtPartitionsExchangeFuture [topVer=AffinityTopologyVersion [topVer=1, minorTopVer=2], evt=DISCOVERY_CUSTOM_EVT, evtNode=TcpDiscoveryNode [id=53d1d351-9c3a-45a0-83b9-7f9fd0f17e65, consistentId=9439e851-2302-40d7-b545-80552a3615d2, addrs=ArrayList [127.0.0.1, 172.17.0.15], sockAddrs=HashSet [/127.0.0.1:39432, bf836fdb9e81/172.17.0.15:39432], discPort=39432, order=1, intOrder=1, lastExchangeTime=1636704010837, loc=true, ver=2.11.0#20210911-sha1:8f3f07d3, isClient=false], rebalanced=true, done=true, newCrdFut=null], topVer=AffinityTopologyVersion [topVer=1, minorTopVer=2]]

6. 적용 후 테스트

💬 ignite stop 전 테이블 생성

  • WITH "template=partitioned,backups=1";
0: jdbc:ignite:thin://127.0.0.1> !table
+-----------+-------------+-----------------------------+------------+
| TABLE_CAT | TABLE_SCHEM |         TABLE_NAME          | TABLE_TYPE | 
+-----------+-------------+-----------------------------+------------+
| IGNITE    | PUBLIC      | CITY                        | TABLE      |  
| IGNITE    | PUBLIC      | CITY1                       | TABLE      |
+-----------+-------------+-----------------------------+------------+

💬 docker stop 후 start 후 !table

0: jdbc:ignite:thin://127.0.0.1> !table
+-----------+-------------+-----------------------------+------------+
| TABLE_CAT | TABLE_SCHEM |         TABLE_NAME          | TABLE_TYPE | 
+-----------+-------------+-----------------------------+------------+
| IGNITE    | PUBLIC      | CITY                        | TABLE      |  
| IGNITE    | PUBLIC      | CITY1                       | TABLE      |
+-----------+-------------+-----------------------------+------------+

!!!잘된다!!!


📚 참고

profile
나도 보기 위해 정리해 놓은 벨로그

0개의 댓글