- apt-get -y install ntp
编辑 /etc/ntp.conf, 指向控制节点
- sed -i -e " s/server ntp.ubuntu.com/server 192.168.4.164/g" /etc/ntp.conf
- service ntp restart
配置 cat /etc/resolv.conf 文件
- nameserver 192.168.4.164 //控制机内网ip
- apt-get install -y kvm libvirt-bin pm-utils
编辑 /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/net/tun",
- ]
编辑 /etc/libvirt/libvirtd.conf, 去掉这三行的注释
- listen_tls = 0
- listen_tcp = 1
- auth_tcp = "none"
- sed -i '/#listen_tls/s/#listen_tls/listen_tls/; /#listen_tcp/s/#listen_tcp/listen_tcp/; /#auth_tcp/s/#auth_tcp/auth_tcp/; /auth_tcp/s/sasl/none/' /etc/libvirt/libvirtd.conf
编辑 /etc/init/libvirt-bin.conf
- env libvirtd_opts="-d -l"
- sed -i '/env libvirtd_opts/s/-d/-d –l/' /etc/init/libvirt-bin.conf
- libvirtd_opts="-d -l"
- sed -i '/libvirtd_opts/s/-d/-d -l/' /etc/default/libvirt-bin
- service libvirt-bin restart
- auto eth2
- iface eth2 inet manual
- pre-up ifconfig eth2 up
- sudo apt-get install nova-compute nova-network nova-api python-keystone novnc bridge-utils
注意:/etc/nova 这个目录的权限,安装完成后有时会出现这个目录的权限问题,这个目录属于nova 用户
- [DEFAULT]
- logdir=/var/log/nova
- state_path=/var/lib/nova
- lock_path=/run/lock/nova
- verbose=False
- api_paste_config=/etc/nova/api-paste.ini
- scheduler_driver=nova.scheduler.simple.SimpleScheduler
- s3_host=192.168.4.164
- ec2_host=192.168.4.164
- ec2_dmz_host=192.168.4.164
- rabbit_host=192.168.4.164
- rabbitrabbit_password=rabbit-pass
- cc_host=192.168.4.164
- nova_url=http://192.168.4.164:8774/v1.1/
- sql_connection=mysql://nova:nova-pass@192.168.4.164/nova
- ec2_url=http://192.168.4.164:8773/services/Cloud
- root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf
- # Auth
- use_deprecated_auth=false
- auth_strategy=keystone
- keystone_ec2_url=http://192.168.4.164:5000/v2.0/ec2tokens
- # Imaging service
- glance_api_servers=192.168.4.165:9292
- p_w_picpath_service=nova.p_w_picpath.glance.GlanceImageService
- # Vnc configuration
- novnc_enabled=true
- novncproxy_base_url=http://0.0.0.0:6080/vnc_auto.html
- novncproxy_port=6080
- vncserver_proxyclient_address=0.0.0.0
- vncserver_listen=0.0.0.0
- # Network settings
- #network_api_class=nova.network.quantumv2.api.API
- #quantum_url=http://192.168.4.164:9696
- #quantum_auth_strategy=keystone
- #quantum_admin_tenant_name=service
- #quantumquantum_admin_username=quantum
- #quantum_admin_password=
- #quantum_admin_auth_url=http://192.168.4.164:35357/v2.0
- #libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver
- #linuxnet_interface_driver=nova.network.linux_net.LinuxOVSInterfaceDriver
- #firewall_driver=nova.virt.libvirt.firewall.IptablesFirewallDriver
- ###### NETWORK
- #network_manager=nova.network.manager.FlatDHCPManager
- network_manager=nova.network.manager.VlanManager
- force_dhcp_release=True
- dhcpbridge_flagfile=/etc/nova/nova.conf
- dhcpbridge=/usr/bin/nova-dhcpbridge
- firewall_driver=nova.virt.libvirt.firewall.IptablesFirewallDriver
- public_inter>
- flat_inter>
- vlan_inter>
- flat_network_bridge=br100
- fixed_range=10.100.0.0/24
- multi_host=true
- # Compute #
- #compute_driver=libvirt.LibvirtDriver
- ###### COMPUTE
- libvirt_type=kvm
- #libvirt_type=qemu
- connection_type=libvirt
- instanceinstance_name_template=instance-%08x
- api_paste_config=/etc/nova/api-paste.ini
- allow_resize_to_same_host=True
- libvirt_use_virtio_for_bridges=true
- #start_guests_on_host_boot=true
- #resume_guests_state_on_host_boot=true
- # Cinder #
- volume_api_class=nova.volume.cinder.API
- osapi_volume_listen_port=5900
- restart nova-compute
- restart nova-network
- restart nova-api
- vlan_interface=eth0
- network_manager=nova.network.manager.VlanManager
- keystone tenant-list
这里会列出最一开始创建的tenant : openstackDemo , service下面指定vlan给哪个tenant是 openstackDemo 可以使用, service最好别用,service表示服务容器。
- nova-manage network create private --multi_host=T --fixed_range_v4=192.168.195.0/28 --vlan=2 --project_id=<tenant_id> --num_networks=1 --network_size=<ip个数>
- nova-manage network list
- nova-manage project scrub --project=<tenant_id>
- nova-manage network delete --uuid=<uuid_id>
- export OS_USERNAME=seconduser
- export OS_TENANT_NAME=secondtenant
- export OS_PASSWORD=password
- export OS_AUTH_URL=http://192.168.4.164:5000/v2.0/
- export OS_REGION_NAME=RegionOne
- nova boot –p_w_picpath 0912cd43-a5dd-4719-8b0f-3c1ebff77fa5 --flavor 1 "test_name"
- nova keypair-add key_name > mykey.pem
- nova keypair-list
- nova keypair-delete <name>
使用key登入的方式 创建虚拟机
- nova boot --p_w_picpath 0912cd43-a5dd-4719-8b0f-3c1ebff77fa5 --flavor 2 "test_name” --key_name key_name
- nova list
- nova-manage vm list
- nova delete <id>
- nova reboot <id>
- vconfig rem vlan2
- ifconfig virbr0 down
- brctl delbr virbr0
- nova secgroup-list-rules default
- nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
- nova secgroup-add-rule default tcp 1 65535 0.0.0.0/0
- nova secgroup-add-rule default udp 1 65535 0.0.0.0/0
- nova-manage project quota "$tid"
- tid=1dc31a6445a64373939825ae546bd896 (tenant_id)
- nova-manage project quota "$tid" volumes 1000
- nova-manage project quota "$tid" gigabytes 10000
- nova-manage project quota "$tid" ram 5120000
- nova-manage project quota "$tid" instances 5120000
- nova-manage project quota "$tid" floating_ips 5120000
- nova-manage project quota "$tid" cores 5120000
- nova-manage floating create --ip_range=192.168.3.160/27
- nova floating-ip-create
- nova add-floating-ip <server> <address>
- nova remove-floating-ip <server> <address>
- nova floating-ip-delete <address>
- nova floating-ip-list
- nova-manage floating list
compute-01.test.com 和compute-02.test.com是两台资源机
注意:如果两台资源机上的nova用户的uid不一致,或者libvirt-* 用户的uid不一致,迁移的过程中就会出现权限问题。
- apt-get install nfs-kernel-server
- /storage *(rw,sync,no_root_squash)
- chown nova:nova / storage
- /etc/init.d/nfs-kernel-server restart
- /etc/init.d/idmapd restart (貌似跟uid 和用户名的对应有关,必需的)
- apt-get install nfs-common
- 192.168.4.166:/storage /var/lib/nova/instances nfs4 defaults 0 0
- ll -d /var/lib/nova/instances
- ssh-keygen -t rsa //直接回车使用默认就可以
- ssh-copy-id -i ~/.ssh/id_rsa.pub '-p20009 root@192.168.4.166'
- scp –P20009 ~/.ssh/id_rsa root@192.168.4.166: /root/.ssh/
- nova flavor-list
- nova resize <server> <flavor>
- nova resize-confirm <server id>
如果不运行 resize-confirm 24小时之后自动resize-confirm ,在这个状态下可以把 resize撤销,也可以把resize 确认