https://github.com/MyCATApache
https://github.com/MyCATApache/Mycat-Server
https://github.com/MyCATApache/Mycat-doc
https://github.com/MyCATApache/Mycat-Web
https://cloud.tencent.com/info/2ea9920a42d3d4f62c4b6840bb40504a.html
1. 安装jdk1.8
2. 配置hosts
yum install rsync -y
vi /etc/hosts
10.10.111.132 mycat_fz_01
10.10.111.133 mycat_fz_02
10.10.111.134 mycat_fz_03
3.Mysql及zookeeper安装(略)
3.配置mycat: Mycat配置使用说明
cd /home/admin
wget http://dl.mycat.io/1.6.6.1/Mycat-server-1.6.6.1-release-20180908155252-linux.tar.gz
tar xf Mycat-server-1.6.6.1-release-20180908155252-linux.tar.gz
提示:访问MyCAT的用户账号和授权信息是在conf/server.xml文件中配置,而MyCAT用来连接后端MySQL库的用户名密码信息则在conf/schema.xml中,这是两套完全独立的系统,类似的还有MyCAT的逻辑库(schema),逻辑表(table)也是类似的。
cd /home/admin/mycat/conf/
vi schema.xml
<?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema> <schema name="sc1" checkSQLschema="true" sqlMaxLimit="100" dataNode="dn1"/> <schema name="sc2" checkSQLschema="true" sqlMaxLimit="100" dataNode="dn2"/> <dataNode name="dn1" dataHost="dh1" database="db1"/> <dataNode name="dn2" dataHost="dh2" database="db2"/> <dataHost name="dh1" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native"> <heartbeat>select user()</heartbeat> <writeHost host="dh1" url="192.168.1.220:3301" user="root" password="123456"/> </dataHost> <dataHost name="dh2" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native"> <heartbeat>select user()</heartbeat> <writeHost host="dh2" url="192.168.1.220:3302" user="root" password="123456"/> </dataHost> </mycat:schema>
or
<?xml version="1.0" encoding="UTF-8"?> <!-- - - Licensed 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. --> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema xmlns:mycat="http://io.mycat/"> <!-- schema定义 --> <!-- rule="sharding-by-murmur" --> <schema name="zhime-uc-center" checkSQLschema="true" sqlMaxLimit="100"> <table name="china_area_entity" primaryKey="id" autoIncrement="true" dataNode="center0"></table> <table name="identifying_code_entity" primaryKey="id" autoIncrement="true" dataNode="center0,center1,center2,center3" rule="sharding-by-murmur"></table> <table name="mobile_apply_entity" primaryKey="id" autoIncrement="true" dataNode="center0,center1,center2,center3" rule="sharding-by-murmur"></table> <table name="online_user_entity" primaryKey="id" autoIncrement="true" dataNode="center0,center1,center2,center3" rule="sharding-by-murmur"></table> <table name="sms_log_entity" primaryKey="id" autoIncrement="true" dataNode="center0,center1,center2,center3" rule="sharding-by-murmur"></table> <table name="sys_config_entity" primaryKey="id" autoIncrement="true" dataNode="center0,center1,center2,center3" rule="sharding-by-murmur"></table> <table name="sys_user_entity" primaryKey="id" autoIncrement="true" dataNode="center0,center1,center2,center3" rule="sharding-by-murmur"></table> <table name="third_party_info_entity" primaryKey="id" autoIncrement="true" dataNode="center0,center1,center2,center3" rule="sharding-by-murmur"></table> <table name="user_config_entity" primaryKey="id" autoIncrement="true" dataNode="center0,center1,center2,center3" rule="sharding-by-murmur"></table> </schema> <schema name="zhime-api" checkSQLschema="true" sqlMaxLimit="100"> <table name="blacklist_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> <table name="enterprise_info_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> <table name="share_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> <table name="short_url_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> <table name="user_hobby_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> <table name="user_info_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> <table name="user_login_log_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> <table name="user_rsa_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> <table name="user_set_entity" primaryKey="id" autoIncrement="true" dataNode="api0,api1,api2,api3" rule="sharding-by-murmur"></table> </schema> <schema name="zhime-theme" checkSQLschema="true" sqlMaxLimit="100"> <table name="topic" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> <table name="theme_log" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> <table name="comment" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> <table name="replace_comment" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> <table name="home_page" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> <table name="attention" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> <table name="favor" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> <table name="ignore_topic" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> <table name="add_score_log" primaryKey="id" autoIncrement="true" dataNode="theme0,theme1,theme2,theme3" rule="sharding-by-murmur"></table> </schema> <schema name="zhime-addressbook" checkSQLschema="true" sqlMaxLimit="100"> <table name="address_books_bulking_detail_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="address_books_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="crowd_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="crowd_file_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="crowd_member_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="crowd_photo_album_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="crowd_photo_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="discussion_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="discussion_file_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="discussion_member_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="discussion_photo_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="evaluation_voice_heard_record_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="friend_appraise_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="friend_appraise_item_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="friend_appraise_score_detail_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="im_single_chat_record_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="im_tribe_char_record_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="im_user_emtity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="local_directory_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="new_friend_recommend_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="new_pal_message_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="single_chat_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> <table name="user_device_entity" primaryKey="id" autoIncrement="true" dataNode="addressbook0,addressbook1,addressbook2,addressbook3" rule="sharding-by-murmur"></table> </schema> <schema name="zhime-email" checkSQLschema="true" sqlMaxLimit="100"> <table name="contact_book_bulking_detail_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="delbox_attachment_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="delbox_bcc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="delbox_cc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="delbox_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="delbox_to_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="draftbox_attachment_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="draftbox_bcc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="draftbox_cc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="draftbox_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="draftbox_to_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="email_contact_book_detail_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="email_contact_book_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="email_count_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="email_set_customize_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="email_share_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="inbox_attachment_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="inbox_bcc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="inbox_cc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="inbox_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="inbox_to_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="junkbox_attachment_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="junkbox_bcc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="junkbox_cc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="junkbox_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="junkbox_to_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="outbox_attachment_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="outbox_bcc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="outbox_cc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="outbox_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="outbox_to_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="recent_contact_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="un_sendbox_attachment_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="un_sendbox_bcc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="un_sendbox_cc_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="un_sendbox_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="un_sendbox_to_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> <table name="user_email_entity" primaryKey="id" autoIncrement="true" dataNode="email0,email1,email2,email3" rule="sharding-by-murmur"></table> </schema> <schema name="zhime-company" checkSQLschema="true" sqlMaxLimit="100"> <table name="advice" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="advice_accessory" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="advice_comment" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_admin" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_admin_dynamic" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_admin_range" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_cooperate" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_department" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_department_update" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_department_version" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_dynamic" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_group" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_member" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_member_role" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_member_update" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_member_version" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_message" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_power" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_product" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_receiving_resume" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_recruit_job" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_role" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_score_detail" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_unit" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="company_version" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="disc" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="disc_common" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="disc_file_send_user" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="disc_log" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="disc_me" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="disc_me_power" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="disc_power_user" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_data" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_data_content" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_data_file" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_data_message" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_data_score_log" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_data_send_user" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_model" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_model_admin" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_model_property" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_model_send_user" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_model_set" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_model_user" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="log_model_value" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="notice" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="notice_user_relation" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="rank_quota" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="receiving_resume_feed_back" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="receiving_resume_log" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="recruit_interview" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_accessory" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_actor" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_attention" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_comment" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_log" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_quota" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_record" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_record_accessory" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_record_comment" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_record_favour" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_setting" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_timer_job" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_user_setting" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="task_zhime_score_record" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="user_interview_assessment" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="work" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="work_automatic_set" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="work_score_log" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="work_set" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> <table name="work_set_user" primaryKey="id" autoIncrement="true" dataNode="company0,company1,company2,company3" rule="sharding-by-murmur"></table> </schema> <schema name="zhime-rating" checkSQLschema="true" dataNode="rating0" sqlMaxLimit="100"></schema> <schema name="zhime-newpoint" checkSQLschema="true" dataNode="newpoint0" sqlMaxLimit="100"></schema> <schema name="zhime-circle" checkSQLschema="true" dataNode="circle0" sqlMaxLimit="100"></schema> <schema name="zhime-treaty" checkSQLschema="true" dataNode="treaty0" sqlMaxLimit="100"></schema> <schema name="zhime-score" checkSQLschema="true" dataNode="score0" sqlMaxLimit="100"></schema> <schema name="zhime-message" checkSQLschema="true" dataNode="message0" sqlMaxLimit="100"></schema> <schema name="zhime-resume" checkSQLschema="true" dataNode="resume0" sqlMaxLimit="100"></schema> <schema name="zhime-operation" checkSQLschema="true" dataNode="operation0" sqlMaxLimit="100"></schema> <dataNode name="center0" dataHost="localhost1" database="zhime-uc-center0" /> <dataNode name="center1" dataHost="localhost1" database="zhime-uc-center1" /> <dataNode name="center2" dataHost="localhost1" database="zhime-uc-center2" /> <dataNode name="center3" dataHost="localhost1" database="zhime-uc-center3" /> <dataNode name="api0" dataHost="localhost1" database="zhime-api0" /> <dataNode name="api1" dataHost="localhost1" database="zhime-api1" /> <dataNode name="api2" dataHost="localhost1" database="zhime-api2" /> <dataNode name="api3" dataHost="localhost1" database="zhime-api3" /> <dataNode name="theme0" dataHost="localhost1" database="zhime-theme0" /> <dataNode name="theme1" dataHost="localhost1" database="zhime-theme1" /> <dataNode name="theme2" dataHost="localhost1" database="zhime-theme2" /> <dataNode name="theme3" dataHost="localhost1" database="zhime-theme3" /> <dataNode name="addressbook0" dataHost="localhost1" database="zhime-addressbook0" /> <dataNode name="addressbook1" dataHost="localhost1" database="zhime-addressbook1" /> <dataNode name="addressbook2" dataHost="localhost1" database="zhime-addressbook2" /> <dataNode name="addressbook3" dataHost="localhost1" database="zhime-addressbook3" /> <dataNode name="email0" dataHost="localhost1" database="zhime-email0" /> <dataNode name="email1" dataHost="localhost1" database="zhime-email1" /> <dataNode name="email2" dataHost="localhost1" database="zhime-email2" /> <dataNode name="email3" dataHost="localhost1" database="zhime-email3" /> <dataNode name="company0" dataHost="localhost1" database="zhime-company0" /> <dataNode name="company1" dataHost="localhost1" database="zhime-company1" /> <dataNode name="company2" dataHost="localhost1" database="zhime-company2" /> <dataNode name="company3" dataHost="localhost1" database="zhime-company3" /> <dataNode name="rating0" dataHost="localhost1" database="zhime-rating" /> <dataNode name="newpoint0" dataHost="localhost1" database="zhime-newpoint" /> <dataNode name="circle0" dataHost="localhost1" database="zhime-circle" /> <dataNode name="treaty0" dataHost="localhost1" database="zhime-treaty" /> <dataNode name="score0" dataHost="localhost1" database="zhime-score" /> <dataNode name="message0" dataHost="localhost1" database="zhime-message" /> <dataNode name="resume0" dataHost="localhost1" database="zhime-resume" /> <dataNode name="operation0" dataHost="localhost1" database="zhime-operation" /> <dataHost name="localhost1" maxCon="500" minCon="10" balance="0" dbType="mysql" dbDriver="native" > <heartbeat>select user()</heartbeat> <!-- can have multi write hosts --> <writeHost host="hostM1" url="10.10.111.2:3306" user="root" password="bnh1923"> <!-- can have multi read hosts --> <readHost host="hostS1" url="10.10.111.2:3306" user="root" password="bnh1923" /> </writeHost> </dataHost> </mycat:schema>
vi server.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mycat:server SYSTEM "server.dtd"> <mycat:server> <system> ... </system> <!-- 全局SQL防火墙设置 --> <!-- <firewall> <whitehost> <host host="127.0.0.1" user="mycat"/> <host host="127.0.0.2" user="mycat"/> </whitehost> <blacklist check="false"> </blacklist> </firewall> --> <user name="root"> <property name="password">bnh1923</property> <property name="schemas">binlog,bydeal-api,bydeal-comment,bydeal-gateway,bydeal-legalcounsel,bydeal-occupation,bydeal-operation,bydeal-usercenter</property> </user> <user name="binlog"> <property name="password">bnh1923</property> <property name="schemas">binlog</property> </user> <user name="bydeal-api"> <property name="password">bnh1923</property> <property name="schemas">bydeal-api</property> </user> <user name="bydeal-comment"> <property name="password">bnh1923</property> <property name="schemas">bydeal-comment</property> </user> <user name="bydeal-gateway"> <property name="password">bnh1923</property> <property name="schemas">bydeal-gateway</property> </user> <user name="bydeal-legalcounsel"> <property name="password">bnh1923</property> <property name="schemas">bydeal-legalcounsel</property> </user> <user name="bydeal-occupation"> <property name="password">bnh1923</property> <property name="schemas">bydeal-occupation</property> </user> <user name="bydeal-operation"> <property name="password">bnh1923</property> <property name="schemas">bydeal-operation</property> </user> <user name="bydeal-usercenter"> <property name="password">bnh1923</property> <property name="schemas">bydeal-usercenter</property> </user>
vi /home/admin/mycat/conf/myid.properties
loadZk=true zkURL=192.168.1.10 #zookeeper集群地址 clusterId=mycat-cluster myid=mycat_fz_01 clusterNodes=mycat_fz_01,mycat_fz_02,mycat_fz_03 #server booster ; booster install on db same server,will reset all minCon to 1 type=server boosterDataHosts=1
vi rule.xml (略)
在schema.xml文件中的逻辑表event 使用的逻辑规则是sharding-by-murmur,因此就需要在rule.xml 中进行配置,这个路由规则是Hash一致性算法。
– colums:表示需要分片的属性,我这里是eventid; – property->count:是在schema.xml中我们配置的分片的个数,即dataNode的个数,我这里是2;
这个是rule.xml提供的,我这里只是删除了其他未使用的路由规则,方便查看,也就是说,我们是使用了MyCat提供给我们的这个路由规则,所以不用修改这个文件的任何内容。
各个标签的对应关系很好理解,algorithm中的murmur对应function的name。
4.初始化zk配置
../bin/init_zk_data.sh
5.启动mycat服务
../bin/mycat/mycat start