您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“heisenberg怎么配置”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“heisenberg怎么配置”這篇文章吧。
首先核心配置就三個文件server.xml,schema.xml,rule.xml,還有hsb.properties,用于對應用服務器配置
hsb的目錄結構如下:
heisenberg
/bin 啟動腳本所在目錄
/conf classpath所在目錄
默認配置文件所在 對應的hsb.properties和log4j.xml必須要在conf下
server.xml,schema.xml,rule.xml 這三個默認在下面
/lib
/logs 默認日志所在目錄
startup.sh -h可以顯示對應的參數
startup.sh -c 可以指定對應的配置folder,比如有幾套系統,-l 可以指定輸出日志目錄,和之前一樣
server.xml
<?xml version="1.0" encoding="UTF-8"?> <heisenberg:server xmlns:heisenberg="https://github.com/brucexx/heisenberg"> <!-- 系統參數定義,服務端口、管理端口,處理器個數、線程池等。 --> <system> <property name="serverPort">4320</property> <property name="managerPort">4321</property> <property name="initExecutor">16</property> <property name="timerExecutor">4</property> <property name="managerExecutor">4</property> <property name="processors">8</property> <property name="processorHandler">16</property> <property name="processorExecutor">16</property> <property name="clusterHeartbeatUser">_HEARTBEAT_USER_</property> <property name="clusterHeartbeatPass">_HEARTBEAT_PASS_</property> <property name="dataNodeHeartbeatPeriod">15000</property> </system> <!--用戶名密碼等 --> <user name="pay"> <property name="password">brucexx</property> <property name="schemas">wms_shard</property> </user> <!-- <user name="pay"> <property name="needEncrypt">true</property> <property name="password">lTrRlcGA0jOuucx8z4pCKj1Qg4GuqQNj2FDT2x9B4P4TEO/O5kj9TxPgzT2JgqY6jo8XsVSvzVqZ4W5DJc1gCA==</property> <property name="schemas">wms_shard</property> </user> --> </heisenberg:server>
其實加密密碼是動態的,大家可根據自己的安全級別來設定,但是要指定hsb.properties里的公鑰
publicKey=xxxxx
大家如果要使用,可以下載源碼 查看EncryptGen這個文件去生成對應的密文,加密方法RSA 位數512,至于如何生成對應的密鑰對,我這里就不說了
schema.xml
<?xml version="1.0" encoding="UTF-8"?> <heisenberg:schema xmlns:heisenberg="https://github.com/brucexx/heisenberg"> <schema name="wms_shard"> <table name="t_asset_deal_type" dataNode="wmsDN$0-99" rule="rule1" /> <table name="t_supplier_account_info" dataNode="wmsDN$0-99" rule="rule1" /> <table name="t_user_account_info" dataNode="wmsDN$0-99" rule="rule1" /> <table name="t_user_bank_sign_request_info" dataNode="wmsDN$0-99" rule="rule2" /> <table name="t_user_bind_bank_info" dataNode="wmsDN$0-99" rule="rule1" /> <table name="t_user_fund_sign_request_info" dataNode="wmsDN$0-99" rule="rule2" /> <table name="t_user_id_map" dataNode="wmsDN$0-99" rule="rule3" /> <table name="t_user_investment_info" dataNode="wmsDN$0-99" rule="rule4" /> <table name="t_cert_info_upload_log" dataNode="wmsDN_Single" rule="rule5" /> <table name="t_cert_file_upload_summary_info" dataNode="wmsDN_Single" rule="rule6" /> <table name="t_user_bind_card_replace_info" dataNode="wmsDN_Single" rule="rule7" /> <table name="t_province_city_info" dataNode="wmsDN_Single" rule="rule7" /> </schema> <dataNode name="wmsDN"> <property name="dataSource"> <dataSourceRef>wmsDS$0-99</dataSourceRef> </property> <property name="poolSize">256</property> <property name="heartbeatSQL">select user()</property> </dataNode> <dataSource name="wmsDS" type="mysql"> <property name="location"> <location>127.0.0.1:5506/wms_db_$00-99</location> </property> <property name="user">work_pay</property> <property name="password">123456</property> </dataSource> <!-- 單庫的 --> <dataNode name="wmsDN_Single"> <property name="dataSource"> <dataSourceRef>wmsDS_Single</dataSourceRef> </property> <property name="poolSize">256</property> <property name="heartbeatSQL">select user()</property> </dataNode> <dataSource name="wmsDS_Single" type="mysql"> <property name="location"> <location>127.0.0.1:5506/wms_db</location> </property> <property name="user">work_pay</property> <property name="password">123456</property> </dataSource> </heisenberg:schema>
里面的密碼也是支持加密的,和server.xml里一樣,加個neeEncrypt,這里不再累述
rule.xml
<?xml version="1.0" encoding="UTF-8"?> <rule> <tableRule name="rule1"> <columns>F_USER_ID</columns> <dbRuleList> <dbRule><![CDATA[ #set($sub_str=$F_USER_ID%1000+"") $!stringUtil.substring($stringUtil.alignRights($sub_str,3,"0"),0,2)]]> </dbRule> </dbRuleList> <tbRuleList> <tbRule><![CDATA[ #set($sub_str=$F_USER_ID%1000+"") #set($sub_str=$stringUtil.alignRights($sub_str,3,"0")) #set($db_flag=$stringUtil.substring($sub_str,0,2)) #set($tb_flag=$stringUtil.substring($sub_str,2)) #set($prefix="_"+$db_flag+"_"+$tb_flag)## $!prefix]]> </tbRule> </tbRuleList> <tbPrefix> <![CDATA[ def map = [:]; for (int i=0; i<100; i++) { def list = []; for (int j=0; j<10; j++) { def k=i<10?"0"+i:i; list.add("_"+k+"_"+j); } map.put(i,list); }; return map; ]]> </tbPrefix> </tableRule> <tableRule name="rule2"> <columns>F_APPLICATION_NO</columns> <dbRuleList> <dbRule><![CDATA[ $!stringUtil.substring($F_APPLICATION_NO,-3,-1)]]> </dbRule> </dbRuleList> <tbRuleList> <tbRule><![CDATA[ #set($db_flag=$!stringUtil.substring($F_APPLICATION_NO,-3,-1)) #set($tb_flag=$!stringUtil.substring($F_APPLICATION_NO,-1)) #set($prefix="_"+$db_flag+"_"+$tb_flag)## $!prefix]]> </tbRule> </tbRuleList> <tbPrefix> <![CDATA[ def map = [:]; for (int i=0; i<100; i++) { def list = []; for (int j=0; j<10; j++) { def k=i<10?"0"+i:i; list.add("_"+k+"_"+j); } map.put(i,list); }; return map; ]]> </tbPrefix> </tableRule> <tableRule name="rule3"> <columns>F_UID</columns> <dbRuleList> <dbRule><![CDATA[ #set($sub_str=$F_UID%1000+"") $!stringUtil.substring($stringUtil.alignRights($sub_str,3,"0"),0,2)]]> </dbRule> </dbRuleList> <tbRuleList> <tbRule><![CDATA[ #set($sub_str=$F_UID%1000+"") #set($sub_str=$stringUtil.alignRights($sub_str,3,"0")) #set($db_flag=$stringUtil.substring($sub_str,0,2)) #set($tb_flag=$stringUtil.substring($sub_str,2)) #set($prefix="_"+$db_flag+"_"+$tb_flag)## $!prefix]]> </tbRule> </tbRuleList> <tbPrefix> <![CDATA[ def map = [:]; for (int i=0; i<100; i++) { def list = []; for (int j=0; j<10; j++) { def k=i<10?"0"+i:i; list.add("_"+k+"_"+j); } map.put(i,list); }; return map; ]]> </tbPrefix> </tableRule> <tableRule name="rule4"> <columns>F_CERTIFICATE_CODE</columns> <dbRuleList> <dbRule><![CDATA[ #set($db_flag=$!stringUtil.crc32($F_CERTIFICATE_CODE)) $!stringUtil.substring($db_flag,-3,-1)]]> </dbRule> </dbRuleList> <tbRuleList> <tbRule><![CDATA[ #set($sub_str=$!stringUtil.crc32($F_CERTIFICATE_CODE)) #set($db_flag=$!stringUtil.substring($sub_str,-3,-1)) #set($tb_flag=$!stringUtil.substring($sub_str,-1)) #set($prefix="_"+$db_flag+"_"+$tb_flag)## $!prefix]]> </tbRule> </tbRuleList> <tbPrefix> <![CDATA[ def map = [:]; for (int i=0; i<100; i++) { def list = []; for (int j=0; j<10; j++) { def k=i<10?"0"+i:i; list.add("_"+k+"_"+j); } map.put(i,list); }; return map; ]]> </tbPrefix> </tableRule> <tableRule name="rule5"> <columns>F_SP_ID</columns> <dbRuleList> <dbRule><![CDATA[0]]> </dbRule> </dbRuleList> <tbRuleList> <tbRule><![CDATA[ #set($tb_flag=$F_SP_ID+"") #set($prefix="_"+$tb_flag)## $!prefix]]> </tbRule> </tbRuleList> <tbPrefix> <![CDATA[ def map = [:]; def list = []; for (int i=0; i<100; i++) { list.add("_"+i); }; map.put(0,list); return map; ]]> </tbPrefix> </tableRule> <tableRule name="rule6"> <columns>F_USER_ID</columns> <dbRuleList> <dbRule><![CDATA[ #set($sub_str=$F_USER_ID%1000+"") $!stringUtil.substring($stringUtil.alignRights($sub_str,3,"0"),0,2)]]> </dbRule> </dbRuleList> <tbRuleList> <tbRule><![CDATA[$!prefix]]> </tbRule> </tbRuleList> <tbPrefix> </tbPrefix> </tableRule> <tableRule name="rule7"> <columns>F_FAKE_PARTITION_ID</columns> <dbRuleList> <dbRule><![CDATA[ #set($sub_str=$F_FAKE_PARTITION_ID%1000+"") $!stringUtil.substring($stringUtil.alignRights($sub_str,3,"0"),0,2)]]> </dbRule> </dbRuleList> <tbRuleList> <tbRule><![CDATA[$!prefix]]> </tbRule> </tbRuleList> <tbPrefix> </tbPrefix> </tableRule> </rule>
大家對號入坐,自己看
然后一個表里有多個字段想命中,
<tableRule name="rule1" forceHit="true"> <columns>F_TRANS_ID,F_BUYER_USER_ID</columns> <dbRuleList> <dbRule><![CDATA[$!stringUtil.substring($F_TRANS_ID,-3,-1)]]></dbRule> <dbRule><![CDATA[ #set($sub_str=$F_BUYER_USER_ID%1000+"") $!stringUtil.substring($stringUtil.alignRights($sub_str,3,"0"),0,2)]]> </dbRule> </dbRuleList> <tbRuleList> <tbRule><![CDATA[ #set($db_flag=$!stringUtil.substring($F_TRANS_ID,-3,-1)) #set($tb_flag=$!stringUtil.substring($F_TRANS_ID,-1)) #set($prefix="_"+$db_flag+"_"+$tb_flag)## $!prefix]]> </tbRule> <tbRule><![CDATA[ #set($sub_str=$F_BUYER_USER_ID%1000+"") #set($sub_str=$stringUtil.alignRights($sub_str,3,"0")) #set($db_flag=$stringUtil.substring($sub_str,0,2)) #set($tb_flag=$stringUtil.substring($sub_str,2)) #set($prefix="_"+$db_flag+"_"+$tb_flag)## $!prefix]]> </tbRule> </tbRuleList> <tbPrefix> <![CDATA[ def map = [:]; for (int i=0; i<100; i++) { def list = []; for (int j=0; j<10; j++) { def k=i<10?"0"+i:i; list.add("_"+k+"_"+j); } map.put(i,list); }; return map; ]]> </tbPrefix> </tableRule>
以上是“heisenberg怎么配置”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。