企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
在计算节点上,使用到的虚拟化技术是KVM,用到的驱动是libvirt驱动。Nova-compute主要为常见实例做一系列准备,另外定时向控制节点报道计算节点的资源状态,使得控制节点上的 nova-scheduler计划在那个计算节点上启动实例。 在computer1、2节点安装相关依赖包 ``` yum install openstack-selinux python-openstackclient yum-plugin-priorities openstack-nova-compute openstack-utils ntpdate -y ``` 1)在computer1、2节点配置nova.conf ``` cp /etc/nova/nova.conf /etc/nova/nova.conf.bak >/etc/nova/nova.conf openstack-config --set /etc/nova/nova.conf DEFAULT debug False openstack-config --set /etc/nova/nova.conf DEFAULT verbose True openstack-config --set /etc/nova/nova.conf DEFAULT force_raw_images True openstack-config --set /etc/nova/nova.conf DEFAULT remove_unused_original_minimum_age_seconds 86400 openstack-config --set /etc/nova/nova.conf DEFAULT image_service nova.image.glance.GlanceImageService openstack-config --set /etc/nova/nova.conf DEFAULT use_cow_images True openstack-config --set /etc/nova/nova.conf DEFAULT heal_instance_info_cache_interval 60 openstack-config --set /etc/nova/nova.conf DEFAULT notify_on_state_change vm_and_task_state openstack-config --set /etc/nova/nova.conf DEFAULT rootwrap_config /etc/nova/rootwrap.conf openstack-config --set /etc/nova/nova.conf DEFAULT allow_resize_to_same_host True openstack-config --set /etc/nova/nova.conf DEFAULT connection_type libvirt openstack-config --set /etc/nova/nova.conf DEFAULT instance_usage_audit True openstack-config --set /etc/nova/nova.conf DEFAULT instance_usage_audit_period hour openstack-config --set /etc/nova/nova.conf DEFAULT rpc_backend rabbit openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 10.1.1.153 openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron True openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver openstack-config --set /etc/nova/nova.conf DEFAULT vif_plugging_is_fatal False openstack-config --set /etc/nova/nova.conf DEFAULT vif_plugging_timeout 30 openstack-config --set /etc/nova/nova.conf DEFAULT resume_guests_state_on_host_boot True openstack-config --set /etc/nova/nova.conf DEFAULT api_rate_limit False openstack-config --set /etc/nova/nova.conf DEFAULT block_device_allocate_retries_interval 3 openstack-config --set /etc/nova/nova.conf DEFAULT network_device_mtu 1500 openstack-config --set /etc/nova/nova.conf DEFAULT report_interval 60 openstack-config --set /etc/nova/nova.conf DEFAULT remove_unused_base_images False openstack-config --set /etc/nova/nova.conf DEFAULT reserved_host_memory_mb 512 openstack-config --set /etc/nova/nova.conf DEFAULT service_down_time 180 openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_hosts controller1:5672,controller2:5672,controller3:5672 openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_userid openstack openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_password yjscloud openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_use_ssl False openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_ha_queues True openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_retry_interval 1 openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_retry_backoff 2 openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_max_retries 0 openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit amqp_durable_queues False openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://yjscloud.com:5000 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://yjscloud.com:35357 openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers controller1:11211,controller2:11211,controller3:11211 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name default openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name default openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova openstack-config --set /etc/nova/nova.conf keystone_authtoken password yjscloud openstack-config --set /etc/nova/nova.conf vnc enabled True openstack-config --set /etc/nova/nova.conf vnc keymap en-us openstack-config --set /etc/nova/nova.conf vnc vncserver_listen 0.0.0.0 openstack-config --set /etc/nova/nova.conf vnc vncserver_proxyclient_address 10.1.1.153 openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url http://192.168.0.168:6080/vnc_auto.html openstack-config --set /etc/nova/nova.conf glance api_servers http://yjscloud.com:9292 openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp openstack-config --set /etc/nova/nova.conf libvirt virt_type qemu openstack-config --set /etc/nova/nova.conf libvirt cpu_mode host-model openstack-config --set /etc/nova/nova.conf libvirt block_migration_flag VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_NON_SHARED_INC openstack-config --set /etc/nova/nova.conf libvirt live_migration_flag VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST openstack-config --set /etc/nova/nova.conf neutron url http://yjscloud.com:9696 openstack-config --set /etc/nova/nova.conf neutron auth_url http://yjscloud.com:35357 openstack-config --set /etc/nova/nova.conf neutron auth_type password openstack-config --set /etc/nova/nova.conf neutron project_domain_name default openstack-config --set /etc/nova/nova.conf neutron user_domain_name default openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne openstack-config --set /etc/nova/nova.conf neutron project_name service openstack-config --set /etc/nova/nova.conf neutron username neutron openstack-config --set /etc/nova/nova.conf neutron password yjscloud openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne ``` ``` scp -p /etc/nova/nova.conf compute2:/etc/nova/nova.conf ``` **注意更改ip** **注意!如果是在物理机上virt_type请改成kvm!** **在线热迁移: 源和目标节点的cpu类型要一致 源和目标节点的Libvirt版本要一致 源和目标节点能互相识别对方主机名称,比如可以在/etc/hosts中加入对方的主机名** ``` vim /etc/nova/nova.conf ``` 在[libvirt]组添加: ``` block_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_NON_SHARED_INC ive_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST ``` 注:如果cpu型号不一样,比如一个cpu版本低,一个cpu版本高,那么cpu版本低上面的虚拟机可以热迁移或冷迁移到cpu版本高的上面, 但是反过来不行,如果要cpu版本高的要cpu版本高的迁移到cpu版本低的上,需要做如下设置: ``` vim /etc/nova/nova.conf ``` 在[libvirt]组额外添加下面两个参数: ``` libvirt_cpu_mode=custom libvirt_cpu_model=kvm64 ``` 在computer1、2节点修改`/etc/sysconfig/libvirtd和/etc/libvirt/libvirtd.conf`文件 ``` sed -i 's/#listen_tls = 0/listen_tls = 0/g' /etc/libvirt/libvirtd.conf sed -i 's/#listen_tcp = 1/listen_tcp = 1/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_tcp = "sasl"/auth_tcp = "none"/g' /etc/libvirt/libvirtd.conf sed -i 's/#LIBVIRTD_ARGS="--listen"/LIBVIRTD_ARGS="--listen"/g' /etc/sysconfig/libvirtd ``` 在nfs-backend节点上操作: `mkdir -p /var/lib/nova/instances `#如果已存在这个目录请清空目录 然后`/etc/exports`里添加以下内容: ``` /var/lib/nova/instances *(rw,sync,no_root_squash) ``` 重启nfs相关服务 ``` systemctl restart rpcbind systemctl restart nfs-server ``` 让NFS共享目录生效: ``` showmount -e ``` 在计算节点上挂载共享目录 ``` mount -t nfs 10.1.1.155:/var/lib/nova/instances /var/lib/nova/instances echo "/usr/bin/mount -t nfs 10.1.1.155:/var/lib/nova/instances /var/lib/nova/instances" >> /etc/rc.d/rc.local cd /var/lib/nova chown -R nova:nova instances/ chmod +x /etc/rc.d/rc.local cat /etc/rc.d/rc.local df -h nova-manage vm list nova live-migration 10.1.1.153 nova-manage vm list ``` ![8-1-28](http://pded8ke3e.bkt.clouddn.com/8-1-28.jpg) 2)设置libvirtd.service 和openstack-nova-compute.service开机启动 ``` systemctl enable libvirtd.service openstack-nova-compute.service systemctl restart libvirtd.service openstack-nova-compute.service systemctl status libvirtd.service openstack-nova-compute.service ``` 3)添加环境变量 ``` cat <<END >/root/admin-openrc export OS_PROJECT_DOMAIN_NAME=default export OS_USER_DOMAIN_NAME=default export OS_PROJECT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=yjscloud export OS_AUTH_URL=http://yjscloud.com:35357/v3 export OS_IDENTITY_API_VERSION=3 END ``` ``` cat <<END >/root/demo-openrc export OS_PROJECT_DOMAIN_NAME=default export OS_USER_DOMAIN_NAME=default export OS_PROJECT_NAME=demo export OS_USERNAME=demo export OS_PASSWORD=yjscloud export OS_AUTH_URL=http://yjscloud.com:5000/v3 export OS_IDENTITY_API_VERSION=3 END ```` 4)验证 ``` source /root/admin-openrc openstack compute service list ``` ![8-1-29](http://pded8ke3e.bkt.clouddn.com/8-1-29.jpg)