openstack是一个开源的云计算服务解决方案项目,应用相对广泛,值得进行学习一下,首先搭建一套nova环境,对openstack的认识,以及后面的源码分析都很有必要。
(首先准备一台学习主机,个人这里使用个人电脑并搭建一台虚拟机centos7.2)
约定:
- 以下所有操作默认都在 root 用户下进行操作,如有特殊将会说明
- xxxxxxxx 为密码, 需指定
一. 安装前准备工作
-
配置网络,可以访问外网(如果环境是虚拟机,则虚拟机也需要访问外网)
-
关闭主机上不用的服务
systemctl disable NetworkManager
systemctl stop NetworkManager
systemctl disable firewalld.service
systemctl stop firewalld.service
- 关闭selinux
vi /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled (重启主机生效)
- 修改/etc/hosts 将集群所有主机hosts解析加入列表,如:
192.168.137.15 nova
- 配置dns:
注: (如果是本地虚拟机可以更改为本地主机的dns ip)
vi /etc/resolv.conf
nameserver 8.8.8.8
- 配置yum源:
这里配置阿里源
(若本地有yum源且有安装需要的所有包,则可以不用访问外网)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
二. 安装
- 配置指定安装的openstack版本:
注: 一些版本官方可能已经停止维护,因此建议使用最新的列表中的版本, 不建议按照网上的命令直接执行,下面有具体的方法
yum list 查看目前支持的openstack 版本,再选择安装
yum list | grep centos-release-openstack
centos-release-openstack-ocata.noarch
centos-release-openstack-pike.x86_64
centos-release-openstack-queens.noarch
centos-release-openstack-rocky.noarch
这里看到支持最新的 O P Q R 4个版本
我这里安装O版
yum install centos-release-openstack-ocata -y
安装client
yum install python-openstackclient -y
这里openstack 的yum源及一些基本配置已经准备完成,下面是各个组件的具体安装
- 安装本地mysql库(若已经有mysql库,则创建对应用户即可)
yum install mariadb mariadb-server python2-PyMySQL -y
systemctl enable mariadb.service
systemctl start mariadb.service
安装完成后可在/etc/my.cnf修改mysql参数,这里先使用默认配置即可
进入myslq验证
[root@nova ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> exit
验证ok,mysql 组件准备完成
- 安装rabbitmq:
rabbit是openstack用来传递消息的消息队列,也非常重要
yum install rabbitmq-server -y
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
如果有多个controller则需要将rabbitmq配置为集群(这里测试,不做集群,略)
rabbitmqctl add_user openstack xxxxx
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
- 安装memcache
yum install -y memcached
修改配置文件
vi /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="4096"
OPTIONS=""
- 安装openstack的rpm包:
这里将openstack的一些组件包一次性安装完成
yum install -y openstack-keystone httpd mod_wsgi openstack-glance openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-compute sysfsutils openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch python-openvswi