工做很忙,可是郵件,qq等來諮詢的人比較多,因此在這裏再發一個閹割後生產的配置供你們參考mysql
首先核心配置就三個文件server.xml,schema.xml,rule.xml,還有hsb.properties,用於對應用服務器配置git
hsb的目錄結構以下:github
heisenberg
sql
/bin 啓動腳本所在目錄安全
/conf classpath所在目錄服務器
默認配置文件所在 對應的hsb.properties和log4j.xml必需要在conf下 加密
server.xml,schema.xml,rule.xml 這三個默認在下面spa
/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>