openstack学习笔记八 glance安装配置
镜像 安装过系统的虚拟硬盘
管理是用glance来完成。
镜像的状态:
active 镜像已经上传完成,并且是可用的
saving 正在被上传,还没有完成
killed 上传出错
queued 并没有真的上传完成,但是被标记有这个镜像
安装glance
在 keystone注册
glance所需要的账户
创建glance服务
指定glance服务的endpoint
安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[[email protected] ~] # yum -y install openstack-glance.noarch
[[email protected] ~] # openstack-db --init --service glance --password 123456 -rootpw 123456
[[email protected] ~(keystone_admin)] # keystone user-create --name glance --pass 123456
[[email protected] ~(keystone_admin)] # keystone user-role-add --user glance --tenant services --role admin
[[email protected] ~(keystone_admin)] # keystone service-create --name glance --type image --description "glance jingxiang"
[[email protected] ~(keystone_admin)] # keystone endpoint-create --service-id 3d0969b633044029a895da1ca2855464 --publicurl 'http://192.168.1.204:9292' --internalurl 'http://192.168.1.204:9292' --adminurl 'http://192.168.1.204:9292'
+-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | adminurl | http: //192 .168.1.204:9292 |
| id | e0f7718b18444f71a43762ca3336ef06 |
| internalurl | http: //192 .168.1.204:9292 |
| publicurl | http: //192 .168.1.204:9292 |
| region | regionOne | | service_id | 3d0969b633044029a895da1ca2855464 | +-------------+----------------------------------+ |
修改配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[[email protected] glance(keystone_admin)] # systemctl list-unit-files | grep glanc
openstack-glance-api.service disabled 接受用户的请求 openstack-glance-registry.service disabled 和数据库进行交互 openstack-glance-scrubber.service disabled 和其他接口进行交互 [[email protected] glance(keystone_admin)] # ls
glance-api.conf glance-registry.conf metadefs schema-image.json glance-cache.conf glance-scrubber.conf policy.json [[email protected] glance(keystone_admin)] # cd /usr/share/glance/模板
[[email protected] glance(keystone_admin)] # ls
glance-api-dist.conf glance-registry-dist.conf glance-api-dist- paste .ini glance-registry-dist- paste .ini
glance-cache-dist.conf glance-scrubber-dist.conf [[email protected] glance(keystone_admin)] # cp glance-api-dist.conf /etc/glance/glance-api.conf ##拷贝模板
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
[[email protected] glance(keystone_admin)] # vim glance-api.conf
[DEFAULT] debug = False verbose = True use_stderr = False log_file = /var/log/glance/api .log
filesystem_store_datadir = /var/lib/glance/images/
scrubber_datadir = /var/lib/glance/scrubber
image_cache_dir = /var/lib/glance/image-cache/
rabbit_host = 192.168.1.204 rabbit_port = 5672 rabbit_hosts = $rabbit_host:$rabbit_port rabbit_use_ssl = false
rabbit_userid = guest rabbit_password = guest rabbit_login_method = AMQPLAIN [database] [keystone_authtoken] admin_tenant_name = services admin_user = glance admin_password = 123456 auth_host = 192.168.1.204 auth_port = 35357 auth_protocol = http auth_uri = http: //192 .168.1.204:5000/
[paste_deploy] config_file = /usr/share/glance/glance-api-dist-paste .ini
flavor = keystone |
1
2
3
|
[[email protected] glance] # chown root.glance glance-api.conf
[[email protected] glance] # systemctl start openstack-glance-api.service openstack-glance-registry.service openstack-glance-scrubber.service
[[email protected] glance] # systemctl enable openstack-glance-api.service openstack-glance-registry.service openstack-glance-scrubber.service
|
管理
1
2
3
4
5
6
7
8
9
10
11
|
[[email protected] ~(keystone_admin)] # glance image-list
+----+------+ | ID | Name | +----+------+ +----+------+ [[email protected] ~(keystone_admin)] # glance help image-create
##########################先上传一个镜像再创建 [[email protected] ~(keystone_admin)] # glance image-create --name hequan --file hequan.img --disk-format qcow2 --visibility publice --container-format bare ##创建
[[email protected] ~(keystone_admin)] # glance image-create --name hequan --os-distro http://mirrors.163.com/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso --disk-format iso --container-format bare
filesystem_store_datadir = /var/lib/glance/images/ ###镜像保存的位置
#default_store=file
|
修改镜像存储位置
swift 做后端存储
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
6 #filesystem_store_datadir = /var/lib/glance/images/ ##先禁用
[glance_store] default_store = swift 默认为 file 改为swift
stores = file , http 默认不用动
swift_store_auth_version = 2 默认版本为2 stores=glance.store.swift.Store,glance.store.filesystem.Store 此项一定要加上,不然无法上传 swift_store_auth_address = http: //192 .168.1.204:5000 /v2 .0/ controller的keystone认证
swift_store_user = service:swift 使用swift用户 swift_store_key = hequan 密码 swift_store_container = glance 将要被创建的容器 swift_store_create_container_on_put = True 上传开 swift_store_large_object_size = 5120 最大5G限制,但与glance结合后限制无效 swift_store_large_object_chunk_size = 200 最大200个容器 swift_enable_snet = False [[email protected] glance(keystone_admin)] # systemctl restart openstack-glance-api.service openstack-glance-registry.service openstack-glance-scrubber.service
|
ceph 共享存储
安装epel仓库
1
2
3
4
5
6
7
8
9
10
11
12
|
rpm -vih http: //mirrors .sohu.com /fedora-epel/7/x86_64/e/epel-release-7-2 .noarch.rpm
添加yum ceph仓库 vim /etc/yum .repos.d /ceph .repo
[ceph] name=Ceph noarch packages baseurl=http: //mirrors .163.com /ceph/rpm-hammer/el7/x86_64/
enabled=1 gpgcheck=1 type =rpm-md
gpgkey=http: //mirrors .163.com /ceph/keys/release .asc
安装ceph-deploy,ceph(ceph所有节点都安装,ceph-deploy只需admin节点安装) yum -y update && yum -y install --release hammer ceph ceph-deploy
|
1 生成相关的MOD信息 监控服务器 h5
1
2
3
|
[[email protected] xx] # ceph-deploy new h5
[[email protected] xx] # ls
ceph.conf ceph-deploy-ceph.log ceph.mon.keyring |
2 要根据自己的情况修改配置文件ceph.conf
1
2
|
osd_pool_default_size = 2 ##几个节点组成,默认是3
osd_pool_defaults_min_size = 1 ##最小值是1
|
3 生成key 当客户端要链接到ceph服务器,需要用户名和密码
1
2
3
4
5
|
[[email protected] xx] # ceph-deploy mon create-initial
[[email protected] myceph] # ls
ceph.bootstrap-mds.keyring ceph.client.admin.keyring ceph.mon.keyring ceph.bootstrap-osd.keyring ceph.conf ceph.bootstrap-rgw.keyring ceph.log |
4 开始准备配置OSD
1
2
3
4
|
mkdir path1 path2
[[email protected] xx] # ceph-deploy osd prepare h5:/path1 h6:/path2
[[email protected] xx] # ceph-deploy osd activate h5:/path1 h6:/path2 ##**
[ceph_deploy.osd][DEBUG ] Host h5 is now ready for osd use.
|
5 把key复制到各个节点上去
1
2
|
[[email protected] ceph] # ceph-deploy admin h5 h6
[[email protected] ceph] # ceph health ##健康性检查
|
6 生成元数据
1
2
3
4
|
[[email protected] ceph] # ceph-deploy mds create h5
[[email protected] ceph] # rados lspools
[[email protected] ceph] # rados mkpool glance
[[email protected] ceph] # rados rmpool glance glance --yes-i-really-really-mean-it ##删除
|
glance配置成ceph的客户端
安装ceph
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[[email protected] ceph(keystone_admin)] # ls
rbdmap [[email protected] myceph] # ceph-deploy admin h4
[[email protected] ceph(keystone_admin)] # ls
ceph.client.admin.keyring ceph.conf rbdmap tmp6BxOoY vim glance-api.conf [glance_store] default_store = rbd stores = rbd rbd_store_pool = glance rbd_store_user = admin rbd_store_ceph_conf = /etc/ceph/ceph .conf
rbd_store_chunk_size = 8 systemctl restart openstack-glance-api.service openstack-glance-registry.service openstack-glance-scrubber.service -rw------- 1 root root 63 7月 21 16:43 ceph.client.admin.keyring setfacl -m u:glance:r-- ceph.client.admin.keyring ##设置权限 能读
|
制作镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
yum -y groupinstall "Server with GUI"
yum install virt-manager python-virtinst qemu-kvm-tools qemu-kvm libvirt
KVM 创建存储卷 centos.qcow2 基本安装 配置网卡 删除MAC 安装基本组件openssh-clients cloud-init ##云包
[[email protected] ~] # vim /etc/default/grub
GRUB_CMDLINE_LINUX= "net.ifnames=0 biosdevname=0 console=tty0 console=ttyS0,115200n8 rhgb quiet" ##指定串口的参数
[[email protected] ~] # grub2-mkconfig -o /boot/grub2/grub.cfg
封装 [[email protected] ~] # yum whatprovides */virt-sysprep
[[email protected] ~] # yum -y install libguestfs-bash-completion-1.28.1-1.55.el7.centos.noarch
[[email protected] ~] # virt-sysprep -d centos
[[email protected] ~] # cd /openstack-image/
[[email protected] openstack-image] # qemu-img info centos.qcow2
qemu-img conver -c -o qcow2 centos.qcow2 newcentos.qcow2 ###3 压缩命令
|
本文转自 295631788 51CTO博客,原文链接:http://blog.51cto.com/hequan/1828592,如需转载请自行联系原作者