《OpenStack实战指南》—— 2.1.3 计算节点的安装

    xiaoxiao2023-07-18  180

    本节书摘来自华章出版社《OpenStack实战指南》一 书中的第2章,第2.1节,作者:黄 凯 毛伟杰 顾骏杰 ,更多章节内容可以访问云栖社区“华章计算机”公众号查看。

    2.1.3 计算节点的安装

    计算节点主要负责运行虚拟机。在这个测试案例中,使用KVM作为底层的虚拟化技术,OpenStack采用libvirt库来管理KVM。网络使用Open vSwitch来和其他计算节点及网络节点通信。在计算节点上,需要安装以下几个部分:

    Open vSwitch neutron-plugin-openvswitch-agent nova-compute open-iscsi

    1.?系统环境准备操作系统仍旧使用Ubuntu 12.04 LTS。网络节点需要两个网口,分别连接network-2和network-3。1)网络IP设置如下:

    # cat /etc/network/interfaces # network-2 Management auto eth1 iface eth1 inet static address 10.80.80.12 netmask 255.255.255.0 # network-3 vm auto eth2 iface eth2 inet static address 10.10.50.2 network 255.255.255.0

    eth1在前面定义的network-2网络中。这个接入管理网络的网口主要负责和controller之间的组件通信,包括所有的数据库连接、RabbitMQ等。eth2在前面定义的network-3网络中。这个网络和所有计算节点连接,用于Open vSwitch的GRE隧道,使得虚拟机能和网络节点通信。重启网络,命令如下:

    # /etc/init.d/networking restart

    2)添加Havana的源,其代码如下:

    # apt-get install -y python-software-properties # add-apt-repository cloud-archive:havana # apt-get update -y # apt-get upgrade -y # apt-get dist-upgrade -y

    更新完系统之后,可以根据实际情况重启服务器。因为计算节点使用时是不需要公网连接的,也不应该有公网连接,只在安装更新软件时需要连接公共网络,所以可以先保证用户的一个网口可以从公网下载安装软件包,等安装完之后再恢复成内网。3)同步时间,代码如下:

    # apt-get install -y ntp # vi /etc/ntp.conf

    编辑ntp.conf,在控制节点的IP中加入下面一行,并且放在所有“server ntp服务器域名”的行之前,或者删除其他关于server ntp服务器的行。

    server 10.80.80.10

    重启NTP服务,代码如下:

    # service ntp restart

    2.?安装Open vSwitch和Neutron的plugin接下来安装Open vSwitch和Neutron的plugin,命令如下:

    # apt-get install -y openvswitch-switch openvswitch-datapath-dkms

    创建一个用于和内部虚拟机通信的虚拟网络交换机,命令如下:

    # ovs-vsctl add-br br-int # apt-get install -y neutron-plugin-openvswitch-agent

    修改配置文件,除了local_ip需要填入计算节点本机的network-3网络的IP之外基本上和网络节点的一样。其代码如下:

    # vi /etc/neutron/neutron.conf [DEFAULT] debug = True verbose = True rabbit_host = 10.80.80.10 # 如果修改过rabbit的guest密码,则一定要修改下面一行 rabbit_password = guest # vi /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini [OVS] tenant_network_type = gre enable_tunneling = True tunnel_type = gre tunnel_id_ranges = 1:1000 integration_bridge = br-int tunnel_bridge = br-tun local_ip = 10.10.50.2 [securitygroup] firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver [database] connection = mysql://neutronuser:openstack@10.80.80.10/neutron

    重启服务,命令如下:

    # service neutron-plugin-openvswitch-agent restart

    3.?安装KVM的虚拟机计算支持安装KVM的虚拟机计算支持命令如下:

    # apt-get install -y nova-compute-kvm

    编辑配置文件,加入认证,代码如下:

    # vi /etc/nova/api-paste.ini [filter:authtoken] paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory auth_host = 10.80.80.10 auth_port = 35357 auth_protocol = http admin_tenant_name = service admin_user = nova admin_password = openstack signing_dir = /var/lib/nova/keystone-signing auth_version = v2.0

    配置Nova文件,可以从控制节点把nova.conf文件的内容复制过来,然后进行修改,主要修改一些涉及IP的地方,其代码如下:

    # vi /etc/nova/nova.conf [DEFAULT] logdir=/var/log/nova state_path=/var/lib/nova lock_path=/run/lock/nova verbose=True debug=True api_paste_config=/etc/nova/api-paste.ini compute_scheduler_driver=nova.scheduler.simple.SimpleScheduler rabbit_host=10.80.80.10 rabbit_password=guest nova_url=http://10.80.80.10:8774/v1.1/ sql_connection=mysql://novauser:openstack@10.80.80.10/nova root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf enabled_apis=ec2,osapi_compute,metadata # Auth use_deprecated_auth=false auth_strategy=keystone # Imaging service glance_api_servers=10.80.80.10:9292 image_service=nova.image.glance.GlanceImageService # Vnc configuration novnc_enabled=true novncproxy_base_url=http://10.10.101.10:6080/vnc_auto.html novncproxy_port=6080 vncserver_proxyclient_address=10.80.80.12 vncserver_listen=10.80.80.12 # Network settings network_api_class=nova.network.neutronv2.api.API neutron_url=http://10.80.80.10:9696 neutron_auth_strategy=keystone neutron_admin_tenant_name=service neutron_admin_username=neutron neutron_admin_password=openstack neutron_admin_auth_url=http://10.80.80.10:35357/v2.0 libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver linuxnet_interface_driver=nova.network.linux_net.LinuxOVSInterfaceDriver #If you want Quantum + Nova Security groups firewall_driver=nova.virt.firewall.NoopFirewallDriver security_group_api=neutron #If you want Nova Security groups only, comment the two lines above and uncomment line -1-. #-1-firewall_driver=nova.virt.libvirt.firewall.IptablesFirewallDriver #Metadata service_neutron_metadata_proxy = True neutron_metadata_proxy_shared_secret = openstack # Compute # #compute_driver=libvirt.LibvirtDriver # Cinder # volume_api_class=nova.volume.cinder.API osapi_volume_listen_port=5900 # Quota # quota_cores=5 quota_floating_ip3=3 quota_gigabytes=20 quota_driver=nova.quota.DbQuotaDriver quota_instances=5 quota_key_pairs=2 quota_ram=51200 quota_volumes=2

    设置qemu的cgroup文件,代码如下:

    # vi /etc/libvirt/qemu.conf cgroup_device_acl = [ "/dev/null", "/dev/full", "/dev/zero", "/dev/random", "/dev/urandom", "/dev/ptmx", "/dev/kvm", "/dev/kqemu", "/dev/rtc","/dev/hpet", "/dev/vfio/vfio", "/dev/net/tun" ]

    重启libvirt服务和nova-compute服务,命令如下:

    # service libvirt-bin restart # service nova-compute restart
    最新回复(0)