CN113824749B - Port allocation method, system, device, equipment and storage medium - Google Patents

Port allocation method, system, device, equipment and storage medium Download PDF

Info

Publication number
CN113824749B
CN113824749B CN202010559221.8A CN202010559221A CN113824749B CN 113824749 B CN113824749 B CN 113824749B CN 202010559221 A CN202010559221 A CN 202010559221A CN 113824749 B CN113824749 B CN 113824749B
Authority
CN
China
Prior art keywords
service
port
port information
proxy
information
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.)
Active
Application number
CN202010559221.8A
Other languages
Chinese (zh)
Other versions
CN113824749A (en
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 Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology 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 Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202010559221.8A priority Critical patent/CN113824749B/en
Publication of CN113824749A publication Critical patent/CN113824749A/en
Application granted granted Critical
Publication of CN113824749B publication Critical patent/CN113824749B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention provides a port allocation method, a system, a device, equipment and a storage medium, which are applied to the field of cloud service, wherein proxy service obtains port information of a service system where the proxy service is located and reports the port information to management service; the method, the system, the device, the equipment and the storage medium for distributing the port can solve the problem that the proxy service cannot normally run because the port distributed to the proxy service is occupied.

Description

Port allocation method, system, device, equipment and storage medium
Technical Field
The present invention relates to the field of cloud services, and in particular, to a method, a system, an apparatus, a device, and a storage medium for port allocation.
Background
To implement load balancing, master-standby switching function in master-standby mode, etc., a proxy service may be used. The proxy service may provide services using a port in the service system, e.g., the proxy service may use the port to forward access requests sent by the user to the service node, etc. The service system where the proxy service is located may be a system that deploys a plurality of services including the proxy service.
The service system where the proxy service is located can also provide other services, and other services also need to use ports in the service system, so that the problem of unreasonable port allocation can exist, and service operation is affected.
Disclosure of Invention
The embodiment of the invention aims to provide a port allocation method, a system, a device, equipment and a storage medium, so as to solve the problem that proxy service cannot normally run because ports allocated to the proxy service are occupied. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a port allocation method, which is applied to proxy service, including:
acquiring port information of a service system where the proxy service is located;
and reporting the port information to a management service, so that the management service receives the port information and allocates an unoccupied port for the proxy service according to the port information.
Optionally, the acquiring port information of the service system where the proxy service is located includes:
and acquiring the port information of the service system where the proxy service is located through a preset system command.
Optionally, the acquiring port information of the service system where the proxy service is located includes:
Acquiring port information of a service system where the proxy service is located through a first thread;
the reporting the port information to the management service includes:
and reporting the port information to the management service through a second thread.
Optionally, the obtaining, by the first thread, port information of a service system where the proxy service is located includes:
acquiring the port information according to a first time interval through the first thread;
after the port information is acquired by the first thread according to the first time interval, the method further comprises:
the acquired port information is stored in a cache module;
the reporting, by the second thread, the port information to the management service includes:
and acquiring the port information from the cache module according to a second time interval by the second thread, and reporting the port information to the management service.
Optionally, before the reporting the port information to the management service, the method further includes:
adding configuration information in the proxy service, wherein the configuration information comprises a service address of the management service;
The reporting the port information to the management service includes:
and sending the port information to the service address.
In a second aspect, an embodiment of the present invention provides a port allocation method, applied to management service, including:
receiving port information of a service system where the proxy service is located, wherein the port information is reported by the proxy service;
and allocating unoccupied ports for the proxy service according to the port information.
Optionally, the port information includes occupation condition information of each port in the service system;
the allocating unoccupied ports for the proxy service according to the port information comprises the following steps:
obtaining unoccupied ports in the service system according to the occupation condition information of each port in the service system;
and selecting ports from the unoccupied ports according to a preset allocation strategy, and allocating the selected ports to the proxy service.
Optionally, the selecting a port from the unoccupied ports according to a preset allocation policy, and allocating the selected port to the proxy service includes:
selecting ports from the unoccupied ports according to the load condition of each machine in the service system and/or the ports designated by the user, and distributing the selected ports to the proxy service.
In a third aspect, an embodiment of the present invention provides a port allocation system, including:
proxy services and management services;
the proxy service acquires port information of a service system where the proxy service is located and reports the port information to the management service;
and the management service receives the port information and allocates unoccupied ports for the proxy service according to the port information.
Optionally, the proxy service includes a first thread and a second thread, where the first thread is used to obtain the port information; and the second thread is used for reporting the port information to the management service.
Optionally, the proxy service further includes: a cache module;
the first thread acquires the port information according to a first time interval and stores the acquired port information to the cache module;
and the second thread acquires the port information from the cache module according to a second time interval and reports the port information to the management service.
Optionally, the proxy service includes a proxy component Haproxy, neutron or nmginx.
In a fourth aspect, an embodiment of the present invention provides a port allocation apparatus, applied to a proxy service, including:
The acquisition module is used for acquiring port information of a service system where the proxy service is located;
and the reporting module is used for reporting the port information to the management service so that the management service receives the port information and allocates unoccupied ports for the proxy service according to the port information.
Optionally, the acquiring module is specifically configured to acquire, through a preset system command, the port information of a service system where the proxy service is located.
Optionally, the acquiring module is specifically configured to acquire, through a first thread, port information of a service system where the proxy service is located;
the reporting module is specifically configured to report the port information to the management service through a second thread.
Optionally, the acquiring module is specifically configured to acquire, by using the first thread, the port information according to a first time interval; after the port information is acquired by the first thread according to a first time interval, the acquired port information is stored in a cache module;
the reporting module is specifically configured to obtain, through the second thread, the port information from the cache module according to a second time interval, and report the port information to the management service.
Optionally, the apparatus further includes:
the configuration adding module is used for adding configuration information in the proxy service before the port information is reported to the management service, wherein the configuration information comprises a service address of the management service;
the reporting module is specifically configured to send the port information to the service address.
In a fifth aspect, an embodiment of the present invention provides a port allocation apparatus, applied to management service, including:
the receiving module is used for receiving port information of a service system where the proxy service is located, which is reported by the proxy service;
and the allocation module is used for allocating unoccupied ports for the proxy service according to the port information.
Optionally, the port information includes occupation condition information of each port in the system;
the distribution module is specifically configured to obtain an unoccupied port in the system according to the occupation condition information of each port in the system; and selecting ports from the unoccupied ports according to a preset allocation strategy, and allocating the selected ports to the proxy service.
In yet another aspect of the embodiments of the present invention, there is provided a port allocation apparatus including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
A memory for storing a computer program;
and a processor, configured to implement the method steps described in the first aspect when executing the program stored in the memory.
In yet another aspect of the embodiments of the present invention, there is provided a port allocation apparatus including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and a processor configured to implement the method steps described in the second aspect when executing the program stored in the memory.
In a further aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, which computer program, when being executed by a processor, carries out the method steps according to the first aspect.
In a further aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the method steps according to the second aspect.
Embodiments of the present invention also provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method steps of the first aspect described above.
Embodiments of the present invention also provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method steps of the second aspect described above.
The embodiment of the invention has the beneficial effects that:
in the port allocation method, the system, the device, the equipment and the storage medium provided by the embodiment of the invention, proxy service obtains port information of a service system where the proxy service is located and reports the port information to management service; the management service may assign the agent service with an unoccupied port based on the port information. Therefore, the occupied ports can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate due to the fact that the ports allocated to the proxy service are occupied can be solved.
Of course, it is not necessary for any one product or method of practicing the invention to achieve all of the advantages set forth above at the same time.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are necessary for the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention and that other embodiments may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic structural diagram of a port allocation system according to an embodiment of the present invention;
fig. 2 is a flow chart of a port allocation method applied to proxy service according to an embodiment of the present invention;
fig. 3 is a flow chart of a port allocation method applied to management service according to an embodiment of the present invention;
FIG. 4 is a flow chart of allocating ports according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a port allocation apparatus applied to proxy service according to an embodiment of the present invention;
fig. 6 is a schematic diagram of another structure of a port allocation apparatus applied to proxy service according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a port allocation device applied to management service according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a port allocation device for implementing a port allocation method applied to proxy service according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a port allocation device for implementing a port allocation method applied to management service according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
To avoid that ports allocated to the proxy service are occupied, the proxy service cannot operate normally. The ports of the service system where the proxy service is located can be monitored through a third party service independent of the proxy service, the obtained port information is sent to another service different from the proxy service and the third party service, and the other service allocates ports for the proxy service according to the port information.
However, this method requires a special third party service to monitor each port, and multiple services interact to implement the process of allocating ports, which makes the system structure complex, and thus the system maintenance complex.
The embodiment of the invention provides a port allocation method, a system, a device, equipment and a storage medium, which are used for solving the problem that proxy service cannot normally operate due to the fact that the port allocated to the proxy service is occupied. In the embodiment of the invention, the proxy service reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
An embodiment of the present invention provides a port allocation system, as shown in fig. 1, may include:
a proxy service 101 and a management service 102;
the proxy service 101 acquires port information of a service system where the proxy service 101 is located, and reports the port information to the management service 102;
the management service 102 receives the port information and allocates an unoccupied port to the proxy service 101 according to the port information.
In the embodiment of the invention, the proxy service 101 acquires port information of a service system where the proxy service 101 is located, and reports the port information to the management service 102; the management service 102 may assign the agent service 101 with unoccupied ports according to the port information. In this way, the occupied ports can be prevented from being allocated to the proxy service, and the problem that the proxy service 101 cannot normally operate due to the occupied ports allocated to the proxy service can be solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
The proxy service can monitor each port in the service system where the proxy service is located, and obtain the port information of each port. The port information is used for indicating the unoccupied port in the service system, namely, the management service can obtain the unoccupied port in the service system according to the port information and allocate the unoccupied port for the proxy service. For example, the port information may include information of an unoccupied port, and then the unoccupied port may be obtained according to the port information; or the port information may include the information of the occupied ports, the occupied ports are obtained according to the port information, and the occupied ports are removed from all ports in the service system, namely the unoccupied ports. In one implementation, the port information may include occupancy information, and the occupancy information for each port may include whether each port has been occupied or unoccupied. The agent service reports the port information to the management service, the management service can obtain the occupied port and the unoccupied port according to the occupation condition information of each port, and the unoccupied port can be allocated for the agent service according to the port information.
The allocation of ports for proxy services can be understood as follows: ports are allocated for clients accessing proxy services. If the proxy service receives an access request sent by the user terminal, port information can be sent to the management service to request the management service to allocate a port, and after the management service is a proxy service port, the proxy service can forward the access request sent by the user terminal to the service node by using the allocated port, and the service node processes the access request.
The service system in which the proxy service is located may be a system that deploys a plurality of services including the proxy service. The service system may include one machine or may include multiple machines deployed in a distributed manner. The machine may be an entity device, software, or the like. The ports of the service system may include ports of individual machines in the service system.
In the embodiment of the invention, the proxy service and the management service can be deployed on the same device in the service system. Alternatively, the proxy service and the management service may be deployed on different devices, e.g., the proxy service may be deployed on a proxy device and the management service may be deployed on a management device.
In an alternative embodiment, before the proxy service reports the port information to the management service, the method may further include:
Adding configuration information in the proxy service, wherein the configuration information comprises a service address of the management service; the port information is sent to the service address.
It is also understood that the proxy service registers the service address of the management service. The service address may be a network protocol (Internet Protocol, IP) address, port address, etc.
Specifically, configuration information "report_server_info= [ ]" may be added to the configuration of the proxy service, and the configuration information indicates a service address of the management service, that is, an address of the proxy service reporting port information.
Thus, the proxy service obtains the port information and can report the port information to the service address indicated by the configuration information.
Here, "ports= [ ]" or the like may be transmitted in json format, and port information of each port is represented.
In one implementation, the proxy service may also pre-configure a preset time interval for acquiring port information and a preset time interval for reporting port information, for example, add configuration information "report_interval" in the configuration of the proxy service to indicate the preset time interval.
In an alternative embodiment, the proxy service may include a first thread and a second thread, the first thread configured to obtain port information; the second thread is used for reporting port information to the management service.
The proxy service can acquire port information of a service system where the proxy service is located through a preset system command.
The first thread can scan each port in the system at regular time according to a preset time interval, and acquire port information of a service system where the proxy service is located through a preset system command.
For example, the command may be: netstat-tln |awk' BEGIN { count=0 } { ++count; if (count > 2) print $4}, obtain port information.
The second thread may also report port information to the management service at preset time intervals. The second thread may be synchronous or asynchronous with the first thread, e.g., the predetermined time interval used by the first thread may be the same as or different from the predetermined time interval used by the second thread.
In one implementation, the proxy service may further include: and a cache module.
The first thread acquires port information according to a first time interval and stores the acquired port information to the cache module;
and the second thread acquires port information from the cache module according to a second time interval and reports the port information to the management service.
The first time interval and the second time interval may be determined according to actual requirements, such as 5 seconds, 10 seconds, etc. In one implementation, the first time interval and the second time interval are different.
Therefore, the problem of coupling between the two threads can be solved through the cache module, decoupling of the first thread and the second thread is achieved, and port information can be obtained through an asynchronous thread mechanism.
In an alternative embodiment, the management service may select a port from the unoccupied ports according to a preset allocation policy, and allocate the selected port to the proxy service.
The preset allocation policy may include allocation according to occupancy of each machine port in the service system.
Specifically, according to the load condition of each machine in the service system and/or the ports designated by the user, the ports are selected from unoccupied ports, and the selected ports are allocated to the proxy service.
In one implementation, the preset allocation policy may include allocation according to load conditions of each machine in the service system in a load balancing manner.
In another implementation manner, multiple machines in the service system may each deploy a proxy service, for example, machine 1, machine 2, and machine 3 each deploy a proxy service, where machine 1, machine 2, and machine 3 are in a master-slave relationship, and as one machine is the master machine at a time, other slave machines are used as standby machines of the master machine to achieve high availability. The agent service of each machine in the system reports the port information obtained by monitoring to the management service, and the management service gathers the port information respectively reported by each agent service, for example, analyzes the port information reported by each agent service to obtain unoccupied ports indicated by each port information.
In another implementation, the preset allocation policy may further include allocating according to a user-specified port. The ports can be allocated in combination with the use of each port and user-specified ports. For example, if the port range specified by the user is 30000-50000, selecting a port within the range 30000-50000 from the unoccupied ports obtained according to the port information, and taking the port within the range as the port to be allocated to the proxy service.
In one implementation, the allocation can be performed according to the serial number sequence of the ports, and meanwhile, each allocation condition can be recorded, so that the allocation efficiency can be improved.
In another implementation, the port assignment may be combined with the load condition of each machine in the service system and the user-specified port assignment. For example, after unoccupied ports are selected in a load-balanced manner according to the load conditions of the respective machines, ports within a user-specified port range are selected from among the selected ports as ports allocated to proxy services, such as ports within the range 30000-50000.
In the distributed database, the service is deployed through the master-standby mode, and in the case of deploying the service through the master-standby mode, there is a need for a primary-standby switch, for example, a standby node switches to provide services for the primary node. In the process of realizing the active-standby switching, the active-standby switching can be realized by using the proxy service in a load balancing mode, so that a user can access the active node.
In particular, the proxy service may be implemented by proxy component Haproxy, neutron or nmginx. While Haproxy, neutron or nmginx have port occupancy problems. For example, if a port assigned to nmginx is occupied, the port is not valid and cannot be loaded normally; if the ports allocated to the Neutron are occupied, port conflicts are generated and error information is returned; if the ports assigned to the Haproxy are occupied, the Haproxy cannot be started, which affects load balancing in the service system where the Haproxy is located, and similarly, other proxy components have the same port occupation problem. Where a port is occupied may be understood as having been used by other services in the service system.
In order to avoid that the ports allocated to the proxy service in the distributed database are occupied, which causes that the proxy service cannot operate normally, affects system load balancing, etc., the proxy service in the embodiment of the invention may include Haproxy, neutron or nmginx, etc.
The port distribution system provided by the embodiment of the invention can be applied to a distributed database, and well operates in the distributed database.
In a specific embodiment, the proxy service is implemented by a proxy component Haproxy. The Haproxy acquires port information of each port in a service system where the Haproxy is located, such as occupation condition information of each port, and reports the port information to a management service, such as a network distribution service (trove-lb).
Specifically, configuration information report_server_info= [ ] is added in the Haproxy configuration to represent the service address to be reported by Haproxy, namely the service address of the management service trove-lb. It is also understood that Haproxy registers the service address of the management service.
Meanwhile, a preset time interval for acquiring port information and a preset time interval for reporting port information can be preset, for example, configuration information 'report_interval' is added in the configuration of Haproxy to represent the preset time interval. The preset time interval for acquiring the port information and the preset time interval for reporting the port information may be the same or different.
Two threads, thread 1 and thread 2, and a cache module cache may be initialized. Haproxy starts thread 1, acquires port information according to a first time interval through thread 1, and stores the acquired port information to a cache. Haproxy starts thread 2, obtains port information from the cache according to a second time interval through thread 2, and reports the port information to the trove-lb.
the control-lb receives port information reported by Haproxy; and assigning unoccupied ports to the Haproxy according to the port information.
Specifically, the trove-lb obtains unoccupied ports in the service system according to the occupation condition information of each port in the service system; selecting ports from unoccupied ports according to a preset allocation strategy, and allocating the selected ports to Haproxy. For example, trove-lb gathers port information reported by each Haproxy, for example, analyzes port information reported by each Haproxy to obtain unoccupied ports indicated by each port information.
In one approach, the assignment may be made in connection with a user-specified port. For example, if the range of the port specified by the user is 30000-50000, the Haproxy sends the scanned available port to the trove-lb, the trove-lb only selects the available port between 30000-50000 when allocated, if 30001 is already occupied, the user can allocate 30002 to the Haproxy, specifically, the user terminal accessing the Haproxy can be allocated, and meanwhile, the trove-lb can save the already allocated port in the loadbandwidth.
In addition, in order to improve the allocation efficiency, the allocation may be performed according to the serial number sequence of the ports, for example, the ports are selected from the unoccupied ports to perform the allocation in a sequential scanning manner, and meanwhile, the allocation condition of each time may also be recorded. For example, the current allocation port 30002 is recorded, and then the port may be selected from 30003 for allocation next time.
In this way, the Haproxy actively reports port information to the trove-lb, the port information can include the service condition of each port, an unoccupied port can be obtained according to the port information, and the port can be understood as an available port, so that the function of actively reporting the available port can be realized. the trove-lb allocates ports to the Haproxy according to the port information, namely allocates unoccupied ports to the Haproxy, so that the problem that the Haproxy cannot normally operate due to the fact that the occupied ports are allocated to the Haproxy can be solved.
Moreover, the Haproxy actively reports port information to the management service, and the ports do not need to be monitored by using a service independent of Haproxy and other third parties, so that the number of system components can be reduced, namely the complexity of a system structure can be reduced, the complexity of system maintenance can be further reduced, the cost of system maintenance, the difficulty of system development and the like are reduced, and the development and maintenance are facilitated.
The embodiment of the invention also provides a port allocation method applied to proxy service, which can comprise the following steps as shown in fig. 2:
s201, acquiring port information of a service system where a proxy service is located;
s202, reporting the port information to the management service, so that the management service receives the port information and allocates unoccupied ports for the proxy service according to the port information.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
Optionally, S201 may include:
and acquiring port information of a service system where the proxy service is located through a preset system command.
Optionally, S201 may include:
acquiring port information of a service system where the proxy service is located through a first thread;
s202 may include:
and reporting the port information to the management service through the second thread.
Optionally, the obtaining, by the first thread, port information of a service system where the proxy service is located may include: acquiring port information according to a first time interval through a first thread;
after the port information is acquired by the first thread according to the first time interval, the method further comprises:
the acquired port information is stored in a cache module;
reporting, by the second thread, the port information to the management service may include:
and acquiring port information from the cache module according to a second time interval through a second thread, and reporting the port information to the management service.
Optionally, before S202, the method may further include:
adding configuration information in the proxy service, wherein the configuration information comprises a service address of the management service;
s202 may include:
the port information is sent to the service address.
The method steps executed by the proxy service in the embodiment of the present invention are described in detail in the above embodiment of the port allocation system, and are not described herein again.
The embodiment of the invention also provides a port allocation method, which is applied to management service, and as shown in fig. 3, can include:
s301, receiving port information of a service system where the proxy service reported by the proxy service is located;
s302, the unoccupied ports are allocated for the proxy service according to the port information.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
Optionally, the port information includes occupation condition information of each port in the service system;
as shown in fig. 4, S302 may include:
s3021, obtaining unoccupied ports in a service system according to occupation condition information of all ports in the service system;
S3022, selecting ports from unoccupied ports according to a preset allocation strategy, and allocating the selected ports to proxy services.
The method steps executed by the management service in the embodiment of the present invention are described in detail in the above embodiment of the port allocation system, and are not described herein again.
Corresponding to the port allocation method applied to the proxy service provided in the above embodiment, the embodiment of the present invention provides a port allocation device applied to the proxy service, as shown in fig. 5, which may include:
an obtaining module 501, configured to obtain port information of a service system where a proxy service is located;
and the reporting module 502 is configured to report the port information to the management service, so that the management service receives the port information, and allocate an unoccupied port to the proxy service according to the port information.
Optionally, the acquiring module 501 is specifically configured to acquire, through a preset system command, port information of a service system where the proxy service is located.
The obtaining module 501 is specifically configured to obtain, through a first thread, port information of a service system where a proxy service is located;
the reporting module 502 is specifically configured to report the port information to the management service through the second thread.
Optionally, the acquiring module 501 is specifically configured to acquire, by using a first thread, port information according to a first time interval; after the port information is acquired according to a first time interval through a first thread, the acquired port information is stored in a cache module;
the reporting module 502 is specifically configured to obtain, through the second thread, port information from the cache module according to a second time interval, and report the port information to the management service.
Optionally, as shown in fig. 6, the apparatus further includes:
an adding configuration module 503, configured to add configuration information in the proxy service before reporting the port information to the management service, where the configuration information includes a service address of the management service;
the reporting module 502 is specifically configured to send the port information to the service address.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
Corresponding to the port allocation method applied to the management service provided in the above embodiment, the embodiment of the present invention provides a port allocation device applied to the management service, as shown in fig. 7, which may include:
the receiving module 701 is configured to receive port information of a service system where a proxy service reported by the proxy service is located;
an allocation module 702, configured to allocate unoccupied ports for proxy services according to the port information.
Optionally, the port information includes occupation condition information of each port in the service system;
the allocation module 702 is specifically configured to obtain an unoccupied port in the service system according to occupancy information of each port in the service system; and selecting ports from unoccupied ports according to a preset allocation strategy, and allocating the selected ports to proxy services.
Optionally, the allocation module 702 is specifically configured to select a port from the unoccupied ports according to the load condition of each machine in the service system and/or the user-specified port, and allocate the selected port to the proxy service.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
Corresponding to the port allocation method applied to proxy service provided in the above embodiment, the embodiment of the present invention provides a port allocation device, as shown in fig. 8, including a processor 801, a communication interface 802, a memory 803, and a communication bus 804, where the processor 801, the communication interface 802, and the memory 803 complete communication with each other through the communication bus 804.
A memory 803 for storing a computer program;
the processor 801 is configured to implement the method steps of the port allocation method applied to the proxy service when executing the program stored in the memory 803.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
Corresponding to the port allocation method applied to the management service provided in the above embodiment, the embodiment of the present invention provides a port allocation device, as shown in fig. 9, including a processor 901, a communication interface 902, a memory 903, and a communication bus 904, where the processor 901, the communication interface 902, and the memory 903 complete communication with each other through the communication bus 904.
A memory 903 for storing a computer program;
the processor 901 is configured to implement the method steps of the port allocation method applied to the management service when executing the program stored in the memory 903.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
The communication bus mentioned by the above-mentioned port assignment device may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the port allocation device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, where a computer program is stored, and the computer program, when executed by a processor, implements the method steps of the port allocation method applied to a proxy service.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
In yet another embodiment of the present invention, a computer readable storage medium is provided, in which a computer program is stored, where the computer program, when executed by a processor, implements the method steps of the port allocation method applied to management services described above.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
In yet another embodiment of the present invention, a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method steps of the port allocation method described above for proxy services is also provided.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
In yet another embodiment of the present invention, a computer program product containing instructions is also provided, which when run on a computer, causes the computer to perform the method steps of the port allocation method for managing services described above.
In the embodiment of the invention, the proxy service reports the port information to the management service, and the management service can allocate the unoccupied port to the proxy service according to the port information, so that the occupied port can be prevented from being allocated to the proxy service, and the problem that the proxy service cannot normally operate because the port allocated to the proxy service is occupied is solved.
In the embodiment of the invention, the proxy service actively reports the port information to the management service, and a third party service independent of the proxy service is not required to monitor each port, so that the complexity of a system structure can be reduced, and further the complexity of system maintenance, the cost of system maintenance, the difficulty of system development and the like can be reduced.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the method, apparatus, port assignment device, computer readable storage medium, and computer program product embodiments, the description is relatively simple as it is substantially similar to the system embodiments, with reference to portions of the system embodiments being relevant.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (22)

1. A port allocation method, applied to a proxy service, comprising:
acquiring port information of a service system where the proxy service is located;
adding configuration information in the proxy service, wherein the configuration information comprises a service address of a management service;
and sending the port information to the service address so that the management service receives the port information and allocates an unoccupied port for the proxy service according to the port information.
2. The method of claim 1, wherein the obtaining port information of the service system in which the proxy service is located comprises:
and acquiring the port information of the service system where the proxy service is located through a preset system command.
3. The method of claim 1, wherein the obtaining port information of the service system in which the proxy service is located comprises:
acquiring port information of a service system where the proxy service is located through a first thread;
The reporting the port information to the management service includes:
and reporting the port information to the management service through a second thread.
4. The method of claim 3, wherein the obtaining, by the first thread, port information of a service system in which the proxy service is located, includes:
acquiring the port information according to a first time interval through the first thread;
after the port information is acquired by the first thread according to the first time interval, the method further comprises:
the acquired port information is stored in a cache module;
the reporting, by the second thread, the port information to the management service includes:
and acquiring the port information from the cache module according to a second time interval by the second thread, and reporting the port information to the management service.
5. A port allocation method, applied to a management service, comprising:
receiving port information of a service system where the proxy service is located, wherein the port information is sent by a service address of a management service included in configuration information after the configuration information is added to the proxy service;
And allocating unoccupied ports for the proxy service according to the port information.
6. The method of claim 5, wherein the port information comprises occupancy information for each port in the service system;
the allocating unoccupied ports for the proxy service according to the port information comprises the following steps:
obtaining unoccupied ports in the service system according to the occupation condition information of each port in the service system;
and selecting ports from the unoccupied ports according to a preset allocation strategy, and allocating the selected ports to the proxy service.
7. The method of claim 6, wherein selecting a port from the unoccupied ports according to a preset allocation policy and allocating the selected port to the proxy service comprises:
selecting ports from the unoccupied ports according to the load condition of each machine in the service system and/or the ports designated by the user, and distributing the selected ports to the proxy service.
8. A port assignment system, comprising:
proxy services and management services;
the proxy service acquires port information of a service system where the proxy service is located, and adds configuration information in the proxy service, wherein the configuration information comprises a service address of the management service;
The proxy service sends the port information to the service address;
and the management service receives the port information through the service address and allocates unoccupied ports for the proxy service according to the port information.
9. The system of claim 8, wherein the proxy service comprises a first thread and a second thread, the first thread to obtain the port information; and the second thread is used for reporting the port information to the management service.
10. The system of claim 9, wherein the proxy service further comprises: a cache module;
the first thread acquires the port information according to a first time interval and stores the acquired port information to the cache module;
and the second thread acquires the port information from the cache module according to a second time interval and reports the port information to the management service.
11. The system of any of claims 8 to 10, wherein the proxy service comprises a proxy component Haproxy, neutron or nginnx.
12. A port assignment device, for use in a proxy service, comprising:
The acquisition module is used for acquiring port information of a service system where the proxy service is located;
an addition configuration module for adding configuration information in the proxy service, wherein the configuration information comprises a service address of a management service;
and the reporting module is used for sending the port information to the service address so that the management service receives the port information and allocates an unoccupied port for the proxy service according to the port information.
13. The apparatus of claim 12, wherein the obtaining module is specifically configured to obtain, through a preset system command, the port information of a service system where the proxy service is located.
14. The apparatus of claim 12, wherein the obtaining module is specifically configured to obtain, by the first thread, port information of a service system in which the proxy service is located;
the reporting module is specifically configured to report the port information to the management service through a second thread.
15. The apparatus of claim 14, wherein the obtaining module is specifically configured to obtain, by the first thread, the port information at a first time interval; after the port information is acquired by the first thread according to a first time interval, the acquired port information is stored in a cache module;
The reporting module is specifically configured to obtain, through the second thread, the port information from the cache module according to a second time interval, and report the port information to the management service.
16. A port allocation apparatus for use in managing services, comprising:
the receiving module is used for receiving port information of a service system where the proxy service is located, which is reported by the proxy service, wherein the port information is sent by a service address of a management service included in the configuration information after the configuration information is added to the proxy service;
and the allocation module is used for allocating unoccupied ports for the proxy service according to the port information.
17. The apparatus of claim 16, wherein the port information comprises occupancy information for each port in the service system;
the distribution module is specifically configured to obtain an unoccupied port in the service system according to occupancy information of each port in the service system; and selecting ports from the unoccupied ports according to a preset allocation strategy, and allocating the selected ports to the proxy service.
18. The apparatus according to claim 17, wherein the allocation module is configured to select a port from the unoccupied ports according to a load condition of each machine in the service system and/or a user-specified port, and to allocate the selected port to the proxy service.
19. The port distribution equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-4 when executing a program stored on a memory.
20. The port distribution equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 5-7 when executing a program stored on a memory.
21. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-4.
22. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 5-7.
CN202010559221.8A 2020-06-18 2020-06-18 Port allocation method, system, device, equipment and storage medium Active CN113824749B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010559221.8A CN113824749B (en) 2020-06-18 2020-06-18 Port allocation method, system, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010559221.8A CN113824749B (en) 2020-06-18 2020-06-18 Port allocation method, system, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113824749A CN113824749A (en) 2021-12-21
CN113824749B true CN113824749B (en) 2023-06-02

Family

ID=78911813

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010559221.8A Active CN113824749B (en) 2020-06-18 2020-06-18 Port allocation method, system, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113824749B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108600282A (en) * 2017-11-30 2018-09-28 深圳市牛鼎丰科技有限公司 Micro services dissemination method, device, storage medium and computer equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102065085A (en) * 2010-12-15 2011-05-18 广东威创视讯科技股份有限公司 Processing system, device and method for simultaneously controlling and processing multiple equipments
US9253125B2 (en) * 2013-06-06 2016-02-02 International Business Machines Corporation Managing a messaging state across multiple clients
CN104424157A (en) * 2013-08-24 2015-03-18 镇江金钛软件有限公司 Service construction method
US10193750B2 (en) * 2016-09-07 2019-01-29 Cisco Technology, Inc. Managing virtual port channel switch peers from software-defined network controller

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108600282A (en) * 2017-11-30 2018-09-28 深圳市牛鼎丰科技有限公司 Micro services dissemination method, device, storage medium and computer equipment

Also Published As

Publication number Publication date
CN113824749A (en) 2021-12-21

Similar Documents

Publication Publication Date Title
US7523178B2 (en) Tolerating failure of traffic management systems
CN110896355B (en) Network slice selection method and device
US8031625B2 (en) Automatic configuration of network for monitoring
CN109995641B (en) Information processing method, computing node and storage medium
CN112333249B (en) Business service system and method
US20100077250A1 (en) Virtualization based high availability cluster system and method for managing failure in virtualization based high availability cluster system
CN109921925B (en) Dial testing method and device
CN109558446B (en) Job request method, job request device, electronic equipment and storage medium
US9071612B2 (en) Service providing system
CN101132373A (en) Method of providing qos for a flow
US20190056975A1 (en) Virtualized network function manager determining method and network functions virtualization orchestrator
CN110971480B (en) Computer network condition monitoring method and device, computer equipment and storage medium
EP3806395A1 (en) Virtual network function (vnf) deployment method and apparatus
CN113326100B (en) Cluster management method, device, equipment and computer storage medium
US20240118935A1 (en) Pod deployment method and apparatus
WO2022007908A1 (en) Method for service collaboration between network element devices, and network element device
CN113824749B (en) Port allocation method, system, device, equipment and storage medium
CN105493444A (en) Fault management apparatus, device and method for network function virtualization (nfv)
CN115705198A (en) Node for operating a group of containers, system and method for managing a group of containers
CN113886058A (en) Cross-cluster resource scheduling method and device
CN113157441B (en) Distributed decentralized load balancing method and system
CN113055461A (en) ZooKeeper-based unmanned cluster distributed cooperative command control method
CN107615872A (en) A kind of method, apparatus and system for discharging connection
CN112087336B (en) Deployment and management method and device of virtual IP service system and electronic equipment
CN113645478B (en) Live broadcast push address allocation method and system

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
GR01 Patent grant
GR01 Patent grant