Openstack部署及keystone.glance组件安装
文章开始把我喜欢的这句话送个大家:这个世界上还有什么比自己写的代码运行在一亿人的电脑上更酷的事情吗,如果有那就是让这个数字再扩大十倍。
一.安装Openstack
首先,配置IP
- #network Management
- auto eth0
- iface eth0 inet static
- address 10.80.80.10
- netmask 255.255.255.0
- #network loopback
- auto lo
- iface lo inet loopback
执行命令
- # /etc/init.d/networking restart
添加Openstack源
- # apt-get install -y python-software-properties
- # add-apt-repository cloud-archive:icehouse
然后更新系统
- # apt-get update
- # apt-get upgrade -y
- # apt-get dist-upgrade -y
安装NTP服务
- # apt-get install -y ntp
安装mysql数据库
- # apt-get install -y mysql-server python-mysqldb
修改mysql的监听ip 重启mysql服务
- # service mysql restart
安装RabbitMQ
- # apt-get install -y rabbitmq-server
默认用户guest密码guest
二.keystone组件安装
1.获取keystone
- # apt-get insatll -y keystone
2.修改配置文件
文件路径: /etc/keystone/keystone.conf
最后文件中的配置如下:
- admin_token = openstack
- admin_bind_host=0.0.0.0
- admin_port=35357
- public_port=5000
- public_endpoint=http://localhost:%(public_port)s/
- admin_endpoint=http://localhost:%(admin_port)s/
- debug = True
- verbose = True
- log_file=/var/log/keystone/keystone.log
- connection = mysql://keystoneuser:openstack@localhost/keystone
3.创建keystone数据库
- # mysql -uroot -p -e "CREATE DATABASE keystone"
- # mysql -uroot -p -e "GRANT ALL PRIVILEGES ON keystone.* TO'keystoneuser'@'localhost'IDENTIFIED BY 'openstack';"service keystone status
- # keystone-manage db_sync
4.重启keystone服务
- # service keystone restart
5.创建keystone用户
创建一个tenant
- # keystone tenant-create --name=admin
创建一个用户
- # keystone user-create --name=admin --pass="opensatck"
- # keystone role-create --name=admin
关联角色,用户和tenant
- # keystone user-role-add --user admin --role admin --tenant admin
6.定义services和API endpoints
- # keystone service-create --name keystone --type identity --description 'OpenStack Identity'
- # keystone endpoint-create --service-id 01fa6ef7e6f847c4a684bfd29c2e9fb5 --publicurl 'http://192.168.0.101:5000/v2.0' --adminurl 'http://10.80.80.10:35357/v2.0' --internalurl 'http://10.80.80.10:5000/v2.0'
文件存放位置可以在默认登陆的用户文件夹下,为方便访问,可放在了 /root 下
- export OS_TENANT_NAME=admin
- export OS_USERNAME=admin
- export OS_PASSWORD=openstack
- export OS_AUTH_URL="http://192.168.0.101:5000/v2.0/"
- # source openstackrc
三 glance组件安装
1.安装glance软件
- # apt-get install -y glance
2.修改glance配置文件 /etc/glance/glance-api.config
- debug = True
- default_store = file
- bind_host = 0.0.0.0
- bind_port = 9292
- log_file = /var/log/glance/api.log
- backlog = 4096
- workers = 1
- registry_host = 0.0.0.0
- registry_port = 9191
- registry_client_protocol = http
- rabbit_host = localhost
- rabbit_port = 5672
- rabbit_use_ssl = false
- rabbit_userid = guest
- rabbit_password = guest
- rabbit_virtual_host = /
- rabbit_notification_exchange = glance
- rabbit_notification_topic = notifications
- rabbit_durable_queues = False
- qpid_notification_exchange = glance
- qpid_notification_topic = notifications
- qpid_hostname = localhost
- qpid_port = 5672
- qpid_username =
- qpid_password =
- qpid_sasl_mechanisms =
- qpid_reconnect_timeout = 0
- qpid_reconnect_limit = 0
- qpid_reconnect_interval_min = 0
- qpid_reconnect_interval_max = 0
- qpid_reconnect_interval = 0
- qpid_heartbeat = 5
- qpid_protocol = tcp
- qpid_tcp_nodelay = True
- filesystem_store_datadir = /var/lib/glance/images/
- swift_store_auth_version = 2
- swift_store_auth_address = 127.0.0.1:5000/v2.0/
- swift_store_user = jdoe:jdoe
- swift_store_key = a86850deb2742ec3cb41518e26aa2d89
- swift_store_container = glance
- swift_store_create_container_on_put = False
- swift_store_large_object_size = 5120
- swift_store_large_object_chunk_size = 200
- swift_enable_snet = False
- s3_store_host = 127.0.0.1:8080/v1.0/
- s3_store_access_key = <20-char AWS access key>
- s3_store_secret_key = <40-char AWS secret key>
- s3_store_bucket = <lowercased 20-char aws access key>glance
- s3_store_create_bucket_on_put = False
- sheepdog_store_address = localhost
- sheepdog_store_port = 7000
- sheepdog_store_chunk_size = 64
- delayed_delete = False
- scrub_time = 43200
- scrubber_datadir = /var/lib/glance/scrubber
- image_cache_dir = /var/lib/glance/image-cache/
- sqlite_db = /var/lib/glance/glance.sqlite
- backend = sqlalchemy
- connection = mysql://glanceuser:openstack@localhost/glance
- <pre name="code" class="python">
3.修改 /etc/glance/glance-registre.conf文件
- verbose = True
- debug = True
- bind_host = 0.0.0.0
- bind_port = 9191
- log_file = /var/log/glance/registry.log
- backlog = 4096
- api_limit_max = 1000
- limit_param_default = 25
- sqlite_db = /var/lib/glance/glance.sqlite
- backend = sqlalchemy
- connection = mysql://glanceuser:openstack@localhost/glance
- [keystone_authtoken]auth_host = 127.0.0.1auth_port = 35357auth_protocol = httpadmin_tenant_name = serviceadmin_user = glanceadmin_password = openstack
- flavor=keystone
4.创建glance数据库
根据上面配置的connection创建用户名为glanceuser密码为opensatck。
- # mysql -uroot -p -e "CREATE DATABASE glance;"
- # mysql -uroot -p -e "GRANT ALL PRIVILEGES ON glance.* TO 'glanceuser'@'localhost'IDENTIFIED BY 'openstack';
5.在keystone中创建glance用户,服务和endpoint
创建一个tenant
- # keystone tenant-create --name=service
- # keystone user-create --name=glance --pass=openstack
关联用户
- # keystone user-role-add --user glance --role admin --tenant service
创建glance的service
- # keystone service-create --name glance --type image --description 'OpenStack ImageService'
创建endpoint
- # keystone endpoint-create --service-id 2b9fcdf627f648ec9ffd6cc7cf3487b2 --publicurl 'http://192.168.0.101:9292' --adminurl 'http://10.80.80.10:9292/' --internalurl 'http:10.80.80.10:9292/'
- # glance-manage db_sync
最好使用下面这条指令执行更新操作以防报错
- # glance-manage db_version_control 0
解决办法:修改数据库表额编码
- mysql -u root -p glance
- mysql> alter table migrate_version convert to character set utf8 collate utf8_unicode_ci;
- mysql> flush privileges;
- mysql> quit;
- # service glance-api restart
- # service glance-registry restart
- # wget http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img
这跳命令下载的镜像会保存在当前pwd路径下,执行前请确认路径是否是你想要保存的位置。
添加镜像到glance
- # glance image-create --name cirros-0.3.1-x86_64 --is-public true --container-format bare --disk-format qcow2 --file cirros-0.3.1-x86_64-disk.img
可以运行下面指令查看已经上传的镜像
- # glance image-list