OpenStack搭建之环境配置(一)

文章
林里克斯

Linux下搭建OpenStack之环境安装


一、实验平台:CentOS Linux release 7.3.1611 (Core)

二、openstack版本:Mitake

三、本机所有IP:

内网(OpenStack通信):192.168.1.2 192.168.1.3

外网(与宿主机通信):192.168.2.4 192.168.2.5

四、openstack1:192.168.1.2 #控制节点 1 处理器, 4 GB 内存, 及20 GB 存储

五、openstack2:192.168.1.3 #计算节点 1 处理器, 2 GB 内存, 及20 GB 存储

OpenStack搭建之环境配置(一)



一、环境配置(请保持一致)


1.编辑/etc/sysconfig/network-scripts/ifcfg-eth0

$ pwd
/etc/sysconfig/network-scripts/
$ vim ifcfg-eth0

TYPE=Ethernet
#BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCon\=yes
#IPV6_DEFROUTE=yes
#IPV6_PEERDNS=yes
#IPV6_PEERROUTES=yes
#IPV6_FAILURE_FATAL=no
UUID=ffa4c7b8-32da-4154-8d49-fb0520630108
HWADDR="00:0C:29:D1:88:17"
DEVICE=eth0
NAME=eth0
ONBOOT=yes
IPADDR=192.168.1.2

因为这块是内网网卡只需要一个IP地址与我主机互通即可(虚拟机中为主机模式)

$ vim ifcfg-eth1

TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCon\=yes
#IPV6_DEFROUTE=yes
#IPV6_PEERDNS=yes
#IPV6_PEERROUTES=yes
#IPV6_FAILURE_FATAL=no
UUID=ffb3037a-34c4-488a-bdb5-8bfe928be900
HWADDR="00:0C:29:D1:88:21"
DEVICE=eth1
NAME=eth1
ONBOOT=yes
DNS1=114.114.114.114
DNS2=8.8.8.8

因为这是一块外网卡是要与Internet互通的,所以打开了dhcp获取IP并添加了两个DNS(虚拟机为NAT模式)。 提示最好将IPV6的配置项注释掉,因为会影响yum源的安装。

2.配置域名解析

控制节点主机名为openstack1 计算节点主机名为openstack2

$ vim /etc/hosts

192.168.1.2     openstack1
192.168.1.3     openstack2

第二台计算节点相同操作

3.配置时间服务器

可以自己搭建时间服务器,也可同步国内阿里时间服务器(保持节点间时间一致即可)

$ yum -y install ntpdate                                  #yum源安装    
$ cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime     #拷贝时区,如果时区已经正确可以省略这一步
$ ntpdate time1.aliyun.com                                #同步阿里云服务器
12 Jul 08:47:12 ntpdate[5062]: step time server 115.28.122.198 offset -28768.398524 sec

$ date
Wed Jul 12 08:45:47 CST 2017

$ crontab -e
*/3 * * * * /usr/sbin/ntpdate time1.aliyun.com > /dev/null
$ crontab -l
*/3 * * * * /usr/sbin/ntpdate time1.aliyun.com > /dev/null

关闭防火墙和selinux(有需要我们再将他打开,为了测试暂时关闭)

$ systemctl disable firewalld.service
$ systemctl stop firewalld.service

第二台计算节点相同操作


二、Openstack包


CentOS中,extras仓库提供用于启用 OpenStack 仓库的RPM包。CentOS 默认启用extras仓库,因此你可以直接安装用于启用OpenStack仓库的包。

$ yum -y install centos-release-openstack-mitaka
#安装完成后会在/etc/yum.repos.d/下生成CentOS-OpenStack-mitaka.repo

在主机上升级包: yum upgrade 如果更新了一个新内核,重启主机来使用新内核。

安装 OpenStack 客户端:

$ yum -y install python-openstackclient
#会把openstack常用的客户端都进行安装

CentOS默认启用了SELinux安装openstack-selinux软件包以便自动管理OpenStack服务的安全策略:

$ yum -y install openstack-selinux

三、数据库


1.MySQL数据库,CentOS 7+ 系统MySQL数据库更名为mariadb

大多数OpenStack 服务使用 SQL 数据库来存储信息。 典型地,数据库运行在控制节点上。

安装软件包:

$ yum -y install mariadb mariadb-server python2-PyMySQL #数据库运行在控制节点上

创建并编辑 /etc/my.cnf.d/openstack.cnf

$ vim /etc/my.cnf.d/openstack.cnf

[mysqld]
bind-address = 192.168.1.2          #监听的IP地址(也可以写0.0.0.0)
default-storage-engine = innodb     #默认存储引擎[innodb]
innodb_file_per_table = on          #使用独享表空间
max_connections = 4096              #最大连接数是4096 (默认是1024)
collation-server = utf8_general_ci  #数据库默认校对规则
character-set-server = utf8         #默认字符集

启动数据库服务,并将其配置为开机自启:

$ systemctl enable mariadb.service
$ systemctl start mariadb.service

为了保证数据库服务的安全性,运行mysql-secure-installation脚本创建root密码

$ mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):   #直接回车设置root密码
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:               #设置root密码,此处设置为redhat
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]           #回车
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]     #回车
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]    #回车
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]          #回车
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

2.NoSQL 数据库

Telemetry服务使用NoSQL数据库来存储信息,典型地,这个数据库运行在控制节点上。如果你的openstack不想使用Telemetry服务,你可以省略此步骤。

安装MongoDB包:

$ yum -y install mongodb-server mongodb

编辑文件 /etc/mongod.conf

$ vim /etc/mongod.conf

bind_ip = 192.168.1.2   #配置 bind_ip 使用控制节点管理网卡的IP地址
smallfiles = true       #默认情况下,MongoDB会在/var/lib/mongodb/journal目录下创建几个 1 GB 大小的日志文件。如果你想将每个日志文件大小减小到128MB并且限制日志文件占用的总空间为512MB,配置 smallfiles 的值.你也可以禁用日志。

启动MongoDB并配置它随系统启动:

$ systemctl enable mongod.service
$ systemctl start mongod.service

四、消息队列


消息队列服务一般运行在控制节点上.

OpenStack支持好几种消息队列服务包括 RabbitMQ, Qpid, 和ZeroMQ。不过,大多数发行版本的OpenStack包支持特定的消息队列服务。 本指南安装RabbitMQ消息队列服务,因为大部分发行版本都支持它。

安装包:

$ yum -y install rabbitmq-server

rabbitmq有很多插件,我们可以使用rabbitmq-plugins list查看可用插件 rabbitmq-management插件提供一个web界面,所以我们要将它开启 使rabbitmq-plugins enable rabbitmq-management安装插件

$ rabbitmq-plugins enable rabbitmq_management        #rabbitmq启动之后会监听15672

The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management

Applying plugin configuration to rabbit@openstack1... failed.
 * Could not contact node rabbit@openstack1.
   Changes will take effect at broker restart.
 * Options: --online  - fail if broker cannot be contacted.
            --offline - do not try to contact broker.

启动消息队列服务并将其配置为随系统启动:

$ systemctl enable rabbitmq-server.service
$ systemctl start rabbitmq-server.service

访问路径:

http://192.168.1.2:15672

默认Username:guest
默认Password:guest

添加 openstack 用户:

$ rabbitmqctl add_user openstack openstack #后面个openstack是密码
Creating user "openstack" ...

openstack用户配置写和读权限

$ rabbitmqctl set_permissions openstack ".*" ".*" ".*"

Setting permissions for user "openstack" in vhost "/" ...

五、缓存服务(Memecached)


1.认证服务认证缓存使用Memcached缓存令牌。缓存服务memecached运行在控制节点。

安装软件包:

$ yum -y install memcached python-memcached

2.启动Memcached服务,并且配置它随机启动。

$ systemctl enable memcached.service
$ systemctl start memcached.service

查看配置信息

$ cat /etc/sysconfig/memcached
PORT="11211"      #端口号
USER="memcached"  #用户
MAXCONN="1024"    #最大连接数
CACHESIZE="64"    #大小64兆
OPTIONS=""

环境配置Over~

版权协议须知!

本篇文章来源于 Uambiguous ,如本文章侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意

930 0 2017-01-13


分享:
icon_mrgreen.gificon_neutral.gificon_twisted.gificon_arrow.gificon_eek.gificon_smile.gificon_confused.gificon_cool.gificon_evil.gificon_biggrin.gificon_idea.gificon_redface.gificon_razz.gificon_rolleyes.gificon_wink.gificon_cry.gificon_surprised.gificon_lol.gificon_mad.gificon_sad.gificon_exclaim.gificon_question.gif
博主卡片
林里克斯 博主大人
一个致力于Linux的运维平台
运维时间
搭建这个平台,只为分享及记载自己所遇之事和难题。

现在时间 2024-04-23

今日天气
站点统计
  • 文章总数:240篇
  • 分类总数:29个
  • 评论总数:10条
  • 本站总访问量 214816 次

@奥奥

@Wong arrhenius 牛比

@MakerFace 厉害了!