目录
glance的安装在一个节点安装配置成功后,将本节点的配置一次同步到其他节点即可。以下所有在任意一个节点执行,但必须都在同一个节点上执行。
一、glance安装
1.创建glance数据库
**1q2w3e4r为glance数据库密码
mysql -h vip -u root -p -e "
create database glance;
grant all privileges on glance.* to 'glance'@'localhost' identified by '1q2w3e4r';
grant all privileges on glance.* to 'glance'@'%' identified by '1q2w3e4r';"
2.创建项目以及用户
1.创建glance用户,密码为1q2w3e4r
source ./admin-openstack.sh
openstack user create --domain default --password=1q2w3e4r glance
openstack role add --project service --user glance admin
2.创建endpoint
openstack service create --name glance --description "OpenStack Image" image
openstack endpoint create --region RegionOne image public http://vip:9292
openstack endpoint create --region RegionOne image internal http://vip:9292
openstack endpoint create --region RegionOne image admin http://vip:9292
3.创建用于存放镜像的路径
**images默认/var/lib/glance/images/
Imgdir=/date/glance
mkdir -p $Imgdir
chmod 777 -R $Imgdir
echo "镜像目录: $Imgdir"
4.Glance 安装
yum install -y openstack-glance python-glance
5.配置glance-api.conf
[DEFAULT]
debug = False
verbose = True
bind_host = 当前节点的ip地址
bind_port = 9292
auth_region = RegionOne
registry_client_protocol = http
[database]
#1q2w3e4r是glance数据库的密码
connection = mysql+pymysql://glance:1q2w3e4r@vip/glance
[keystone_authtoken]
#1q2w3e4r是glance用户的密码
auth_uri = http://vip:5000/v3
auth_url = http://vip:35357/v3
memcached_servers = 缓存部署节点1的ip:11211,缓存部署节点2的ip:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = 1q2w3e4r
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = 镜像存储的路径
[paste_deploy]
flavor = keystone
[oslo_messaging_rabbit]
#1q2w3e4r是rabbit服务openstack用户密码
rabbit_userid =openstack
rabbit_password = 1q2w3e4r
rabbit_durable_queues=true
rabbit_ha_queues = True
rabbit_max_retries=0
rabbit_port = 5672
rabbit_hosts = rabbit部署节点1的ip:5672,rabbit部署节点1的ip:5672
6.配置glance-registry.conf
[DEFAULT]
debug = False
verbose = True
bind_host = 当前节点的ip地址
bind_port = 9191
workers = 2
[database]
#1q2w3e4r是glance数据库密码
connection = mysql+pymysql://glance:1q2w3e4r@vip/glance
[paste_deploy]
flavor = keystone
[keystone_authtoken]
#1q2w3e4r是glance用户密码
auth_uri = http://vip:5000/v3
auth_url = http://vip:35357/v3
memcached_servers = 缓存部署节点1的ip:11211,缓存部署节点2的ip:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = 1q2w3e4r
[oslo_messaging_rabbit]
#1q2w3e4r是rabbit密码
rabbit_userid =openstack
rabbit_password = 1q2w3e4r
rabbit_durable_queues=true
rabbit_ha_queues = True
rabbit_max_retries=0
rabbit_port = 5672
rabbit_hosts = rabbit部署节点1的ip:5672,rabbit部署节点1的ip:5672
7.同步数据库
1.同步数据表
su -s /bin/sh -c "glance-manage db_sync" glance
mysql -h vip -u glance -p -e "use glance;show tables;"
2.启动服务
systemctl enable openstack-glance-api openstack-glance-registry
systemctl restart openstack-glance-api openstack-glance-registry
sleep 3
netstat -antp|grep python2 #检测服务端口
#netstat -antp|egrep '9292|9191' #检测服务端口
8.haproxy代理设置
1.配置代理
echo '
#glance_api_cluster
listen glance_api_cluster
bind vip:9292
#balance source
option tcpka
option httpchk
option tcplog
server galnce部署节点1的IP galnce部署节点1的IP:9292 check inter 2000 rise 2 fall 5
server galnce部署节点2的IP galnce部署节点2的IP:9292 check inter 2000 rise 2 fall 5
'>>/etc/haproxy/haproxy.cfg
2.重启代理
systemctl restart haproxy.service
netstat -antp|grep haproxy
9.上传镜像
1.将镜像复制到/root路径下
2.上传镜像
source ./admin-openstack.sh
openstack image create "cirros" \
--file cirros-0.3.5-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public
3.检测是否上传成功
openstack image list
10.nfs镜像服务搭建
nfs镜像服务搭建的目的主要是将当前节点的镜像,共享到其他节点。
1.nfs镜像服务端搭建
#10.27.0.0/16 表示这个网段的ip地址都可以访问此镜像服务
yum install nfs-utils rpcbind -y
echo "/date/glance 10.27.0.0/16 (rw,no_root_squash,sync)">>/etc/exports
exportfs -r
systemctl enable rpcbind nfs-server
systemctl start rpcbind nfs-server
showmount -e localhost
2.nfs镜像客户端搭建
#nfs客户端的ip指的是其他glance服务节点。
#共享镜像服务端ip指的是搭建nfs镜像服务所在的glance节点ip.
ssh nfs客户端的ip "systemctl enable rpcbind;systemctl start rpcbind"
ssh nfs客户端的ip "mkdir -p /date/glance;mount -t nfs 共享镜像服务端ip:/date/glance /date/glance"
ssh nfs客户端的ip 'echo "/usr/bin/mount -t nfs 共享镜像服务端ip:/date/glance /date/glance">>/etc/rc.local;chmod +x /etc/rc.d/rc.local;df -h'
二、将已经部署好的节点同步到其他节点
1.Glance 安装
1.安装
ssh glance其他节点的ip "yum install -y openstack-glance python-glance"
2.同步配置
rsync -avzP -e 'ssh -p 22' /etc/glance/* glance其他节点ip:/etc/glance/
rsync -avzP -e 'ssh -p 22' /etc/haproxy/haproxy.cfg glance其他节点ip:/etc/haproxy/
3.修改配置
#在每个安装glance的节点,分别修改以下配置。
3.1修改glance-api.conf
bind_host = 当前节点的ip地址
3.2修改glance-registry.conf
bind_host = 当前节点的ip地址
4.重启服务
ssh glance其他节点IP "systemctl enable openstack-glance-api openstack-glance-registry"
ssh glance其他节点IP "systemctl restart openstack-glance-api openstack-glance-registry haproxy.service;"