部署脚本,非自动化安装,Exess版本
##############################################0. Prepare Before Install ############################################## #System#1. Ubuntu Server amd64 12.04 LTS#2. 分区:Controller:3 ,Compute Node:4#3. 1 for OS , 2 for image storage , 3 for swap#4. 1 for OS , 2 for VM , 3 for volume(block storage) , 4 for swap#5. 主机名不能相同,最好用编号表示主机名。 #Network#静态IP , config /etc/network/interfaces#1. 1 网卡 #2. 3 网卡 #1 for internet , 2 for LAN , 3 for manage #BIOS#1. VT virtualization Technology Support (process setting) ####################################################1. Controller ######################################################## #######MySql install & config ######## #Some variable. MYSQL_PASS='hisoft'OPENSTACK_USER='openstack'OPENSTACK_PASS='hisoft' #Preseed the mysql installcat<<EOF | sudodebconf-set-selectionsmysql-server-5.1mysql-server/root_passwordpassword ${MYSQL_PASS}mysql-server-5.1mysql-server/root_password_againpassword ${MYSQL_PASS}mysql-server-5.1mysql-server/start_on_bootboolean trueEOF #Set up the mysql database serversudoapt-get install-y python-mysqldb mysql-server#Configure MySQL and Restartsudosed -i 's/127.0.0.1/0.0.0.0/g'/etc/mysql/my.cnfsudoservice mysql restart #Create the openstack databasesudorm /var/lib/keystone/keystone.dbsudomysql -u root -p$MYSQL_PASS -e "CREATEDATABASE openstack;"sudomysql -u root -p$MYSQL_PASS -e "GRANTALL ON openstack.* TO '${OPENSTACK_USER}'@'localhost' IDENTIFIED BY '${OPENSTACK_PASS}';"sudomysql -u root -p$MYSQL_PASS -e "GRANTALL ON openstack.* TO '${OPENSTACK_USER}'@'%' IDENTIFIED BY '${OPENSTACK_PASS}';" ###### Install Nova & Dependencies ###### #InstallDependenciessudoapt-get install-y rabbitmq-server euca2ools bridge-utils #Installthe compute service (nova) except nova volumesudoapt-get install-y nova-api nova-compute nova-network nova-scheduler nova-cert nova-consoleauth nova-doc nova-vncproxy novnc ###############################################################NODE:FITTINGYOUR CONDITION BEFORE EXECUTE THIS COMMOND##################################################################DESC:#--vlan_interface=eth0 ,Configure LAN IP On this device#--public_interface=eth1 ,Configure public IP on this device#IF Only have one device , ALL use eth0 ,# --vlan_interface=eth0# --public_interface=eth0#--my_ip=[this host's IP]#--sql_connection=mysql://openstack:hisoft@[thecontroller's IP]/openstack#--rabbit_host=[the controller's IP]#--glance_api_servers=[the controller's IP]#--ec2_dmz_host=[the controller's IP]#--ec2_host=[the controller's IP]#--instances_path=[the/path/to/store/instances] (cat| sudotee -a /etc/nova/nova.conf) <<EOF--dhcpbridge_flagfile=/etc/nova/nova.conf--dhcpbridge=/usr/bin/nova-dhcpbridge--logdir=/var/log/nova--state_path=/var/lib/nova--lock_path=/var/lock/nova--force_dhcp_release--iscsi_helper=tgtadm--libvirt_use_virtio_for_bridges--connection_type=libvirt--root_helper=sudonova-rootwrap--verbose--ec2_private_dns_show_ip--network_manager=nova.network.manager.VlanManager--fixed_range=10.0.0.0/8--vlan_interface=eth0--public_interface=eth0--auth_strategy=keystone--my_ip=192.168.80.54--instances_path=/mnt/instances--sql_connection=mysql://openstack:hisoft@127.0.0.1/openstack--rabbit_host=192.168.80.54--glance_api_servers=192.168.80.54:9292--ec2_dmz_host=192.168.80.54--ec2_host=192.168.80.54--quota_cores=200--quota_floating_ips=50--quota_gigabytes=3000--quota_instances=100--quota_ram=300000--quota_volumes=100EOF #Initialize the nova databasesudonova nova-manage db sync #Restart nova servicessudoservice nova-network restartsudoservice nova-compute restartsudoservice nova-scheduler restartsudoservice nova-api restartsudoservice nova-cert restartsudoservice nova-consoleauth restart watchsudo nova-manage service list #### Install the image service (glance)##### sudoapt-get install-y glance #Configure glance to use the new databasesudosed -i "s|sql_connection= sqlite:////var/lib/glance/glance.sqlite|sql_connection = mysql://${OPENSTACK_USER}:${OPENSTACK_PASS}@127.0.0.1/openstack|g" /etc/glance/glance-registry.confecho"sql_connection = mysql://${OPENSTACK_USER}:${OPENSTACK_PASS}@127.0.0.1/openstack" | sudotee -a /etc/glance/glance-scrubber.conf #modify default image store path vi/etc/glance/glance-api.conf#change this option#filesystem_store_datadir = /path/you/want/to/store/ sudoglance-manage version_control 0sudoglance-manage db_sync #Verify glance is functioningglance--version ####Install the identity service (keystone)#### sudoapt-get install-y keystone #Configure keystone to use the new databasesudosed -i "s|connection= sqlite:////var/lib/keystone/keystone.db|connection = mysql://${OPENSTACK_USER}:${OPENSTACK_PASS}@127.0.0.1/openstack|g" /etc/keystone/keystone.conf#Initialize the databasesudoservice keystone restartsudokeystone-manage db_sync #Set up the keystone credentialsmkdir~/credentialscat> ~/credentials/openrc<<EOFexportOS_USERNAME=adminexportOS_PASSWORD=hisoftexportOS_TENANT_NAME=adminexportOS_AUTH_URL=http://127.0.0.1:5000/v2.0/exportOS_REGION_NAME=RegionOneexportSERVICE_TOKEN=ADMINexportSERVICE_ENDPOINT=http://127.0.0.1:35357/v2.0EOF #Update the envirnoment with the new credentialscat~/credentials/openrc>> ~/.bashrcsource~/.bashrc #Create a new tenantTENANT_ID=`keystonetenant-create --name admin | awk-F"|"'{ if (NR == 6) print $3}' | tr-d ''` #Create a new userUSER_ID=`keystoneuser-create --tenant_id $TENANT_ID --name admin --pass admin | awk-F"|"'{ if (NR == 6) print $3}' | tr-d ''` #Create new rolesROLE_ID=`keystonerole-create --name admin | awk-F"|"'{ if (NR == 4) print $3}' | tr-d ''`keystonerole-create --name member #List the new tenants, users and roleskeystonetenant-listkeystoneuser-listkeystonerole-list #Grant the role to the userkeystoneuser-role-add --user $USER_ID --tenant_id $TENANT_ID --role $ROLE_ID #Populate the services in the service catalog KEYSTONE_SVC_ID=`keystoneservice-create --name=keystone --type=identity--description="KeystoneIdentity Service" | awk-F"|"'{ if (NR == 5) print $3}' | tr-d ''`NOVA_SVC_ID=`keystoneservice-create --name=nova --type=compute--description="NovaCompute Service" | awk-F"|"'{ if (NR == 5) print $3}' | tr-d ''`VOLUME_SVC_ID=`keystoneservice-create --name=volume --type=volume--description="NovaVolume Service" | awk-F"|"'{ if (NR == 5) print $3}' | tr-d ''`GLANCE_SVC_ID=`keystoneservice-create --name=glance --type=image--description="GlanceImage Service" | awk-F"|"'{ if (NR == 5) print $3}' | tr-d ''`EC2_SVC_ID=`keystoneservice-create --name=ec2 --type=ec2--description="EC2Compatibility Layer" | awk-F"|"'{ if (NR == 5) print $3}' | tr-d ''` #Verify the new serviceskeystoneservice-list #Populate the endpoints in the service catalogkeystoneendpoint-create --region RegionOne --service_id=$KEYSTONE_SVC_ID --publicurl=http://[publicIP]:5000/v2.0--internalurl=http://[InternalIP]:5000/v2.0--adminurl=http://[InternalIP]:35357/v2.0keystoneendpoint-create --region RegionOne --service_id=$NOVA_SVC_ID --publicurl='http://192.168.80.52:8774/v2/%(tenant_id)s'--internalurl='http://127.0.0.1:8774/v2/%(tenant_id)s'--adminurl='http://127.0.0.1:8774/v2/%(tenant_id)s'keystoneendpoint-create --region RegionOne --service_id=$VOLUME_SVC_ID --publicurl='http://192.168.80.52:8776/v1/%(tenant_id)s'--internalurl='http://127.0.0.1:8776/v1/%(tenant_id)s'--adminurl='http://127.0.0.1:8776/v1/%(tenant_id)s'keystoneendpoint-create --region RegionOne --service_id=$GLANCE_SVC_ID --publicurl=http://192.168.80.52:9292/v1--internalurl=http://127.0.0.1:9292/v1--adminurl=http://127.0.0.1:9292/v1keystoneendpoint-create --region RegionOne --service_id=$EC2_SVC_ID --publicurl='http://192.168.80.52:8773/services/Cloud'--internalurl='http://127.0.0.1:8773/services/Cloud'--adminurl='http://127.0.0.1:8773/services/Admin' #Verify the new endpointskeystoneendpoint-list #Verify identity service is functioningcurl-d '{"auth":{"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "admin"}}}'-H "Content-type:application/json" http://127.0.0.1:35357/v2.0/tokens| python -m json.tool #Configure nova to use keystonesudosed -i 's/admin_tenant_name= %SERVICE_TENANT_NAME%/admin_tenant_name = admin/g' /etc/nova/api-paste.inisudosed -i 's/admin_user= %SERVICE_USER%/admin_user = admin/g' /etc/nova/api-paste.inisudosed -i 's/admin_password= %SERVICE_PASSWORD%/admin_password = admin/g' /etc/nova/api-paste.inisudosed -i 's/--use_deprecated_auth/--auth_strategy=keystone/g'/etc/nova/nova.conf #Configure the glance-api service to use keystonesudosed -i 's/admin_tenant_name= %SERVICE_TENANT_NAME%/admin_tenant_name = admin/g' /etc/glance/glance-api-paste.inisudosed -i 's/admin_user= %SERVICE_USER%/admin_user = admin/g' /etc/glance/glance-api-paste.inisudosed -i 's/admin_password= %SERVICE_PASSWORD%/admin_password = admin/g' /etc/glance/glance-api-paste.inisudosed -i 's/pipeline= versionnegotiation context apiv1app/pipeline = versionnegotiation authtoken auth-context apiv1app/g'/etc/glance/glance-api-paste.ini (cat| sudotee -a /etc/glance/glance-api.conf) <<EOF[paste_deploy]flavor= keystoneEOF #Configure the glance-registry service to use keystonesudosed -i 's/admin_tenant_name= %SERVICE_TENANT_NAME%/admin_tenant_name = admin/g' /etc/glance/glance-registry-paste.inisudosed -i 's/admin_user= %SERVICE_USER%/admin_user = admin/g' /etc/glance/glance-registry-paste.inisudosed -i 's/admin_password= %SERVICE_PASSWORD%/admin_password = admin/g' /etc/glance/glance-registry-paste.inisudosed -i 's/pipeline= context registryapp/pipeline = authtoken auth-context context registryapp/g'/etc/glance/glance-registry-paste.ini (cat| sudotee -a /etc/glance/glance-registry.conf) <<EOF[paste_deploy]flavor= keystoneEOF #Restart all servicessudoservice nova-network restartsudoservice nova-compute restartsudoservice nova-scheduler restartsudoservice nova-api restartsudoservice nova-consoleauth restartsudoservice nova-cert restartsudoservice glance-api restartsudoservice glance-registry restartsudoservice keystone restartsudoservice novnc restart watchsudo nova-manage service list #Verify the image exists in glance#Nothing output means glance works wellglanceindex #Configure fixed IP , private Network/--mulit-host=T For network HA , So IF Single node , you can remove this optionsudonova-manage network create private --fixed_range_v4=10.0.0.0/24--num_networks=1 --network_size=256 --vlan=100 --bridge_interface=eth0 --multi_host=T --project_id=$TENANT_IDsudonova-manage network list ############################################################### Compute Node ################################################################# apt-getinstall-y nova-api nova-compute nova-network ###############################################################NODE:FITTINGYOUR CONDITION BEFORE EXECUTE THIS COMMOND##################################################################DESC:#--vlan_interface=eth0 ,Configure LAN IP On this device#--public_interface=eth1 ,Configure public IP on this device#IF Only have one device , ALL use eth0 ,# --vlan_interface=eth0# --public_interface=eth0#--my_ip=[this host's IP]#--sql_connection=mysql://openstack:hisoft@[thecontroller's IP]/openstack#--rabbit_host=[the controller's IP]#--glance_api_servers=[the controller's IP]#--ec2_dmz_host=[the controller's IP]#--ec2_host=[the controller's IP]#--instances_path=[the/path/to/store/instances] (cat| sudotee -a /etc/nova/nova.conf) <<EOF--dhcpbridge_flagfile=/etc/nova/nova.conf--dhcpbridge=/usr/bin/nova-dhcpbridge--logdir=/var/log/nova--state_path=/var/lib/nova--lock_path=/var/lock/nova--force_dhcp_release--iscsi_helper=tgtadm--libvirt_use_virtio_for_bridges--connection_type=libvirt--root_helper=sudonova-rootwrap--verbose--ec2_private_dns_show_ip--network_manager=nova.network.manager.VlanManager--fixed_range=10.0.0.0/8--vlan_interface=eth0--public_interface=eth0--auth_strategy=keystone--my_ip=192.168.80.54--instances_path=/mnt/instances--sql_connection=mysql://openstack:hisoft@127.0.0.1/openstack--rabbit_host=192.168.80.54--glance_api_servers=192.168.80.54:9292--ec2_dmz_host=192.168.80.54--ec2_host=192.168.80.54--quota_cores=200--quota_floating_ips=50--quota_gigabytes=3000--quota_instances=100--quota_ram=300000--quota_volumes=100EOF #Install nova-volume#Check the LVM partitionfdisk-l pvcreate/dev/sdb1vgcreatenova-volumes /dev/sdb1sudoapt-get installlvm2 nova-volume open-iscsi sudoservice nova-network restartsudoservice nova-compute restartsudoservice nova-volume restartsudoservice nova-api restart watchsudo nova-manage service list