一、初识openstack
OpenStack是一个由NASA(美国国家航空航天局)和Rackspace合作研发并发起的,以Apache许可证授权的自由软件和开放源代码项目。
OpenStack是一个开源的云计算管理平台项目,由几个主要的组件组合起来完成具体工作。OpenStack支持几乎所有类型的云环境,项目目标是提供实施简单、可大规模扩展、丰富、标准统一的云计算管理平台。OpenStack通过各种互补的服务提供了基础设施即服务(IaaS)的解决方案,每个服务提供API以进行集成。
OpenStack是一个旨在为公共及私有云的建设与管理提供软件的开源项目。它的社区拥有超过130家企业及1350位开发者,这些机构与个人都将OpenStack作为基础设施即服务(IaaS)资源的通用前端。OpenStack项目的首要任务是简化云的部署过程并为其带来良好的可扩展性。
二、openstack的核心项目
三、基本环境搭建
1.配置主机网络
(1)配置双网卡,eth1不需要ip只需要开启即可
[root@server1 ~]# cd /etc/sysconfig/network-scripts/
[root@server1 network-scripts]# ls
[root@server1 network-scripts]# cp ifcfg-eth0 ifcfg-eth1
[root@server1 network-scripts]# vim ifcfg-eth1
[root@server1 network-scripts]# cat ifcfg-eth1
BOOTPROTO=none
DEVICE=eth1
ONBOOT=yes
[root@server1 network-scripts]# ifup eth1
[root@server1 network-scripts]# ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:5c:aa:68 brd ff:ff:ff:ff:ff:ff
inet 172.25.43.1/24 brd 172.25.43.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe5c:aa68/64 scope link
valid_lft forever preferred_lft forever
3: eth1: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:df:ce:3b brd ff:ff:ff:ff:ff:ff
inet6 fe80::5054:ff:fedf:ce3b/64 scope link
valid_lft forever preferred_lft forever
(2)在控制节点配置域名解析,设置节点主机名为 controller
[root@server1 ~]# hostnamectl set-hostname controller
[root@server1 ~]# vim /etc/hosts
172.25.43.1 controller
172.25.43.2 compute1
172.25.43.3 block1
(3)在计算节点配置域名解析,设置节点主机名为compute1
[root@server2 ~]# hostnamectl set-hostname compute1
[root@server2 ~]# vim /etc/hosts
172.25.43.1 controller
172.25.43.2 compute1
172.25.43.3 block1
2.配置网络时间协议
(1)在宿主机上配置时间同步,设置跟172.25.254.250这台主机时间同步,允许172.25.也就是允许自己的虚拟机同步服务,重启服务
[root@foundation43 Desktop]# vim /etc/chrony.conf
server 172.25.254.250 iburst
allow 172.25/16
[root@foundation43 Desktop]# systemctl restart chronyd
(2)在控制节点服务器上安装时间同步软件,设置跟宿主机时间同步,开启服务
[root@server1 ~]# yum install chrony -y
[root@server1 ~]# vim /etc/chrony.conf
server 172.25.43.250 iburst
[root@server1 ~]# systemctl start chronyd
[root@server1 ~]# chronyc sources -v
210 Number of sources = 1
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* foundation43.ilt.example. 4 6 17 11 -2829ns[-5000ns] +/- 75ms
3.配置新的yum源
[root@server1 ~]# cd /etc/yum.repos.d/
[root@server1 yum.repos.d]# ls
redhat.repo westos.repo
[root@server1 yum.repos.d]# vim openstack.repo
[root@server1 yum.repos.d]# cat openstack.repo
[openstack]
name=mitaka
baseurl=http://172.25.43.250:/mitaka/
gpgcheck=0
[root@server1 yum.repos.d]# yum repolist
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
openstack | 2.9 kB 00:00
openstack/primary_db | 141 kB 00:00
repo id repo name status
openstack mitaka 279
rhel7.3 rhel7.3 4,751
repolist: 5,030
4.更新一下yum源
[root@server1 yum.repos.d]# yum upgrade -y
6.安装OpenStack 客户端
[root@server1 yum.repos.d]# yum install python-openstackclient -y
7.设置selinux为disabled
[root@server1 ~]# getenforce
Disabled
[root@server1 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
8.配置sql数据库
(1)安装软件包
[root@controller ~]# yum install mariadb mariadb-server python2-PyMySQL -y
(2)创建并编辑 /etc/my.cnf.d/openstack.cnf
[root@controller ~]# vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 172.25.43.1
设置启动
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096 最大连接
collation-server = utf8_general_ci
character-set-server = utf8
(3)启动数据库服务,并将其配置为开机自启
[root@controller ~]# systemctl enable mariadb.service
[root@controller ~]# systemctl start mariadb.service
(4)为了保证数据库服务的安全性,进行安全初始化
[root@controller ~]# mysql_secure_installation
9.配置消息队列
(1)安装安装包
[root@controller ~]# yum install rabbitmq-server -y
(2)启动消息队列服务并将其配置为随系统启动
[root@controller ~]# systemctl start rabbitmq-server.service
[root@controller ~]# systemctl enable rabbitmq-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
(3)添加 openstack 用户
[root@controller ~]# rabbitmqctl add_user openstack openstack
Creating user "openstack" ...
(4)给openstack用户配置写和读权限
[root@controller ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...
(5)列出消息队列的插件
[root@controller ~]# rabbitmq-plugins list
Configured: E = explicitly enabled; e = implicitly enabled
| Status: * = running on rabbit@controller
|/
[ ] amqp_client 3.6.5
[ ] cowboy 1.0.3
[ ] cowlib 1.0.1
[ ] mochiweb 2.13.1
[ ] rabbitmq_amqp1_0 3.6.5
[ ] rabbitmq_auth_backend_ldap 3.6.5
[ ] rabbitmq_auth_mechanism_ssl 3.6.5
[ ] rabbitmq_consistent_hash_exchange 3.6.5
[ ] rabbitmq_event_exchange 3.6.5
[ ] rabbitmq_federation 3.6.5
[ ] rabbitmq_federation_management 3.6.5
[ ] rabbitmq_jms_topic_exchange 3.6.5
[ ] rabbitmq_management 3.6.5
[ ] rabbitmq_management_agent 3.6.5
[ ] rabbitmq_management_visualiser 3.6.5
[ ] rabbitmq_mqtt 3.6.5
[ ] rabbitmq_recent_history_exchange 1.2.1
[ ] rabbitmq_sharding 0.1.0
[ ] rabbitmq_shovel 3.6.5
[ ] rabbitmq_shovel_management 3.6.5
[ ] rabbitmq_stomp 3.6.5
[ ] rabbitmq_top 3.6.5
[ ] rabbitmq_tracing 3.6.5
[ ] rabbitmq_trust_store 3.6.5
[ ] rabbitmq_web_dispatch 3.6.5
[ ] rabbitmq_web_stomp 3.6.5
[ ] rabbitmq_web_stomp_examples 3.6.5
[ ] sockjs 0.3.4
[ ] webmachine 1.10.3
(6)消息队列服务设为开机自启动
[root@controller ~]# rabbitmq-plugins enable rabbitmq_management
(7)查看15672端口是否开启
[root@controller ~]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 172.25.43.1:3306 0.0.0.0:* LISTEN 1784/mysqld
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 868/sshd
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 1945/beam.smp
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 963/master
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 1945/beam.smp
tcp 0 0 172.25.43.1:59274 172.25.43.1:25672 TIME_WAIT -
tcp 0 0 127.0.0.1:41680 127.0.0.1:4369 TIME_WAIT -
tcp 0 0 127.0.0.1:4369 127.0.0.1:37983 ESTABLISHED 2037/epmd
tcp 0 0 172.25.43.1:4369 172.25.43.1:42295 TIME_WAIT -
tcp 0 0 172.25.43.1:4369 172.25.43.1:45702 TIME_WAIT -
tcp 0 0 127.0.0.1:37983 127.0.0.1:4369 ESTABLISHED 1945/beam.smp
tcp 0 0 172.25.43.1:22 172.25.43.250:56604 ESTABLISHED 1220/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 868/sshd
tcp6 0 0 ::1:25 :::* LISTEN 963/master
tcp6 0 0 :::5672 :::* LISTEN 1945/beam.smp
(8)浏览器访问http://172.25.43.1:15672,用户和密码都是guest
查看权限是否正确
10.配置Memcached
(1)安装软件包
[root@controller ~]# yum install memcached python-memcached -y
(2)编辑Memcached的配置文件,注释掉最后一行
[root@controller ~]# vim /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
#OPTIONS="-l 127.0.0.1,::1"
(3)启动Memcached服务,并且配置它随机启动
[root@controller ~]# systemctl start memcached
[root@controller ~]# systemctl enable memcached
Created symlink from /etc/systemd/system/multi-user.target.wants/memcached.service to /usr/lib/systemd/system/memcached.service.
(4)查看端口11211是否开启
[root@controller ~]# netstat -antlp | grep :11211
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 3585/memcached
tcp6 0 0 :::11211 :::* LISTEN 3585/memcached