OpenStack Add a new compute node

Source: Internet
Author: User
Tags python script scp command ssh access

Because the lab needs to add a compute node to the OpenStack cluster, the process of adding compute nodes is recorded here. The cluster is still using the FLATDHCP network approach.

The new node of the machine is still dual network card, here special attention, can not use an Ethernet card and a wireless card as a dual network card, because the wireless network card can not bridge to the bridge br100, or you will receive the following error: error:failed to add Interface: Can ' t add wlan0 to bridge br100:operation not supported.

The new node's system is Ubuntu 14.04. The operations here are done on the controller node and then communicate with each node in SSH or SCP. First, configure the network environment 1. Still use the way of the dual network card, the network using the NIC is eth1, intranet with eth0, LAN IP set to 10.0.0.31, the way I set up the network directly in the Ubuntu graphics operating interface to complete, will not repeat. 2. Increase the Compute2 IP address in the/etc/hosts file of the controller node and compute1 node; Compute2 in/etc/node The Hosts file adds the IP address of the controller node and the Compute1 node, as shown below.

127.0.0.1 localhost hjy-ms-7673
#127.0.1.1 hjy-ms-7673
10.0.0.11 Controller 10.0.0.31 compute1 10.0.0.32 Compute2
Note that 127.0.1.1 is commented, and then the network service is restarted to take effect. 3. Verify that the network environment is properly configured, by pinging the other nodes on each node, then ping www.baidu.com, if all can ping, indicating that the network environment has been configured correctly. 4. Note: here because to operate multiple machines, so you can install Openssh-server on each machine, so you can remotely access through SSH, the use of the following commands, of course, can also be configured to do without password ssh access.
sudo apt-get install openssh-server
ssh compute2
II. configuration of other environmentsHere, the main is to configure the NTP service, the database service. 1. Install the NTP service using the following command, then go to the/etc/ntp.conf file and add server controller, as shown in the following figure
Apt-get Install NTP
2. Install the database service components using the following command
sudo apt-get install Python-mysqldb
Third, the Configuration compute serviceUse the following Python script to configure the compute service, the meaning of the code, has been written in the previous blog, no longer repeat. Note To modify the IP, my environment under the COMPUTE2 node IP is 10.0.0.32.
Import OS import configparser os.system (' sudo apt-get install NOVA-COMPUTE-KVM ') Keystone_authtoken = {' Auth_uri ': ' http: controller:5000 ', ' auth_host ': ' Controller ', ' auth_port ': ' 35357 ', ' auth_protocol ': ' http ', ' admin_tenant_name ': ' Service ', ' Admin_user ': ' Nova ', ' Admin_password ': ' 123456 '} rabbit = {' rpc_backend ': ' Rabbit ', ' rabbit_host ': ' Controller ', ' Rabbit_password ': ' 123456 '} VNC = {' my_ip ': ' 10.0.0.32 ', ' vnc_enabled ': ' True ', ' vncserver_listen ': ' 0.0.0.0 ', ' vncserver_proxyclient_address ': ' 10.0.0.32 ', ' novncproxy_base_url ': ' Http://controller:6080/vnc_
auto.html '} config = Configparser.configparser () os.system (' CP/ETC/NOVA/NOVA.CONF/ETC/NOVA/NOVA.CONF.CP ') # Copy 
Print "Cp/etc/nova/nova.conf done!" With open ('/etc/nova/nova.conf ', ' RW ') as CFGFILE:CONFIG.READFP (cfgfile) config.set (' DEFAULT ', ' auth_strategy ', ' Keystone ') config.set (' DEFAULT ', ' glance_host ', ' controller ') sections = config.sections () If ' keystone_authtoken ' not In Sections:config.add_section (' Keystone_authtoKen ') If ' database ' not in sections:config.add_section (' database ') # Set [Database] Config.set (' database ', ' Connect Ion ', ' Mysql://nova:123456@controller/nova ') for (k,v) in Keystone_authtoken.iteritems (): Config.set (' Keystone_ Authtoken ', K, V) for (k,v) in Rabbit.iteritems (): Config.set (' DEFAULT ', K, V) for (k,v) in Vnc.iteritems (): CONFIG. Set (' DEFAULT ', K, v) config.write (open ('/etc/nova/nova.conf ', ' W ')) output = Os.popen ("Egrep-c ' (VMX|SVM) '/proc/cpuinf") O ") out = Output.readlines () Acc_value = Out[0].strip () print" The Acc_value is "+ Acc_value if (Acc_value < 1): OS. System (' CP/ETC/NOVA/NOVA-COMPUTE.CONF/ETC/NOVA/NOVA-COMPUTE.CONF.CP ') with open ('/etc/nova/nova-compute.conf ', ' RW ') as CFGFILE:CONFIG.READFP (cfgfile) sections = config.sections () If ' libvirt ' not in sections:config.add_sec tion (' Libvirt ') config.set (' Libvirt ', ' virt_type ', ' Qemu ') config.write (open ('/etc/nova/nova-compute.conf ', ' W ')) OS . System (' Rm/var/lib/nova/nova.sqlite ')
Os.system (' Service nova-compute restart ') 
After writing this script, you can use the SCP command to send this file to the Compute2 node, which commands the following to deliver the execution of this Python script.
Scp-r/home/hjy/work/openstack/config_compute_nod.py Openstack@compute2:/home/openstack/openstack_python/compute _service.py
iv. configuration of network servicesExecute the following Python script to install the Nova Network service. I will not repeat the details. Note that to modify the value of Public_interface and Flat_interface, this two values are external network network card, need to be based on specific circumstances, I use the eth1.
Import OS
import configparser

os.system (' sudo apt-get install nova-network nova-api-metadata ')

Net_set = { ' Network_api_class ': ' Nova.network.api.API ', ' Security_group_api ': ' Nova ', ' firewall_driver ': ' Nova.virt.libvirt.firewall.IptablesFirewallDriver ', ' network_manager ': ' Nova.network.manager.FlatDHCPManager ', ' Network_size ': ' 254 ', ' allow_same_net_traffic ': ' False ', ' multi_host ': ' true ', ' send_arp_for_ha ': ' true ', ' share_dhcp_ Address ': ' true ', ' force_dhcp_release ': ' true ', ' Flat_network_bridge ': ' br100 ', ' flat_interface ': ' eth1 ', ' public_ Interface ': ' eth1 '}

config = Configparser.configparser ()
CONFIG.READFP (open ('/etc/nova/nova.conf ', ' RW ')
for K,v in Net_set.iteritems ():
	config.set (' DEFAULT ', K, v)
config.write (open ('/etc/nova/nova.conf ', ' W '))

Os.system (' Service nova-network restart ')
os.system (' Service nova-api-metadata restart ')
v. Verify that the installation is successful1. Use the following command to see if the KVM is available and, if not available, enter the BIOS and turn on the CPU virtualization functionality. If the CPU does not support virtualization, then there is no way.
Kvm-ok

2. Log in Dashboard to see if the node is installed successfully. You can see the newly added node in the administrator interface of the dashboard page.
3. Install the image on the new node to see if it can be installed successfully. If all is normal, after the image is installed, you can see the results shown in the following figure, and in the example of the administrator navigation, you can see that the new Cirros3 I just built runs on our newly added openstack-1-0 host, which can be reached through the console.
The virtual machine can ping the external network, the extranet can ping the virtual machine, proving that the network is normal.


At this point, the new compute node of the work is completed, or relatively simple, can be used in lieu of a script to do most of the work manually. I also feel the loose coupling of the OpenStack.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.