WO2022037359A1 - Configuration data access method, apparatus, and device, configuration center, and storage medium - Google Patents

Configuration data access method, apparatus, and device, configuration center, and storage medium Download PDF

Info

Publication number
WO2022037359A1
WO2022037359A1 PCT/CN2021/108147 CN2021108147W WO2022037359A1 WO 2022037359 A1 WO2022037359 A1 WO 2022037359A1 CN 2021108147 W CN2021108147 W CN 2021108147W WO 2022037359 A1 WO2022037359 A1 WO 2022037359A1
Authority
WO
WIPO (PCT)
Prior art keywords
configuration
database
computer
server
slave
Prior art date
Application number
PCT/CN2021/108147
Other languages
French (fr)
Chinese (zh)
Inventor
邓辉超
Original Assignee
百果园技术(新加坡)有限公司
邓辉超
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 百果园技术(新加坡)有限公司, 邓辉超 filed Critical 百果园技术(新加坡)有限公司
Publication of WO2022037359A1 publication Critical patent/WO2022037359A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Definitions

  • the present application relates to the field of computer technology, for example, to a configuration data access method, apparatus, device, configuration center, and storage medium.
  • the configuration center has increasingly become one of the core basic components in the entire service governance architecture system.
  • Many other components in the service governance architecture system need to rely on the configuration center to achieve features such as automatic failover, high availability, and current limiting and fuse; while the business system needs to rely on the configuration center to achieve dynamic expansion and the ability to adjust behavior when the business system is running. Therefore, the configuration center needs to have high availability and effectively ensure data consistency.
  • the configuration center since the configuration center is the underlying component, it needs to minimize the dependence on other systems or components.
  • MMM Mysql Master-Master replication manager for Mysql
  • MHA Master High Availability
  • MGR MySQL Group Replication
  • MMM and MHA have the risk of data loss
  • MHA and MGA need to introduce other components or middleware to provide a unified entry, and the configuration center as the underlying component does not want to rely on other components
  • MMM The high availability of MHA and MGA is aimed at the master database, and is not suitable for direct use when the slave database is deployed in a large area.
  • the present application provides a configuration data access method, apparatus, device, configuration center and storage medium, which can optimize the configuration data access scheme of the configuration center in the microservice architecture.
  • the present application provides a configuration data access method, which is applied to a configuration management server of a configuration center in a micro-service architecture, where the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes the A configuration management server and a configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets preset quality requirements, and the configuration server is deployed at least In two groups of second computer rooms, the same group of second computer rooms is located in the same business area, and different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database, the said The master database and the slave database are included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
  • the method includes:
  • the configuration data writing operation is performed on the target master database, wherein the master database in the writable state is based on the preset consistency protocol Sure;
  • the writing success information is fed back.
  • the present application provides a configuration data access method, which is applied to a configuration server of a configuration center in a microservice architecture, where the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes a configuration management service and the configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets the preset quality requirements, and the configuration server is deployed in at least two In a group of second computer rooms, the same group of second computer rooms are located in the same business area, and different groups of second computer rooms are located in different business areas.
  • Each first computer room is equipped with a master database
  • each second computer room is equipped with a slave database.
  • the database and the slave database are included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
  • the method includes:
  • the purpose slave database is selected from the candidate slave database, and the configuration data read operation is performed from the database for the purpose, wherein the purpose is the first distance between the computer room where the database is located and the second computer room where the current configuration server is located. It is less than the second distance between the computer room where the candidate secondary database except the target secondary database is located in the candidate secondary database and the second computer room where the current configuration server is located.
  • the present application provides a configuration data access device, which is applied to a configuration management server of a configuration center in a microservice architecture.
  • the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes the configuration center server.
  • a configuration management server and a configuration server the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets preset quality requirements, and the configuration server is deployed at least In two groups of second computer rooms, the same group of second computer rooms is located in the same business area, and different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database, the said The master database and the slave database are included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
  • the device includes:
  • Write event monitoring module set to detect whether the configuration data write event is triggered
  • the writing operation module is set to be triggered in response to detecting that the configuration data writing event is triggered, and in the case where it is detected that the target main database corresponding to the first computer room is in a writable state, write configuration data to the target main database operations, wherein the master database in a writable state is determined based on the preset consistency protocol;
  • the write operation feedback module is configured to feed back write success information after detecting that the master databases in all the master databases except the target master database have completed data synchronization for this write operation.
  • the present application provides a configuration data access device, which is applied to a configuration server of a configuration center in a microservice architecture, where the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes a configuration management service and the configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets the preset quality requirements, and the configuration server is deployed in at least two In a group of second computer rooms, the same group of second computer rooms are located in the same business area, and different groups of second computer rooms are located in different business areas.
  • Each first computer room is equipped with a master database
  • each second computer room is equipped with a slave database.
  • the database and the slave database are included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
  • the device includes:
  • the read event triggers the detection module, which is set to detect whether the configuration data read event is triggered;
  • a state detection module configured to detect an alternate slave database in a readable state in response to detecting that the configuration data read event is triggered
  • the read operation module is set to select the purpose from the database from the alternative database, and perform a configuration data read operation from the database for the purpose, wherein the purpose is from the computer room where the database is located and the current configuration server is located.
  • the first distance of the second computer room is smaller than the second distance between the computer room where the candidate secondary database except the destination secondary database is located in the candidate secondary database and the second computer room where the current configuration server is located.
  • the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the above-mentioned configuration data access method when the computer program is executed.
  • the application provides a configuration center in a micro-service architecture, including a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in multiple In a first computer room, the network quality between the multiple first computer rooms meets the preset quality requirements, the configuration server is deployed in at least two groups of second computer rooms, and the same group of second computer rooms is located in the same service area, Different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database, the master database and the slave database are included in the database cluster corresponding to the configuration center , all master databases are set to ensure strong data consistency based on preset consistency protocols;
  • the configuration management server is set to perform configuration data access based on the above-mentioned configuration data access method applied to the configuration management server;
  • the configuration server is configured to perform configuration data access based on the above-mentioned configuration data access method applied to the configuration server.
  • the present application provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned configuration data access method is implemented.
  • FIG. 1 is a scenario architecture diagram of an application scenario to which a configuration data access method provided by an embodiment of the present application is applicable;
  • FIG. 2 is a schematic diagram of a configuration center deployment solution provided by an embodiment of the present application
  • FIG. 3 is a schematic diagram of a database cluster deployment solution provided by an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of a configuration data access method provided by an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of another configuration data access method provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of an implementation manner of an intelligent data source provided by an embodiment of the present application.
  • FIG. 7 is a structural block diagram of a configuration data access device provided by an embodiment of the present application.
  • FIG. 8 is a structural block diagram of another configuration data access device provided by an embodiment of the present application.
  • FIG. 9 is a structural block diagram of a computer device according to an embodiment of the present application.
  • This embodiment mainly improves the configuration center in the microservice architecture.
  • the basic idea of microservices is to consider creating applications around business domain components that can be independently developed, managed and accelerated, using microservices cloud architecture and platforms in decentralized components, enabling deployment, management and service functions Interaction just got easier.
  • the configuration of the program is increasing, such as the switch of various functions, the configuration of parameters, and the address of the server, etc., and the expectations for configuration are also getting higher and higher, such as configuration After modification, it takes effect in real time, grayscale release, sub-environment or sub-cluster management configuration, perfect authority mechanism and audit mechanism, etc., adopt a distributed development model, so that the mutual reference between projects increases with the continuous increase of services.
  • the complexity of calling each other between projects increases exponentially, and the workload continues to increase each time a new project is put into production or online, so it is necessary to refer to the configuration center for governance.
  • FIG. 1 is a scenario architecture diagram of an application scenario to which a configuration data access method provided by an embodiment of the present application is applicable.
  • the application scenario may include a configuration center (Config Center) 100 , a database (DataBase, DB) 200 and a business system 300 .
  • the configuration center 100 includes a configuration center server 101 and a configuration center client (Config Client) 102, the configuration center server 101 includes a configuration management service (Config Admin Service) end 1011 and a configuration service (Config Service) end 1012, and the database 200 Including the master database 201 and the slave database 202.
  • the configuration center 100 can be understood as a complete set of systems that provide distributed configuration services.
  • the distributed configuration service can include functions such as configuration modification, publishing, and push.
  • the configuration management server 1011, the configuration server 1012, and the configuration center client 102 can be understood as Submodules in the configuration center 100 are configured.
  • the configuration server 1012 is generally a read-only server, providing configuration pull and push services for clients;
  • the configuration management server 1011 can provide configuration management services, including configuration viewing, modification, and publishing functions;
  • the configuration center client 102 can provide a software development kit (Software Development Kit, SDK) used by the business system, and interact with the configuration server 1012 to implement configuration pull and push functions.
  • the configuration center 100 needs to have high availability and effectively ensure data consistency. At the same time, since the configuration center 100 is a bottom-level component, it needs to minimize the dependence on other systems or components.
  • the configuration center 100 needs to manage the types and data volumes of the configuration data.
  • the configuration management server 1011 can perform write operations such as configuration modification for the master database 201.
  • the master database 201 and the slave database 202 perform data synchronization and configure services.
  • the terminal 1012 may perform a configuration read operation from the database 202 to provide configuration data to the configuration center client 102 .
  • the business system forms multiple business areas (for example, divided by continents, countries, regions or cities, etc.), and it is necessary to deploy equipment equipped with multiple sub-modules or databases of the configuration center in a large geographical scope.
  • equipment equipped with multiple sub-modules or databases of the configuration center in a large geographical scope.
  • the computer rooms where the servers are stored are widely distributed, and the communication distance between each two computer rooms is also greatly increased, so the network environment becomes more and more unreliable, and the reliability and availability of the configuration center implementation plan are more and more difficult to guarantee. .
  • MMM is a set of script programs that support dual-master failover and dual-master daily management. Since MMM cannot fully guarantee data consistency, MMM is only suitable for scenarios where data consistency requirements are not very high; MHA is MySQL A relatively mature solution in terms of high availability, the software consists of two parts, including a management node (MHA Manager) and a data node (MHA Node).
  • MHA Manager management node
  • MHA Node data node
  • MHA Manager will regularly detect the master (master) node in the cluster, when the master node When a node fails, it can automatically promote the slave (slave) node that stores the latest data to the new master node, and then redirect all other slave nodes to the new master node;
  • MGR is a replication plug-in based on MySQL architecture, using The Paxos protocol implements data consistency among multiple nodes, and MGR supports single-master mode and multi-master mode.
  • both MMM and MHA have the risk of data loss; MHA and MGA need to introduce other components (such as virtual IP address (Virtual IP Address, VIP) components) or database middleware to provide a unified entry, relying on additional operations.
  • VIP Virtual IP Address
  • the configuration center in the embodiment of the present application includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in a plurality of first computer rooms, The network quality between the plurality of first computer rooms meets the preset quality requirements, the configuration server is deployed in at least two groups of second computer rooms, the same group of second computer rooms is located in the same business area, and different groups of second computer rooms are located in the same business area.
  • each first computer room is equipped with a master database
  • each second computer room is equipped with a slave database.
  • the master database and the slave database are included in the database cluster corresponding to the configuration center. Set up a consistency protocol to ensure strong data consistency.
  • strong consistency can mean that any read operation can read the last written value of a data, or, at any time, the data in all nodes is the same, for example, for a relational database, it is required to update Subsequent access to the past data can be seen.
  • the number of the first computer room is not limited, that is, the number of deployments of the configuration management server is not limited, which can be set according to the actual situation (such as the number of business areas).
  • the number of the first computer room can be set as Three, one configuration management server can be integrated into computer equipment such as a server in the corresponding first computer room.
  • Each first computer room is equipped with a main database, that is, the number of the main databases and the number of the first computer rooms can be equal, that is, the number of the main databases can be equal to the deployment number of the configuration management server.
  • the configuration management server can access configuration data for its corresponding main database, and the device where the main database is located and the device where the configuration management server is located can be the same.
  • the types of the master database and the slave database are generally the same. This application does not limit the types of the master database and the slave database.
  • the types of the master database and the slave database can be relational databases such as MySQL, or can be a remote dictionary service (Remote dictionary server). , Redis) and other non-relational databases. All master databases ensure strong data consistency based on a preset consistency protocol. Therefore, the network quality between multiple first computer rooms needs to meet the preset quality requirements, and the network quality between multiple first computer rooms can meet the preset quality requirements.
  • the network quality between any two first computer rooms in all the first computer rooms meets the preset quality requirements, or there may be another first computer room corresponding to each first computer room in all the first computer rooms and each of the first computer rooms
  • the network quality between a computer room meets the preset quality requirements.
  • the network quality can be measured by indicators such as packet loss rate or round-trip time (RTT). Connection, to ensure that the network communication between each other is reliable.
  • the preset consistency protocol may be, for example, the Paxos protocol, or other protocols that can ensure strong data consistency between databases.
  • one or more master nodes can be elected in multiple master databases to be set for data writing, that is, it can be guaranteed that one or more master nodes can be set to write data, and other master databases automatically become
  • the slave node of the master node when writing configuration data to the master node, the master node synchronizes the written configuration data to the slave node, that is, the slave node can passively write the configuration data.
  • the preset consistency protocol will confirm the success of the write operation, thereby ensuring strong data consistency between the primary databases.
  • data synchronization between master-slave nodes or between dual-master nodes is asynchronous, that is to say, during a write operation, as long as one database completes the write, the next write can be performed. , if there is a problem with the database at this time, and other databases have not been synchronized in time, it will cause data loss.
  • strong data consistency is ensured between multiple master databases based on a preset consistency protocol, and data loss due to a problem in one of the master databases will not occur.
  • the slave database is deployed in the business area.
  • the division rules of business areas and the number of business areas can be determined according to the actual business scope and other related factors.
  • a group of second computer rooms can be deployed in each business area.
  • the number of second computer rooms in different groups can be the same or different.
  • the application does not limit the number of second computer rooms in each group of second computer rooms.
  • the number of second computer rooms is not limited, that is, the number of configuration servers deployed is not limited, and one configuration server can be integrated into computer equipment such as servers in the corresponding second computer room.
  • Each second computer room is equipped with a slave database
  • the number of slave databases can be equal to the number of second computer rooms, that is, the number of slave databases can be equal to the deployment quantity of the configuration server, and the configuration server can target its corresponding slave database.
  • the device where the database is located and the device where the configuration server is located can be the same.
  • the following is a schematic description of the configuration center deployment scheme and the database cluster deployment scheme. Take the master database and the slave database as MySQL databases, and the default consistency protocol as the Paxos protocol.
  • the first computer room corresponds to a business area, a group of second computer rooms is deployed in each business area, and the number of second computer rooms in each group of second computer rooms is three.
  • FIG. 2 is a schematic diagram of a configuration center deployment scheme provided by an embodiment of the present application.
  • the portal can be understood as a human-computer interaction interface operated by staff, and the staff can use the Portal to manage services (Configuration) according to the configuration.
  • the address information of the device where the Admin Service) end is located such as IP address and port number, to call the Config Admin Service to perform access operations such as writing configuration data, and the Config Admin Service end can write the configuration data to the corresponding master database.
  • three main databases can form an MGR group.
  • the MGR group realizes strong data consistency based on the Paxos protocol.
  • the Portal and Config Admin Service mainly provide configuration management, writing functions, and reading and writing the main database. Requires global deployment.
  • the Config Service side is set to implement configuration pull and real-time push for the business, which requires high availability and requires global deployment.
  • the Config Service side can select the nearest slave database to read configuration data, and each business area is set with a corresponding slave database. , such as three Asian slave databases, three European slave databases, and three Americas slave databases.
  • FIG 3 is a schematic diagram of a database cluster deployment solution provided by an embodiment of the present application.
  • an MGR Group consists of three nodes (Nodes), that is, three main databases, and the three nodes are elected through the Paxos protocol
  • a Master node is set to write data, and the data of the three nodes is kept strongly consistent through the Paxos protocol.
  • the configuration management server can perceive the role changes of the three nodes of the MGR Group and automatically select the Master node for configuration writing.
  • the three nodes are deployed in three computer rooms in the same city.
  • Slave databases are deployed on three continents around the world, and three computer rooms (second computer rooms) are deployed on each continent.
  • Asynchronous replication (Replicate) can be used to achieve eventual consistency between the slave database and the master database.
  • the configuration server of each second computer room preferentially reads the slave database in the computer room, and downgrades to read other slave databases in the same area when the slave database in the computer room is unavailable, so as to realize the mutual backup of the slave databases, so as to achieve high availability.
  • the implementation details can be See related content below.
  • the type and quantity of the master database the type and quantity of the slave database, the type of the preset consistency protocol, the division method of the business area, the number of the first computer room, and the second computer room in each group of the second computer room.
  • the number of computer rooms, etc. can be set according to actual needs.
  • FIG. 4 is a schematic flowchart of a configuration data access method provided by an embodiment of the present application.
  • the method is applied to a configuration management server of a configuration center in a microservice architecture, and can be executed by a configuration data access device, which can be configured by software and/or Or hardware implementation, generally can be integrated in computer equipment such as servers.
  • the method includes:
  • Step 401 it is detected that a configuration data write event is triggered.
  • the configuration data writing event here may be a configuration data writing event for the master database, and the triggering condition of the event may be set according to actual requirements. For example, when a staff member needs to perform configuration addition, configuration modification, configuration deletion or other configuration data change operations, the above-mentioned addition, modification and deletion can be regarded as write operations.
  • the configuration data writing to the main database is realized by calling the configuration management server.
  • the configuration management server receives the configuration data writing request sent by the configuration management device, it can be considered that the configuration data writing has been detected. event is fired.
  • This application does not limit the number of configuration management devices, which can be one or more. When the number is more than one, it can be the same as the number of the first computer room.
  • the configuration management devices can be set in the first computer room or in Other locations can communicate with the device where the configuration management server is located.
  • Step 402 If it is detected that the target master database corresponding to the first computer room is in a writable state, perform a configuration data writing operation for the target master database, wherein the master database in the writable state is based on the preset consistency. Agreement is confirmed.
  • multiple master databases may elect a master database as a master node based on a preset consistency protocol, and the master database as a master node is in a writable state.
  • the number of master nodes may be one or more, and this application does not limit the number of master nodes. If the target master database corresponding to the first computer room where the current configuration management server is located is the master node, the target master database is in a writable state, and the current configuration management server can detect that the target master database is writable, and then can target the target master database.
  • the primary database performs configuration data write operations. If the target master database corresponding to the first computer room where the current configuration management server is located is not the master node, other configuration management servers will detect the writable master database, thereby realizing highly reliable configuration data writing.
  • Step 403 After detecting that the primary database other than the target primary database has completed the data synchronization for this writing operation, feedback the writing success information.
  • the target master database in the process of writing configuration data to the target master database, since all master databases ensure strong data consistency based on a preset consistency protocol, the target master database will synchronize the written configuration data to other master databases. In the database, after detecting that other primary databases have completed data synchronization for this write operation, it can confirm that the configuration data to be written has been successfully written to all primary databases, and can feedback the successful writing information to the configuration management device. for subsequent operations.
  • the configuration center in the micro-service architecture includes a configuration center server and a configuration center client
  • the configuration center server includes a configuration management server and a configuration server
  • the configuration management server is deployed in In multiple first computer rooms, each first computer room is equipped with a master database. All master databases ensure strong data consistency based on a preset consistency protocol.
  • the network quality between the first computer rooms meets the preset quality requirements, which can ensure that the first computer room is At the same time, it can also ensure the synchronization performance between the main databases and the high availability of the main database.
  • the configuration server is deployed in at least two sets of second computer rooms, and the same group of second computer rooms are located in the same business area.
  • each second computer room is equipped with a slave database.
  • the master database and the slave database are included in the database cluster corresponding to the configuration center.
  • the configuration management server Based on the architecture of the configuration center, the configuration management server detects that the After the configuration data write event is triggered, it actively detects whether the target master database corresponding to the first computer room is in a writable state. If the target master database corresponding to the first computer room is in a writable state, the configuration data is written to the target master database.
  • the main database in the writable state is determined based on the preset consistency protocol, that is, the master node defined in the preset consistency protocol, so as to ensure strong data consistency between the master databases based on this protocol, and detect After the data synchronization for this write operation is completed in the main database other than the target main database, the write success information is fed back, so that the intelligent detection of the writable main database and the configuration data can be realized in the configuration center without relying on other components.
  • High-reliability write operations, and all primary databases are based on preset consistency protocols to ensure high availability and data consistency of the primary databases, avoiding business impact due to data loss.
  • the method before the detecting that the configuration data writing event is triggered, the method further includes: acquiring topology structure information of the database cluster, wherein the topology structure information includes the corresponding relationship between the computer room and the database; The topological structure information is queried in the target master database corresponding to the first computer room where it is located.
  • the topology information can be included in a database topology configuration file, and the application does not limit the format of the configuration file, for example, it can be in a JS Object Notation (JavaScript Object Notation, JSON) format, such as a database topology configuration file. Can be recorded as datasource.json.
  • the topology information can include a list of master databases and a list of slave databases.
  • the master database list may include the IP and port number of each master database
  • the slave database list may include computer room information and location information (such as local area information) corresponding to each slave database.
  • the configuration management server can confirm the IP and port number of its own device, and then compare its own IP and port number with the IP and port number in the main database list, and find the highest similarity (if the device where the configuration management server is located and If the device where the corresponding master database is located is the same, then the master database with the same IP and port number is determined as its corresponding target master database.
  • the method further includes: establishing a first connection with the target master database; detecting the target master database Being in a writable state includes: attempting to write first data to the target primary database based on the first connection, and determining that the target primary database is in a writable state if it is detected that the writing of the first data is successful.
  • the method further includes: if a change in the topology structure information is monitored, determining a new target master database according to the changed topology structure information; The new target master database establishes a second connection.
  • the advantage of this setting is that if the topology information changes, the corresponding target master database may also change, and the first connection with the original target master database can be disconnected, and the second connection with the new target master database can be established.
  • the method further includes: detecting that a configuration data read event is triggered; detecting a candidate master database in a readable state; selecting a target master database from the candidate master databases, and targeting the purpose
  • the main database performs a configuration data read operation, wherein the first distance between the computer room where the target main database is located and the first computer room where the current configuration management server is located is smaller than the first computer room where the other candidate master databases are located and the first computer room where the current configuration management server is located. the second distance.
  • the advantage of this setting is that the configuration management server may also need to read the configuration data. When the configuration management server needs to read the configuration data in the main database, it can select the nearest main database for the read operation.
  • the main database of the purpose is the main database of the same equipment or the same computer room as the current configuration management server.
  • the nearest main database can also be selected from the main databases in the readable state for reading. operate.
  • the detection method may be one by one according to the distance between the computer room where the main database is located and the first computer room where the current configuration management server is located, or may be batch detection. The application does not limit the detection method.
  • FIG. 5 is a schematic flowchart of another configuration data access method provided by an embodiment of the present application.
  • the method is applied to a configuration server of a configuration center in a microservice architecture, and can be executed by a configuration data access device, which can be implemented by software and/or Or hardware implementation, generally can be integrated in computer equipment such as servers.
  • the method includes:
  • Step 501 it is detected that a configuration data read event is triggered.
  • the configuration data reading event here may be an event for reading configuration data from a database, and the triggering condition of the event may be set according to actual requirements.
  • the business system when it needs to obtain configuration data, it can send a configuration data acquisition request to the configuration server through the configuration center client.
  • the configuration server needs to read the configuration data from the database.
  • the configuration server receives the request, It can be considered that the configuration data read event is triggered; for another example, the configuration server can push the configuration data to the business system according to the preset push rules (such as timing or real-time push), and when it is detected that the configuration data needs to be pushed, the configuration service
  • the client needs to read the configuration data from the database, and it can be considered that the configuration data read event is triggered.
  • a configuration server can correspond to one or more configuration center clients, that is, a configuration server can provide configuration pull or push services for one or more business systems.
  • Step 502 Detect a candidate slave database in a readable state.
  • the detection range may be a service area corresponding to the currently configured server, and detection operations may be reduced. To further ensure availability, the detection range may also be multiple service areas.
  • the configuration server in the embodiment of the present application can automatically detect the candidate slave database in a readable state, so as to facilitate the subsequent selection of the optimal slave database to perform the read operation of configuration data.
  • the detection method may be one by one according to the distance between the computer room where the database is located and the computer room where the current configuration server is located, or may be batch detection, which is not limited in this application.
  • Step 503 select the purpose from the database from the alternative database, and perform a configuration data read operation from the database for the purpose, wherein the purpose is from the computer room where the database is located and the second computer room where the current configuration server is located.
  • the first distance is smaller than the second distance between the computer room where the other candidate slave databases are located and the second computer room where the current configuration server is located.
  • the closest slave database may be selected from the candidate slave databases in the readable state to read the configuration data.
  • the slave database that is in the same device or room as the configuration server is the closest. If the slave database is abnormal and is not in a readable state, other slave databases in the same business area can be selected to read the configuration data.
  • the granularity of the distance can be freely set, which can be the distance of the actual geographic coordinates, or it can be a city or a region. For example, if the granularity of the distance is a city, the distance between the computer rooms in the same city can be considered as 0, and the distance between the computer rooms in two adjacent cities can be considered as 1 and so on.
  • the configuration center in the micro-service architecture includes a configuration center server and a configuration center client
  • the configuration center server includes a configuration management server and a configuration server
  • the configuration management server is deployed in In multiple first computer rooms, each first computer room is equipped with a master database. All master databases ensure strong data consistency based on a preset consistency protocol.
  • the network quality between the first computer rooms meets the preset quality requirements, which can ensure that the first computer room is At the same time, it can also ensure the synchronization performance between the main databases and the high availability of the main database.
  • the configuration server is deployed in at least two sets of second computer rooms, and the same group of second computer rooms are located in the same business area. Different groups of second computer rooms are located in different business areas.
  • Each second computer room is equipped with a slave database.
  • the master database and the slave database are included in the database cluster corresponding to the configuration center.
  • the configuration server Based on the architecture of the configuration center, the configuration server detects the configuration After the data read event is triggered, it actively detects the candidate slave database in the readable state, and selects the candidate slave database closest to the current configuration server to read the configuration data, realizes the mutual backup of the slave databases, and ensures the configuration center. high availability.
  • the method before the detecting that the configuration data read event is triggered, the method further includes: acquiring topology structure information of the database cluster, wherein the topology structure information includes information about the correspondence between the computer room and the database, And the corresponding relationship information between the database and the business area; according to the topology information, query the multiple slave databases contained in the target business area corresponding to the second computer room;
  • the detection of the candidate slave database in a readable state includes: A candidate slave database in a readable state is detected from the queried multiple slave databases.
  • the topology information can be included in the database topology configuration file, and the topology information in the configuration server can be the same as the topology information in the configuration management server, that is, the configuration server and the configuration management server belong to The same database topology configuration file may exist in all devices, which facilitates the unified writing, unified update and unified distribution of the database topology configuration file.
  • the topology information in the configuration server can also only include the slave database list. The configuration server can confirm the region and computer room to which it belongs, and then query the slave database that is the same as its own region and computer room in the slave database list.
  • the method further includes: separately establishing a third slave database with the queried multiple slave databases. connecting; the detecting a candidate slave database in a readable state from the queried multiple slave databases includes: trying to read the second data from the multiple queried slave databases based on the third connection. , if it is detected that the second data is successfully read, it is determined that the corresponding slave database is in a readable state, and the determined slave database is used as an alternate slave database.
  • the state of the slave database can be accurately judged.
  • the third connection with the slave database in the same device or in the same computer room as the current configuration server can be established first.
  • a read operation if the slave database is detected based on the third connection
  • a third connection is established with other slave databases, and an alternate slave database in a readable state is detected.
  • the method further includes: if it is monitored that the topology information changes, determining a new query query according to the changed topology information.
  • the multiple slave databases obtained by the new query respectively establish a fourth connection with the multiple slave databases obtained by the new query.
  • the configuration data access method applied to the configuration management server and the configuration data access method applied to the configuration server can be completed by the same program code, and the program can intelligently determine that the configuration data write is currently triggered.
  • the event is still a configuration data read event. Whether the configuration data read event is for the master database or the slave database can be judged according to the received request type or Structured Query Language (SQL) statement.
  • SQL Structured Query Language
  • FIG. 6 is a schematic diagram of an implementation manner of an intelligent data source provided in an embodiment of the present application.
  • datasource.json is the above-mentioned Database topology configuration file.
  • DataSourceConfigSyncer configures a listener for the data source, which is responsible for monitoring changes in datasource.json and notifying the DataSourceManager to rebuild the smart data source.
  • SmartDataSource is the implementation class of smart data source, which provides a unified data access interface to the upper layer. It contains the write data source MultiWriteDataSource and the read data source MultiReadDataSource, and route to the corresponding data source according to the type of SQL.
  • MultiWriteDataSource is the encapsulation of write data source, which contains multiple (for example, 3, the same as the number of main database) WriteDataSource, MultiWriteDataSource will select a writable WriteDataSource to write, and whether it is writable is determined by write heartbeat (WriteHeartbeat)
  • the write SQL is periodically sent for detection.
  • the single-master mode in the MGR may be adopted. In this mode, only one node can write at any time.
  • MultiReadDataSource is the encapsulation of read data source, which contains multiple (for example, a business area deploys 3 slave databases, the number here can be 3) ReadDataSource, MultiReadDataSource will read from all healthy (that is, in readable state) ReadDataSource Select an optimal ReadDataSource for read operations.
  • the health status is detected by periodically sending read SQL through the read heartbeat (ReadHeartbeat), and the selection of the optimal ReadDataSource is based on the priority field indication (select the smallest priority value).
  • the priority is sorted by distance, that is, The smaller the distance, the smaller the corresponding priority value.
  • FIG. 7 is a structural block diagram of a configuration data access device provided by an embodiment of the present application.
  • the device is applied to a configuration management server of a configuration center in a microservice architecture, and can be implemented by software and/or hardware, and can generally be integrated in a server, etc.
  • configuration data access may be performed by executing a configuration data access method.
  • the device includes:
  • the write event monitoring module 701 is set to detect whether the configuration data write event is triggered; the write operation module 702 is set to, after detecting that the configuration data write event is triggered, if the target host corresponding to the first computer room where it is located is detected If the database is in a writable state, the configuration data writing operation is performed on the target master database, wherein the master database in the writable state is determined based on the preset consistency protocol; the write operation feedback module 703 is set to detect After the master database other than the target master database completes the data synchronization for this writing operation, the writing success information is fed back.
  • the configuration center in the micro-service architecture includes a configuration center server and a configuration center client
  • the configuration center server includes a configuration management server and a configuration server
  • the configuration management server is deployed in multiple
  • each first computer room is equipped with a master database. All the master databases ensure strong data consistency based on the preset consistency protocol.
  • the network quality between the first computer rooms meets the preset quality requirements, which can ensure the first computer room. At the same time, it can also ensure the synchronization performance between the main databases and the high availability of the main database.
  • the configuration server is deployed in at least two groups of second computer rooms.
  • the same group of second computer rooms are located in the same business area, but different The second computer room of the group is located in different business areas.
  • Each second computer room is equipped with a slave database.
  • the master database and the slave database are included in the database cluster corresponding to the configuration center.
  • the configuration management server Based on the architecture of the configuration center, the configuration management server detects the configuration After the data write event is triggered, it actively detects whether the target master database corresponding to the first computer room is in a writable state. If the target master database corresponding to the first computer room is in a writable state, the configuration data is written to the target master database.
  • the master database in the writable state is determined based on the preset consistency protocol, that is, the master node defined in the preset consistency protocol, so as to ensure strong data consistency between master databases based on this protocol.
  • the write success information is fed back, so that the intelligent detection of the writable master database and the high level of configuration data can be realized in the configuration center without relying on other components.
  • Reliable write operations, and all primary databases ensure high availability and data consistency of the primary databases based on preset consistency protocols, avoiding business impact due to data loss.
  • FIG. 8 is a structural block diagram of another configuration data access device provided by an embodiment of the present application.
  • the device is applied to a configuration server of a configuration center in a microservice architecture, and can be implemented by software and/or hardware, and can generally be integrated in a server, etc.
  • configuration data access may be performed by executing a configuration data access method.
  • the device includes:
  • the read event trigger detection module 801 is configured to detect whether the configuration data read event is triggered; the state detection module 802 is configured to detect an alternative slave database in a readable state after detecting that the configuration data read event is triggered
  • the read operation module 803 is set to select the purpose from the database from the alternative database, and carry out the configuration data reading operation from the database for the purpose, wherein, the purpose is from the computer room where the database is located and the current configuration service.
  • the first distance of the second computer room where the terminal is located is smaller than the second distance between the computer room where the other candidate slave databases are located and the second computer room where the current configuration server is located.
  • the configuration center in the micro-service architecture includes a configuration center server and a configuration center client
  • the configuration center server includes a configuration management server and a configuration server
  • the configuration management server is deployed in In multiple first computer rooms, each first computer room is equipped with a master database. All master databases ensure strong data consistency based on a preset consistency protocol.
  • the network quality between the first computer rooms meets the preset quality requirements, which can ensure that the first computer room is At the same time, it can also ensure the synchronization performance between the main databases and the high availability of the main database.
  • the configuration server is deployed in at least two sets of second computer rooms, and the same group of second computer rooms are located in the same business area. Different groups of second computer rooms are located in different business areas.
  • Each second computer room is equipped with a slave database.
  • the master database and the slave database are included in the database cluster corresponding to the configuration center.
  • the configuration server Based on the architecture of the configuration center, the configuration server detects the configuration After the data read event is triggered, it actively detects the candidate slave database in the readable state, and selects the candidate slave database closest to the current configuration server to read the configuration data, realizes the mutual backup of the slave databases, and ensures the configuration center. high availability.
  • FIG. 9 is a structural block diagram of a computer device according to an embodiment of the present application.
  • the computer device 900 includes a memory 901, a processor 902, and a computer program that is stored in the memory 901 and can run on the processor 902.
  • the processor 902 executes the computer program, the configuration data access method provided by the embodiments of the present application is implemented. .
  • the embodiments of the present application further provide a storage medium containing computer-executable instructions, where the computer-executable instructions, when executed by a computer processor, are used to execute the configuration data access method provided by the embodiments of the present application.
  • Embodiments of the present application further provide a configuration center in a micro-service architecture, including a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server deploys In a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets the preset quality requirements, the configuration server is deployed in at least two groups of second computer rooms, and the same group of second computer rooms is located in the same service different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database, the master database and the slave database are included in the database corresponding to the configuration center In the cluster, all main databases ensure strong data consistency based on a preset consistency protocol; the configuration management server performs access operations such as configuration data writing based on the configuration data access method described in the embodiment of the present application; the configuration server is based on the The configuration data access method described in the embodiments of the present application performs access operations such as configuration data reading.
  • the configuration data access device, device, storage medium, and configuration center provided in the above embodiments can execute the configuration data access method provided by the embodiment of the present application, and have corresponding functional modules and effects for executing the method.
  • the configuration data access method provided by the corresponding embodiment of the present application can execute the configuration data access method provided by the corresponding embodiment of the present application.

Abstract

A configuration data access method, apparatus, and device, a configuration center, and a storage medium. The configuration data access method is applied to a configuration management server. The configuration management server is deployed in multiple first computer rooms, and a configuration server is deployed in at least two sets of second computer rooms; each first computer room is equipped with a main database, each second computer room is equipped with a secondary database, and the main database is configured to ensure strong data consistency on the basis of a preset consistency protocol. The method comprises: detecting that a configuration data write event is triggered (401); when detected that a target main database, which corresponds to the first computer room in which same is located, is in a writable state, performing a configuration data write operation for the target main database, the main database in the writable state being determined on the basis of a preset consistency protocol (402); and once it is detected that all of the main databases except for the target main database have completed data synchronization for the present write operation, feeding back write success information (403).

Description

配置数据访问方法、装置、设备、配置中心及存储介质Configuration data access method, apparatus, device, configuration center and storage medium
本申请要求在2020年08月18日提交中国专利局、申请号为202010831215.3的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application with application number 202010831215.3 filed with the China Patent Office on August 18, 2020, the entire contents of which are incorporated herein by reference.
技术领域technical field
本申请涉及计算机技术领域,例如涉及配置数据访问方法、装置、设备、配置中心及存储介质。The present application relates to the field of computer technology, for example, to a configuration data access method, apparatus, device, configuration center, and storage medium.
背景技术Background technique
随着微服务架构的发展,配置中心越来越成为整个服务治理架构体系中的核心基础组件之一。服务治理架构体系中的很多其他组件,需要依赖配置中心实现自动故障转移、高可用以及限流熔断等特性;而业务系统需要依赖配置中心实现业务系统运行时的动态扩展和调整行为的能力。因此,配置中心需要具备较高的可用性以及有效保证数据的一致性,同时由于配置中心作为底层组件,需要尽量减少对其他系统或组件的依赖。With the development of the microservice architecture, the configuration center has increasingly become one of the core basic components in the entire service governance architecture system. Many other components in the service governance architecture system need to rely on the configuration center to achieve features such as automatic failover, high availability, and current limiting and fuse; while the business system needs to rely on the configuration center to achieve dynamic expansion and the ability to adjust behavior when the business system is running. Therefore, the configuration center needs to have high availability and effectively ensure data consistency. At the same time, since the configuration center is the underlying component, it needs to minimize the dependence on other systems or components.
在业务部署范围较大(如需要跨越国家或地区)的情况下,要实现配置中心的高可用性及数据一致性的难度更是大大增加。配置中心需要管理的配置数据的种类以及数据量非常庞大,一般需要存储在对应的数据库内,也即配置中心至少要依赖于数据库这一外部系统,因此,实现数据库的高可用和数据一致性非常重要。相关技术中,一般采用多个数据库进行数据存储,包括至少一个主数据库和至少一个从数据库,并采用一定的部署方案来保证数据库的高可用和数据一致性。以常见的关系型数据库MySQL为例,业界常用的MySQL的高可用部署方案有Mysql主主复制管理器(Master-Master replication manager for Mysql,MMM)、主高可用(Master High Availability,MHA)以及MySQL群组复制(MySQL Group Replication,MGR)。但是直接使用这些方案都存在一些问题,MMM和MHA都存在数据丢失的风险;MHA和MGA需要引入其他组件或者中间件来提供统一入口,而配置中心作为底层的组件不希望依赖其他组件;MMM、MHA和MGA的高可用都是针对主数据库的,并不适合在较大区域范围内部署从数据库的情况下直接使用。In the case of a large business deployment range (such as needing to cross countries or regions), it is even more difficult to achieve high availability and data consistency in the configuration center. The type and amount of configuration data that the configuration center needs to manage is very large, and generally needs to be stored in the corresponding database, that is, the configuration center at least depends on the external system of the database. Therefore, it is very important to achieve high availability and data consistency of the database. important. In the related art, multiple databases are generally used for data storage, including at least one master database and at least one slave database, and a certain deployment scheme is adopted to ensure high availability and data consistency of the databases. Taking the common relational database MySQL as an example, the commonly used MySQL high-availability deployment solutions in the industry include Mysql Master-Master replication manager for Mysql (MMM), Master High Availability (MHA) and MySQL Group Replication (MySQL Group Replication, MGR). However, there are some problems in using these solutions directly. Both MMM and MHA have the risk of data loss; MHA and MGA need to introduce other components or middleware to provide a unified entry, and the configuration center as the underlying component does not want to rely on other components; MMM, The high availability of MHA and MGA is aimed at the master database, and is not suitable for direct use when the slave database is deployed in a large area.
发明内容SUMMARY OF THE INVENTION
本申请提供了配置数据访问方法、装置、设备、配置中心及存储介质,可以优化微服务架构中的配置中心的配置数据访问方案。The present application provides a configuration data access method, apparatus, device, configuration center and storage medium, which can optimize the configuration data access scheme of the configuration center in the microservice architecture.
本申请提供了一种配置数据访问方法,应用于微服务架构中的配置中心的配置管理服务端,所述配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括所述配置管理服务端和配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;The present application provides a configuration data access method, which is applied to a configuration management server of a configuration center in a micro-service architecture, where the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes the A configuration management server and a configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets preset quality requirements, and the configuration server is deployed at least In two groups of second computer rooms, the same group of second computer rooms is located in the same business area, and different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database, the said The master database and the slave database are included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
所述方法包括:The method includes:
响应于检测到配置数据写入事件被触发;triggered in response to detecting a configuration data write event;
在探测到所在第一机房对应的目标主数据库处于可写状态的情况下,针对所述目标主数据库进行配置数据写入操作,其中,处于可写状态的主数据库基于所述预设一致性协议确定;When it is detected that the target master database corresponding to the first computer room is in a writable state, the configuration data writing operation is performed on the target master database, wherein the master database in the writable state is based on the preset consistency protocol Sure;
检测到所述所有主数据库中除所述目标主数据库之外的主数据库完成针对本次写入操作的数据同步后,反馈写入成功信息。After it is detected that the primary databases other than the target primary database among all primary databases have completed data synchronization for this writing operation, the writing success information is fed back.
本申请提供了一种配置数据访问方法,应用于微服务架构中的配置中心的配置服务端,所述配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括配置管理服务端和所述配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;The present application provides a configuration data access method, which is applied to a configuration server of a configuration center in a microservice architecture, where the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes a configuration management service and the configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets the preset quality requirements, and the configuration server is deployed in at least two In a group of second computer rooms, the same group of second computer rooms are located in the same business area, and different groups of second computer rooms are located in different business areas. Each first computer room is equipped with a master database, and each second computer room is equipped with a slave database. The database and the slave database are included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
所述方法包括:The method includes:
响应于检测到配置数据读取事件被触发;triggered in response to detecting a configuration data read event;
探测出处于可读状态的备选从数据库;Detect an alternate slave database in a readable state;
从所述备选从数据库中挑选出目的从数据库,并针对所述目的从数据库进行配置数据读取操作,其中,所述目的从数据库所在机房与当前配置服务端所在第二机房的第一距离小于所述备选从数据库中除所述目的从数据库之外的备选从数据库所在机房与当前配置服务端所在第二机房的第二距离。The purpose slave database is selected from the candidate slave database, and the configuration data read operation is performed from the database for the purpose, wherein the purpose is the first distance between the computer room where the database is located and the second computer room where the current configuration server is located. It is less than the second distance between the computer room where the candidate secondary database except the target secondary database is located in the candidate secondary database and the second computer room where the current configuration server is located.
本申请提供了一种配置数据访问装置,应用于微服务架构中的配置中心的 配置管理服务端,所述配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括所述配置管理服务端和配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;The present application provides a configuration data access device, which is applied to a configuration management server of a configuration center in a microservice architecture. The configuration center includes a configuration center server and a configuration center client, and the configuration center server includes the configuration center server. A configuration management server and a configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets preset quality requirements, and the configuration server is deployed at least In two groups of second computer rooms, the same group of second computer rooms is located in the same business area, and different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database, the said The master database and the slave database are included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
所述装置包括:The device includes:
写入事件监测模块,设置为检测配置数据写入事件是否被触发;Write event monitoring module, set to detect whether the configuration data write event is triggered;
写入操作模块,设置为响应于检测到配置数据写入事件被触发,在探测到所在第一机房对应的目标主数据库处于可写状态的情况下,针对所述目标主数据库进行配置数据写入操作,其中,处于可写状态的主数据库基于所述预设一致性协议确定;The writing operation module is set to be triggered in response to detecting that the configuration data writing event is triggered, and in the case where it is detected that the target main database corresponding to the first computer room is in a writable state, write configuration data to the target main database operations, wherein the master database in a writable state is determined based on the preset consistency protocol;
写入操作反馈模块,设置为检测到所述所有主数据库中除所述目标主数据库之外的主数据库完成针对本次写入操作的数据同步后,反馈写入成功信息。The write operation feedback module is configured to feed back write success information after detecting that the master databases in all the master databases except the target master database have completed data synchronization for this write operation.
本申请提供了一种配置数据访问装置,应用于微服务架构中的配置中心的配置服务端,所述配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括配置管理服务端和所述配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;The present application provides a configuration data access device, which is applied to a configuration server of a configuration center in a microservice architecture, where the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes a configuration management service and the configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets the preset quality requirements, and the configuration server is deployed in at least two In a group of second computer rooms, the same group of second computer rooms are located in the same business area, and different groups of second computer rooms are located in different business areas. Each first computer room is equipped with a master database, and each second computer room is equipped with a slave database. The database and the slave database are included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
所述装置包括:The device includes:
读取事件触发检测模块,设置为检测配置数据读取事件是否被触发;The read event triggers the detection module, which is set to detect whether the configuration data read event is triggered;
状态探测模块,设置为响应于检测到配置数据读取事件被触发,探测出处于可读状态的备选从数据库;a state detection module, configured to detect an alternate slave database in a readable state in response to detecting that the configuration data read event is triggered;
读取操作模块,设置为从所述备选从数据库中挑选出目的从数据库,并针对所述目的从数据库进行配置数据读取操作,其中,所述目的从数据库所在机房与当前配置服务端所在第二机房的第一距离小于所述备选从数据库中除所述目的从数据库之外的备选从数据库所在机房与当前配置服务端所在第二机房的 第二距离。The read operation module is set to select the purpose from the database from the alternative database, and perform a configuration data read operation from the database for the purpose, wherein the purpose is from the computer room where the database is located and the current configuration server is located. The first distance of the second computer room is smaller than the second distance between the computer room where the candidate secondary database except the destination secondary database is located in the candidate secondary database and the second computer room where the current configuration server is located.
本申请提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述的配置数据访问方法。The present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the above-mentioned configuration data access method when the computer program is executed.
本申请提供了一种微服务架构中的配置中心,包括配置中心服务端和配置中心客户端,所述配置中心服务端包括配置管理服务端和配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;The application provides a configuration center in a micro-service architecture, including a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in multiple In a first computer room, the network quality between the multiple first computer rooms meets the preset quality requirements, the configuration server is deployed in at least two groups of second computer rooms, and the same group of second computer rooms is located in the same service area, Different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database, the master database and the slave database are included in the database cluster corresponding to the configuration center , all master databases are set to ensure strong data consistency based on preset consistency protocols;
所述配置管理服务端设置为基于上述的应用于配置管理服务端的配置数据访问方法进行配置数据访问;The configuration management server is set to perform configuration data access based on the above-mentioned configuration data access method applied to the configuration management server;
所述配置服务端设置为基于上述的应用于配置服务端的配置数据访问方法进行配置数据访问。The configuration server is configured to perform configuration data access based on the above-mentioned configuration data access method applied to the configuration server.
本申请提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述的配置数据访问方法。The present application provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned configuration data access method is implemented.
附图说明Description of drawings
图1为本申请实施例提供的一种配置数据访问方法所适用的应用场景的场景架构图;1 is a scenario architecture diagram of an application scenario to which a configuration data access method provided by an embodiment of the present application is applicable;
图2为本申请实施例提供的一种配置中心部署方案示意图;FIG. 2 is a schematic diagram of a configuration center deployment solution provided by an embodiment of the present application;
图3为本申请实施例提供的一种数据库集群部署方案示意图;3 is a schematic diagram of a database cluster deployment solution provided by an embodiment of the present application;
图4为本申请实施例提供的一种配置数据访问方法的流程示意图;4 is a schematic flowchart of a configuration data access method provided by an embodiment of the present application;
图5为本申请实施例提供的另一种配置数据访问方法的流程示意图;5 is a schematic flowchart of another configuration data access method provided by an embodiment of the present application;
图6为本申请实施例提供的一种智能数据源实现方式示意图;FIG. 6 is a schematic diagram of an implementation manner of an intelligent data source provided by an embodiment of the present application;
图7为本申请实施例提供的一种配置数据访问装置的结构框图;FIG. 7 is a structural block diagram of a configuration data access device provided by an embodiment of the present application;
图8为本申请实施例提供的另一种配置数据访问装置的结构框图;8 is a structural block diagram of another configuration data access device provided by an embodiment of the present application;
图9为本申请实施例提供的一种计算机设备的结构框图。FIG. 9 is a structural block diagram of a computer device according to an embodiment of the present application.
具体实施方式detailed description
下面结合附图和实施例对本申请进行说明。The present application will be described below with reference to the accompanying drawings and embodiments.
本实施例中主要针对微服务架构中的配置中心进行改进。微服务的基本思想在于考虑围绕着业务领域组件来创建应用程序,这些应用程序可独立地进行开发、管理和加速,在分散的组件中使用微服务云架构和平台,使部署、管理和服务功能交互变得更加简单。随着微服务架构中的应用程序功能的日益复杂,程序的配置日益增多,如多种功能的开关、参数的配置以及服务器的地址等等,并且对配置的期望也越来越高,如配置修改后实时生效、灰度发布、分环境或分集群管理配置、完善的权限机制以及审核机制等等,采用分布式的开发模式,使得项目之间的相互引用随着服务的不断增多而增多,项目相互之间的调用复杂度成指数升高,每次投产或者上线新的项目时工作量不断加大,因此需要引用配置中心治理。This embodiment mainly improves the configuration center in the microservice architecture. The basic idea of microservices is to consider creating applications around business domain components that can be independently developed, managed and accelerated, using microservices cloud architecture and platforms in decentralized components, enabling deployment, management and service functions Interaction just got easier. With the increasing complexity of application functions in the microservice architecture, the configuration of the program is increasing, such as the switch of various functions, the configuration of parameters, and the address of the server, etc., and the expectations for configuration are also getting higher and higher, such as configuration After modification, it takes effect in real time, grayscale release, sub-environment or sub-cluster management configuration, perfect authority mechanism and audit mechanism, etc., adopt a distributed development model, so that the mutual reference between projects increases with the continuous increase of services. The complexity of calling each other between projects increases exponentially, and the workload continues to increase each time a new project is put into production or online, so it is necessary to refer to the configuration center for governance.
图1为本申请实施例提供的一种配置数据访问方法所适用的应用场景的场景架构图。参考图1,该应用场景中可以包括配置中心(Config Center)100、数据库(DataBase,DB)200和业务系统300。其中,配置中心100包括配置中心服务端101和配置中心客户端(Config Client)102,配置中心服务端101包括配置管理服务(Config Admin Service)端1011和配置服务(Config Service)端1012,数据库200包括主数据库201和从数据库202。配置中心100可理解为提供分布式配置服务的一整套系统,分布式配置服务可包括配置修改、发布以及推送等功能,配置管理服务端1011、配置服务端1012和配置中心客户端102可理解为配置中心100中的子模块。其中,配置服务端1012一般是一个只读服务端,为客户端提供配置的拉取和推送服务;配置管理服务端1011可以提供配置管理服务,配置管理服务包括配置查看、修改以及发布等功能;配置中心客户端102可以提供给业务系统使用的软件开发工具包(Software Development Kit,SDK),与配置服务端1012交互实现配置拉取和推送功能。配置中心100需要具备较高的可用性以及有效保证数据的一致性,同时由于配置中心100作为底层组件,需要尽量减少对其他系统或组件的依赖,配置中心100需要管理的配置数据的种类以及数据量非常庞大,一般需要存储在对应的数据库200内,也即配置中心至少要依赖于数据库200这一外部系统。考虑到数据可靠性等因素,一般设置有主数据库201和从数据库202,配置管理服务端1011可针对主数据库201进行配置修改等写入操作,主数据库201和从数据库202进行数据同步,配置服务端1012可以针对从数据库202进行配置读取操作,从而向配置中心客户端102提供配置数据。FIG. 1 is a scenario architecture diagram of an application scenario to which a configuration data access method provided by an embodiment of the present application is applicable. Referring to FIG. 1 , the application scenario may include a configuration center (Config Center) 100 , a database (DataBase, DB) 200 and a business system 300 . The configuration center 100 includes a configuration center server 101 and a configuration center client (Config Client) 102, the configuration center server 101 includes a configuration management service (Config Admin Service) end 1011 and a configuration service (Config Service) end 1012, and the database 200 Including the master database 201 and the slave database 202. The configuration center 100 can be understood as a complete set of systems that provide distributed configuration services. The distributed configuration service can include functions such as configuration modification, publishing, and push. The configuration management server 1011, the configuration server 1012, and the configuration center client 102 can be understood as Submodules in the configuration center 100 are configured. Among them, the configuration server 1012 is generally a read-only server, providing configuration pull and push services for clients; the configuration management server 1011 can provide configuration management services, including configuration viewing, modification, and publishing functions; The configuration center client 102 can provide a software development kit (Software Development Kit, SDK) used by the business system, and interact with the configuration server 1012 to implement configuration pull and push functions. The configuration center 100 needs to have high availability and effectively ensure data consistency. At the same time, since the configuration center 100 is a bottom-level component, it needs to minimize the dependence on other systems or components. The configuration center 100 needs to manage the types and data volumes of the configuration data. It is very huge and generally needs to be stored in the corresponding database 200 , that is, the configuration center at least depends on the external system of the database 200 . Considering factors such as data reliability, a master database 201 and a slave database 202 are generally provided. The configuration management server 1011 can perform write operations such as configuration modification for the master database 201. The master database 201 and the slave database 202 perform data synchronization and configure services. The terminal 1012 may perform a configuration read operation from the database 202 to provide configuration data to the configuration center client 102 .
随着业务范围的不断扩大,业务系统形成多个业务区域(如以大洲、国家、地区或城市等进行划分),需要在较大的地域范围内部署搭载配置中心的多个子模块或数据库的设备(如服务器等),存放服务器的机房分布范围广,每两 个机房之间的通信距离也大大增加,因此网络环境变得愈加不可靠,配置中心实现方案的可靠性和可用性越来越难以保障。With the continuous expansion of the business scope, the business system forms multiple business areas (for example, divided by continents, countries, regions or cities, etc.), and it is necessary to deploy equipment equipped with multiple sub-modules or databases of the configuration center in a large geographical scope. (such as servers, etc.), the computer rooms where the servers are stored are widely distributed, and the communication distance between each two computer rooms is also greatly increased, so the network environment becomes more and more unreliable, and the reliability and availability of the configuration center implementation plan are more and more difficult to guarantee. .
相关技术中,以常见的MySQL为例,常用的高可用部署方案有MMM、MHA以及MGR。其中,MMM是一套支持双主故障切换和双主日常管理的脚本程序,由于MMM无法完全的保证数据一致性,所以MMM仅适用于对数据的一致性要求不是很高的场景;MHA是MySQL在高可用方面的一个相对成熟的解决方案,该软件由两部分组成,包括管理节点(MHA Manager)和数据节点(MHA Node),MHA Manager会定时探测集群中的主(master)节点,当master节点出现故障时,它可以自动将存储最新数据的从(slave)节点提升为新的master节点,然后将所有其他的slave节点重新指向新的master节点;MGR是基于MySQL架构实现的复制插件,使用Paxos协议实现多个节点间的数据一致性,MGR支持单主模式和多主模式。上述三种方案中,MMM和MHA都存在数据丢失的风险;MHA和MGA需要引入其他组件(如虚拟IP地址(Virtual IP Address,VIP)组件)或者数据库中间件来提供统一入口,依赖额外的运维工具或者中间件实现高可用,而数据库中间件等都是依赖配置中心来实现高可用的,因此,会形成循环依赖,而配置中心作为底层的组件不希望依赖其他组件;另外,上述三种方案的高可用都是针对主数据库的,并不适合在较大区域范围内部署从数据库的情况下直接使用。In related technologies, taking common MySQL as an example, commonly used high-availability deployment solutions include MMM, MHA, and MGR. Among them, MMM is a set of script programs that support dual-master failover and dual-master daily management. Since MMM cannot fully guarantee data consistency, MMM is only suitable for scenarios where data consistency requirements are not very high; MHA is MySQL A relatively mature solution in terms of high availability, the software consists of two parts, including a management node (MHA Manager) and a data node (MHA Node). MHA Manager will regularly detect the master (master) node in the cluster, when the master node When a node fails, it can automatically promote the slave (slave) node that stores the latest data to the new master node, and then redirect all other slave nodes to the new master node; MGR is a replication plug-in based on MySQL architecture, using The Paxos protocol implements data consistency among multiple nodes, and MGR supports single-master mode and multi-master mode. In the above three schemes, both MMM and MHA have the risk of data loss; MHA and MGA need to introduce other components (such as virtual IP address (Virtual IP Address, VIP) components) or database middleware to provide a unified entry, relying on additional operations. Maintenance tools or middleware achieve high availability, while database middleware relies on the configuration center to achieve high availability. Therefore, circular dependencies will be formed, and the configuration center, as the underlying component, does not want to depend on other components; in addition, the above three The high availability of the scheme is aimed at the master database, and is not suitable for direct use when the slave database is deployed in a larger area.
本申请实施例中的配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括配置管理服务端和配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库基于预设一致性协议保证数据强一致。其中,强一致可以指任何一次读操作都能读到一个数据的最近一次被写入的数值,或者说,在任意时刻,所有节点中的数据是一样的,例如,对于关系型数据库,要求更新过的数据的后续的访问都能看到。The configuration center in the embodiment of the present application includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in a plurality of first computer rooms, The network quality between the plurality of first computer rooms meets the preset quality requirements, the configuration server is deployed in at least two groups of second computer rooms, the same group of second computer rooms is located in the same business area, and different groups of second computer rooms are located in the same business area. In different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database. The master database and the slave database are included in the database cluster corresponding to the configuration center. Set up a consistency protocol to ensure strong data consistency. Among them, strong consistency can mean that any read operation can read the last written value of a data, or, at any time, the data in all nodes is the same, for example, for a relational database, it is required to update Subsequent access to the past data can be seen.
示例性的,对第一机房的数量不做限定,也即对配置管理服务端的部署数量不做限定,可以根据实际情况(如业务区域的数量)进行设置,例如可以设置第一机房的数量为三个,一个配置管理服务端可集成于对应的第一机房中的服务器等计算机设备中。每个第一机房配备一个主数据库,也即主数据库的数量与第一机房的数量可以是相等的,也即主数据库的数量可以与配置管理服务端的部署数量相等。配置管理服务端可以针对其对应的主数据库进行配置数据访问,主数据库所在设备和配置管理服务端所在设备可以相同。主数据库和从 数据库的类型一般一致,本申请对主数据库和从数据库的类型不做限定,例如主数据库和从数据库的类型可以是MySQL等关系型数据库,还可以是远程字典服务(Remote dictionary server,Redis)等非关系型数据库等。所有主数据库基于预设一致性协议保证数据强一致,因此,需要多个第一机房之间的网络质量满足预设质量要求,多个第一机房之间的网络质量满足预设质量要求可以是所有第一机房中的任意两个第一机房之间的网络质量满足预设质量要求,也可以是对应所有第一机房中的每个第一机房存在另外一个第一机房与所述每个第一机房之间的网络质量满足预设质量要求。其中,网络质量可采用丢包率或往返时间(Round-Trip Time,RTT)等指标进行衡量,所有第一机房可部署在同一个城市中,这样,所有第一机房之间可以采用城域网连接,保证相互之间的网络通信是可靠的。预设一致性协议例如可以是Paxos协议,还可以是其他的可以保证数据库之间数据强一致的协议。通过预设一致性协议可以在多个主数据库中选举出一个或多个主节点设置为数据写入,也即,可以保证一个或多个主节点可以设置为数据写入,其他主数据库自动成为主节点的从节点,在向主节点写入配置数据时,主节点将所写入的配置数据同步到从节点,也即从节点可实现配置数据的被动写入,当主节点和从节点的配置数据写入操作均完成后,预设一致性协议才会确认写入操作成功,从而可以保证主数据库之间的数据强一致。在MMM和MHA中,主从节点之间或双主节点之间的数据同步是异步的,也就是说在一次写操作过程中,只要有一个数据库完成本次写入,则可进行下一次写入,若此时该数据库出现问题,而其他数据库还未来得及同步,就会导致数据丢失。而本申请实施例中,多个主数据库之间基于预设一致性协议保证数据强一致,不会产生因其中一个主数据库出现问题而导致数据丢失的情况。Exemplarily, the number of the first computer room is not limited, that is, the number of deployments of the configuration management server is not limited, which can be set according to the actual situation (such as the number of business areas). For example, the number of the first computer room can be set as Three, one configuration management server can be integrated into computer equipment such as a server in the corresponding first computer room. Each first computer room is equipped with a main database, that is, the number of the main databases and the number of the first computer rooms can be equal, that is, the number of the main databases can be equal to the deployment number of the configuration management server. The configuration management server can access configuration data for its corresponding main database, and the device where the main database is located and the device where the configuration management server is located can be the same. The types of the master database and the slave database are generally the same. This application does not limit the types of the master database and the slave database. For example, the types of the master database and the slave database can be relational databases such as MySQL, or can be a remote dictionary service (Remote dictionary server). , Redis) and other non-relational databases. All master databases ensure strong data consistency based on a preset consistency protocol. Therefore, the network quality between multiple first computer rooms needs to meet the preset quality requirements, and the network quality between multiple first computer rooms can meet the preset quality requirements. The network quality between any two first computer rooms in all the first computer rooms meets the preset quality requirements, or there may be another first computer room corresponding to each first computer room in all the first computer rooms and each of the first computer rooms The network quality between a computer room meets the preset quality requirements. Among them, the network quality can be measured by indicators such as packet loss rate or round-trip time (RTT). Connection, to ensure that the network communication between each other is reliable. The preset consistency protocol may be, for example, the Paxos protocol, or other protocols that can ensure strong data consistency between databases. Through the preset consistency protocol, one or more master nodes can be elected in multiple master databases to be set for data writing, that is, it can be guaranteed that one or more master nodes can be set to write data, and other master databases automatically become The slave node of the master node, when writing configuration data to the master node, the master node synchronizes the written configuration data to the slave node, that is, the slave node can passively write the configuration data. After the data write operations are completed, the preset consistency protocol will confirm the success of the write operation, thereby ensuring strong data consistency between the primary databases. In MMM and MHA, data synchronization between master-slave nodes or between dual-master nodes is asynchronous, that is to say, during a write operation, as long as one database completes the write, the next write can be performed. , if there is a problem with the database at this time, and other databases have not been synchronized in time, it will cause data loss. However, in the embodiment of the present application, strong data consistency is ensured between multiple master databases based on a preset consistency protocol, and data loss due to a problem in one of the master databases will not occur.
示例性的,在业务区域部署从数据库。业务区域的划分规则以及业务区域的数量可根据实际业务范围以及其他相关因素确定,每个业务区域内可以部署一组第二机房,不同组内的第二机房的数量可以相同也可以不同,本申请对每组第二机房内的第二机房的数量不做限定。对第二机房的数量不做限定,也即对配置服务端的部署数量不做限定,一个配置服务端可集成于对应的第二机房中的服务器等计算机设备中。每个第二机房配备一个从数据库,从数据库的数量与第二机房的数量可以是相等的,也即从数据库的数量可以与配置服务端的部署数量相等,配置服务端可以针对其对应的从数据库进行配置数据访问,从数据库所在设备和配置服务端所在设备可以相同。Exemplarily, the slave database is deployed in the business area. The division rules of business areas and the number of business areas can be determined according to the actual business scope and other related factors. A group of second computer rooms can be deployed in each business area. The number of second computer rooms in different groups can be the same or different. The application does not limit the number of second computer rooms in each group of second computer rooms. The number of second computer rooms is not limited, that is, the number of configuration servers deployed is not limited, and one configuration server can be integrated into computer equipment such as servers in the corresponding second computer room. Each second computer room is equipped with a slave database, and the number of slave databases can be equal to the number of second computer rooms, that is, the number of slave databases can be equal to the deployment quantity of the configuration server, and the configuration server can target its corresponding slave database. For configuration data access, the device where the database is located and the device where the configuration server is located can be the same.
下面对配置中心部署方案以及数据库集群部署方案进行示意性说明。以主数据库和从数据库均为MySQL数据库,预设一致性协议为Paxos协议为例,业务区域按照大洲划分,如划分为亚洲区、美洲区和欧洲区,第一机房数量为三个,每个第一机房对应一个业务区域,每个业务区域内部署一组第二机房,每 组第二机房中第二机房的数量为三个。The following is a schematic description of the configuration center deployment scheme and the database cluster deployment scheme. Take the master database and the slave database as MySQL databases, and the default consistency protocol as the Paxos protocol. The first computer room corresponds to a business area, a group of second computer rooms is deployed in each business area, and the number of second computer rooms in each group of second computer rooms is three.
图2为本申请实施例提供的一种配置中心部署方案示意图,如图2所示,入口(Portal)可理解为工作人员操作的人机交互界面,工作人员可以利用Portal根据配置管理服务(Config Admin Service)端所在设备的地址信息,如IP地址和端口(port)号,来调用Config Admin Service进行配置数据的写入等访问操作,Config Admin Service端可将配置数据写入到对应的主数据库中,三个主数据库可构成MGR组(Group),MGR Group基于Paxos协议实现数据强一致,该部署方案中Portal和Config Admin Service端主要提供配置管理、写入功能以及读写主数据库,可以不需要全球化部署。Config Service端设置为针对业务实现配置拉取和实时推送,可用性要求高,需要全球化部署,Config Service端可以就近选取从数据库进行配置数据的读取,每个业务区域均设置有相应的从数据库,如三个亚洲从数据库、三个欧洲从数据库和三个美洲从数据库。FIG. 2 is a schematic diagram of a configuration center deployment scheme provided by an embodiment of the present application. As shown in FIG. 2 , the portal (Portal) can be understood as a human-computer interaction interface operated by staff, and the staff can use the Portal to manage services (Configuration) according to the configuration. The address information of the device where the Admin Service) end is located, such as IP address and port number, to call the Config Admin Service to perform access operations such as writing configuration data, and the Config Admin Service end can write the configuration data to the corresponding master database. Among them, three main databases can form an MGR group. The MGR group realizes strong data consistency based on the Paxos protocol. In this deployment scheme, the Portal and Config Admin Service mainly provide configuration management, writing functions, and reading and writing the main database. Requires global deployment. The Config Service side is set to implement configuration pull and real-time push for the business, which requires high availability and requires global deployment. The Config Service side can select the nearest slave database to read configuration data, and each business area is set with a corresponding slave database. , such as three Asian slave databases, three European slave databases, and three Americas slave databases.
图3为本申请实施例提供的一种数据库集群部署方案示意图,如图3所示,MGR Group由三个节点(Node)组成,也即由三个主数据库组成,三个节点通过Paxos协议选举出一个Master节点设置为数据写入,通过Paxos协议保持三个节点的数据强一致。配置管理服务端可以感知MGR Group的三个节点的角色变化并自动选择Master节点进行配置写入,实现细节可参考下文相关内容。为了兼顾Paxos协议的数据同步性能和可用性,三个节点分别部署在同城的三个机房内。在全球三个洲部署从(Slave)数据库,在每个洲部署三个机房(第二机房),从数据库和主数据库之间可以采用异步复制(Replicate)的方式实现最终的一致性。每个第二机房的配置服务端优先读本机房的从数据库,并在本机房的从数据库不可用时降级到读同区域的其他从数据库,实现从数据库的互备,从而达到高可用,实现细节可参考下文相关内容。Figure 3 is a schematic diagram of a database cluster deployment solution provided by an embodiment of the present application. As shown in Figure 3, an MGR Group consists of three nodes (Nodes), that is, three main databases, and the three nodes are elected through the Paxos protocol A Master node is set to write data, and the data of the three nodes is kept strongly consistent through the Paxos protocol. The configuration management server can perceive the role changes of the three nodes of the MGR Group and automatically select the Master node for configuration writing. For implementation details, please refer to the related content below. In order to take into account the data synchronization performance and availability of the Paxos protocol, the three nodes are deployed in three computer rooms in the same city. Slave databases are deployed on three continents around the world, and three computer rooms (second computer rooms) are deployed on each continent. Asynchronous replication (Replicate) can be used to achieve eventual consistency between the slave database and the master database. The configuration server of each second computer room preferentially reads the slave database in the computer room, and downgrades to read other slave databases in the same area when the slave database in the computer room is unavailable, so as to realize the mutual backup of the slave databases, so as to achieve high availability. The implementation details can be See related content below.
上述仅为举例说明,其中的主数据库的类型和数量、从数据库的类型和数量、预设一致性协议的类型、业务区域的划分方式、第一机房的数量以及每组第二机房中第二机房的数量等,均可根据实际需求进行设置。The above is only an example, the type and quantity of the master database, the type and quantity of the slave database, the type of the preset consistency protocol, the division method of the business area, the number of the first computer room, and the second computer room in each group of the second computer room. The number of computer rooms, etc., can be set according to actual needs.
图4为本申请实施例提供的一种配置数据访问方法的流程示意图,该方法应用于微服务架构中的配置中心的配置管理服务端,可以由配置数据访问装置执行,该装置可由软件和/或硬件实现,一般可集成在服务器等计算机设备中。如图4所示,该方法包括:4 is a schematic flowchart of a configuration data access method provided by an embodiment of the present application. The method is applied to a configuration management server of a configuration center in a microservice architecture, and can be executed by a configuration data access device, which can be configured by software and/or Or hardware implementation, generally can be integrated in computer equipment such as servers. As shown in Figure 4, the method includes:
步骤401、检测到配置数据写入事件被触发。 Step 401, it is detected that a configuration data write event is triggered.
示例性的,此处的配置数据写入事件可以是针对主数据库的配置数据写入事件,该事件的触发条件可根据实际需求设置。例如,当工作人员需要进行配置增加、配置修改、配置删除或其他配置数据变更操作时,上述增加、修改以 及删除等均可视为写入操作,工作人员可以利用配置管理设备(例如在该设备中的Portal界面进行操作)通过调用配置管理服务端实现针对主数据库的配置数据写入,当配置管理服务端接收到配置管理设备发送的配置数据写入请求时,可认为检测到配置数据写入事件被触发。本申请对配置管理设备的数量不做限定,可以是一个或多个,当数量为多个时,可以与第一机房的数量一致,配置管理设备可以设置于第一机房中,也可设置于其他地点,可以与配置管理服务端所在设备进行通信。Exemplarily, the configuration data writing event here may be a configuration data writing event for the master database, and the triggering condition of the event may be set according to actual requirements. For example, when a staff member needs to perform configuration addition, configuration modification, configuration deletion or other configuration data change operations, the above-mentioned addition, modification and deletion can be regarded as write operations. The configuration data writing to the main database is realized by calling the configuration management server. When the configuration management server receives the configuration data writing request sent by the configuration management device, it can be considered that the configuration data writing has been detected. event is fired. This application does not limit the number of configuration management devices, which can be one or more. When the number is more than one, it can be the same as the number of the first computer room. The configuration management devices can be set in the first computer room or in Other locations can communicate with the device where the configuration management server is located.
步骤402、若探测到所在第一机房对应的目标主数据库处于可写状态,则针对所述目标主数据库进行配置数据写入操作,其中,处于可写状态的主数据库基于所述预设一致性协议确定。Step 402: If it is detected that the target master database corresponding to the first computer room is in a writable state, perform a configuration data writing operation for the target master database, wherein the master database in the writable state is based on the preset consistency. Agreement is confirmed.
示例性的,多个主数据库可以基于预设一致性协议选举出作为主节点的主数据库,作为主节点的主数据库处于可写状态。其中,主节点的数量可以是一个或多个,本申请对主节点的数量不做限定。若当前配置管理服务端所在的第一机房对应的目标主数据库为主节点,则该目标主数据库为可写状态,当前配置管理服务端能够探测到目标主数据库为可写状态,进而可以针对目标主数据库进行配置数据写入操作。若当前配置管理服务端所在的第一机房对应的目标主数据库不是主节点,那么其他配置管理服务端会探测到可写状态的主数据库,从而实现高可靠的配置数据写入。Exemplarily, multiple master databases may elect a master database as a master node based on a preset consistency protocol, and the master database as a master node is in a writable state. The number of master nodes may be one or more, and this application does not limit the number of master nodes. If the target master database corresponding to the first computer room where the current configuration management server is located is the master node, the target master database is in a writable state, and the current configuration management server can detect that the target master database is writable, and then can target the target master database. The primary database performs configuration data write operations. If the target master database corresponding to the first computer room where the current configuration management server is located is not the master node, other configuration management servers will detect the writable master database, thereby realizing highly reliable configuration data writing.
步骤403、检测到所述目标主数据库之外的主数据库完成针对本次写入操作的数据同步后,反馈写入成功信息。Step 403: After detecting that the primary database other than the target primary database has completed the data synchronization for this writing operation, feedback the writing success information.
示例性的,针对目标主数据库进行配置数据写入操作的过程中,由于所有主数据库基于预设一致性协议保证数据强一致,因此,目标主数据库会将被写入的配置数据同步到其他主数据库中,在检测到其他主数据库完成针对本次写入操作的数据同步后,可确认需要写入的配置数据已经成功写入到所有主数据库中,可以向配置管理设备反馈写入成功信息,以便进行后续操作。Exemplarily, in the process of writing configuration data to the target master database, since all master databases ensure strong data consistency based on a preset consistency protocol, the target master database will synchronize the written configuration data to other master databases. In the database, after detecting that other primary databases have completed data synchronization for this write operation, it can confirm that the configuration data to be written has been successfully written to all primary databases, and can feedback the successful writing information to the configuration management device. for subsequent operations.
本申请实施例中提供的配置数据访问方法,微服务架构中的配置中心包括配置中心服务端和配置中心客户端,配置中心服务端包括配置管理服务端和配置服务端,配置管理服务端部署于多个第一机房内,每个第一机房配备一个主数据库,所有主数据库基于预设一致性协议保证数据强一致,第一机房之间的网络质量满足预设质量要求,可以保证第一机房之间的通信可靠性,同时,也能够保证主数据库之间的同步性能以及主数据库的高可用性,配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第二机房配备一个从数据库,主数据库和从数据库包含于配置中心对应的数据库集群中,在上述配置中心的架构基础上,配置管 理服务端检测到配置数据写入事件被触发后,主动探测所在第一机房对应的目标主数据库是否处于可写状态,若所在第一机房对应的目标主数据库处于可写状态,则针对目标主数据库进行配置数据写入操作,而处于可写状态的主数据库是基于预设一致性协议确定的,也即预设一致性协议中定义的主节点,以便能够基于该协议保障主数据库之间的数据强一致,检测到目标主数据库之外的主数据库完成针对本次写入操作的数据同步后,反馈写入成功信息,从而可以不依赖其他组件而在配置中心内部实现智能探测可写主数据库并进行配置数据的高可靠性写入操作,且所有主数据库基于预设一致性协议保证主数据库的高可用和数据一致性,避免了发生因数据丢失而影响业务的情况。In the configuration data access method provided in the embodiment of this application, the configuration center in the micro-service architecture includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in In multiple first computer rooms, each first computer room is equipped with a master database. All master databases ensure strong data consistency based on a preset consistency protocol. The network quality between the first computer rooms meets the preset quality requirements, which can ensure that the first computer room is At the same time, it can also ensure the synchronization performance between the main databases and the high availability of the main database. The configuration server is deployed in at least two sets of second computer rooms, and the same group of second computer rooms are located in the same business area. Different groups of second computer rooms are located in different business areas, and each second computer room is equipped with a slave database. The master database and the slave database are included in the database cluster corresponding to the configuration center. Based on the architecture of the configuration center, the configuration management server detects that the After the configuration data write event is triggered, it actively detects whether the target master database corresponding to the first computer room is in a writable state. If the target master database corresponding to the first computer room is in a writable state, the configuration data is written to the target master database. The main database in the writable state is determined based on the preset consistency protocol, that is, the master node defined in the preset consistency protocol, so as to ensure strong data consistency between the master databases based on this protocol, and detect After the data synchronization for this write operation is completed in the main database other than the target main database, the write success information is fed back, so that the intelligent detection of the writable main database and the configuration data can be realized in the configuration center without relying on other components. High-reliability write operations, and all primary databases are based on preset consistency protocols to ensure high availability and data consistency of the primary databases, avoiding business impact due to data loss.
在一些实施例中,在所述检测到配置数据写入事件被触发之前,还包括:获取所述数据库集群的拓扑结构信息,其中,所述拓扑结构信息中包含机房与数据库的对应关系;根据所述拓扑结构信息查询所在第一机房对应的目标主数据库。这样设置的好处在于,可以便于配置管理服务端快速准确地确认与自己对应的目标主数据库。In some embodiments, before the detecting that the configuration data writing event is triggered, the method further includes: acquiring topology structure information of the database cluster, wherein the topology structure information includes the corresponding relationship between the computer room and the database; The topological structure information is queried in the target master database corresponding to the first computer room where it is located. The advantage of this setting is that it is convenient for the configuration management server to quickly and accurately confirm the target master database corresponding to itself.
示例性的,拓扑结构信息可以包含于数据库拓扑结构配置文件中,本申请对该配置文件的格式不做限定,例如可以是JS对象简谱(JavaScript Object Notation,JSON)格式,如数据库拓扑结构配置文件可被记为datasource.json。拓扑结构信息中可包括主数据库列表和从数据库列表。主数据库列表中可包括每个主数据库的IP和端口号,从数据库列表可包括每个从数据库对应的机房信息和位置信息(如所在地区信息)等。对于配置管理服务端读取的拓扑结构信息来说,也可以仅包括主数据库列表。配置管理服务端可以确认自己所属设备的IP和端口号,进而将自己的IP和端口号与主数据库列表中的IP和端口号进行比对,将相似度最高(若配置管理服务端所在设备和对应的主数据库所在设备相同,则IP和端口号也相同)的主数据库确定为自己对应的目标主数据库。Exemplarily, the topology information can be included in a database topology configuration file, and the application does not limit the format of the configuration file, for example, it can be in a JS Object Notation (JavaScript Object Notation, JSON) format, such as a database topology configuration file. Can be recorded as datasource.json. The topology information can include a list of master databases and a list of slave databases. The master database list may include the IP and port number of each master database, and the slave database list may include computer room information and location information (such as local area information) corresponding to each slave database. For the topology information read by the configuration management server, it may only include the list of the main database. The configuration management server can confirm the IP and port number of its own device, and then compare its own IP and port number with the IP and port number in the main database list, and find the highest similarity (if the device where the configuration management server is located and If the device where the corresponding master database is located is the same, then the master database with the same IP and port number is determined as its corresponding target master database.
在一些实施例中,在所述根据所述拓扑结构信息查询所在第一机房对应的目标主数据库之后,还包括:与所述目标主数据库建立第一连接;所述探测到所述目标主数据库处于可写状态,包括:基于所述第一连接尝试向所述目标主数据库写入第一数据,若检测到所述第一数据写入成功,则确定所述目标主数据库处于可写状态。这样设置的好处在于,在确定对应的目标主数据库后,可以与该目标主数据库建立连接,在需要进行配置数据访问时,不需要临时建立连接,提高配置数据访问效率,另外,通过尝试写入数据的方式,可以对目标主数据库的状态进行准确的判断。In some embodiments, after the querying the target master database corresponding to the first computer room according to the topology information, the method further includes: establishing a first connection with the target master database; detecting the target master database Being in a writable state includes: attempting to write first data to the target primary database based on the first connection, and determining that the target primary database is in a writable state if it is detected that the writing of the first data is successful. The advantage of this setting is that after determining the corresponding target master database, a connection can be established with the target master database. When configuration data access is required, there is no need to temporarily establish a connection, which improves the efficiency of configuration data access. In addition, by trying to write The data method can accurately judge the status of the target master database.
在一些实施例中,在与所述目标主数据库建立第一连接之后,还包括:若监听到所述拓扑结构信息发生变化,则根据变化后的拓扑结构信息确定新的目 标主数据库;与所述新的目标主数据库建立第二连接。这样设置的好处在于,若拓扑结构信息发生变化,那么对应的目标主数据库可能也发生变化,可以断开与原来的目标主数据库的第一连接,并与新的目标主数据库建立第二连接,在后续需要进行配置数据访问时,不需要临时变更连接,提高配置数据访问效率。In some embodiments, after establishing the first connection with the target master database, the method further includes: if a change in the topology structure information is monitored, determining a new target master database according to the changed topology structure information; The new target master database establishes a second connection. The advantage of this setting is that if the topology information changes, the corresponding target master database may also change, and the first connection with the original target master database can be disconnected, and the second connection with the new target master database can be established. When configuration data access is required in the future, there is no need to temporarily change the connection, which improves the efficiency of configuration data access.
在一些实施例中,还包括:检测到配置数据读取事件被触发;探测出处于可读状态的备选主数据库;从所述备选主数据库中挑选出目的主数据库,并针对所述目的主数据库进行配置数据读取操作,其中,所述目的主数据库所在机房与当前配置管理服务端所在第一机房的第一距离小于其他备选主数据库所在机房与当前配置管理服务端所在第一机房的第二距离。这样设置的好处在于,配置管理服务端可能也存在对配置数据的读取需求,当配置管理服务端需要读取主数据库中的配置数据时,可以就近选择主数据库进行读取操作,一般的,目的主数据库为与当前配置管理服务端同设备或同机房的主数据库,当距离最近的主数据库出现异常时,也可从处于可读状态的主数据库中选出距离最近的主数据库进行读取操作。其中,探测方式可以是按照主数据库所在机房与当前配置管理服务端所在第一机房的距离从近至远逐一探测,也可以是批量探测,本申请对探测方式不做限定。In some embodiments, the method further includes: detecting that a configuration data read event is triggered; detecting a candidate master database in a readable state; selecting a target master database from the candidate master databases, and targeting the purpose The main database performs a configuration data read operation, wherein the first distance between the computer room where the target main database is located and the first computer room where the current configuration management server is located is smaller than the first computer room where the other candidate master databases are located and the first computer room where the current configuration management server is located. the second distance. The advantage of this setting is that the configuration management server may also need to read the configuration data. When the configuration management server needs to read the configuration data in the main database, it can select the nearest main database for the read operation. Generally, The main database of the purpose is the main database of the same equipment or the same computer room as the current configuration management server. When the nearest main database is abnormal, the nearest main database can also be selected from the main databases in the readable state for reading. operate. The detection method may be one by one according to the distance between the computer room where the main database is located and the first computer room where the current configuration management server is located, or may be batch detection. The application does not limit the detection method.
图5为本申请实施例提供的另一种配置数据访问方法的流程示意图,该方法应用于微服务架构中的配置中心的配置服务端,可以由配置数据访问装置执行,该装置可由软件和/或硬件实现,一般可集成在服务器等计算机设备中。如图5所示,该方法包括:5 is a schematic flowchart of another configuration data access method provided by an embodiment of the present application. The method is applied to a configuration server of a configuration center in a microservice architecture, and can be executed by a configuration data access device, which can be implemented by software and/or Or hardware implementation, generally can be integrated in computer equipment such as servers. As shown in Figure 5, the method includes:
步骤501、检测到配置数据读取事件被触发。 Step 501, it is detected that a configuration data read event is triggered.
示例性的,此处的配置数据读取事件可以是针对从数据库的配置数据读取事件,该事件的触发条件可根据实际需求设置。例如,当业务系统需要获取配置数据时,可以通过配置中心客户端向配置服务端发送配置数据获取请求,配置服务端需要到从数据库中读取配置数据,配置服务端在接收到该请求时,可认为检测到配置数据读取事件被触发;又如,配置服务端可以按照预设推送规则(如定时或实时推送)向业务系统推送配置数据,在检测到需要进行配置数据推送时,配置服务端需要到从数据库中读取配置数据,可认为检测到配置数据读取事件被触发。一般的,一个配置服务端可以对应一个或多个配置中心客户端,也即一个配置服务端可以为一个或多个业务系统提供配置拉去或推送服务。Exemplarily, the configuration data reading event here may be an event for reading configuration data from a database, and the triggering condition of the event may be set according to actual requirements. For example, when the business system needs to obtain configuration data, it can send a configuration data acquisition request to the configuration server through the configuration center client. The configuration server needs to read the configuration data from the database. When the configuration server receives the request, It can be considered that the configuration data read event is triggered; for another example, the configuration server can push the configuration data to the business system according to the preset push rules (such as timing or real-time push), and when it is detected that the configuration data needs to be pushed, the configuration service The client needs to read the configuration data from the database, and it can be considered that the configuration data read event is triggered. Generally, a configuration server can correspond to one or more configuration center clients, that is, a configuration server can provide configuration pull or push services for one or more business systems.
步骤502、探测出处于可读状态的备选从数据库。Step 502: Detect a candidate slave database in a readable state.
示例性的,探测范围可以是当前配置服务端对应的业务区域,可以减少探 测操作,如果为了进一步保障可用性,探测范围也可以是多个业务区域。本申请实施例中的配置服务端可以自动探测出处于可读状态的备选从数据库,便于后续从中选择最优的从数据库进行配置数据的读取操作。其中,探测方式可以是按照从数据库所在机房与当前配置服务端所在机房的距离从近至远逐一探测,也可以是批量探测,本申请对探测方式不做限定。Exemplarily, the detection range may be a service area corresponding to the currently configured server, and detection operations may be reduced. To further ensure availability, the detection range may also be multiple service areas. The configuration server in the embodiment of the present application can automatically detect the candidate slave database in a readable state, so as to facilitate the subsequent selection of the optimal slave database to perform the read operation of configuration data. The detection method may be one by one according to the distance between the computer room where the database is located and the computer room where the current configuration server is located, or may be batch detection, which is not limited in this application.
步骤503、从所述备选从数据库中挑选出目的从数据库,并针对所述目的从数据库进行配置数据读取操作,其中,所述目的从数据库所在机房与当前配置服务端所在第二机房的第一距离小于其他备选从数据库所在机房与当前配置服务端所在第二机房的第二距离。 Step 503, select the purpose from the database from the alternative database, and perform a configuration data read operation from the database for the purpose, wherein the purpose is from the computer room where the database is located and the second computer room where the current configuration server is located. The first distance is smaller than the second distance between the computer room where the other candidate slave databases are located and the second computer room where the current configuration server is located.
示例性的,可以从处于可读状态的备选从数据库中挑选出距离最近的从数据库进行配置数据读取。一般的,与配置服务端处于同设备或同机房的从数据库距离最近,若该从数据库出现异常,未处于可读状态,则可挑选同一个业务区域的其他从数据库进行配置数据读取。其中,距离的粒度可自由设置,可以是实际的地理坐标的距离,也可以是城市或地区等。例如,若距离的粒度为城市,则同一城市的机房的距离均可认为是0,相邻两个城市的机房的距离可认为1等。Exemplarily, the closest slave database may be selected from the candidate slave databases in the readable state to read the configuration data. Generally, the slave database that is in the same device or room as the configuration server is the closest. If the slave database is abnormal and is not in a readable state, other slave databases in the same business area can be selected to read the configuration data. Among them, the granularity of the distance can be freely set, which can be the distance of the actual geographic coordinates, or it can be a city or a region. For example, if the granularity of the distance is a city, the distance between the computer rooms in the same city can be considered as 0, and the distance between the computer rooms in two adjacent cities can be considered as 1 and so on.
本申请实施例中提供的配置数据访问方法,微服务架构中的配置中心包括配置中心服务端和配置中心客户端,配置中心服务端包括配置管理服务端和配置服务端,配置管理服务端部署于多个第一机房内,每个第一机房配备一个主数据库,所有主数据库基于预设一致性协议保证数据强一致,第一机房之间的网络质量满足预设质量要求,可以保证第一机房之间的通信可靠性,同时,也能够保证主数据库之间的同步性能以及主数据库的高可用性,配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第二机房配备一个从数据库,主数据库和从数据库包含于配置中心对应的数据库集群中,在上述配置中心的架构基础上,配置服务端检测到配置数据读取事件被触发后,主动探测处于可读状态的备选从数据库,并挑选出距离当前配置服务端最近的备选从数据库进行配置数据读取,实现从数据库的互相备用,保证配置中心的高可用。In the configuration data access method provided in the embodiment of this application, the configuration center in the micro-service architecture includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in In multiple first computer rooms, each first computer room is equipped with a master database. All master databases ensure strong data consistency based on a preset consistency protocol. The network quality between the first computer rooms meets the preset quality requirements, which can ensure that the first computer room is At the same time, it can also ensure the synchronization performance between the main databases and the high availability of the main database. The configuration server is deployed in at least two sets of second computer rooms, and the same group of second computer rooms are located in the same business area. Different groups of second computer rooms are located in different business areas. Each second computer room is equipped with a slave database. The master database and the slave database are included in the database cluster corresponding to the configuration center. Based on the architecture of the configuration center, the configuration server detects the configuration After the data read event is triggered, it actively detects the candidate slave database in the readable state, and selects the candidate slave database closest to the current configuration server to read the configuration data, realizes the mutual backup of the slave databases, and ensures the configuration center. high availability.
在一些实施例中,在所述检测到配置数据读取事件被触发之前,还包括:获取所述数据库集群的拓扑结构信息,其中,所述拓扑结构信息中包含机房与数据库的对应关系信息,以及数据库与业务区域的对应关系信息;根据所述拓扑结构信息查询所在第二机房对应的目标业务区域中包含的多个从数据库;所述探测出处于可读状态的备选从数据库,包括:从所查询到的多个从数据库中探测出处于可读状态的备选从数据库。这样设置的好处在于,可以便于配置服 务端快速准确地确认与自己对应的业务区域,并从该业务区域内快速探测出处于可读状态的备选从数据库。In some embodiments, before the detecting that the configuration data read event is triggered, the method further includes: acquiring topology structure information of the database cluster, wherein the topology structure information includes information about the correspondence between the computer room and the database, And the corresponding relationship information between the database and the business area; according to the topology information, query the multiple slave databases contained in the target business area corresponding to the second computer room; The detection of the candidate slave database in a readable state includes: A candidate slave database in a readable state is detected from the queried multiple slave databases. The advantage of this setting is that it is convenient for the configuration server to quickly and accurately confirm the business area corresponding to itself, and quickly detect the candidate slave database in the readable state from the business area.
如前文所述,拓扑结构信息可以包含于数据库拓扑结构配置文件中,配置服务端中的拓扑结构信息可以与配置管理服务端中的拓扑结构信息相同,也即配置服务端和配置管理服务端所属设备中,均可以存在相同的数据库拓扑结构配置文件,这样可以便于数据库拓扑结构配置文件的统一编写、统一更新以及统一下发。可选的,配置服务端中的拓扑结构信息也可仅包含从数据库列表。配置服务端可以确认自己所属的地区和机房,进而在从数据库列表中查询与自己所属地区和机房相同的从数据库。As mentioned above, the topology information can be included in the database topology configuration file, and the topology information in the configuration server can be the same as the topology information in the configuration management server, that is, the configuration server and the configuration management server belong to The same database topology configuration file may exist in all devices, which facilitates the unified writing, unified update and unified distribution of the database topology configuration file. Optionally, the topology information in the configuration server can also only include the slave database list. The configuration server can confirm the region and computer room to which it belongs, and then query the slave database that is the same as its own region and computer room in the slave database list.
在一些实施例中,在所述根据所述拓扑结构信息查询所在第二机房对应的目标业务区域中包含的多个从数据库之后,还包括:与所查询到的多个从数据库分别建立第三连接;所述从所查询到的多个从数据库中探测出处于可读状态的备选从数据库,包括:基于所述第三连接尝试从所查询到的多个从数据库分别读取第二数据,若检测到所述第二数据读取成功,则确定对应的从数据库处于可读状态,将确定的从数据库作为备选从数据库。这样设置的好处在于,在查询到对应的从数据库后,可以与该从数据库建立连接,在需要进行配置数据访问时,不需要临时建立连接,提高配置数据访问效率,另外,通过尝试读取数据的方式,可以对从数据库的状态进行准确的判断。在与从数据库建立第三连接时,可以优先建立与当前配置服务端处于同设备或同机房的从数据库的第三连接,在需要进行读取操作时,若基于该第三连接探测到该从数据库未处于可读状态时,再与其他从数据库建立第三连接,进而探测出处于可读状态的备选从数据库。In some embodiments, after the querying, according to the topology information, the multiple slave databases included in the target business area corresponding to the second computer room, the method further includes: separately establishing a third slave database with the queried multiple slave databases. connecting; the detecting a candidate slave database in a readable state from the queried multiple slave databases includes: trying to read the second data from the multiple queried slave databases based on the third connection. , if it is detected that the second data is successfully read, it is determined that the corresponding slave database is in a readable state, and the determined slave database is used as an alternate slave database. The advantage of this setting is that after querying the corresponding slave database, you can establish a connection with the slave database. When you need to access configuration data, you do not need to temporarily establish a connection, which improves the efficiency of configuration data access. In addition, by trying to read data In this way, the state of the slave database can be accurately judged. When establishing the third connection with the slave database, the third connection with the slave database in the same device or in the same computer room as the current configuration server can be established first. When a read operation is required, if the slave database is detected based on the third connection When the database is not in a readable state, a third connection is established with other slave databases, and an alternate slave database in a readable state is detected.
在一些实施例中,在与所查询到的多个从数据库分别建立第三连接之后,还包括:若监听到所述拓扑结构信息发生变化,则根据变化后的拓扑结构信息确定新的查询到的多个从数据库;与新的查询到的多个从数据库分别建立第四连接。这样设置的好处在于,若拓扑结构信息发生变化,那么对应的从数据库可能也发生变化,可以断开与原来的从数据库的第三连接,并与新查询到的从数据库建立第四连接,在后续需要进行配置数据读取时,不需要临时变更连接,提高配置数据读取效率。In some embodiments, after respectively establishing third connections with the multiple slave databases that have been queried, the method further includes: if it is monitored that the topology information changes, determining a new query query according to the changed topology information. The multiple slave databases obtained by the new query respectively establish a fourth connection with the multiple slave databases obtained by the new query. The advantage of this setting is that if the topology information changes, the corresponding slave database may also change, so the third connection with the original slave database can be disconnected, and a fourth connection can be established with the newly queried slave database. When the configuration data needs to be read later, there is no need to temporarily change the connection, which improves the efficiency of configuration data reading.
在一些实施例中,上述应用于配置管理服务端的配置数据访问方法以及应用于配置服务端的配置数据访问方法可以由同样的程序代码完成,该程序可以智能判断出当前被触发的是配置数据写入事件还是配置数据读取事件,配置数据读取事件是针对主数据库的还是针对从数据库的,可以根据接收到的请求类型或结构化查询语言(Structured Query Language,SQL)语句等判断。In some embodiments, the configuration data access method applied to the configuration management server and the configuration data access method applied to the configuration server can be completed by the same program code, and the program can intelligently determine that the configuration data write is currently triggered. The event is still a configuration data read event. Whether the configuration data read event is for the master database or the slave database can be judged according to the received request type or Structured Query Language (SQL) statement.
示例性的,本申请实施例中可将上述程序称为智能数据源,图6为本申请实施例提供的一种智能数据源实现方式示意图,如图6所示,datasource.json为前文所述数据库拓扑结构配置文件。DataSourceConfigSyncer为数据源配置监听器,负责监听datasource.json的变化,并通知DataSourceManager重建智能数据源。SmartDataSource为智能数据源的实现类,提供给上层统一的数据访问接口,其内部包含写数据源MultiWriteDataSource和读数据源MultiReadDataSource,并根据SQL的类型路由到对应数据源。Exemplarily, in this embodiment of the present application, the above program may be referred to as an intelligent data source. FIG. 6 is a schematic diagram of an implementation manner of an intelligent data source provided in an embodiment of the present application. As shown in FIG. 6 , datasource.json is the above-mentioned Database topology configuration file. DataSourceConfigSyncer configures a listener for the data source, which is responsible for monitoring changes in datasource.json and notifying the DataSourceManager to rebuild the smart data source. SmartDataSource is the implementation class of smart data source, which provides a unified data access interface to the upper layer. It contains the write data source MultiWriteDataSource and the read data source MultiReadDataSource, and route to the corresponding data source according to the type of SQL.
MultiWriteDataSource为写数据源的封装,内部包含多个(例如可以是3个,与主数据库数量相同)WriteDataSource,MultiWriteDataSource会选择一个可写的WriteDataSource进行写入,而是否可写则通过写心跳(WriteHeartbeat)周期性发送写SQL进行探测,在本申请实施例中可以采用MGR中的单主模式,在该模式下,任何时刻只有一个节点可写入。MultiWriteDataSource is the encapsulation of write data source, which contains multiple (for example, 3, the same as the number of main database) WriteDataSource, MultiWriteDataSource will select a writable WriteDataSource to write, and whether it is writable is determined by write heartbeat (WriteHeartbeat) The write SQL is periodically sent for detection. In this embodiment of the present application, the single-master mode in the MGR may be adopted. In this mode, only one node can write at any time.
MultiReadDataSource为读数据源的封装,内部包含多个(例如一个业务区域部署3个从数据库,则此处数量可以为3个)ReadDataSource,MultiReadDataSource会从所有健康的(也即处于可读状态的)ReadDataSource中选择一个最优的ReadDataSource进行读操作。健康状态通过读心跳(ReadHeartbeat)周期性发送读SQL进行探测,而最优ReadDataSource的选择则根据优先级(priority)字段标示(选择priority值最小的)进行选择,priority是按距离排序的,也即距离越小,对应的priority值越小。MultiReadDataSource is the encapsulation of read data source, which contains multiple (for example, a business area deploys 3 slave databases, the number here can be 3) ReadDataSource, MultiReadDataSource will read from all healthy (that is, in readable state) ReadDataSource Select an optimal ReadDataSource for read operations. The health status is detected by periodically sending read SQL through the read heartbeat (ReadHeartbeat), and the selection of the optimal ReadDataSource is based on the priority field indication (select the smallest priority value). The priority is sorted by distance, that is, The smaller the distance, the smaller the corresponding priority value.
通过上述配置服务端和MySQL集群部署方案及智能数据源的设计,可以实现在全球化部署以及不可靠网络环境下的配置高可用和最终一致性,并且可以做到系统自治,在故障发生时不需要任何外部介入(也即不依赖其他中间件等组件,也不需要人为干预)即能实现故障转移,实现主数据库的高可用和多个业务区域的从数据库的高可用。Through the above configuration server and MySQL cluster deployment scheme and intelligent data source design, high availability and eventual consistency of configuration in global deployment and unreliable network environment can be achieved, and system autonomy can be achieved, and no faults occur. Failover can be achieved without any external intervention (that is, without relying on other components such as middleware, and without human intervention) to achieve high availability of the master database and high availability of slave databases in multiple business areas.
图7为本申请实施例提供的一种配置数据访问装置的结构框图,该装置应用于微服务架构中的配置中心的配置管理服务端,可由软件和/或硬件实现,一般可集成在服务器等计算机设备中,可通过执行配置数据访问方法来进行配置数据访问。如图7所示,该装置包括:7 is a structural block diagram of a configuration data access device provided by an embodiment of the present application. The device is applied to a configuration management server of a configuration center in a microservice architecture, and can be implemented by software and/or hardware, and can generally be integrated in a server, etc. In the computer equipment, configuration data access may be performed by executing a configuration data access method. As shown in Figure 7, the device includes:
写入事件监测模块701,设置为检测配置数据写入事件是否被触发;写入操作模块702,设置为在检测到配置数据写入事件被触发后,若探测到所在第一机房对应的目标主数据库处于可写状态,则针对所述目标主数据库进行配置数据写入操作,其中,处于可写状态的主数据库基于所述预设一致性协议确定;写入操作反馈模块703,设置为检测到所述目标主数据库之外的主数据库完成针对本次写入操作的数据同步后,反馈写入成功信息。The write event monitoring module 701 is set to detect whether the configuration data write event is triggered; the write operation module 702 is set to, after detecting that the configuration data write event is triggered, if the target host corresponding to the first computer room where it is located is detected If the database is in a writable state, the configuration data writing operation is performed on the target master database, wherein the master database in the writable state is determined based on the preset consistency protocol; the write operation feedback module 703 is set to detect After the master database other than the target master database completes the data synchronization for this writing operation, the writing success information is fed back.
本申请实施例提供的配置数据访问装置,微服务架构中的配置中心包括配置中心服务端和配置中心客户端,配置中心服务端包括配置管理服务端和配置服务端,配置管理服务端部署于多个第一机房内,每个第一机房配备一个主数据库,所有主数据库基于预设一致性协议保证数据强一致,第一机房之间的网络质量满足预设质量要求,可以保证第一机房之间的通信可靠性,同时,也能够保证主数据库之间的同步性能以及主数据库的高可用性,配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第二机房配备一个从数据库,主数据库和从数据库包含于配置中心对应的数据库集群中,在上述配置中心的架构基础上,配置管理服务端检测到配置数据写入事件被触发后,主动探测所在第一机房对应的目标主数据库是否处于可写状态,若所在第一机房对应的目标主数据库处于可写状态,则针对目标主数据库进行配置数据写入操作,而处于可写状态的主数据库是基于预设一致性协议确定的,也即预设一致性协议中定义的主节点,以便能够基于该协议保障主数据库之间的数据强一致,检测到目标主数据库之外的主数据库完成针对本次写入操作的数据同步后,反馈写入成功信息,从而可以不依赖其他组件而在配置中心内部实现智能探测可写主数据库并进行配置数据的高可靠性写入操作,且所有主数据库基于预设一致性协议保证主数据库的高可用和数据一致性,避免了发生因数据丢失而影响业务的情况。In the configuration data access device provided by the embodiment of the present application, the configuration center in the micro-service architecture includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in multiple In the first computer room, each first computer room is equipped with a master database. All the master databases ensure strong data consistency based on the preset consistency protocol. The network quality between the first computer rooms meets the preset quality requirements, which can ensure the first computer room. At the same time, it can also ensure the synchronization performance between the main databases and the high availability of the main database. The configuration server is deployed in at least two groups of second computer rooms. The same group of second computer rooms are located in the same business area, but different The second computer room of the group is located in different business areas. Each second computer room is equipped with a slave database. The master database and the slave database are included in the database cluster corresponding to the configuration center. Based on the architecture of the configuration center, the configuration management server detects the configuration After the data write event is triggered, it actively detects whether the target master database corresponding to the first computer room is in a writable state. If the target master database corresponding to the first computer room is in a writable state, the configuration data is written to the target master database. operation, and the master database in the writable state is determined based on the preset consistency protocol, that is, the master node defined in the preset consistency protocol, so as to ensure strong data consistency between master databases based on this protocol. After the master database other than the target master database completes the data synchronization for this write operation, the write success information is fed back, so that the intelligent detection of the writable master database and the high level of configuration data can be realized in the configuration center without relying on other components. Reliable write operations, and all primary databases ensure high availability and data consistency of the primary databases based on preset consistency protocols, avoiding business impact due to data loss.
图8为本申请实施例提供的另一种配置数据访问装置的结构框图,该装置应用于微服务架构中的配置中心的配置服务端,可由软件和/或硬件实现,一般可集成在服务器等计算机设备中,可通过执行配置数据访问方法来进行配置数据访问。如图8所示,该装置包括:8 is a structural block diagram of another configuration data access device provided by an embodiment of the present application. The device is applied to a configuration server of a configuration center in a microservice architecture, and can be implemented by software and/or hardware, and can generally be integrated in a server, etc. In the computer equipment, configuration data access may be performed by executing a configuration data access method. As shown in Figure 8, the device includes:
读取事件触发检测模块801,设置为检测配置数据读取事件是否被触发;状态探测模块802,设置为在检测到配置数据读取事件被触发后,探测出处于可读状态的备选从数据库;读取操作模块803,设置为从所述备选从数据库中挑选出目的从数据库,并针对所述目的从数据库进行配置数据读取操作,其中,所述目的从数据库所在机房与当前配置服务端所在第二机房的第一距离小于其他备选从数据库所在机房与当前配置服务端所在第二机房的第二距离。The read event trigger detection module 801 is configured to detect whether the configuration data read event is triggered; the state detection module 802 is configured to detect an alternative slave database in a readable state after detecting that the configuration data read event is triggered The read operation module 803 is set to select the purpose from the database from the alternative database, and carry out the configuration data reading operation from the database for the purpose, wherein, the purpose is from the computer room where the database is located and the current configuration service. The first distance of the second computer room where the terminal is located is smaller than the second distance between the computer room where the other candidate slave databases are located and the second computer room where the current configuration server is located.
本申请实施例中提供的配置数据访问装置,微服务架构中的配置中心包括配置中心服务端和配置中心客户端,配置中心服务端包括配置管理服务端和配置服务端,配置管理服务端部署于多个第一机房内,每个第一机房配备一个主数据库,所有主数据库基于预设一致性协议保证数据强一致,第一机房之间的网络质量满足预设质量要求,可以保证第一机房之间的通信可靠性,同时,也能够保证主数据库之间的同步性能以及主数据库的高可用性,配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机 房位于不同业务区域,每个第二机房配备一个从数据库,主数据库和从数据库包含于配置中心对应的数据库集群中,在上述配置中心的架构基础上,配置服务端检测到配置数据读取事件被触发后,主动探测处于可读状态的备选从数据库,并挑选出距离当前配置服务端最近的备选从数据库进行配置数据读取,实现从数据库的互相备用,保证配置中心的高可用。In the configuration data access device provided in the embodiment of this application, the configuration center in the micro-service architecture includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in In multiple first computer rooms, each first computer room is equipped with a master database. All master databases ensure strong data consistency based on a preset consistency protocol. The network quality between the first computer rooms meets the preset quality requirements, which can ensure that the first computer room is At the same time, it can also ensure the synchronization performance between the main databases and the high availability of the main database. The configuration server is deployed in at least two sets of second computer rooms, and the same group of second computer rooms are located in the same business area. Different groups of second computer rooms are located in different business areas. Each second computer room is equipped with a slave database. The master database and the slave database are included in the database cluster corresponding to the configuration center. Based on the architecture of the configuration center, the configuration server detects the configuration After the data read event is triggered, it actively detects the candidate slave database in the readable state, and selects the candidate slave database closest to the current configuration server to read the configuration data, realizes the mutual backup of the slave databases, and ensures the configuration center. high availability.
本申请实施例提供了一种计算机设备,该计算机设备中可集成本申请实施例提供的配置数据访问装置。图9为本申请实施例提供的一种计算机设备的结构框图。计算机设备900包括存储器901、处理器902及存储在存储器901上并可在处理器902上运行的计算机程序,所述处理器902执行所述计算机程序时实现本申请实施例提供的配置数据访问方法。The embodiments of the present application provide a computer device, and the configuration data access apparatus provided by the embodiments of the present application can be integrated into the computer device. FIG. 9 is a structural block diagram of a computer device according to an embodiment of the present application. The computer device 900 includes a memory 901, a processor 902, and a computer program that is stored in the memory 901 and can run on the processor 902. When the processor 902 executes the computer program, the configuration data access method provided by the embodiments of the present application is implemented. .
本申请实施例还提供一种包含计算机可执行指令的存储介质,所述计算机可执行指令在由计算机处理器执行时用于执行本申请实施例提供的配置数据访问方法。The embodiments of the present application further provide a storage medium containing computer-executable instructions, where the computer-executable instructions, when executed by a computer processor, are used to execute the configuration data access method provided by the embodiments of the present application.
本申请实施例还提供一种微服务架构中的配置中心,包括配置中心服务端和配置中心客户端,所述配置中心服务端包括配置管理服务端和配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库基于预设一致性协议保证数据强一致;所述配置管理服务端基于本申请实施例所述的配置数据访问方法进行配置数据写入等访问操作;所述配置服务端基于本申请实施例所述的配置数据访问方法进行配置数据读取等访问操作。Embodiments of the present application further provide a configuration center in a micro-service architecture, including a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server deploys In a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets the preset quality requirements, the configuration server is deployed in at least two groups of second computer rooms, and the same group of second computer rooms is located in the same service different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, and each second computer room is equipped with a slave database, the master database and the slave database are included in the database corresponding to the configuration center In the cluster, all main databases ensure strong data consistency based on a preset consistency protocol; the configuration management server performs access operations such as configuration data writing based on the configuration data access method described in the embodiment of the present application; the configuration server is based on the The configuration data access method described in the embodiments of the present application performs access operations such as configuration data reading.
上述实施例中提供的配置数据访问装置、设备、存储介质以及配置中心可执行本申请实施例所提供的配置数据访问方法,具备执行该方法相应的功能模块和效果。未在上述实施例中详尽描述的技术细节,可参见本申请相应实施例所提供的配置数据访问方法。The configuration data access device, device, storage medium, and configuration center provided in the above embodiments can execute the configuration data access method provided by the embodiment of the present application, and have corresponding functional modules and effects for executing the method. For technical details not described in detail in the foregoing embodiments, reference may be made to the configuration data access method provided by the corresponding embodiment of the present application.

Claims (14)

  1. 一种配置数据访问方法,应用于微服务架构中的配置中心的配置管理服务端,所述配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括所述配置管理服务端和配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;A configuration data access method is applied to a configuration management server of a configuration center in a microservice architecture, the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes the configuration management server and a configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets the preset quality requirements, and the configuration server is deployed in at least two sets of second computer rooms. In the computer room, the same group of second computer rooms are located in the same business area, and different groups of second computer rooms are located in different business areas. Each first computer room is equipped with a master database, and each second computer room is equipped with a slave database. The slave database is included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
    所述方法包括:The method includes:
    响应于检测到配置数据写入事件被触发;triggered in response to detecting a configuration data write event;
    在探测到所在第一机房对应的目标主数据库处于可写状态的情况下,针对所述目标主数据库进行配置数据写入操作,其中,处于可写状态的主数据库基于所述预设一致性协议确定;When it is detected that the target master database corresponding to the first computer room is in a writable state, the configuration data writing operation is performed on the target master database, wherein the master database in the writable state is based on the preset consistency protocol Sure;
    检测到所述所有主数据库中除所述目标主数据库之外的主数据库完成针对本次写入操作的数据同步后,反馈写入成功信息。After it is detected that the main databases other than the target main database among all the main databases have completed data synchronization for this write operation, the write success information is fed back.
  2. 根据权利要求1所述的方法,在所述检测到配置数据写入事件被触发之前,还包括:The method according to claim 1, before the detecting that the configuration data write event is triggered, further comprising:
    获取所述数据库集群的拓扑结构信息,其中,所述拓扑结构信息中包含机房与数据库的对应关系信息;acquiring topology information of the database cluster, wherein the topology information includes information on the correspondence between the computer room and the database;
    根据所述拓扑结构信息查询所在第一机房对应的目标主数据库。The target master database corresponding to the first computer room where it is located is queried according to the topology structure information.
  3. 根据权利要求2所述的方法,在所述根据所述拓扑结构信息查询所在第一机房对应的目标主数据库之后,还包括:The method according to claim 2, after querying the target master database corresponding to the first computer room according to the topology structure information, further comprising:
    与所述目标主数据库建立第一连接;establishing a first connection with the target master database;
    所述探测到所在第一机房对应的目标主数据库处于可写状态,包括:The detected target master database corresponding to the first computer room is in a writable state, including:
    基于所述第一连接尝试向所述目标主数据库写入第一数据,在检测到所述第一数据写入成功的情况下,确定所述目标主数据库处于可写状态。Based on the first connection attempt to write the first data to the target primary database, in the case that the writing of the first data is detected to be successful, it is determined that the target primary database is in a writable state.
  4. 根据权利要求3所述的方法,在所述与所述目标主数据库建立第一连接之后,还包括:The method according to claim 3, after establishing the first connection with the target master database, further comprising:
    在监听到所述拓扑结构信息发生变化的情况下,根据变化后的拓扑结构信息确定新的目标主数据库;In the case of monitoring the change of the topology structure information, determine a new target master database according to the changed topology structure information;
    与所述新的目标主数据库建立第二连接。A second connection is established with the new target master database.
  5. 根据权利要求1所述的方法,还包括:The method of claim 1, further comprising:
    检测到配置数据读取事件被触发;It is detected that the configuration data read event is triggered;
    探测出处于可读状态的备选主数据库;Detects an alternate primary database in a readable state;
    从所述备选主数据库中挑选出目的主数据库,并针对所述目的主数据库进行配置数据读取操作,其中,所述目的主数据库所在机房与当前配置管理服务端所在第一机房的第一距离小于所述备选主数据库中除所述目的主数据库之外的备选主数据库所在机房与当前配置管理服务端所在第一机房的第二距离。The target main database is selected from the candidate main database, and the configuration data reading operation is performed on the target main database, wherein the first computer room where the target main database is located and the first computer room where the current configuration management server is located is located. The distance is smaller than the second distance between the computer room where the candidate primary databases other than the target primary database are located in the candidate primary database and the first computer room where the current configuration management server is located.
  6. 一种配置数据访问方法,应用于微服务架构中的配置中心的配置服务端,所述配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括配置管理服务端和所述配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;A configuration data access method is applied to a configuration server of a configuration center in a microservice architecture, the configuration center includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and the configuration center server A configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets a preset quality requirement, and the configuration server is deployed in at least two sets of second computer rooms In the same group of second computer rooms are located in the same business area, different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, each second computer room is equipped with a slave database, the master database and the The slave database is included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
    所述方法包括:The method includes:
    响应于检测到配置数据读取事件被触发;triggered in response to detecting a configuration data read event;
    探测出处于可读状态的备选从数据库;Detect an alternate slave database in a readable state;
    从所述备选从数据库中挑选出目的从数据库,并针对所述目的从数据库进行配置数据读取操作,其中,所述目的从数据库所在机房与当前配置服务端所在第二机房的第一距离小于所述备选从数据库中除所述目的从数据库之外的备选从数据库所在机房与当前配置服务端所在第二机房的第二距离。The purpose slave database is selected from the candidate slave database, and the configuration data read operation is performed from the database for the purpose, wherein the purpose is the first distance between the computer room where the database is located and the second computer room where the current configuration server is located. It is less than the second distance between the computer room where the candidate slave databases other than the destination slave database are located in the candidate slave database and the second computer room where the current configuration server is located.
  7. 根据权利要求6所述的方法,在所述检测到配置数据读取事件被触发之前,还包括:The method according to claim 6, before the detecting that the configuration data read event is triggered, further comprising:
    获取所述数据库集群的拓扑结构信息,其中,所述拓扑结构信息中包含机房与数据库的对应关系信息,以及数据库与业务区域的对应关系信息;Obtaining the topology structure information of the database cluster, wherein the topology structure information includes the information of the correspondence between the computer room and the database, and the information of the correspondence between the database and the business area;
    根据所述拓扑结构信息查询所在第二机房对应的目标业务区域中包含的多个从数据库;Query multiple slave databases included in the target business area corresponding to the second computer room according to the topology information;
    所述探测出处于可读状态的备选从数据库,包括:The detected candidate slave database in a readable state includes:
    从所查询到的所述多个从数据库中探测出所述处于可读状态的备选从数据库。The candidate slave database in the readable state is detected from the plurality of slave databases queried.
  8. 根据权利要求7所述的方法,在所述根据所述拓扑结构信息查询所在第 二机房对应的目标业务区域中包含的多个从数据库之后,还包括:The method according to claim 7, after the multiple slave databases included in the target business area corresponding to the second computer room where the query is based on the topology structure information, further comprising:
    与所查询到的所述多个从数据库分别建立第三连接;respectively establishing a third connection with the queried multiple slave databases;
    所述从所查询到的所述多个从数据库中探测出所述处于可读状态的备选从数据库,包括:The detection of the candidate slave database in a readable state from the plurality of slave databases queried includes:
    基于所述第三连接尝试从所查询到的所述多个从数据库分别读取第二数据,在检测到所述第二数据读取成功的情况下,确定读取成功的所述第二数据对应的从数据库处于可读状态,将确定的所述从数据库作为所述备选从数据库。Based on the third connection attempt to read the second data from the plurality of queried slave databases, respectively, in the case of detecting that the second data is successfully read, determine the second data that has been successfully read The corresponding slave database is in a readable state, and the determined slave database is used as the candidate slave database.
  9. 根据权利要求8所述的方法,在所述与所查询到的所述多个从数据库分别建立第三连接之后,还包括:The method according to claim 8, after the third connection is respectively established with the plurality of queried slave databases, further comprising:
    监听到所述拓扑结构信息发生变化的情况下,根据变化后的拓扑结构信息确定新的查询到的多个从数据库;In the case of monitoring the change of the topology structure information, determine a plurality of newly queried slave databases according to the changed topology structure information;
    与所述新的查询到的多个从数据库分别建立第四连接。Fourth connections are respectively established with the multiple slave databases obtained by the new query.
  10. 一种配置数据访问装置,应用于微服务架构中的配置中心的配置管理服务端,所述配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括所述配置管理服务端和配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;A configuration data access device is applied to a configuration management server of a configuration center in a microservice architecture, the configuration center includes a configuration center server and a configuration center client, and the configuration center server includes the configuration management server and a configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets the preset quality requirements, and the configuration server is deployed in at least two sets of second computer rooms. In the computer room, the same group of second computer rooms are located in the same business area, and different groups of second computer rooms are located in different business areas. Each first computer room is equipped with a master database, and each second computer room is equipped with a slave database. The slave database is included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
    所述装置包括:The device includes:
    写入事件监测模块,设置为检测配置数据写入事件是否被触发;Write event monitoring module, set to detect whether the configuration data write event is triggered;
    写入操作模块,设置为响应于检测到配置数据写入事件被触发,在探测到所在第一机房对应的目标主数据库处于可写状态的情况下,针对所述目标主数据库进行配置数据写入操作,其中,处于可写状态的主数据库基于所述预设一致性协议确定;The writing operation module is set to be triggered in response to detecting that the configuration data writing event is triggered, and in the case of detecting that the target main database corresponding to the first computer room is in a writable state, write configuration data to the target main database operations, wherein the master database in a writable state is determined based on the preset consistency protocol;
    写入操作反馈模块,设置为检测到所述所有主数据库中除所述目标主数据库之外的主数据库完成针对本次写入操作的数据同步后,反馈写入成功信息。The write operation feedback module is configured to feed back write success information after detecting that the main databases in all the main databases except the target main database have completed data synchronization for this write operation.
  11. 一种配置数据访问装置,应用于微服务架构中的配置中心的配置服务端,所述配置中心包括配置中心服务端和配置中心客户端,所述配置中心服务端包括配置管理服务端和所述配置服务端,所述配置管理服务端部署于多个第 一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;A configuration data access device is applied to a configuration server of a configuration center in a microservice architecture, the configuration center includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and the configuration center server A configuration server, the configuration management server is deployed in a plurality of first computer rooms, the network quality between the plurality of first computer rooms meets a preset quality requirement, and the configuration server is deployed in at least two sets of second computer rooms In the same group of second computer rooms are located in the same business area, different groups of second computer rooms are located in different business areas, each first computer room is equipped with a master database, each second computer room is equipped with a slave database, the master database and the The slave database is included in the database cluster corresponding to the configuration center, and all master databases are set to ensure strong data consistency based on a preset consistency protocol;
    所述装置包括:The device includes:
    读取事件触发检测模块,设置为检测配置数据读取事件是否被触发;The read event triggers the detection module, which is set to detect whether the configuration data read event is triggered;
    状态探测模块,设置为响应于检测到配置数据读取事件被触发,探测出处于可读状态的备选从数据库;A state detection module, configured to detect an alternate slave database in a readable state in response to detecting that the configuration data read event is triggered;
    读取操作模块,设置为从所述备选从数据库中挑选出目的从数据库,并针对所述目的从数据库进行配置数据读取操作,其中,所述目的从数据库所在机房与当前配置服务端所在第二机房的第一距离小于所述备选从数据库中除所述目的从数据库之外的备选从数据库所在机房与当前配置服务端所在第二机房的第二距离。The read operation module is set to select the purpose from the database from the alternative database, and perform a configuration data read operation from the database for the purpose, wherein the purpose is from the computer room where the database is located and the current configuration server is located. The first distance of the second computer room is smaller than the second distance between the computer room where the candidate secondary database except the destination secondary database is located in the candidate secondary database and the second computer room where the current configuration server is located.
  12. 一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现如权利要求1-9中任一项所述的配置数据访问方法。A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the computer program described in claims 1-9 when the processor executes the computer program The configuration data access method of any one.
  13. 一种微服务架构中的配置中心,包括配置中心服务端和配置中心客户端,所述配置中心服务端包括配置管理服务端和配置服务端,所述配置管理服务端部署于多个第一机房内,所述多个第一机房之间的网络质量满足预设质量要求,所述配置服务端部署于至少两组第二机房内,同一组第二机房位于同一个业务区域,不同组第二机房位于不同业务区域,每个第一机房配备一个主数据库,每个第二机房配备一个从数据库,所述主数据库和所述从数据库包含于所述配置中心对应的数据库集群中,所有主数据库设置为基于预设一致性协议保证数据强一致;A configuration center in a microservice architecture includes a configuration center server and a configuration center client, the configuration center server includes a configuration management server and a configuration server, and the configuration management server is deployed in a plurality of first computer rooms The network quality between the multiple first computer rooms meets the preset quality requirements, the configuration server is deployed in at least two groups of second computer rooms, the same group of second computer rooms is located in the same business area, and different groups of second computer rooms are located in the same business area. The computer rooms are located in different business areas. Each first computer room is equipped with a master database, and each second computer room is equipped with a slave database. The master database and the slave database are included in the database cluster corresponding to the configuration center. All master databases Set to ensure strong data consistency based on the preset consistency protocol;
    所述配置管理服务端设置为基于如权利要求1-5中任一项所述的配置数据访问方法进行配置数据访问;The configuration management server is set to perform configuration data access based on the configuration data access method according to any one of claims 1-5;
    所述配置服务端设置为基于如权利要求6-9中任一项所述的配置数据访问方法进行配置数据访问。The configuration server is configured to perform configuration data access based on the configuration data access method according to any one of claims 6-9.
  14. 一种计算机可读存储介质,存储有计算机程序,其中,所述程序被处理器执行时实现如权利要求1-9中任一项所述的配置数据访问方法。A computer-readable storage medium storing a computer program, wherein when the program is executed by a processor, the configuration data access method according to any one of claims 1-9 is implemented.
PCT/CN2021/108147 2020-08-18 2021-07-23 Configuration data access method, apparatus, and device, configuration center, and storage medium WO2022037359A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010831215.3 2020-08-18
CN202010831215.3A CN112015744A (en) 2020-08-18 2020-08-18 Configuration data access method, device, equipment, configuration center and storage medium

Publications (1)

Publication Number Publication Date
WO2022037359A1 true WO2022037359A1 (en) 2022-02-24

Family

ID=73504895

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/108147 WO2022037359A1 (en) 2020-08-18 2021-07-23 Configuration data access method, apparatus, and device, configuration center, and storage medium

Country Status (2)

Country Link
CN (1) CN112015744A (en)
WO (1) WO2022037359A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114844951A (en) * 2022-04-22 2022-08-02 百果园技术(新加坡)有限公司 Request processing method, system, device, storage medium and product
CN115934428A (en) * 2023-01-10 2023-04-07 湖南三湘银行股份有限公司 Main disaster recovery backup switching method and device of MYSQL database and electronic equipment

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112015744A (en) * 2020-08-18 2020-12-01 广州市百果园信息技术有限公司 Configuration data access method, device, equipment, configuration center and storage medium
CN113703866B (en) * 2021-08-25 2024-04-26 上海哔哩哔哩科技有限公司 Configuration center information synchronization method and system
CN114666418B (en) * 2022-03-10 2024-02-20 北京九恒星科技股份有限公司 Service system connection method, device and storage medium
CN115185961A (en) * 2022-06-24 2022-10-14 北京奥星贝斯科技有限公司 Node configuration method, transaction log synchronization method and node of distributed database
CN117369906B (en) * 2023-12-07 2024-02-09 成都市楠菲微电子有限公司 Pcie verification platform, method and device, storage medium and electronic equipment

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105205182A (en) * 2015-10-28 2015-12-30 北京奇虎科技有限公司 System deployed in multiple computer rooms and cross-computer-room business data processing method
CN106341454A (en) * 2016-08-23 2017-01-18 世纪龙信息网络有限责任公司 Across-room multiple-active distributed database management system and across-room multiple-active distributed database management method
CN108090222A (en) * 2018-01-05 2018-05-29 中国科学院计算技术研究所 A kind of data-base cluster internodal data synchronization system
CN109471755A (en) * 2018-11-14 2019-03-15 江苏鸿信系统集成有限公司 A kind of method and its system that the same city strange land calamity based on cloud computing is standby
CN109726250A (en) * 2018-12-27 2019-05-07 星环信息科技(上海)有限公司 Data-storage system, metadatabase synchronization and data cross-domain calculation method
US20190250575A1 (en) * 2018-02-13 2019-08-15 Tridonic Gmbh & Co Kg Commissioning smart lighting systems
CN110633175A (en) * 2019-09-27 2019-12-31 掌阅科技股份有限公司 Multi-computer-room data processing method based on micro-service, electronic equipment and storage medium
CN110851528A (en) * 2019-10-09 2020-02-28 网联清算有限公司 Database synchronization method and device, storage medium and computer equipment
CN111078426A (en) * 2019-12-03 2020-04-28 紫光云(南京)数字技术有限公司 High concurrency solution under back-end micro-service architecture
CN111090637A (en) * 2019-12-20 2020-05-01 辽宁振兴银行股份有限公司 Financial-level high-availability MySQL database implementation method based on A10
CN112015744A (en) * 2020-08-18 2020-12-01 广州市百果园信息技术有限公司 Configuration data access method, device, equipment, configuration center and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7685131B2 (en) * 2006-02-28 2010-03-23 International Business Machines Corporation Web services database cluster architecture
CN108306955B (en) * 2018-01-24 2021-06-15 北京万得嘉瑞汽车技术有限公司 Large-scale interconnection clustering method for vehicle-mounted terminals

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105205182A (en) * 2015-10-28 2015-12-30 北京奇虎科技有限公司 System deployed in multiple computer rooms and cross-computer-room business data processing method
CN106341454A (en) * 2016-08-23 2017-01-18 世纪龙信息网络有限责任公司 Across-room multiple-active distributed database management system and across-room multiple-active distributed database management method
CN108090222A (en) * 2018-01-05 2018-05-29 中国科学院计算技术研究所 A kind of data-base cluster internodal data synchronization system
US20190250575A1 (en) * 2018-02-13 2019-08-15 Tridonic Gmbh & Co Kg Commissioning smart lighting systems
CN109471755A (en) * 2018-11-14 2019-03-15 江苏鸿信系统集成有限公司 A kind of method and its system that the same city strange land calamity based on cloud computing is standby
CN109726250A (en) * 2018-12-27 2019-05-07 星环信息科技(上海)有限公司 Data-storage system, metadatabase synchronization and data cross-domain calculation method
CN110633175A (en) * 2019-09-27 2019-12-31 掌阅科技股份有限公司 Multi-computer-room data processing method based on micro-service, electronic equipment and storage medium
CN110851528A (en) * 2019-10-09 2020-02-28 网联清算有限公司 Database synchronization method and device, storage medium and computer equipment
CN111078426A (en) * 2019-12-03 2020-04-28 紫光云(南京)数字技术有限公司 High concurrency solution under back-end micro-service architecture
CN111090637A (en) * 2019-12-20 2020-05-01 辽宁振兴银行股份有限公司 Financial-level high-availability MySQL database implementation method based on A10
CN112015744A (en) * 2020-08-18 2020-12-01 广州市百果园信息技术有限公司 Configuration data access method, device, equipment, configuration center and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114844951A (en) * 2022-04-22 2022-08-02 百果园技术(新加坡)有限公司 Request processing method, system, device, storage medium and product
CN114844951B (en) * 2022-04-22 2024-03-19 百果园技术(新加坡)有限公司 Request processing method, system, device, storage medium and product
CN115934428A (en) * 2023-01-10 2023-04-07 湖南三湘银行股份有限公司 Main disaster recovery backup switching method and device of MYSQL database and electronic equipment

Also Published As

Publication number Publication date
CN112015744A (en) 2020-12-01

Similar Documents

Publication Publication Date Title
WO2022037359A1 (en) Configuration data access method, apparatus, and device, configuration center, and storage medium
US10713134B2 (en) Distributed storage and replication system and method
CN108632067B (en) Disaster recovery deployment method, device and system
CN109729111B (en) Method, apparatus and computer program product for managing distributed systems
EP3694148A1 (en) Configuration modification method for storage cluster, storage cluster and computer system
CN107391294B (en) Method and device for establishing IPSAN disaster recovery system
CN105471622B (en) A kind of high availability method and system of the control node active-standby switch based on Galera
CN100426751C (en) Method for ensuring accordant configuration information in cluster system
CN108234302A (en) Keep the consistency in the distributed operating system of network equipment
US11095742B2 (en) Query proxy for delivery of dynamic system state
Suh et al. On performance of OpenDaylight clustering
CN103986789A (en) Method for realizing dual redundant of NFS (network file system) nodes in HADOOP HA (home address) cluster based on NFS
WO2023082800A1 (en) Main node selection method, distributed database and storage medium
CN109639773A (en) A kind of the distributed data cluster control system and its method of dynamic construction
CN115794499B (en) Method and system for dual-activity replication data among distributed block storage clusters
CN114116912A (en) Method for realizing high availability of database based on Keepalived
WO2017071384A1 (en) Message processing method and apparatus
CN112000444B (en) Database transaction processing method and device, storage medium and electronic equipment
WO2015196692A1 (en) Cloud computing system and processing method and apparatus for cloud computing system
CN103780433B (en) Self-healing type virtual resource configuration management data architecture
CN116055314A (en) Configuration synchronization method and device
CN114172821B (en) Service state synchronization method and device and server
CN114500289B (en) Control plane recovery method, device, control node and storage medium
CN111064643B (en) Node server and data interaction method and related device thereof
CN113472891A (en) SDN controller cluster data processing method, device and medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21857454

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21857454

Country of ref document: EP

Kind code of ref document: A1