In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what is the configuration of schema.xml". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the configuration of schema.xml"?
Schema.xml configuration introduction schema label
1. Name: the name of the configuration logic library (that is, the database instance name shown by mycat)
2. DataNode: it is used to configure the default shards of the logic library. Tables that are not configured through the table tag will go to the default shard. Note here that the table that is not configured in the table tag cannot be displayed with the tool, but it can be used normally.
If the dataNode attribute is not configured, the table that is not configured on the table tag cannot be used.
If you create a table through mycat and the table is not pre-configured with table tags, mycat will find the default dataNode and build the table on the default dataNode. If the default dataNode is not configured, mycat will report an error.
If the table has a configured table tag, the table is created on the dataNode specified by the table tag.
3. CheckSQLschema:boolean type
When the current side executes [select * from USERDB.tf_user;] (the mycat logical library name is specified before the table name)
Two values:
True:mycat converts the statement to [select * from tf_user;]
False: will report an error
4. SqlMaxLimit: equivalent to the result set of sql, plus [limit N]. If the sql itself has specified limit, then the sql specifies shall prevail.
If the needAddLimit attribute of a table-tagged table is configured to false, the sql of the table forbids automatic addition of limit
Table tag
The table tag is a child of the schema tag.
The table tag is used to define the logical table of the Mycat and the slicing rules of the logical table.
1. Name: the table name of the logical table. The same schema table name must be unique.
2. DataNode: define the dataNode to which this logical table belongs, separated by commas, such as: dataNode= "dn1,dn2"
3. Rule: this attribute is used to specify the rule name to be used by the logical table. The rule name is defined in rule.xml and must correspond to the value of the name attribute attribute in the tableRule tag.
4. RuleRequired: this attribute is used to specify whether the table is bound with sharding rules. If it is configured as true, but no specific rule is configured, the program will report an error.
5. PrimaryKey: specifies that the logical table corresponds to the primary key of the real table. MyCat caches information about the primary key (configured through the primaryKey property) and the specific dataNode. When the sharding rule uses a non-primary key for sharding, then when querying with the primary key, MyCat will first determine which dataNode the record is recorded on through the cache, and then execute the query on that dataNode.
If the cache does not hit, the statement is still sent to all dataNode.
With regard to the primary key cache of Mycat, the mechanism is that when the SQL statement queried by the primary key is executed for the first time, Mycat will analyze the result, determine which part the primary key is on, and cache the primary key to the shard ID. By connecting to the 9066 management port of MyCAT and performing show@@cache, you can display the current cache usage. You can execute show @ @ cache at two time points before and after the execution of sql, and determine whether the cache of the corresponding table has been updated by the LAST_PUT and LAST_ACCESS columns in the result information.
6. Type: this attribute defines the type of logical table. At present, there are only two types of logical table: global table and normal table.
Corresponding configuration:
Overall table: global.
Regular tables: all tables that do not specify this value as global.
7. AutoIncrement: indicates that the table uses self-growth strategy
8. SubTables: sub-table configuration, which is supported after mycat1.6, but dataNode can only be configured with one sub-table.
9. NeedAddLimit: used in conjunction with the sqlMaxLimit of the schema tag. If the limit value is false, the statement will not add limit.
ChildTable tag
The childTable tag is used to define the child table of the Emurr shard. Associate with the parent table through the attributes on the tag.
1. Name: defines the table name of the child table
2. JoinKey: when inserting a child table, the value of this column is used to find the data node stored in the parent table.
3. ParentKey: the value specified by this attribute is generally the name of the column associated with the parent table. Mycat first gets the value of joinkey, then generates a query statement through the column name specified by the parentKey attribute, and executes the statement to get which slice the parent table is stored on. Thus determine the location where the child table is stored.
4. PrimaryKey: same as the table tag description.
5. NeedAddLimit: same as the table tag description.
DataNode tag
1. Name: specify the name of the part
2. DataHost: define which database instance the shard belongs to
3. Database: define which specific database instance the shard belongs to (that is, the actual DB in the mysql)
DataHost tag
Define the database host at the back end
1. Name: specify the name of dataHost
2. MaxCon: specify the maximum connection for each read-write instance connection pool. In other words, the writeHost and readHost tags nested within the tag will use the value of this attribute to instantiate the maximum number of connections to the connection pool.
3. MinCon: specify the minimum connection of each read-write instance connection pool and initialize the size of the connection pool.
4. Balance: type of load balancer:
(1) balance= "0". The read-write separation mechanism is not enabled, and all read operations are sent to the currently available writeHost.
(2) balance= "1", all readHost and stand by writeHost participate in the load balancing of select statements. To put it simply, when the double master and double slave mode (M1-> S1 Magi M2-> S2, and M1 and M2 are the main and standby of each other), under normal circumstances, M2Magine S1 and S2 participate in the load balancing of select statements.
(3) balance= "2", all read operations are randomly distributed on writeHost and readhost.
(4) balance= "3". All read requests are randomly distributed to the corresponding readhost of wiriterHost for execution. WriterHost does not bear the read pressure. Note that balance=3 is only available in version 1.4 and later.
5. WriteType: load balancing strategy:
(1) writeType= "0". All write operations are sent to the first writeHost of the configuration, and the first riteHost is hung up to the second riteHost that is still alive. After rebooting, the switch is recorded in the configuration file: dnindex.properties.
(2) writeType= "1". It is not recommended that all write operations are randomly sent to the configured writeHost,1.5.
6. DbType: specify the database type for backend connections. Currently, binary mysql protocol is supported, as well as other databases that use JDBC connections. For example: mongodb, oracle, spark, etc.
7. DbDriver: specify the Driver used to connect to the backend database. Available values are native and JDBC. If you use native, because this value implements the binary mysql protocol, you can use mysql and maridb. Other types of databases need to be supported by JDBC drivers.
8 、 switchType:
-1 means no automatic switching
1 default value, automatic switching
2 decide whether to switch the heartbeat statement to show slave status based on the status of MySQL master-slave synchronization
3 MySQL galary cluster-based handover mechanism (suitable for cluster) heartbeat statement is show status like 'wsrep%'.
9. TempReadHostAvailable: if the readHost under writeHost is still available if this property is configured, 0 is configurable by default (0,1).
WriteHost tags and readHost tags
1. Host: used to identify different instances. Generally, we use M1 writeHost and we use S1 to identify different instances.
2. Url: the connection address of the backend instance. If the dbDriver of native is used, it is generally in the form of address:port. If you use JDBC or other dbDriver, you need a special specification. When using JDBC, you can write: jdbc:mysql://localhost:3306/.
3. User: user name of instance database
4. Password: user password of instance database
5. Weight attribute: the weight is configured in readhost as the weight of the read node (after 1.4)
6. UsingDecrypt: whether to encrypt the password by default 0 No, if you need to enable configuration 1, use the encryption program to encrypt the password.
Thank you for your reading, the above is the content of "what is the configuration of schema.xml?" after the study of this article, I believe you have a deeper understanding of what the configuration of schema.xml has, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.