CN117729214A - Proxy method, proxy device, electronic equipment and storage medium - Google Patents

Proxy method, proxy device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117729214A
CN117729214A CN202311723177.XA CN202311723177A CN117729214A CN 117729214 A CN117729214 A CN 117729214A CN 202311723177 A CN202311723177 A CN 202311723177A CN 117729214 A CN117729214 A CN 117729214A
Authority
CN
China
Prior art keywords
database
master node
distributed database
address
connection request
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202311723177.XA
Other languages
Chinese (zh)
Inventor
孙智慧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
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 Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202311723177.XA priority Critical patent/CN117729214A/en
Publication of CN117729214A publication Critical patent/CN117729214A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a proxy method, a proxy device, electronic equipment and a storage medium, wherein the proxy method comprises the following steps: acquiring a database connection request, wherein the database connection request comprises master node identifiers of a distributed database; searching an IP address and a network port corresponding to the master node identifier; sending a database connection request to a distributed database according to the IP address and the network port; and receiving a database connection response sent by the distributed database. By searching the IP address and the network port corresponding to the master node identifier, sending a database connection request to the distributed database according to the IP address and the network port, and then receiving a database connection response sent by the distributed database, even if the master node needs to be reelected in the distributed database, the distributed database can be connected according to the newly-selected master node identifier, and the stability of connecting the distributed database is effectively improved.

Description

Proxy method, proxy device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the technical field of data security and server proxy, and in particular, to a proxy method, a proxy device, an electronic device, and a storage medium.
Background
A distributed database (Distributed Data Base, DDB) is a logically unified database consisting of physically discrete database units connected by a computer network. Each connected database unit is referred to as a site or node. The distributed database has a unified database management system for management, referred to as a distributed database management system.
Currently, connection and operation distributed databases are typically operated by client software on the terminal device, such as: the DBeaver software is used for connecting to the HBase database, and then the operations of adding, deleting, modifying or inquiring the table or data in the HBase database are carried out. However, in practice, it has been found that the stability of the client software connection to the distributed database is poor.
Disclosure of Invention
An objective of the embodiments of the present application is to provide a proxy method, a proxy device, an electronic device, and a storage medium, which are used for improving the problem of poor stability of a connection distributed database.
The embodiment of the application provides a proxy method, which comprises the following steps: acquiring a database connection request, wherein the database connection request comprises master node identifiers of a distributed database; searching an IP address and a network port corresponding to the master node identifier; sending a database connection request to a distributed database according to the IP address and the network port; and receiving a database connection response sent by the distributed database. In the implementation process of the scheme, the database connection request is sent to the distributed database by searching the IP address and the network port corresponding to the master node identifier, and then the database connection response sent by the distributed database is received, so that even if the master node needs to be reelected in the distributed database, the distributed database can be connected according to the newly-elected master node identifier, the equipment can continuously obtain the database connection response sent by the distributed database, and the stability of connecting the distributed database is effectively improved.
Optionally, in an embodiment of the present application, before acquiring the database connection request, the method further includes: and receiving a master node identifier returned by the Zookeeper server cluster, wherein the Zookeeper server cluster is operated with the distributed database, and transmitting the master node identifier to the terminal equipment. In the implementation process of the scheme, the master node identification in the distributed database is returned by receiving the Zookeeper server cluster, and the master node identification is sent to the terminal equipment, so that even if the master node in the distributed database is reelected, the terminal equipment can be connected with the distributed database again according to the reelected master node identification, thereby enhancing the stability of connecting the distributed database.
Optionally, in an embodiment of the present application, before receiving the master node identifier returned by the Zookeeper server cluster in the distributed database, the method further includes: receiving a node identification request sent by terminal equipment; sending a node identification request to a Zookeeper server so as to enable a Zookeeper server cluster to return a master node identification in a distributed database; after receiving the master node identification returned by the Zookeeper server cluster in the distributed database, the method further comprises the following steps: and sending the master node identification to the terminal equipment. In the implementation process of the scheme, the master node identification in the distributed database is returned by receiving the Zookeeper server cluster, and the master node identification is sent to the terminal equipment, so that even if the master node in the distributed database is reelected, the terminal equipment can be connected with the distributed database again according to the reelected master node identification, thereby enhancing the stability of connecting the distributed database.
Optionally, in an embodiment of the present application, the distributed database includes an HBase database; searching the IP address and the network port corresponding to the master node identifier comprises the following steps: and searching the IP address and the network port corresponding to the master node identifier from the configuration file, wherein all node identifiers of the HBase database and the corresponding relation between each node identifier and the IP address and the network port are stored in the configuration file. In the implementation process of the scheme, the distributed database is connected through the actual IP address and the network port corresponding to the master node identifier searched from the configuration file, so that the terminal equipment can be connected with the distributed database without knowing the actual IP address and the network port corresponding to the actual master node identifier, the risk that the actual IP address and the network port corresponding to the actual master node identifier are leaked to an external network is effectively reduced, and the safety of the distributed database is improved.
Optionally, in the embodiment of the present application, before searching the IP address and the network port corresponding to the master node identifier from the configuration file, the method further includes: acquiring all node identifiers and network ports of an HBase database; and storing all node identifiers of the HBase database, and IP addresses and network ports corresponding to each node identifier into a configuration file. In the implementation process of the scheme, all node identifiers of the HBase database and the IP address and the network port corresponding to each node identifier are stored in the configuration file, so that the terminal equipment can be connected with the distributed database from the actual IP address and the network port corresponding to the master node identifier searched in the configuration file without knowing the actual IP address and the network port corresponding to the actual master node identifier, and the risk that the actual IP address and the network port corresponding to the actual master node identifier are leaked to an external network is effectively reduced, and the security of the distributed database is improved.
Optionally, in an embodiment of the present application, obtaining the database connection request includes: receiving a database connection request sent by terminal equipment; after receiving the database connection response sent by the distributed database, the method further comprises the following steps: and sending a database connection response to the terminal equipment. In the implementation process of the scheme, after receiving the database connection response sent by the terminal equipment and the distributed database, the database connection response is sent to the terminal equipment, so that the operation request of the database of the terminal equipment is proxied, the terminal equipment can be connected and operated with the distributed database without knowing the actual IP address and the network port corresponding to the actual master node identification, the risk that the actual IP address and the network port corresponding to the actual master node identification are leaked to an external network is effectively reduced, and the security of the distributed database is improved.
Optionally, in an embodiment of the present application, after sending a database connection response to the terminal device, the method further includes: receiving an operation request of a distributed database sent by terminal equipment; an operation request is sent to the distributed database. In the implementation process of the scheme, the operation request of the distributed database sent by the terminal equipment is received, and the operation request is sent to the distributed database, so that the operation request of the database of the terminal equipment is proxied, the distributed database can be operated by the terminal equipment without knowing the actual IP address and the network port corresponding to the actual master node identification, the risk that the actual IP address and the network port corresponding to the actual master node identification are leaked to an external network is effectively reduced, and the safety of the distributed database is improved.
The embodiment of the application also provides a proxy device, which comprises: the connection request acquisition module is used for acquiring a database connection request, wherein the database connection request comprises master node identifiers of the distributed database; the address port searching module is used for searching the IP address and the network port corresponding to the master node identifier; the connection request sending module is used for sending a database connection request to the distributed database according to the IP address and the network port; and the connection response receiving module is used for receiving the database connection response sent by the distributed database.
Optionally, in an embodiment of the present application, the proxy device further includes: the node identification receiving module is used for receiving master node identifications returned by the Zookeeper server cluster in the distributed database, and the distributed database is operated on the Zookeeper server cluster.
Optionally, in an embodiment of the present application, the proxy device further includes: the identification request receiving module is used for receiving a node identification request sent by the terminal equipment; the identification request sending module is used for sending a node identification request to the Zookeeper server so as to enable the Zookeeper server cluster to return a master node identification in the distributed database; and the node identifier sending module is used for sending the master node identifier to the terminal equipment.
Optionally, in an embodiment of the present application, the distributed database includes an HBase database; an address port lookup module comprising: the IP port searching sub-module is used for searching the IP address and the network port corresponding to the master node identifier from the configuration file, wherein all node identifiers of the HBase database and the corresponding relation between each node identifier and the IP address and the network port are stored in the configuration file.
Optionally, in an embodiment of the present application, the address port lookup module further includes: the IP port receiving sub-module is used for acquiring all node identifiers and network ports of the HBase database; and the IP port storage sub-module is used for storing all the node identifiers of the HBase database, and the IP address and the network port corresponding to each node identifier into the configuration file.
Optionally, in an embodiment of the present application, the proxy device further includes: the connection request receiving module is used for receiving a database connection request sent by the terminal equipment; and the connection response sending module is used for sending the database connection response to the terminal equipment.
Optionally, in an embodiment of the present application, the proxy device further includes: the operation request receiving module is used for receiving an operation request of the distributed database sent by the terminal equipment; and the operation request sending module is used for sending the operation request to the distributed database.
The embodiment of the application also provides electronic equipment, which comprises: a processor and a memory storing machine-readable instructions executable by the processor to perform the method as described above when executed by the processor.
Embodiments of the present application also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs a method as described above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application, and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort to a person having ordinary skill in the art.
Fig. 1 is a schematic flow chart of a proxy method provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of a communication network of a distributed database cluster according to an embodiment of the present application;
fig. 3 is a schematic flow chart of a database connection request of a proxy terminal device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a proxy device according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the accompanying drawings in the embodiments of the present application are only for the purpose of illustration and description, and are not intended to limit the scope of protection of the embodiments of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in embodiments of the present application, illustrates operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to or removed from the flowcharts within the scope of embodiments of the present application.
In addition, the described embodiments are only a portion of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Accordingly, the following detailed description of the embodiments of the present application, which is provided in the accompanying drawings, is not intended to limit the scope of the claimed embodiments of the present application, but is merely representative of selected embodiments of the present application.
It is understood that "first" and "second" in the embodiments of the present application are used to distinguish similar objects. It will be appreciated by those skilled in the art that the words "first," "second," etc. do not limit the number and order of execution, and that the words "first," "second," etc. do not necessarily differ. In the description of the embodiments of the present application, the term "and/or" is merely an association relationship describing an association object, which means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship. The term "plurality" refers to two or more (including two), and similarly, "plurality" refers to two or more (including two).
Before describing the proxy method provided in the embodiments of the present application, some concepts involved in the embodiments of the present application are described:
the reverse proxy is a reverse proxy service provided by a proxy server in a computer network, that is, the proxy server can acquire resources from one or more groups of back-end servers (such as Web servers) related to the proxy server according to the request of the client, and then return the resources to the client, and the client only knows the IP address of the reverse proxy, but does not know the cluster behind the proxy server.
Zookeeper is an open source framework for a distributed coordination service for coordinating scheduling among servers within a cluster, for example: when a master node in the cluster fails, the Zookeeper reelects among the servers (e.g., servers in the role of slave nodes) of the cluster again, thereby electing a new master node server.
The Hadoop distributed file system (Hadoop Distributed File System, HDFS) refers to a distributed file system designed to fit on general purpose hardware (commodity hardware).
It should be noted that, the proxy method provided in the embodiment of the present application may be executed by an electronic device, where the electronic device refers to a device terminal or a proxy server that has a function of executing a computer program, and the device terminal is for example: smart phones, personal computers, tablet computers, personal digital assistants, or mobile internet appliances, etc. A proxy server refers to a device that provides proxy services and computing services over a network, for example: an x86 server and a non-x 86 server, the non-x 86 server comprising: mainframe, minicomputer, and UNIX servers.
Application scenarios to which the proxy method is applicable are described below, where the application scenarios include, but are not limited to: after the server cluster is built using the Zookeeper and the HDFS, and in the case where a distributed database (e.g., HBase database) is installed based on the HDFS, the proxy method may also be used to provide a reverse proxy service to the distributed database, which may be executed on servers in a non-cluster alone. Specifically, the HBase database described above may include a Master node (also referred to as a name node) and a Slave node (also referred to as a data node); the Master node is an important node selected by an active node election mechanism of the Zookeeper, and when the Zookeeper cannot communicate with the current Master node, the Zookeeper can elect a new Master node from all nodes included in the HBase database and provide database services by using the new Master node.
In long-term practice and research, it was found that the client software (e.g., dbeaner software) cannot communicate with the current Master node (e.g., the Master node itself fails or a network to the outside fails), and cannot learn the IP address and port of the reelected Master node, so that the client software cannot continue to operate the HBase database. To improve this situation, the proxy method may be used to provide a reverse proxy service for the distributed database, so that the client software reconnects to the distributed database through the reverse proxy service, and performs the function of continuing to operate the HBase database, thereby enhancing the stability of connecting to the distributed database.
Please refer to fig. 1, which illustrates a flowchart of a proxy method provided in an embodiment of the present application; it may be appreciated that the proxy method provided by the embodiments of the present application may be performed by a proxy server, which may be a server in a non-distributed database cluster. The above-mentioned distributed databases are generally operated in a cluster manner, and for convenience of description and illustration, hereinafter, the distributed databases will be simply referred to as distributed databases, and an embodiment of the proxy method may include:
step S110: and acquiring a database connection request, wherein the database connection request comprises master node identifiers of the distributed database.
Please refer to fig. 2, which illustrates a schematic diagram of a communication network of a distributed database cluster according to an embodiment of the present application; it will be appreciated that the database connection request may be sent by the terminal device of the user, and the terminal device may send the database connection request to the proxy server to reconnect the distributed database through the proxy server, because the IP address and port of the reselected Master node cannot be known on the terminal device of the user. The above-mentioned distributed databases are generally operated in a cluster manner, and for convenience of description and illustration, they will be simply referred to as distributed databases hereinafter.
The master node identifier of the distributed database in the database connection request can be obtained by the proxy server from the Zookeeper server cluster in advance and sent to the terminal equipment, or can be obtained by the user from the Zookeeper server cluster in a query way and filled in the terminal equipment. Therefore, the terminal device may acquire the master node identifier of the distributed database in various ways, generate a database connection request according to the master node identifier, and then send the database connection request to the proxy server. After receiving the database connection request sent by the terminal device, the proxy server can parse the master node identification of the distributed database from the database connection request.
Step S120: and searching the IP address and the network port corresponding to the master node identification.
It can be understood that, because the proxy server stores the correspondence between all node identifiers and the IP addresses (IP addresses) and the network ports (ports) in the configuration file or the cache database in advance, the proxy server can search the actual IP addresses and the network ports corresponding to the master node identifiers from the configuration file or the cache database. That is, there are many embodiments of searching for the actual IP address and network port corresponding to the master node identifier, and the actual IP address and network port may be searched from a configuration file, or may be searched from a cache database, and thus, the embodiment of step S120 will be described in detail below.
Step S130: and sending a database connection request to the distributed database according to the IP address and the network port.
The embodiment of step S130 described above is, for example: assuming that the actual IP address and network port corresponding to the master node identifier are 2.2.2.2 and 16000, the proxy server may send a database connection request to the distributed database according to 2.2.2.2 and 16000 through a transmission control protocol (Transmission Control Protocol, TCP) so that the distributed database generates and returns a database connection response according to the received database connection request.
Step S140: and receiving a database connection response sent by the distributed database.
The embodiment of step S140 described above is, for example: the distributed database may generate a database connection response from the received database connection request after the database connection request, and then send the database connection response to the proxy server through the TCP protocol. The proxy server can receive the database connection response sent by the distributed database through the TCP protocol, and send the database connection response to the terminal equipment through the TCP protocol.
In the implementation process of the scheme, the database connection request is sent to the distributed database by searching the IP address and the network port corresponding to the master node identifier, and then the database connection response sent by the distributed database is received, so that even if the master node needs to be reelected in the distributed database, the distributed database can be connected according to the newly-elected master node identifier, the equipment can continuously obtain the database connection response sent by the distributed database, and the stability of connecting the distributed database is effectively improved.
As an alternative implementation manner of the above proxy method, before acquiring the database connection request, the master node identifier of the distributed database may also be acquired from the Zookeeper server cluster, where this implementation manner may include:
step S101: and the proxy server receives master node identifiers returned by the Zookeeper server cluster, and the Zookeeper server cluster is operated with the distributed database.
Step S102: the proxy server sends the master node identification to the terminal device.
The embodiment of step S101 described above is, for example: the proxy server sends a node identification request to the Zookeeper server cluster, and then receives the master node identification returned by the Zookeeper server cluster in the distributed database. After receiving the master node identifier returned by the Zookeeper server cluster, the proxy server can also send the master node identifier to the terminal equipment, so that the terminal equipment generates the database connection request according to the master node identifier.
As an alternative embodiment of the above proxy method, the electronic device (e.g. proxy server) may further synchronize master node identification with the terminal device, and the embodiment may include:
step S111: and receiving a node identification request sent by the terminal equipment.
Step S112: and sending a node identification request to the Zookeeper server so as to enable the Zookeeper server cluster to return the master node identification in the distributed database.
The embodiments of the above steps S111 to S112 are, for example: the terminal equipment sends a node identification request to the proxy server so that the proxy server returns a master node identification in the distributed database. After receiving the node identification request sent by the terminal device, the proxy server may obtain the master node identification through the Zookeeper server cluster, for example: the proxy server may first send a node identification request to the Zookeeper server cluster, and then receive the master node identification returned by the Zookeeper server cluster in the distributed database.
Step S113: and receiving master node identifiers returned by the Zookeeper server cluster, wherein the Zookeeper server cluster is operated with the distributed database.
Alternatively, the proxy server may send other information about the master node to the terminal device, such as: node name and node description of master node, etc.
Step S114: and sending the master node identification to the terminal equipment.
The embodiments of the above steps S113 to S114 are, for example: before receiving the node identification request sent by the proxy server, the Zookeeper server cluster can acquire the master node identification in the distributed database according to the node identification request, and then sends the master node identification in the distributed database to the proxy server. After receiving the master node identifier sent by the Zookeeper server cluster, the proxy server can also send the master node identifier to the terminal equipment through a TCP protocol, so that the terminal equipment generates the database connection request according to the master node identifier.
Optionally, the proxy server may also periodically send a node identifier request to the Zookeeper server according to a preset frequency, so that the Zookeeper server cluster periodically returns a master node identifier in the distributed database, and after the proxy server finds that the master node identifier changes, the proxy server sends the changed master node identifier to the terminal device. Alternatively, the proxy server may also periodically send the master node identifier to the terminal device, so that the terminal device checks whether the master node identifier changes, and if the master node identifier changes, the distributed database may be reconnected according to the changed master node identifier.
In the implementation process of the scheme, the master node identification in the distributed database is returned by receiving the Zookeeper server cluster, and the master node identification is sent to the terminal equipment, so that even if the master node in the distributed database is reelected, the terminal equipment can be connected with the distributed database again according to the reelected master node identification, thereby enhancing the stability of connecting the distributed database.
As a first alternative implementation manner of the step S120, the distributed database may be an HBase database, but may be other distributed databases (for example, oceanBase, etc.); the above embodiment for searching the IP address and the network port corresponding to the master node identifier may include:
step S121: and searching the IP address and the network port corresponding to the master node identifier from the configuration file, wherein all node identifiers of the HBase database and the corresponding relation between each node identifier and the IP address and the network port are stored in the configuration file.
The configuration file refers to a file for configuring and storing all node identities of the HBase database, and the format of the configuration file may be a script object profile (JavaScript Object Notation, JSON) format or an extensible markup language (eXtensible Markup Language, XML) format.
The embodiment of step S121 described above is, for example: searching an IP address and a network port corresponding to a master node identifier from a configuration file of a big data security protection product by using an executable program compiled or interpreted by a preset programming language, wherein the programming language can be used, for example: C. c++, java, BASIC, javaScript, LISP, shell, perl, ruby, python, PHP, etc.
In the implementation process, the distributed database is connected through the actual IP address and the network port corresponding to the master node identifier searched from the configuration file, so that the terminal equipment can be connected with the distributed database without knowing the actual IP address and the network port corresponding to the actual master node identifier, the risk that the actual IP address and the network port corresponding to the actual master node identifier are leaked to an external network is effectively reduced, and the safety of the distributed database is improved.
As a second alternative implementation manner of the above step S120, the IP address and the network port corresponding to the master node identifier may be searched for from the cache database, and then the implementation manner of searching for the IP address and the network port corresponding to the master node identifier may include:
step S122: searching an IP address and a network port corresponding to the master node identifier from a cache database, wherein all node identifiers of the HBase database and the corresponding relation between each node identifier and the IP address and the network port are stored in the cache database.
The embodiment of step S122 described above is, for example: the executable program compiled or interpreted by using a preset programming language is used to search the cache database, such as Memcached and dis, for example, and the like, and programming languages, such as C, C ++, java, BASIC, javaScript, LISP, shell, perl, ruby, python, PHP, and the like, can be used to find the actual IP address and network port corresponding to the master node identifier.
As an alternative implementation manner of the above step S120, before searching the configuration file for the IP address and the network port corresponding to the master node identifier, the IP address and the network port may also be stored in the configuration file, where this implementation manner may include:
step S123: and acquiring all node identifiers and network ports of the HBase database.
It will be appreciated that the IP address corresponding to each node identifier may be predefined and configured in the cluster server by the developer, and the IP addresses and network ports corresponding to all node identifiers configured in the cluster server are stored in a configuration file or other Excel file of the proxy server.
Step S124: and storing all node identifiers of the HBase database, and IP addresses and network ports corresponding to each node identifier into a configuration file.
The embodiment of step S123 to step S124 described above is, for example: the Zookeeper server cluster may send all node identifiers and network ports of the HBase database to the proxy server through the TCP protocol, so that the proxy server obtains an IP address corresponding to each node identifier (e.g., a developer stores the node identifier and the IP address in an Excel file in advance, and may obtain the node identifier and the IP address from the Excel file), and then stores all node identifiers and the IP address and the network port corresponding to each node identifier in the configuration file or the cache database. The proxy server uses an executable program compiled or interpreted by a preset programming language to store all node identifiers of the HBase database, and IP addresses and network ports corresponding to each node identifier into a configuration file or a cache database; among these, programming languages such as C, C ++, java, BASIC, javaScript, LISP, shell, perl, ruby, python, and PHP, etc., may be used.
Please refer to fig. 3, which is a schematic flowchart of a database connection request of a proxy terminal device provided in an embodiment of the present application; as an alternative embodiment of the proxy method, the electronic device (e.g. proxy server) may further proxy the database connection request of the terminal device, where the embodiment may include:
step S210: the proxy server receives a database connection request sent by the terminal equipment, wherein the database connection request comprises master node identifiers of the distributed databases.
The embodiment of step S210 described above is, for example: the proxy server receives a database connection request sent by the terminal device through an HTTP protocol or an HTTPS protocol, and the database connection request can comprise master node identification of the distributed database.
Step S220: the proxy server searches the IP address and the network port corresponding to the master node identification.
Step S230: the proxy server sends a database connection request to the distributed database according to the IP address and the network port.
Step S240: the proxy server receives a database connection response sent by the distributed database.
The implementation principle and implementation of the above steps S220 to S240 are similar to those of the steps S120 to S140, and thus, the implementation principle and implementation thereof will not be described again, and reference may be made to the description of the steps S120 to S140.
Step S250: the proxy server sends a database connection response to the terminal device.
The embodiment of step S250 described above is, for example: the proxy server sends a database connection response to the terminal device through the HTTP protocol or the HTTPS protocol.
As an alternative embodiment of the above proxy method, after sending the database connection response to the terminal device, the operation request of the database of the terminal device may be further proxied, and the embodiment may include:
step S260: and the proxy server receives an operation request of the distributed database sent by the terminal equipment.
Step S270: the proxy server sends an operation request to the distributed database.
The embodiments of the above steps S260 to S270 are, for example: after receiving the response of successful database connection sent by the proxy server, the terminal device can send operation requests such as creating (create) table, deleting (drop) table or modifying (alter) table to the proxy server through the TCP protocol. After receiving the operation request of the distributed database sent by the terminal device through the TCP protocol, the proxy server may send an operation request such as create (create) table, delete (drop) table, or modify (alter) table to the distributed database through the TCP protocol.
Please refer to fig. 4, which illustrates a schematic structural diagram of a proxy device provided in an embodiment of the present application; the embodiment of the application provides a proxy device 300, which comprises:
the connection request obtaining module 310 is configured to obtain a database connection request, where the database connection request includes a master node identifier of the distributed database.
The address port searching module 320 is configured to search the IP address and the network port corresponding to the master node identifier.
The connection request sending module 330 is configured to send a database connection request to the distributed database according to the IP address and the network port.
The connection response receiving module 340 is configured to receive a database connection response sent by the distributed database.
Optionally, in an embodiment of the present application, the proxy device further includes:
the node identification receiving module is used for receiving master node identifications returned by the Zookeeper server cluster in the distributed database, and the distributed database is operated on the Zookeeper server cluster.
Optionally, in an embodiment of the present application, the proxy device further includes:
the identification request receiving module is used for receiving the node identification request sent by the terminal equipment.
The identification request sending module is used for sending a node identification request to the Zookeeper server so as to enable the Zookeeper server cluster to return a master node identification in the distributed database.
And the node identifier sending module is used for sending the master node identifier to the terminal equipment.
Optionally, in an embodiment of the present application, the distributed database includes an HBase database; an address port lookup module comprising:
the IP port searching sub-module is used for searching the IP address and the network port corresponding to the master node identifier from the configuration file, wherein all node identifiers of the HBase database and the corresponding relation between each node identifier and the IP address and the network port are stored in the configuration file.
Optionally, in an embodiment of the present application, the address port lookup module further includes:
and the IP port receiving sub-module is used for acquiring all node identifiers and network ports of the HBase database.
And the IP port storage sub-module is used for storing all the node identifiers of the HBase database, and the IP address and the network port corresponding to each node identifier into the configuration file.
Optionally, in an embodiment of the present application, the proxy device further includes:
and the connection request receiving module is used for receiving the database connection request sent by the terminal equipment.
And the connection response sending module is used for sending the database connection response to the terminal equipment.
Optionally, in an embodiment of the present application, the proxy device further includes:
and the operation request receiving module is used for receiving the operation request of the distributed database sent by the terminal equipment.
And the operation request sending module is used for sending the operation request to the distributed database.
It should be understood that the apparatus corresponds to the above proxy method embodiment, and is capable of executing the steps involved in the above method embodiment, and specific functions of the apparatus may be referred to the above description, and detailed descriptions thereof are omitted herein as appropriate. The device includes at least one software functional module that can be stored in memory in the form of software or firmware (firmware) or cured in an Operating System (OS) of the device.
Please refer to fig. 5, which illustrates a schematic structural diagram of an electronic device provided in an embodiment of the present application. An electronic device 400 provided in an embodiment of the present application includes: a processor 410 and a memory 420, the memory 420 storing machine-readable instructions executable by the processor 410, which when executed by the processor 410 perform the method as described above.
The present embodiment also provides a computer readable storage medium 430, the computer readable storage medium 430 having stored thereon a computer program which, when executed by the processor 410, performs the method as above. The computer-readable storage medium 430 may be implemented by any type or combination of volatile or nonvolatile Memory devices, such as static random access Memory (Static Random Access Memory, SRAM for short), electrically erasable programmable Read-Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM for short), erasable programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM for short), programmable Read-Only Memory (Programmable Read-Only Memory, PROM for short), read-Only Memory (ROM for short), magnetic Memory, flash Memory, magnetic disk, or optical disk.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described as different from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other. For the apparatus class embodiments, the description is relatively simple as it is substantially similar to the method embodiments, and reference is made to the description of the method embodiments for relevant points.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, of the flowcharts and block diagrams in the figures that illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
In addition, the functional modules of the embodiments in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part. Furthermore, in the description of the present specification, the descriptions of the terms "one embodiment," "some embodiments," "examples," "specific examples," "some examples," and the like, mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the embodiments of the present application. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
The foregoing description is merely an optional implementation of the embodiments of the present application, but the scope of the embodiments of the present application is not limited thereto, and any person skilled in the art may easily think about changes or substitutions within the technical scope of the embodiments of the present application, and the changes or substitutions should be covered in the scope of the embodiments of the present application.

Claims (10)

1. A proxy method, comprising:
acquiring a database connection request, wherein the database connection request comprises master node identifiers of a distributed database;
searching an IP address and a network port corresponding to the master node identifier;
sending the database connection request to the distributed database according to the IP address and the network port;
and receiving a database connection response sent by the distributed database.
2. The method of claim 1, further comprising, prior to the obtaining the database connection request:
and receiving a master node identifier returned by the Zookeeper server cluster, wherein the Zookeeper server cluster is operated with the distributed database.
3. The method of claim 2, further comprising, prior to the receiving Zookeeper server cluster returning master node identification in the distributed database:
receiving a node identification request sent by terminal equipment;
sending the node identification request to the Zookeeper server so as to enable the Zookeeper server cluster to return master node identification in the distributed database;
after the receiving Zookeeper server cluster returns the master node identification in the distributed database, the method further comprises:
and sending the master node identification to the terminal equipment.
4. The method of claim 1, wherein the distributed database comprises an HBase database; the searching the IP address and the network port corresponding to the master node identifier comprises the following steps:
and searching an IP address and a network port corresponding to the master node identifier from a configuration file, wherein all node identifiers of the HBase database and the corresponding relation between each node identifier and the IP address and the network port are stored in the configuration file.
5. The method of claim 4, further comprising, prior to said looking up the master node identification corresponding IP address and network port from the configuration file:
acquiring all node identifiers of the HBase database, and IP addresses and network ports corresponding to each node identifier;
and storing all node identifiers of the HBase database, and the IP address and the network port corresponding to each node identifier into the configuration file.
6. The method according to any one of claims 1-5, wherein the obtaining a database connection request comprises:
receiving a database connection request sent by terminal equipment;
after receiving the database connection response sent by the distributed database, the method further comprises the following steps:
and sending the database connection response to the terminal equipment.
7. The method of claim 6, further comprising, after said sending said database connection response to said terminal device:
receiving an operation request of the distributed database sent by the terminal equipment;
and sending the operation request to the distributed database.
8. A proxy device, comprising:
the connection request acquisition module is used for acquiring a database connection request, wherein the database connection request comprises master node identifiers of a distributed database;
the address port searching module is used for searching the IP address and the network port corresponding to the master node identifier;
a connection request sending module, configured to send the database connection request to the distributed database according to the IP address and the network port;
and the connection response receiving module is used for receiving the database connection response sent by the distributed database.
9. An electronic device, comprising: a processor and a memory storing machine-readable instructions executable by the processor to perform the method of any one of claims 1 to 7 when executed by the processor.
10. A computer-readable storage medium, characterized in that it has stored thereon a computer program which, when executed by a processor, performs the method according to any of claims 1 to 7.
CN202311723177.XA 2023-12-14 2023-12-14 Proxy method, proxy device, electronic equipment and storage medium Pending CN117729214A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311723177.XA CN117729214A (en) 2023-12-14 2023-12-14 Proxy method, proxy device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311723177.XA CN117729214A (en) 2023-12-14 2023-12-14 Proxy method, proxy device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117729214A true CN117729214A (en) 2024-03-19

Family

ID=90201030

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311723177.XA Pending CN117729214A (en) 2023-12-14 2023-12-14 Proxy method, proxy device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117729214A (en)

Similar Documents

Publication Publication Date Title
US11323316B2 (en) Device configuration method and apparatus that are based on network configuration protocol
CN111970315A (en) Method, device and system for pushing message
KR102513998B1 (en) Communication methods and devices, entities and computer readable storage media
CN107800565B (en) Inspection method, inspection device, inspection system, computer equipment and storage medium
CN111182089B (en) Container cluster system, method and device for accessing big data assembly and server
US20180343590A1 (en) Resource obtaining method and related device
US10200507B2 (en) Creation of a binding based on a description associated with a server
CN110413845B (en) Resource storage method and device based on Internet of things operating system
CN107172214B (en) Service node discovery method and device with load balancing function
CN111885216B (en) DNS query method, device, equipment and storage medium
CN112217856A (en) Address acquisition method, device, equipment and storage medium of application example
CN114327710B (en) Function management method, management device, terminal equipment and readable storage medium
US11108854B2 (en) Peer-to-peer network for internet of things resource allocation operation
CN113079098B (en) Method, device, equipment and computer readable medium for updating route
KR102285352B1 (en) PROXY, METHOD FOR INTERWORKING BETWEEN HETEROGENEOUS IoT DEVICE AND IoT FLATFORM AND SYSTEM THE PROXY
CN117729214A (en) Proxy method, proxy device, electronic equipment and storage medium
US20220263759A1 (en) Addressing method, addressing system, and addressing apparatus
US11924294B2 (en) Service request handling
CN112702441B (en) Container-based access data processing method, device, system and storage medium
CN112131263B (en) Software package acquisition method, system, device, electronic equipment and storage medium
CN113824785A (en) Resource downloading method, system and storage medium based on point-to-point network
US20150282121A1 (en) Local resource sharing method of machine to machine component and apparatus thereof
CN113542319A (en) Service providing entity change notification method, device and system used in Dubbo framework
CN114900519B (en) Capability calling method, capability calling device, storage medium and electronic equipment
CN114422477B (en) Domain name resolution method, device and storage medium based on edge cloud architecture

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination