Control.test.com: html
其中 192.168.3.0/24 做爲物理機IP段(可認爲是公網IP,)python
192.168.3.168---192.168.3.190 做爲虛擬機 Floating_ip 段(分配給虛擬機,從外部能夠直接訪問的,能夠認爲是公網IP地址)mysql
因爲程序中會對共享目錄中的uid進行操做,因此須要nfs server 和client端的uid是一致的,至少必須不一樣主機之間nova用戶的uid是一致的,libvirt-bin用戶也要一致linux
別的計算節點 做爲 client端sql
如今咱們提供磁盤的主機是存儲服務器(192.168.3.166),同時也是一個nfs server節點。數據庫
- cat <<EOF >>/etc/apt/sources.list
- deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/folsom main
- deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/folsom main
- EOF
- apt-get install ubuntu-cloud-keyring
- apt-get update
- cat /etc/hostname
- control
- cat /etc/hosts
- 127.0.0.1 localhost
- 192.168.4.165 compute-01.test.com compute-01
- 192.168.4.166 compute-02.test.com compute-02
- hostname
- control
- hostname -f
- control.test.com
- auto lo
- iface lo inet loopback
- auto eth0
- iface eth0 inet static
- address 192.168.3.164
- netmask 255.255.255.0
- gateway 192.168.3.1
- auto eth1
- iface eth1 inet static
- address 192.168.4.164
- netmask 255.255.255.0
- /etc/init.d/networking restart
- sed -i -r 's/^\s*#(net\.ipv4\.ip_forward=1.*)/\1/' /etc/sysctl.conf
- sysctl -p
- server ntp.ubuntu.com
- server 127.127.1.0
- fudge 127.127.1.0 stratum 10
- sed -i 's/server ntp.ubuntu.com/server ntp.ubuntu.com\nserver 127.127.1.0\nfudge 127.127.1.0 stratum 10/g' /etc/ntp.conf
- service ntp restart
- apt-get -y install mysql-server python-mysqldb
- sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
- service mysql restart
建立數據庫
- mysql -uroot -proot-pass <<EOF
- CREATE DATABASE nova;
- GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova-pass';
- CREATE DATABASE glance;
- GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance-pass';
- CREATE DATABASE keystone;
- GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%'IDENTIFIED BY ' keystone-pass';
- CREATE DATABASE cinder;
- GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%'IDENTIFIED BY 'cinder-pass';
- FLUSH PRIVILEGES;
- EOF
- apt-get -y install rabbitmq-server
把默認密碼 guest,改爲rabbit-pass
- rabbitmqctl change_password guest rabbit-pass
- apt-get install keystone python-keystone python-keystoneclient
- rm /var/lib/keystone/keystone.db
配置 /etc/keystone/keystone.confjson
- [DEFAULT]
- admin_token = 012345SECRET99TOKEN012345
- bind_host = 0.0.0.0
- public_port = 5000
- admin_port = 35357
- compute_port = 8774
- verbose = True
- debug = True
- log_file = keystone.log
- log_dir = /var/log/keystone
- log_config = /etc/keystone/logging.conf
- [sql]
- connection = mysql://keystone:keystone-pass@192.168.4.64:3306/keystone
- idle_timeout = 200
- service keystone restart
- keystone-manage db_sync
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 tenant-create --name openstackDemo --description "Default Tenant" --enabled true
在這個tenant裏建立用戶 adminUser
ubuntu
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 user-create --tenant_id b5815b046cfe47bb891a7b64119e7f80 --name adminUser --pass secretword --enabled true
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 role-create --name admin
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 role-create --name memberRole
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 user-role-add --user_id a4c2d43f80a549a19864c89d759bb3fe --tenant_id b5815b046cfe47bb891a7b64119e7f80 --role_id e3d9d157cc95410ea45d23bbbc2e5c10
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 tenant-create --name service --description "Service Tenant" --enabled true
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 user-create --tenant_id eb7e0c10a99446cfa14c244374549e9d --name glance --pass glance --enabled true
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 user-role-add --user_id 46b2667a7807483d983e0b4037a1623b --tenant_id eb7e0c10a99446cfa14c244374549e9d --role_id e3d9d157cc95410ea45d23bbbc2e5c10
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 user-create --tenant_id eb7e0c10a99446cfa14c244374549e9d --name nova --pass nova --enabled true
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 user-role-add --user_id 54b3776a8707834d983e0b4037b1345c --tenant_id eb7e0c10a99446cfa14c244374549e9d --role_id e3d9d157cc95410ea45d23bbbc2e5c10
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 user-create --tenant_id eb7e0c10a99446cfa14c244374549e9d --name ec2 --pass ec2 --enabled true
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 user-role-add --user_id 32e7668b8707834d983e0b4037b1345c --tenant_id eb7e0c10a99446cfa14c244374549e9d --role_id e3d9d157cc95410ea45d23bbbc2e5c10
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 service-create --name=keystone --type=identity --description="Keystone Identity Service"
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 endpoint-create --region RegionOne --service_id=15c11a23667e427e91bc31335b45f4bd --publicurl=http://192.168.4.164:5000/v2.0 --internalurl=http://192.168.4.164:5000/v2.0 --adminurl=http://192.168.4.164:35357/v2.0
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 service-create --name=nova --type=compute --description="Nova Compute Service"
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 endpoint-create --region RegionOne --service_id=abc0f03c02904c24abdcc3b7910e2eed --publicurl='http://192.168.4.164:8774/v2/%(tenant_id)s' --internalurl='http://192.168.4.164:8774/v2/%(tenant_id)s' --adminurl='http://192.168.4.164:8774/v2/%(tenant_id)s'
定義volume service ,也須要制定 tenant後端
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 service-create --name=volume --type=volume --description="Nova Volume Service"
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 endpoint-create --region RegionOne --service_id=1ff4ece13c3e48d8a6461faebd9cd38f --publicurl='http://192.168.4.164:8776/v1/%(tenant_id)s' --internalurl='http://192.168.4.164:8776/v1/%(tenant_id)s' --adminurl='http://192.168.4.164:8776/v1/%(tenant_id)s'
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 service-create --name=glance --type=p_w_picpath --description="Glance Image Service"
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 endpoint-create --region RegionOne --service_id=7d5258c490144c8c92505267785327c1 --publicurl=http://192.168.4.165:9292/v1 --internalurl=http://192.168.4.165:9292/v1 --adminurl=http://192.168.4.165:9292/v1
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 service-create --name=ec2 --type=ec2 --description="EC2 Compatibility Layer"
- keystone --token 012345SECRET99TOKEN012345 --endpoint http://192.168.4.164:35357/v2.0 endpoint-create --region RegionOne --service_id=181cdad1d1264387bcc411e1c6a6a5fd --publicurl=http://192.168.4.164:8773/services/Cloud --internalurl=http://192.168.4.164:8773/services/Cloud --adminurl=http://192.168.4.164:8773/services/Admin
- sudo apt-get install curl openssl
- curl -d '{"auth": {"tenantName": "adminTenant", "passwordCredentials":{"username": "adminUser", "password": "secretword"}}}' -H "Content-type:application/json" http://192.168.4.164:35357/v2.0/tokens | python -mjson.tool
- apt-get -y install glance glance-api python-glanceclient glance-common
- sudo rm /var/lib/glance/glance.sqlite
- sql_connection = mysql://glance:glance-pass@192.168.4.164/glance
- auth_host = 192.168.4.164
- admin_tenant_name = service
- admin_user = glance
- admin_password = glance-pass
- #notifier_strategy = noop
- notifier_strategy = rabbit
- #rabbit_password = guest
- rabbitrabbit_password = rabbit-pass
- cat <<EOF >>/etc/glance/glance-api.conf
- flavor = keystone+cachemanagement
- EOF
- cat <<EOF >>/etc/glance/glance-registry.conf
- flavor = keystone
- EOF
- service glance-api restart && service glance-registry restart
- glance-manage version_control 0
- glance-manage db_sync
- sudo service glance-registry restart
- glance --version
- mkdir /tmp/p_w_picpaths
- cd /tmp/p_w_picpaths/
- wget http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-12.1_2.6.35-22_1.tar.gz
- tar -zxvf ttylinux-uec-amd64-12.1_2.6.35-22_1.tar.gz
- glance --os_username=adminUser --os_password=secretword --os_tenant=openstackDemo --os_auth_url=http://127.0.0.1:5000/v2.0 add name="tty-linux-kernel" disk_format=aki container_format=aki < ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz
- glance --os_username=adminUser --os_password=secretword --os_tenant=openstackDemo --os_auth_url=http://127.0.0.1:5000/v2.0 add name="tty-linux-ramdisk" disk_format=ari container_format=ari < ttylinux-uec-amd64-12.1_2.6.35-22_1-loader
- glance --os_username=adminUser --os_password=secretword --os_tenant=openstackDemo --os_auth_url=http://127.0.0.1:5000/v2.0 add name="tty-linux" disk_format=ami container_format=ami kernel_id=599907ff-296d-4042-a671-d015e34317d2 ramdisk_id=7d9f0378-1640-4e43-8959-701f248d999d < ttylinux-uec-amd64-12.1_2.6.35-22_1.img
- glance --os_username=adminUser --os_password=secretword --os_tenant=openstackDemo --os_auth_url=http://127.0.0.1:5000/v2.0 index
上面的例子使用 --os_username, --os_password, --os_tenant, --os_auth_url ,也可使用 OS_*環境變量api
- export OS_USERNAME=adminUser
- export OS_TENANT_NAME=openstackDemo
- export OS_PASSWORD=secretword
- export OS_AUTH_URL=http://192.168.4.164:5000/v2.0/
- export OS_REGION_NAME=RegionOne
- apt-get -y install nova-api nova-cert nova-common nova-scheduler python-nova python-novaclient nova-consoleauth novnc nova-novncproxy
- auth_host = 192.168.4.164
- auth_port = 35357
- auth_protocol = http
- admin_tenant_name = service
- admin_user = nova
- admin_password = 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
- 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
- nova-manage db sync
- service nova-api restart
- service nova-cert restart
- service nova-consoleauth restart
- service nova-scheduler restart
- service nova-novncproxy restart
- apt-get install -y cinder-api cinder-scheduler cinder-volume open-iscsi tgt python-cinderclient
硬盤專門一個分區給volume使用
- pvcreate /dev/sda5
- vgcreate cinder-volumes /dev/sda5
編輯 /etc/cinder/cinder.conf ,直接運行下面命令就能夠
- [DEFAULT]
- rootwrap_config = /etc/cinder/rootwrap.conf
- sql_connection = mysql://cinder:cinder-pass@192.168.4.164:3306/cinder
- api_paste_confg = /etc/cinder/api-paste.ini
- iscsi_helper = ietadm
- volume_group = cinder-volumes
- volumevolume_name_template = volume-%s
- rabbitrabbit_password = rabbit-pass
- logdir = /var/log/cinder
- verbose = False
- auth_strategy = keystone
編輯 /etc/cinder/api-paste.ini
- admin_tenant_name = service
- admin_user = cinder
- admin_password = cinder
- cinder-manage db sync
- service cinder-api restart
- service cinder-scheduler restart
- service cinder-volume restart
volume-attach Attach a volume to a server.