作者:【吴业亮】
博客:http://blog.csdn.net/wylfengyujiancheng
安装和配置glance
创建glance用户(任一节点)
# openstack user create --domain default --project service --password Changeme_123 glance
赋予glance用户admin权限(任一节点)
# openstack role add --project service --user glance admin
创建glance服务(任一节点)
# openstack service create --name glance --description "OpenStack Image service" image
定义controller管理网IP(任一节点)
# export controller=172.16.8.50
创建public的endpoint(任一节点)
# openstack endpoint create --region RegionOne image public http://$controller:9292
创建internal的endpoint(任一节点)
# openstack endpoint create --region RegionOne image internal http://$controller:9292
创建admin的endpoint(任一节点)
# openstack endpoint create --region RegionOne image admin http://$controller:9292
创建数据库(任一节点)
# mysql -uroot -pChangeme_123
MariaDB [(none)]> create database glance;
MariaDB [(none)]> grant all privileges on glance.* to glance@'localhost' identified by 'Changeme_123';
MariaDB [(none)]> grant all privileges on glance.* to glance@'%' identified by 'Changeme_123';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
Bye
安装软件包(各个节点)
# yum -y install openstack-glance
修改配置文件(各个节点)
# mv /etc/glance/glance-api.conf /etc/glance/glance-api.conf.org
cat <<END > /etc/glance/glance-api.conf
[DEFAULT]
bind_host = 172.16.8.60
notification_driver = noop
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[database]
connection = mysql+pymysql://glance:Changeme_123@172.16.8.50/glance
[keystone_authtoken]
auth_uri = http://172.16.8.50:5000
auth_url = http://172.16.8.50:35357
memcached_servers = node1:11211,node2:11211,node3:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = Changeme_123
[paste_deploy]
flavor = keystone
END
注意 修改监听IP
修改配置文件glance-registry.conf(各个节点)
# mv /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.org
# cat <<END > /etc/glance/glance-registry.conf
[DEFAULT]
bind_host = 172.16.8.60
notification_driver = noop
[database]
connection = mysql+pymysql://glance:Changeme_123@172.16.8.50/glance
[keystone_authtoken]
auth_uri = http://172.16.8.50:5000
auth_url = http://172.16.8.50:35357
memcached_servers = 172.16.8.50:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = Changeme_123
[paste_deploy]
flavor = keystone
END
注意 修改监听IP
一、 服务端(选一个节点作为nfs的server)
1、安装软件包
# yum -y install nfs-utils
创建目录
# mkdir /glance
# chown 161:161 /glance -R
其中161为cinder用户的的ID
修改/etc/exports
/glance 172.16.8.0/24(rw,no_root_squash)
2、启动服务
# systemctl start rpcbind nfs-server
# systemctl enable rpcbind nfs-server
二、三个controller节点
1、安装软件包
# yum -y install nfs-utils
2、手动挂载
# mount -t nfs 172.16.8.63:/glance /var/lib/glance
3、修改 /etc/fstab添加
172.16.8.63:/glance /var/lib/glance nfs defaults 0 0
修改文件权限
# chmod 640 /etc/glance/glance-api.conf /etc/glance/glance-registry.conf
# chown root:glance /etc/glance/glance-api.conf /etc/glance/glance-registry.conf
创建数据库表结构
# su -s /bin/bash glance -c "glance-manage db_sync"
启动服务并设置开机启动
# systemctl start openstack-glance-api openstack-glance-registry
# systemctl enable openstack-glance-api openstack-glance-registry
验证
下载镜像
# wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
加载镜像
# openstack image create "cirros" \
--file cirros-0.3.5-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public
其他镜像(根据个人需要)
# wget http://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
# openstack image create "Ubuntu1604" --file /var/kvm/images/ubuntu-16.04-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --public
查看镜像
# openstack image list