CentOS 7部署OpenStack(

2023-01-31 05:01:52 openstack centos 部署

1、创建数据库

[root@controller ~]# Mysql -u root -p -e "CREATE DATABASEglance;"

Enter passWord:

[root@controller ~]# mysql -u root -p -e "GRANT ALL PRIVILEGES ONglance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance';"

Enter password:

[root@controller ~]# mysql -u root -p -e "GRANT ALL PRIVILEGES ONglance.* TO 'glance'@'%' IDENTIFIED BY 'glance';"

Enter password:

2、安装glance

[root@controller ~]# yum install -y openstack-glance python-glancePython-glanceclient

3、配置glance

3.1、同步数据库

[root@controller ~]# vim /etc/glance/glance-api.conf

538 connection=mysql://glance:glance@192.168.1.11/glance

[root@controller ~]# vim /etc/glance/glance-reGIStry.conf

363 connection=mysql://glance:glance@192.168.1.11/glance

[root@controller ~]# su -s /bin/sh -c "glance-manage db_sync"glance

3.2、创建glance用户

[root@controller ~]# source admin-openrc.sh

[root@controller ~]# openstack user create --domain default--password=glance glance

+-----------+----------------------------------+

| Field     | Value                            |

+-----------+----------------------------------+

| domain_id | default                          |

| enabled   | True                             |

| id        |c13D8e0ef83f466e95bdd4040284c52b |

| name      | glance                           |

+-----------+----------------------------------+

[root@controller ~]# openstack role add --project service --user glanceadmin

3.3、配置glance-api

3.3.1、配置连接keystone

[root@controller ~]# vim /etc/glance/glance-api.conf

973 [keystone_authtoken]

974 auth_uri = Http://192.168.1.11:5000

975 auth_url = http://192.168.1.11:35357

976 auth_plugin = password

977 project_domain_id = default

978 user_domain_id = default

979 project_name = service

980 username = glance

981 password = glance

1484 flavor=keystone

3.3.2、配置不使用消息队列

[root@controller ~]# vim /etc/glance/glance-api.conf

491 notification_driver = noop

3.3.3、配置镜像存放位置

[root@controller ~]# vim /etc/glance/glance-api.conf

642 default_store=file

701 filesystem_store_datadir=/var/lib/glance/p_w_picpaths/

3.4、配置glance-registry

3.4.1、配置连接keystone

[root@controller ~]# vim /etc/glance/glance-registry.conf

762 [keystone_authtoken]

763 uth_uri = http://192.168.1.11:5000

764 auth_url = http://192.168.1.11:35357

765 auth_plugin = password

766 project_domain_id = default

767 user_domain_id = default

768 project_name = service

769 username = glance

770 password = glance

1256 flavor=keystone

3.5、注册到keystone

[root@controller ~]# openstack service create --name glance --description"OpenStack Image service" p_w_picpath

+-------------+----------------------------------+

| Field       | Value                            |

+-------------+----------------------------------+

| description | OpenStack Image service          |

| enabled     | True                             |

| id          |9d7176f5cfab47aa99789159dd8ea8a2 |

| name        | glance                           |

| type        | p_w_picpath                            |

+-------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne   p_w_picpath public http://192.168.1.11:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           |e8c6bfd66506449094a2aab994e7a4be |

| interface    | public                           |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   |9d7176f5cfab47aa99789159dd8ea8a2 |

| service_name | glance                           |

| service_type | p_w_picpath                            |

| url          | http://192.168.1.11:9292         |

+--------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne   p_w_picpath internal http://192.168.1.11:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           |3b18ac8bd0764d009451223f26dccede |

| interface    | internal                         |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   |9d7176f5cfab47aa99789159dd8ea8a2 |

| service_name | glance                           |

| service_type | p_w_picpath                            |

| url          |http://192.168.1.11:9292         |

+--------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne   p_w_picpath admin http://192.168.1.11:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | db9f2e251e26413d836bacd725677426|

| interface    | admin                            |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   |9d7176f5cfab47aa99789159dd8ea8a2 |

| service_name | glance                           |

| service_type | p_w_picpath                            |

| url          |http://192.168.1.11:9292         |

+--------------+----------------------------------+

4、启动glance

[root@controller ~]# systemctl enable openstack-glance-api

[root@controller ~]# systemctl enable openstack-glance-registry

[root@controller ~]# systemctl start openstack-glance-api

[root@controller ~]# systemctl start openstack-glance-registry

5、添加glance环境变量

[root@controller ~]# echo "export OS_IMAGE_API_VERSION=2" \

| tee -a admin-openrc.sh kevin-openrc.sh

6、验证是否安装成功

[root@controller ~]# glance p_w_picpath-list

+----+------+

| ID | Name |

+----+------+

+----+------+

7、上传镜像

下载cirros镜像,该镜像为大约13M大小的镜像

[root@controller ~]# wget https://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

[root@controller ~]# rm -f cirros-0.3.4-x86_64-disk.img

[root@controller ~]#

[root@controller ~]# glance p_w_picpath-create --name "cirros" \

--file cirros-0.3.4-x86_64-disk.img \

--disk-fORMat qcow2 --container-format bare \

--visibility public --progress    //要在镜像当前目录执行

[=============================>] 100%

+------------------+--------------------------------------+

| Property         | Value                                |

+------------------+--------------------------------------+

| checksum         |ee1eca47dc88f4879d8a229cc70a07c6     |

| container_format | bare                                 |

| created_at       |2015-12-28T07:20:25Z                 |

| disk_format      | qcow2                                |

| id               |de72b13d-3f0f-4292-9afa-30c94175c3b5 |

| min_disk         | 0                                    |

| min_ram          | 0                                    |

| name             | cirros                               |

| owner            |69d1967e59d247e6b7c4c3937d5baa89     |

| protected        | False                                |

| size             | 13287936                             |

| status           | active                               |

| tags             | []                                   |

| updated_at       |2015-12-28T07:20:26Z                 |

| virtual_size     | None                                 |

| visibility       | public                               |

+------------------+--------------------------------------+

root@controller ~]# glance p_w_picpath-list

+--------------------------------------+--------+

| ID                                   | Name   |

+--------------------------------------+--------+

| de72b13d-3f0f-4292-9afa-30c94175c3b5 | cirros |

+--------------------------------------+--------+

linux运维开发技术交流群:298324302

北京linux运维求职招聘群:153677549

相关文章