CN103677961A - Method for setting host name of virtual machine - Google Patents

Method for setting host name of virtual machine Download PDF

Info

Publication number
CN103677961A
CN103677961A CN201310714340.6A CN201310714340A CN103677961A CN 103677961 A CN103677961 A CN 103677961A CN 201310714340 A CN201310714340 A CN 201310714340A CN 103677961 A CN103677961 A CN 103677961A
Authority
CN
China
Prior art keywords
host name
virtual machine
serial port
host
order
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
CN201310714340.6A
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.)
G Cloud Technology Co Ltd
Original Assignee
G Cloud 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 G Cloud Technology Co Ltd filed Critical G Cloud Technology Co Ltd
Priority to CN201310714340.6A priority Critical patent/CN103677961A/en
Publication of CN103677961A publication Critical patent/CN103677961A/en
Pending legal-status Critical Current

Links

Abstract

The method relates to the technical field of cloud computing, in particular to a method for setting the host name of a virtual machine. The method includes the steps that first, a virtual machine mirror image comprising one virtual serial port is made first, and a serial port service is made to operate in a default mode; then, the virtual machine is established on a host with the mirror image; the host sends a preset serial port command for setting the host name to the serial port of the virtual machine through a serial port tool; the specified virtual serial port is monitored and the received serial port command is analyzed through the serial port service of the virtual machine; if the analyzed host name is valid, the host name is set according to the information obtained through analysis by the serial port service of the virtual machine; if the analyzed command is incorrect or the host name is invalid, failure information is sent back to the host. Meanwhile, the host acquires the host name of the virtual machine outside the hypervisor through serial port communication. The method solves the problems that time is long and the success rate is low when the host name of the virtual machine is set and can be used for setting the host name of the virtual machine.

Description

A kind of method that virtual machine host name is set
Technical field
The present invention relates to cloud computing technology field, refer to especially a kind of method that virtual machine host name is set.
Background technology
Under cloud computing environment, a lot of application-dependent are distinguished the identity of fictitious host computer in host name rather than IP address, such as the communication between hadoop depends on the binding of host name and IP address, and owing to creating virtual machine in mirror image used host name be all provided, after virtual machine operation, the problem that there will be virtual hostname to bear the same name, this just need to re-start setting to virtual machine host name, at present, the host name of virtual machine is provided with to two kinds of ways:
The first is to obtain new host name by reinstalling the operating system of virtual machine, and this method can avoid network to bear the same name, but the time needing is long.
The second is by signing in to the remote desktop of virtual machine, the order of running specific operation system goes to arrange the host name of virtual machine, this method has following shortcoming: 1, can not carry out unified planning to the host name of all virtual machines in broadcast domain, when virtual machine quantity is larger, the host name of setting occurs that the probability of bearing the same name can increase greatly; 2, need user to grasp the collocation method of different operating system, this mode is disunity very, easily makes mistakes.
Therefore a kind of method that virtual machine host name is set that, needs fast and reliable.
Summary of the invention
The technical matters that the present invention solves is to provide a kind of method that virtual machine host name is set, and the solution traditional virtual machine host name method to set up time is long, the problem that success ratio is low.
The technical scheme that the present invention solves the problems of the technologies described above is:
Comprise the steps:
Step 1: make a virtual machine image that comprises a virtual serial port, and a serial ports service of acquiescence operation;
Step 2: utilize the virtual machine image that step 1 is made to create virtual machine on host;
Step 3: host utilizes serial ports instrument to send the predetermined host name serial port command that arranges to the serial ports of virtual machine;
Step 4: the virtual serial port of appointment is monitored in the serial ports service of virtual machine, resolves the serial port command receiving; If the host name parsing is effective, execution step 5; If the order parsing is incorrect or host name is invalid, upgrade unsuccessfully execution step 7;
Step 5: the information that the serial ports service of virtual machine obtains according to parsing arranges host name;
Step 6: if be correctly provided with host name, postback successful information to host;
Step 7: if host name setup failed postbacks failure information to host;
Step 8: the serial communication that passes through that host is real-time obtains the host name of virtual machine in hypervisor outside, to realize the effective monitoring of host to virtual machine host name.
Described serial ports refers to virtual serial port, does not have concrete equipment, shows as a device file on physical server, when sending order to virtual serial port, only need to write data to the device file of physical machine.
Described serial ports service provides two functions, the firstth, the monitor function of serial port command, the secondth, the parsing of serial port command and practical function;
Whether described serial port command monitor function refers to the specific serial ports of poll has data to send over, and has and receives;
Described serial port command is resolved and practical function refers to the order that serial port command is resolved to host name and generate the specific operation system of revising host name according to host name.
The order of the specific operation system of described modification host name, refers to the method for the operating system of modification host name different under Windows, RedHat Linux, Debian Linux;
The method of revising host name under described Windows is to carry out
wmic?computersystem?where?caption=″gcloud″call?rename?gcloud1
Host name before the modification that wherein gcloud is virtual machine, gcloud1 is amended host name;
The order of revising host name under described RehHat Linux is modification/etc/sysconfig/network file, then carries out hostname order;
The order of revising host name under described Debian Linux is modification/etc/hostname file, then carries out hostname order.
The described host name of obtaining virtual machine in hypervisor outside, refers to serial ports service and under Windows, calls and under ipconfig/all order or Linux, call the result that hostname order returns and turn back to hypervisor outside by serial ports.
Beneficial effect of the present invention has:
1, method of the present invention needs the time shorter.
2, the host name of the virtual machine in method energy unified planning broadcast domain of the present invention, the situation of avoiding appearance to bear the same name.
3, no matter which kind of operating system virtual machine is used, the mode that host name is set is consistent.
4, method of the present invention can monitor the attack of distorting virtual machine host name, improves the security of virtual machine.
Accompanying drawing explanation
Below in conjunction with accompanying drawing, the present invention is further described:
Accompanying drawing is the inventive method process flow diagram.
Embodiment
As shown in Figure 1, the present invention first makes a virtual machine image, comprises a virtual serial port above, and acquiescence operation serial ports service routine, and the virtual serial port that this process can define in libvirt.xml is realized, and is defined as follows:
Figure BDA0000443495310000042
Here defined a serial ports, port numbers is 0, and be mapped to physical machine /dev/pts/0 device file on;
The mode that serial port command monitor function in serial ports service starts with a service processes runs on the serial port command that virtual machine waits for that host transmits, and code is as follows:
Figure BDA0000443495310000051
More than define a listening function, utilized " while1 " endless loop to call the port port that recv_msg (port) monitors appointment.
The msg information that in serial ports service, serial port command is resolved and practical function receives according to serial port command monitor function, calls process_msg (msg) and carries out the parsing of msg message, and code is as follows:
Figure BDA0000443495310000052
Figure BDA0000443495310000061
Macro definition corresponding to FUNCTION in code represents related pattern in predefined serial port command, in serial ports service serial port command resolve and practical function successfully resolved after, the order of executive system.
Figure BDA0000443495310000062
Concrete call method is as follows:
(1) on host, revise windows virtual machine host name
#/usr/share/gTunnel/sendSerial.py--sport/dev/pts/1--cmd?string--msg′wmic?computersystem?where?caption=″gcloud′′call?rename?gcloud1′--proc?exec
# note: gcloud is the host name before the modification of virtual machine, and gcloud1 is amended host name, and other parameters do not need to change.
(2) on host, revise centos virtual machine host name
#/usr/share/gTunnel/sendSerial.py?--sport/dev/pts/1--cmd?string?--msg′echo?-ne″NETWORKING=yes\nHOSTNAME=gcloud1″>/etc/sysconfig/network;hostname?gcloud1′--proc?exec
# note: gcloud1 is the amended host name of virtual machine, and other parameters do not need to change.
(3) on host, revise ubuntu and debian virtual machine host name.
#/usr/share/gTunnel/sendSerial.py?--sport/dev/pts/7--cmd?string?--msg′echo?″ubuntu1″>/etc/hostname;hostname-F/etc/hostname′--proc?exec?。

Claims (7)

1. the method that virtual machine host name is set, is characterized in that: comprise the steps:
Step 1: make a virtual machine image that comprises a virtual serial port, and a serial ports service of acquiescence operation;
Step 2: utilize the virtual machine image that step 1 is made to create virtual machine on host;
Step 3: host utilizes serial ports instrument to send the predetermined host name serial port command that arranges to the serial ports of virtual machine;
Step 4: the virtual serial port of appointment is monitored in the serial ports service of virtual machine, resolves the serial port command receiving; If the host name parsing is effective, execution step 5; If the order parsing is incorrect or host name is invalid, upgrade unsuccessfully execution step 7;
Step 5: the information that the serial ports service of virtual machine obtains according to parsing arranges host name;
Step 6: if be correctly provided with host name, postback successful information to host;
Step 7: if host name setup failed postbacks failure information to host;
Step 8: the serial communication that passes through that host is real-time obtains the host name of virtual machine in hypervisor outside, to realize the effective monitoring of host to virtual machine host name.
2. the method that virtual machine host name is set according to claim 1, it is characterized in that: described serial ports refers to virtual serial port, do not have concrete equipment, on physical server, show as a device file, when sending order to virtual serial port, only need to write data to the device file of physical machine.
3. the method that virtual machine host name is set according to claim 1, is characterized in that: described serial ports service provides two functions, the firstth, the monitor function of serial port command, the secondth, the parsing of serial port command and practical function;
Whether described serial port command monitor function refers to the specific serial ports of poll has data to send over, and has and receives;
Described serial port command is resolved and practical function refers to the order that serial port command is resolved to host name and generate the specific operation system of revising host name according to host name.
4. the method that virtual machine host name is set according to claim 2, is characterized in that: described serial ports service provides two functions, the firstth, the monitor function of serial port command, the secondth, the parsing of serial port command and practical function;
Whether described serial port command monitor function refers to the specific serial ports of poll has data to send over, and has and receives;
Described serial port command is resolved and practical function refers to the order that serial port command is resolved to host name and generate the specific operation system of revising host name according to host name.
5. the method that virtual machine host name is set according to claim 3, it is characterized in that: the order of the specific operation system of described modification host name, refers to the method for the operating system of modification host name different under Windows, RedHat Linux, Debian Linux;
The method of revising host name under described Windows is to carry out
wmic?computersystem?where?caption=″gcloud″call?rename?gcloud1
Host name before the modification that wherein gcloud is virtual machine, gcloud1 is amended host name;
The order of revising host name under described RehHat Linux is modification/etc/sysconfig/network file, then carries out hostname order;
The order of revising host name under described Debian Linux is modification/etc/hostname file, then carries out hostname order.
6. the method that virtual machine host name is set according to claim 4, it is characterized in that: the order of the specific operation system of described modification host name, refers to the method for the operating system of modification host name different under Windows, RedHat Linux, Debian Linux;
The method of revising host name under described Windows is to carry out
wmic?computersystem?where?caption=″gcloud″call?rename?gcloud1
Host name before the modification that wherein gcloud is virtual machine, gcloud1 is amended host name;
The order of revising host name under described RehHat Linux is modification/etc/sysconfig/network file, then carries out hostname order;
The order of revising host name under described Debian Linux is modification/etc/hostname file, then carries out hostname order.
7. according to the method that virtual machine host name is set described in claim 1 to 6 any one, it is characterized in that: the described host name of obtaining virtual machine in hypervisor outside, refers to serial ports service and under Windows, call and under ipconfig/all order or Linux, call the result that hostname order returns and turn back to hypervisor outside by serial ports.
CN201310714340.6A 2013-12-20 2013-12-20 Method for setting host name of virtual machine Pending CN103677961A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310714340.6A CN103677961A (en) 2013-12-20 2013-12-20 Method for setting host name of virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310714340.6A CN103677961A (en) 2013-12-20 2013-12-20 Method for setting host name of virtual machine

Publications (1)

Publication Number Publication Date
CN103677961A true CN103677961A (en) 2014-03-26

Family

ID=50315618

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310714340.6A Pending CN103677961A (en) 2013-12-20 2013-12-20 Method for setting host name of virtual machine

Country Status (1)

Country Link
CN (1) CN103677961A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105373417A (en) * 2015-11-04 2016-03-02 浪潮(北京)电子信息产业有限公司 Method and system for virtual machine management in cloud computing
CN105426230A (en) * 2015-12-09 2016-03-23 湖南昇云科技有限公司 Method and system for automatically modifying computer names for system under KVM virtualization platform
CN105550567A (en) * 2015-12-09 2016-05-04 国云科技股份有限公司 USB device read-write authority management and control method of Windows virtual machine
US20200183948A1 (en) * 2018-12-07 2020-06-11 Capital One Services, Llc Provisioning compute and data resources within an elastic data warehouse system

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050076155A1 (en) * 2003-10-01 2005-04-07 Lowell David E. Runtime virtualization and devirtualization of I/O devices by a virtual machine monitor
CN101493781A (en) * 2008-01-24 2009-07-29 中国长城计算机深圳股份有限公司 Virtual machine system and start-up method thereof
CN101557420A (en) * 2009-03-31 2009-10-14 北京航空航天大学 Realization method of high-efficiency network communication of a virtual machine monitor
EP2178268A2 (en) * 2008-10-17 2010-04-21 Hitachi Ltd. Method and apparatus for resource provisioning
CN102110071A (en) * 2011-03-04 2011-06-29 浪潮(北京)电子信息产业有限公司 Virtual machine cluster system and implementation method thereof
CN102110009A (en) * 2009-12-28 2011-06-29 中国移动通信集团公司 Method for deploying application in virtual platform and virtual platform manager
CN102214118A (en) * 2010-04-08 2011-10-12 中国移动通信集团公司 Method, system and device for controlling virtual machine (VM)
CN102567075A (en) * 2011-12-05 2012-07-11 中标软件有限公司 Virtual machine context setting method in cloud computing environment
CN102662727A (en) * 2012-04-05 2012-09-12 北京天地云箱科技有限公司 Virtual machine creating method and virtual machine creating device
CN103441867A (en) * 2013-08-15 2013-12-11 国云科技股份有限公司 Method for updating internal network resource allocation of virtual machine

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050076155A1 (en) * 2003-10-01 2005-04-07 Lowell David E. Runtime virtualization and devirtualization of I/O devices by a virtual machine monitor
CN101493781A (en) * 2008-01-24 2009-07-29 中国长城计算机深圳股份有限公司 Virtual machine system and start-up method thereof
EP2178268A2 (en) * 2008-10-17 2010-04-21 Hitachi Ltd. Method and apparatus for resource provisioning
CN101557420A (en) * 2009-03-31 2009-10-14 北京航空航天大学 Realization method of high-efficiency network communication of a virtual machine monitor
CN102110009A (en) * 2009-12-28 2011-06-29 中国移动通信集团公司 Method for deploying application in virtual platform and virtual platform manager
CN102214118A (en) * 2010-04-08 2011-10-12 中国移动通信集团公司 Method, system and device for controlling virtual machine (VM)
CN102110071A (en) * 2011-03-04 2011-06-29 浪潮(北京)电子信息产业有限公司 Virtual machine cluster system and implementation method thereof
CN102567075A (en) * 2011-12-05 2012-07-11 中标软件有限公司 Virtual machine context setting method in cloud computing environment
CN102662727A (en) * 2012-04-05 2012-09-12 北京天地云箱科技有限公司 Virtual machine creating method and virtual machine creating device
CN103441867A (en) * 2013-08-15 2013-12-11 国云科技股份有限公司 Method for updating internal network resource allocation of virtual machine

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105373417A (en) * 2015-11-04 2016-03-02 浪潮(北京)电子信息产业有限公司 Method and system for virtual machine management in cloud computing
CN105426230A (en) * 2015-12-09 2016-03-23 湖南昇云科技有限公司 Method and system for automatically modifying computer names for system under KVM virtualization platform
CN105550567A (en) * 2015-12-09 2016-05-04 国云科技股份有限公司 USB device read-write authority management and control method of Windows virtual machine
US20200183948A1 (en) * 2018-12-07 2020-06-11 Capital One Services, Llc Provisioning compute and data resources within an elastic data warehouse system

Similar Documents

Publication Publication Date Title
CN103441867B (en) A kind of method updating virtual machine internal Network resource allocation
CN107493344B (en) Method and system for Web access to Docker container
US20180262388A1 (en) Remote device deployment
CN107864217B (en) Cloud desktop intelligent pushing system
CN103986786A (en) Remote cloud desktop operation system
CN107800743B (en) Cloud desktop system, cloud management system and related equipment
WO2021203979A1 (en) Operation and maintenance processing method and apparatus, and computer device
CN103347020B (en) A kind of system and method across application authorization access
CN112583815B (en) Operation instruction management method and device
CN103281331A (en) Method for enabling windows client to login remote server desktop
CN103677961A (en) Method for setting host name of virtual machine
CN105260377B (en) A kind of upgrade method and system based on classification storage
TW201339850A (en) Remote desktop management system and method
CN104461635A (en) System file installation method and equipment
CN105450748A (en) Remote desktop method for physical machine based on Openstack
CN105812413B (en) Communication method and device
KR102533536B1 (en) A method, an apparatus, an electronic device and a storage medium for communicating between private networks
CN103685536A (en) Monopolized type virtual desktop management method
CN105407150A (en) Remote control method of application program
CN104468493A (en) Method and system for logging into web page in network communication
CN108259477B (en) Network access control method and device based on SDN and computer equipment
WO2022121492A1 (en) File transmission method and apparatus, computer device, and storage medium
US20140122437A1 (en) Dynamically provisioned storage server operating on a data communications network
CN110022310B (en) Authorization method and device based on cloud computing open network operating system
CN114619462A (en) Remote desktop control method based on robot flow automation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
C10 Entry into 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: 20140326