OpenStack(Queens)详细安装部署(一)-基础环境安装
本系列文章将在CentOS7环境下手动安装OpenStack Q版本,手动安装对大家问题定位能力有极大的帮助。文章如果有不正确的地方欢迎大家留言指出。
目录
安装环境准备
OpenStack官方的硬件要求如下图所示,其中虚线节点是可选部分,是块存储节点与对象存储节点,本次我们暂不安装。
本次将搭建一个简单的OpenStack平台,你需要服务器或虚拟机两台,一台作为OpenStack的控制节点,一台作为计算节点。
其中,控制节点将完成消息队列、数据库、ntp以及OpenStack相关的认证服务、镜像服务、计算服务、网络服务、界面服务的安装。计算节点将完成计算服务、网络服务的安装。
博主条件有限,使用vmware创建了两台虚拟机具体配置如下:
硬件配置
控制节点: cpu 1 ,内存 2G,网卡 2张,存储 25G
计算节点: cpu 1 ,内存 2G,网卡 2张,存储 25G
操作系统
CentOS-7-x86_64-DVD-1708.iso
( 官网下载地址:http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1708.iso )
配置ip地址
ip地址大家根据自己实际情况而定
- 控制节点第一张网卡:192.168.0.77 - 控制节点第二张网卡: - 计算节点第一张网卡:192.168.0.78 - 计算几点第二张网卡:
修改主机名
编辑文件/etc/hostname,删除原有内容,然后添加自己的主机名
控制节点
1controller
计算节点
1compute
注意:修改完成之后如果没生效,可以退出登录一次或者重启一次。
增加主机名解析
在控制节点和计算节点编辑/etc/hosts,在其中增加如下内容:
192.168.0.77 controller 192.168.0.78 compute
完成这步后,即可通过主机名互相访问。
关闭防火墙
关闭防火墙是因为踩了很多坑! 在控制节点与计算节点执行下面的操作。
systemctl disable firewalld systemctl stop firewalld
禁用selinux,避免踩坑!编辑/etc/selinux/config,将enforcing修改为disabled。
SELINUX=disabled
selinux的设置需要重启节点才能生效。
准备yum本地源
安装OpenStack的过程中下载安装包是比较慢的,因此OpenStack核心组件所有需要用到的rpm包我们已经下载并制作成了iso文件,有了这个iso文件我们就可以完全本地安装了。扫描文章下方二维码,关注扶艾微信公众号,回复fuAi_qrpm即可获取!
将下载完成的fuai_openstack_q.iso拷贝到控制节点与计算节点
创建iso挂载文件目录,并挂载iso
mkdir /opt/fuAi mount fuai_openstack_q.iso /opt/fuAi
设置开机自动挂载
echo 'mount /root/fuai_openstack_q.iso /opt/fuAi' >>/etc/rc.local chmod -R 777 /etc/rc.d/rc.local
备份原有的repo文件,并创建fuAi.repo文件
cd /etc/yum.repos.d/ mkdir bak mv CentOS* bak vi fuAi.repo
[fuAi] name=fuAi baseurl=file:///opt/fuAi/ gpgcheck=0
测试下本地源是否生效了,先安装个vim压压惊!
yum install vim -y
不出意外,vim安装成功。
至此,我们所有的准备工作已经完成,接下来就将进入OpenStack的正式安装。
OpenStack基础环境安装
注意:后面的安装的步骤中,博主会在标题前的括号中注明该步骤在哪个节点执行,这个很重要!
(控制节点)安装ntp服务
因为设置了本地源,后面的yum安装应该都很爽!
- 安装chrony
yum install chrony -y
编辑配置文件/etc/chrony.conf增加以下内容:
server controller iburst allow 192.168.0.0/24 #这个根据自己子网情况
设置服务的开机启动,并启动服务
systemctl enable chronyd systemctl start chronyd
(计算节点)安装ntp服务
安装chrony
yum install chrony -y
编辑配置文件/etc/chrony.conf增加如下内容:
server controller iburst
设置服务的开机启动,并启动服务
systemctl enable chronyd systemctl start chronyd
(控制节点、计算节点)升级软件包,安装OpenStack客户端
- 升级软件包
yum upgrade
注意:升级完成之后重启节点
安装OpenStack客户端
yum install python-openstackclient -y
安装openstack-selinux
yum install openstack-selinux -y
(控制节点)sql数据库安装
安装软件包
yum install mariadb mariadb-server python2-PyMySQL -y
创建并编辑文件/etc/my.cnf.d/openstack.cnf增加如下内容:
[mysqld] bind-address = 192.168.0.77
default-storage-engine = innodb innodb_file_per_table = on max_connections = 4096 collation-server = utf8_general_ci character-set-server = utf8
设置数据库服务的开机启动,并启动服务
systemctl enable mariadb.service systemctl start mariadb.service
为数据库设置密码
mysql_secure_installation
2 3NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB 4 SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! 5 6In order to log into MariaDB to secure it, we'll need the current 7password for the root user. If you've just installed MariaDB, and 8you haven't set the root password yet, the password will be blank, 9so you should just press enter here. 10 11Enter current password for root (enter for none): #这里直接回车 12OK, successfully used password, moving on... 13 14Setting the root password ensures that nobody can log into the MariaDB 15root user without the proper authorisation. 16 17Set root password? [Y/n] y 18New password: 19Re-enter new password: #设置数据库的root密码,我设置的fuai123 20Password updated successfully! 21Reloading privilege tables.. 22 ... Success! 23 24 25By default, a MariaDB installation has an anonymous user, allowing anyone 26to log into MariaDB without having to have a user account created for 27them. This is intended only for testing, and to make the installation 28go a bit smoother. You should remove them before moving into a 29production environment. 30 31Remove anonymous users? [Y/n] y 32 ... Success! 33 34Normally, root should only be allowed to connect from 'localhost'. This 35ensures that someone cannot guess at the root password from the network. 36 37Disallow root login remotely? [Y/n] y 38 ... Success! 39 40By default, MariaDB comes with a database named 'test' that anyone can 41access. This is also intended only for testing, and should be removed 42before moving into a production environment. 43 44Remove test database and access to it? [Y/n] y 45 - Dropping test database... 46 ... Success! 47 - Removing privileges on test database... 48 ... Success! 49 50Reloading the privilege tables will ensure that all changes made so far 51will take effect immediately. 52 53Reload privilege tables now? [Y/n] y 54 ... Success! 55 56Cleaning up... 57 58All done! If you've completed all of the above steps, your MariaDB 59installation should now be secure. 60 61Thanks for using MariaDB!
(控制节点)安装消息队列
安装软件包
yum install rabbitmq-server -y
设置消息队列服务的开机自启,并启动服务
systemctl enable rabbitmq-server.service systemctl start rabbitmq-server.service
添加openstack用户并设置openstack使用消息队列的权限
注意:下面的fuai123是我自己设置的openstack使用消息队列的密码,可以自行设置
rabbitmqctl add_user openstack fuai123 Creating user "openstack" ... rabbitmqctl set_permissions openstack ".*" ".*" ".*" Setting permissions for user "openstack" in vhost "/" ...
(控制节点)安装memcached服务
安装软件包
yum install memcached python-memcached -y
编辑/etc/sysconfig/memcached文件设置以下内容
OPTIONS="-l 127.0.0.1,::1,controller"
设置服务开机自启动,并启动服务
systemctl enable memcached.service systemctl start memcached.service
(控制节点)安装etcd服务
下载软件包
yum install etcd -y
编辑文件/etc/etcd/etcd.conf设置以下内容
1#[Member] 2#ETCD_CORS="" 3ETCD_DATA_DIR="/var/lib/etcd/default.etcd" 4#ETCD_WAL_DIR="" 5ETCD_LISTEN_PEER_URLS="http://localhost:2380" 6ETCD_LISTEN_CLIENT_URLS="http://localhost:2379" 7#ETCD_MAX_SNAPSHOTS="5" 8#ETCD_MAX_WALS="5" 9ETCD_NAME="controller" 10#ETCD_SNAPSHOT_COUNT="100000" 11#ETCD_HEARTBEAT_INTERVAL="100" 12#ETCD_ELECTION_TIMEOUT="1000" 13#ETCD_QUOTA_BACKEND_BYTES="0" 14#ETCD_MAX_REQUEST_BYTES="1572864" 15#ETCD_GRPC_KEEPALIVE_MIN_TIME="5s" 16#ETCD_GRPC_KEEPALIVE_INTERVAL="2h0m0s" 17#ETCD_GRPC_KEEPALIVE_TIMEOUT="20s" 18# 19#[Clustering] 20ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380" 21ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379" 22#ETCD_DISCOVERY="" 23#ETCD_DISCOVERY_FALLBACK="proxy" 24#ETCD_DISCOVERY_PROXY="" 25#ETCD_DISCOVERY_SRV="" 26ETCD_INITIAL_CLUSTER="controller=http://localhost:2380" 27ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" 28ETCD_INITIAL_CLUSTER_STATE="new"
设置开机服务自启动,并启动服务
systemctl enable etcd systemctl start etcd
至此,OpenStack基础环境已经安装完成,下面将进行认证服务的安装,