In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to configure datanode and datahost in mycat, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
1. DataNode tag
The dataNode tag defines the data nodes in MyCat, which is what we usually call data fragmentation. A data node tag is an independent data fragment.
What this means is that we use the db1 physical database on the database instance named db1, which constitutes a data shard, and finally we identify this shard with the name dn1.
dataNode tag Related properties:
------------------------------
|property name| value| quantitative restrictions|
|----------------------------|
|name | String | (1) |
|----------------------------|
|dataHost | String | (1) |
|----------------------------|
|database | String | (1) |
------------------------------
6.5.1 Name attribute
Define the name of the data node. This name needs to be unique. We need to apply this name to the table tag to establish the relationship between the table and the shard.
6.5.2 DataHost attribute
This attribute is used to define which database instance the shard belongs to. The attribute value refers to the name attribute defined on the datahost tag.
6.5.3 Database Properties
This attribute is used to define the specific library on which specific database instance the shard attribute belongs, because two dimensions are used to define shards here, namely: instance + specific library. Because the table and table structure created on each cry are the same. So doing this makes it easy to split the table horizontally.
6.6 dataHost tag
As the last tag in schema.xml, this tag also exists as the lowest tag in mycat logic library, directly defining specific database instances, read-write separation configurations and heartbeat statements. Now let's parse this label.
select user()
Related properties of dataHost tag:
--------------------------------
|property name| value| quantitative restrictions|
|-------------------------------
|name | String | (1) |
|-------------------------------
|maxCon | Integer | (1) |
|-------------------------------
|minCon | Integer | (1) |
|-------------------------------
|balance | Integer | (1) |
|-------------------------------
|writeType | Integer | (1) |
|-------------------------------
|dbType | String | (1) |
|-------------------------------
|dbDriver | String | (1) |
--------------------------------
6.6.1 Name attribute
Uniquely identifies the datahost tag for use by the upper tags.
6.6.2 maxCon attribute
Specifies the maximum connection per read-write instance connection pool. In other words, the writehost and readhost tags nested within the tag will use this attribute only to instantiate the maximum number of connections in the connection pool.
6.6.3 minCon Properties
Specifies the minimum connections per read-write instance connection pool, initializing the size of the connection pool.
6.6.4 Balance properties
Load Balancer type. Currently, there are 3 values:
1. balance="0", read/write separation is not enabled, all reads are sent to the currently available writehost.
2. balance="1," all readhost and standby wtirehost participate in Load Balancer of select statement. Simply put, when dual-master and dual-slave mode (M1->S1, M2->S2, and M1 and M2 are active and standby), under normal circumstances, M2,S1 and S2 all participate in Load Balancer of select statement.
3. balance="2", so reads are randomly distributed on writehost and readhost.
4. balance="3", all read requests are randomly distributed to the readhost corresponding to writehost, writehost does not bear the read pressure, note that balance=3 is only available in version 1.4 and later, and not available in version 1.3.
6.6.5 The writeType attribute
Load Balancer type. Currently, there are 3 values:
1. writeType="0", many write operations are sent to the first writehost configured, the first one is suspended, the second writehost is still alive, and after restarting, the one after switching shall prevail. The switching is recorded in the configuration file: dnindex.properties
2. writeType="1", all writes are sent randomly to the configured wtirehost, deprecated after 1.5 is not recommended.
switchtype attribute
6.6.6 dbType attribute
Specifies the database type of the backend connection, currently supporting the binary mysql protocol, and other databases connected using jdbc. For example: mongodb, oracle, spark, etc.
6.6.7 dbDriver Properties
Specifies the driver used to connect to the backend database, currently optional values are native and jdbc. Using native, since this value implements the binary mysql protocol, mysql and maridb can be used. Other types of databases need to be supported using the jdbc driver.
If jdbc is used, you need to put the driver jar package conforming to jdbc4 standard into mycat\lib directory, and detect the files in the driver jar package including the following directory structure: META-INF\services\java.sql.Driver. Write a specific Driver class name in this file, for example: com.mysql.jdbc.Driver.
6.6.8 switchType attribute
- -1 means no automatic switching
- 1 Default, automatic switching
- 2 Decide whether to switch based on mysql master-slave synchronization status
Heartbeat query is show slave status
Switching mechanism for MySQL galary cluster (suitable for clustering)(1.4.1)
Heartbeat statement is show status like 'wsrep %'.
6.6.9 tempReadHostAvailable Properties
If this property is configured, readhost under writehost is still available, and the default is 0 configurable (0, 1).
6.7 heartbeat label
This tag indicates the statement used to perform heartbeat checks with the backend database. For example,MYSQL can use select user(), Oracle can use select 1 from dual, etc.
This tag also has a connectionInitSql attribute, mainly when using Oracla database, the initialization SQL statement that needs to be executed is placed here. For example: alter session set nls_date_format ='y-mm-dd hh34:mi:ss'
1.4 The master-slave switch statement must be: show slave status
6.7.1 writeHost tag, readHost tag
Both tags specify the relevant configuration of the backend database to mycat for instantiating the backend connection pool. The only difference is that writehost specifies a write instance, readhost specifies a read instance, and these read-write instances are composed to meet the system requirements.
Multiple writehosts and readhosts can be defined within a datahost. However, if the backend database specified by writehost goes down, all readhosts bound to that writehost will be unavailable. On the other hand, due to this writehost outage the system will automatically detect it and switch to the alternate writehost.
The attributes of these two tags are the same, so we will introduce them together here.
-----------------------------------
|property name| value| quantitative restrictions|
-----------------------------------
|host | String | (1) |
-----------------------------------
|url | String | (1) |
-----------------------------------
|password | String | (1) |
-----------------------------------
|user | String | (1) |
-----------------------------------
|weight | String | (1) |
-----------------------------------
|usingDecrypt | String | (1) |
-----------------------------------
6.7.2 Host attributes
For identifying different instances, generally writehost we use *M1,readhost we use *S1.
6.7.3 url attribute
Backend instance connection address, if it is a dbdriver using native, it is generally in the form of address: port. Using jdbc or other dbdrivers requires special specification. When jdbc is used, it can be as follows: jdbc:mysql://localhost:3306/.
6.7.4 User Properties
User names required for backend storage instances
6.7.5 Password attribute
Passwords required for backend storage instances
6.7.6 Weight attributes
Weight configuration in readhost as weight of read node (after 1.4)
6.7.7 usingDecrypt Properties
Whether to encrypt password, default 0 No, if you want to enable configuration 1
Thank you for reading this article carefully. I hope that Xiaobian's article "How to configure datanodes and datahosts in mycat" will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!
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.