CN112887322A - Redis-based IP resource management method and device - Google Patents

Redis-based IP resource management method and device Download PDF

Info

Publication number
CN112887322A
CN112887322A CN202110175706.1A CN202110175706A CN112887322A CN 112887322 A CN112887322 A CN 112887322A CN 202110175706 A CN202110175706 A CN 202110175706A CN 112887322 A CN112887322 A CN 112887322A
Authority
CN
China
Prior art keywords
redis
ips
resource management
difference
white list
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
CN202110175706.1A
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.)
Shanghai Yingfang Software Co ltd
Original Assignee
Shanghai Yingfang 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 Shanghai Yingfang Software Co ltd filed Critical Shanghai Yingfang Software Co ltd
Priority to CN202110175706.1A priority Critical patent/CN112887322A/en
Publication of CN112887322A publication Critical patent/CN112887322A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/02Network architectures or network communication protocols for network security for separating internal from external traffic, e.g. firewalls
    • H04L63/0227Filtering policies
    • H04L63/0236Filtering by address, protocol, port number or service, e.g. IP-address or URL
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/10Network architectures or network communication protocols for network security for controlling access to devices or network resources
    • H04L63/101Access control lists [ACL]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses an IP resource management method and a device based on Redis, wherein the method comprises the following steps: step S1, receiving an IP application request, wherein the IP application request comprises a target IP section and the required number; step S2, generating set data with the target IP section as key and the value as field range according to the IP application request; step S3, carrying out difference set calculation on the set data and the used IP set to obtain a difference set; and step S4, traversing the IP in the difference set, matching the IP with the white list, and returning the IP which is not used and is not in the white list according to the matching result.

Description

Redis-based IP resource management method and device
Technical Field
The invention relates to the technical field of computer data backup, in particular to an IP resource management method and device based on Redis.
Background
In order to meet the increasingly high traffic demand and perfect management of company server equipment resources, IP resource management needs to be performed on newly added equipment, when a docker container or a kvm virtual machine is newly built, the IP is often required to be distributed, and the key is to distinguish which IPs are available and which IPs are not distributable in a white list.
In the prior art, when an IP application is made, used IPs are taken from a database and then calculated in a program, but this method is not flexible enough, because the used IPs may be a single IP or a certain IP segment, and the access stored in the relational database needs to be processed. The IPs in the white list also need to be stored in a database, requiring two tables to be read at a time and more extra computations.
The Reids is a memory database supporting persistence, the Reids memory database is used for realizing the management system, and the Reids has the characteristics of single thread, high speed and the like, so that the Reids can meet the requirement of high concurrency distribution.
Disclosure of Invention
In order to overcome the defects in the prior art, the present invention provides a method and an apparatus for IP resource management based on Redis, so as to achieve the purpose of IP resource management based on Redis.
In order to achieve the above object, the present invention provides an IP resource management method based on Redis, comprising the following steps:
step S1, receiving an IP application request, wherein the IP application request comprises a target IP section and the required number;
step S2, generating set data with the target IP section as key and the value as field range according to the IP application request;
step S3, carrying out difference set calculation on the set data and the used IP set to obtain a difference set;
and step S4, traversing the IP in the difference set, matching the IP with the white list, and returning the IP which is not used and is not in the white list according to the matching result.
Preferably, in step S2, the generated set data is stored in a redis database and stored as a set data type.
Preferably, in step S3, the IPs in the set data are traversed and matched in the used IP set, if matching, the IP is considered as a used IP, and the used IP is removed, and finally all unused IPs are obtained as a difference set.
Preferably, the difference set is obtained by performing difference set calculation on the requested set and the used set by using diff operation.
Preferably, in step S4, the IP of the poor member is traversed, and the unused IP and the IP not in the white list are returned, and the IP is added to the used IP set.
In order to achieve the above object, the present invention further provides an IP resource management device based on Redis, including:
the IP application request receiving unit is used for receiving an IP application request, and the IP application request comprises a target IP section and the required number;
the set generation unit is used for generating set data with a target IP section as a key and a value as a field range according to the IP application request;
a difference set calculation unit, configured to perform difference set calculation on the set data and a used IP set to obtain a difference set;
and the white list filtering unit is used for traversing the IPs in the difference set, matching the IPs with the white list and returning the unused IPs which are not in the white list according to the matching result.
Preferably, the white list filtering unit traverses the IPs of the bad crowd, returns the IPs which have not been used and are not in the white list, and adds the IPs to the used IP set.
Preferably, the set generating unit stores the generated set data in a redis database and as a set data type.
Preferably, the difference set calculation unit performs traversal matching on the IPs in the set data one by one in the used IP set, and if the IPs are matched, the IP is considered to be a used IP, and the used IP is removed, and finally all unused IPs are obtained as the difference set.
Preferably, the difference set calculation unit performs difference set calculation on the requested set and the used set by using diff operation to obtain the difference set.
Compared with the prior art, the method and the device for managing the IP resources based on Redis generate the set data with the target IP section as the key and the value as the field range according to the received IP application request, then perform difference set calculation on the set data and the used IP set to obtain a difference set, traverse the IP in the difference set, match the IP with the white list, return the IP which is not used and is not in the white list according to the matching result, and achieve the purpose of managing the IP resources based on the Redis database.
Drawings
FIG. 1 is a flowchart illustrating steps of a Redis-based IP resource management method according to the present invention;
fig. 2 is a system architecture diagram of an IP resource management device based on Redis according to the present invention.
Detailed Description
Other advantages and capabilities of the present invention will be readily apparent to those skilled in the art from the present disclosure by describing the embodiments of the present invention with specific embodiments thereof in conjunction with the accompanying drawings. The invention is capable of other and different embodiments and its several details are capable of modification in various other respects, all without departing from the spirit and scope of the present invention.
Fig. 1 is a flowchart illustrating steps of an IP resource management method based on Redis according to the present invention. As shown in fig. 1, the IP resource management method based on Redis of the present invention includes the following steps:
step S1, receiving an IP application request, where the IP application request includes a target IP segment and a required number.
That is, when the user needs to apply for the IP, the IP application request is made with the target IP segment and the required number, such as the target IP fields 10.200.10.1-10.200.10.100, where the number of the IP is 10.
And step S2, generating the set data with the target IP section as key and the value as field range according to the IP application request.
In the embodiment of the present invention, assuming that the IP application request includes a target IP field of 10.200.10.1-10.200.10.100 and the number of IPs is 10, aggregate data of IP data in IP segments of 10.200.10.1-10.200.10.100 as keys and a value of 10.1-10.100 is generated according to the IP application request.
Preferably, in step S2, the generated set data is stored in a redis database and stored as a set data type.
And step S3, performing difference set calculation on the set data and the used IP set to obtain a difference set.
In the embodiment of the present invention, the set data is traversed and matched in the used IP set, if matching, the IP is considered to be a used IP, the used IP is removed, and finally all unused IPs are obtained as a difference set.
In step S3, a diff operation is used to perform a difference calculation between the requested set and the used set, for example, the set of the requested set data types stored in the redis database is 10.200.10.10-10.200.10.20, and the diff operation is used to perform a difference calculation between the set and the used set stored as the set data types in the redis database, and the result is an unused ip segment in the range.
And step S4, traversing the IPs in the difference set, matching the IPs with the white list, and returning unused IPs which are not in the white list according to a matching result.
Specifically, the IP of the bad crowd is traversed, and the IP that is unused and not in the white list is returned while being added to the set of used IPs.
Fig. 2 is a system architecture diagram of an IP resource management device based on Redis according to the present invention. As shown in fig. 2, an IP resource management device based on Redis in the present invention includes:
an IP application request receiving unit 201, configured to receive an IP application request, where the IP application request includes a target IP segment and a required number.
That is, when the user needs to apply for the IP, the IP application request is made according to the target IP segment and the required number, for example, the target IP field 10.200.10.1-10.200.10.100, the IP number is 10, and the IP application request receiving unit 201 receives the IP application request including the target IP segment and the required number.
And the set generating unit 202 is configured to generate set data with the target IP segment as a key and the value as a field range according to the IP application request.
In the embodiment of the present invention, assuming that the IP application request includes target IP fields of 10.200.10.1-10.200.10.100 and the number of IPs is 10, the set generation unit 202 generates set data with 10.200.10.1-10.200.10.100 as keys and a value of 10.1-10.100 according to the IP application request.
Preferably, the set generating unit 202 stores the generated set data into a redis database and as a set data type.
A difference set calculating unit 203, configured to perform difference set calculation on the set data and the used IP set to obtain a difference set.
In the embodiment of the present invention, the difference set calculation unit 203 traverses and matches the set data one by one in the used IP set, and if matching, the IP is considered to be a used IP, and the used IP is removed, and finally all unused IPs are obtained as the difference set.
Specifically, the difference set calculation unit 203 performs difference set calculation on the requested set and the already used set by using diff operation, for example, the requested set of set data types stored in the redis database is 10.200.10.10-10.200.10.20, and the difference set calculation is performed on the set and the already used set of set data types stored in the redis database by using diff operation, and the result is an unused ip segment in the range
And the white list filtering unit 204 is configured to traverse the IPs in the difference set, match the IPs with the white list, and return an unused IP that is not in the white list according to a matching result.
Specifically, the white list filtering unit 204 may traverse the IPs of the bad audience, return the IPs that have not been used and are not in the white list, and add the IPs to the set of used IPs.
Examples
In this embodiment, an IP resource management process based on Redis is as follows:
step 1, a user applies for IP sections and required number, such as: 10.200.10.1-10.200.10.100.
And 2, generating set data with keys of 10.200.10.1-10.200.10.100 and values of 10.1-10.100.
And 3, performing difference set calculation on the set and the used set (used is used ip).
And 4, traversing the IP in the difference set, checking whether the white-IP is true or not, for example, traversing the difference set, packaging the IP into the key of white-10.200.10.11 to check whether the key exists in the redis database white list or not on the assumption that 10.200.10.11 is obtained, and taking the next IP if the key exists.
And 5, returning the unused IP and the IP which is not in the white list, and adding the IP into the used set.
In this embodiment, white-list management of several unallocated IPs is set in the white-IP white list, for example, white-list management of string type of white-10.200.10.99 (that is, white-10.200.10.99 is used as key, and the value is true, meaning 10.200.10.99 is IP in the white list, and cannot be taken out.
And 7, utilizing the Redis set to store in the implementation process, and utilizing the output result of high-speed operation among sets.
The method is realized by using the reids memory database, and can meet the requirement of high concurrency distribution due to the characteristics of single thread high speed and the like of the reidis.
In summary, the method and the device for managing IP resources based on Redis in the present invention generate the set data with the target IP segment as key and the value as the field range according to the received IP application request, then perform the difference set calculation on the set data and the used IP set to obtain the difference set, traverse the IP in the difference set, match the IP with the white list, and return the unused IP that is not in the white list according to the matching result, thereby achieving the purpose of IP resource management based on the Redis database.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Modifications and variations can be made to the above-described embodiments by those skilled in the art without departing from the spirit and scope of the present invention. Therefore, the scope of the invention should be determined from the following claims.

Claims (10)

1. An IP resource management method based on Redis includes the following steps:
step S1, receiving an IP application request, wherein the IP application request comprises a target IP section and the required number;
step S2, generating set data with the target IP section as key and the value as field range according to the IP application request;
step S3, carrying out difference set calculation on the set data and the used IP set to obtain a difference set;
and step S4, traversing the IP in the difference set, matching the IP with the white list, and returning the IP which is not used and is not in the white list according to the matching result.
2. The Redis-based IP resource management method of claim 1, wherein: in step S2, the generated set data is stored in the redis database as a set data type.
3. A method for Redis-based IP resource management as claimed in claim 2, wherein: in step S3, the IPs in the set data are traversed and matched one by one in the used IP set, if matching, the IP is considered to be a used IP, and the used IP is removed, and finally all unused IPs are obtained as a difference set.
4. A method for Redis-based IP resource management according to claim 3, wherein: and performing difference set calculation on the set obtained by the request and the set used by the request by using diff operation to obtain the difference set.
5. The Redis-based IP resource management method of claim 4, wherein: in step S4, the IP of the poor member is traversed, and the unused IP and the IP not in the white list are returned, and the IP is added to the used IP set.
6. An IP resource management apparatus based on Redis, comprising:
the IP application request receiving unit is used for receiving an IP application request, and the IP application request comprises a target IP section and the required number;
the set generation unit is used for generating set data with a target IP section as a key and a value as a field range according to the IP application request;
a difference set calculation unit, configured to perform difference set calculation on the set data and a used IP set to obtain a difference set;
and the white list filtering unit is used for traversing the IPs in the difference set, matching the IPs with the white list and returning the unused IPs which are not in the white list according to the matching result.
7. The Redis-based IP resource management apparatus of claim 6, wherein the white list filtering unit traverses IPs of the bad leader, returns IPs that are unused and not in a white list, and adds the IPs to the used IP set.
8. A Redis-based IP resource management apparatus as claimed in claim 7, wherein: the set generating unit stores the generated set data in a redis database and stores as a set data type.
9. A Redis-based IP resource management apparatus as claimed in claim 8, wherein: and the difference set calculation unit is used for traversing and matching the IPs in the set data in the used IP set one by one, if the IP is matched with the used IP set, the used IP is removed, and finally all the unused IPs are obtained as the difference set.
10. A Redis-based IP resource management apparatus as claimed in claim 8, wherein: and the difference set calculation unit performs difference set calculation on the set obtained by the request and the set used by the request by using diff operation to obtain the difference set.
CN202110175706.1A 2021-02-07 2021-02-07 Redis-based IP resource management method and device Pending CN112887322A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110175706.1A CN112887322A (en) 2021-02-07 2021-02-07 Redis-based IP resource management method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110175706.1A CN112887322A (en) 2021-02-07 2021-02-07 Redis-based IP resource management method and device

Publications (1)

Publication Number Publication Date
CN112887322A true CN112887322A (en) 2021-06-01

Family

ID=76056215

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110175706.1A Pending CN112887322A (en) 2021-02-07 2021-02-07 Redis-based IP resource management method and device

Country Status (1)

Country Link
CN (1) CN112887322A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023221508A1 (en) * 2022-05-18 2023-11-23 天翼云科技有限公司 Floating ip allocation method and apparatus, and electronic device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160119278A1 (en) * 2014-10-27 2016-04-28 Aruba Networks Inc. Method to distribute a centralized service
CN110290228A (en) * 2019-06-03 2019-09-27 网宿科技股份有限公司 A kind of internet protocol address distribution method and device
US20200314058A1 (en) * 2019-04-01 2020-10-01 International Business Machines Corporation Automatic ip range selection
CN112187541A (en) * 2020-09-28 2021-01-05 杭州安恒信息技术股份有限公司 Virtual topology construction method, device and medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160119278A1 (en) * 2014-10-27 2016-04-28 Aruba Networks Inc. Method to distribute a centralized service
US20200314058A1 (en) * 2019-04-01 2020-10-01 International Business Machines Corporation Automatic ip range selection
CN110290228A (en) * 2019-06-03 2019-09-27 网宿科技股份有限公司 A kind of internet protocol address distribution method and device
CN112187541A (en) * 2020-09-28 2021-01-05 杭州安恒信息技术股份有限公司 Virtual topology construction method, device and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
马巾凌: "《PHP企业级应用》", 31 August 2020 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023221508A1 (en) * 2022-05-18 2023-11-23 天翼云科技有限公司 Floating ip allocation method and apparatus, and electronic device and storage medium

Similar Documents

Publication Publication Date Title
US20030055809A1 (en) Methods, systems, and articles of manufacture for efficient log record access
US8321873B2 (en) System and method for offline data generation for online system analysis
CN106886371B (en) Caching data processing method and device
CN111352902A (en) Log processing method and device, terminal equipment and storage medium
US20150081914A1 (en) Allocation of Resources Between Web Services in a Composite Service
US7774320B1 (en) Verifying integrity of file system data structures
US20040015976A1 (en) Optimized distributed resource management system with digital signature
CN110975293A (en) Method, device, server and medium for establishing resource reference relation table
CN115168341A (en) Service processing method, system, medium and equipment
CN111061740A (en) Data synchronization method, equipment and storage medium
CN113760847A (en) Log data processing method, device, equipment and storage medium
CN112307052A (en) Data management method, service system, terminal and storage medium
CN112887322A (en) Redis-based IP resource management method and device
CN107832446A (en) A kind of searching method and computing device of configuration item information
CN112685417B (en) Database operation method, system, device, server and storage medium
US11403273B1 (en) Optimizing hash table searching using bitmasks and linear probing
CN110109867A (en) Improve the method, apparatus and computer program product of on-line mode detection
CN113704245A (en) Database main key generation method, sub-table positioning method and device
CN105978744A (en) Resource allocation method, device and system
CN111858586A (en) Data processing method and device
CN104780235A (en) IP attribution inquiry method and device and server
CN106843971A (en) BIOS method for refreshing, server, BMC, medium and storage control
CN108306976B (en) SDN controller architecture used in cloud computing network virtualization
CN114840562B (en) Distributed caching method and device for business data, electronic equipment and storage medium
CN116069810A (en) Data query method and device and terminal equipment

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210601