7)openstack 扩充计算节点

使用一断时间之后,玩的正hgin,创建一个新主机报错了:
openstack创建云主机时界面报错:错误: 实例 "xxxx" 执行所请求操作失败,实例处于错误状态。: 请稍后再试 [错误: No valid host was found. There are not enough hosts available.].
出现这种情况,大家可以去调查一下nova下的调度信息日志(nova-scheduler.log),不外乎下面资源用完了的情况:vCPU,内存,存储空间,网络。
我们假定现在是cpu和内存资源不够用了,无法创建更多虚拟机了,我们需要扩充计算节点。下面我们新增一台计算节点。
我们同样准备了一台CentOS7.2的主机,把它升级到最新,它的管理IP为192.168.25.25。
1,执行安装脚本安装。创建下面脚本,保存在任意位置,赋予执行权限,然后执行。

[root@nova-node02 ~]# vi novainstall.sh

拷贝下面内容到该文件,注意如果你的环境不是严格按照我的做的话,必要的参数自行修改。

#!/bin/sh
# openstack pike nova节点安装
# 环境 centos 7.x.1708 x86_64
# modify by Qiao

[[ `uname -r` = *el7* ]] && { echo '开启安装openstack pike nova'; } || { echo '请在CentOS7.x 环境运行';exit; }

##########################################
#参数

#获取第一块网卡名、ip地址
Net=`ip add|egrep global|awk '{ print $NF }'|head -n 1`
IP=`ip add|grep global|awk -F'[ /]+' '{ print $3 }'|head -n 1`
echo  "网卡名称:$Net"
echo  "IP地址:  $IP"

#参数
Netname=$Net        #网卡名称
MyIP=$IP            #IP地址
ControllerName="controller"  # 控制节点主机名
ControllerIP="192.168.25.24" # 控制节点IP
VncProxy="110.110.110.110"        #VNC代理controller的外网IP地址。如果没有外网地址,输入控制节点controoler的内网IP地址。
Imgdir=/data/glance #自定义glance镜像目录
VHD=/data/nova      #自定义Nova实例路径
Kvm=qemu            #QEMU或KVM ,KVM需要硬件支持

##########################################
#1、设置

echo  '关闭selinux、防火墙'
systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --state
sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config
sed -i 's/^SELINUXTYPE=.*/SELINUXTYPE=disabled/g' /etc/selinux/config
grep --color=auto '^SELINUX' /etc/selinux/config
setenforce 0

[[ -f /usr/bin/wget ]] || { yum install wget -y; } #若没wget则安装
[[ -f /usr/sbin/ntpdate ]] || { yum install ntpdate -y; } #若没ntpdate则安装

echo  '时间同步'
/usr/sbin/ntpdate ntp6.aliyun.com
echo "*/3 * * * * /usr/sbin/ntpdate ntp6.aliyun.com  &> /dev/null" > /tmp/crontab
crontab /tmp/crontab

echo  '设置hostname'
echo "$ControllerIP $ControllerName">>/etc/hosts
#使用阿里源
rm -f /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed -i '/aliyuncs.com/d' /etc/yum.repos.d/*.repo #删除阿里内网地址
echo  '自定义openstack源'
wget -O /etc/yum.repos.d/Ali-pike.repo http://elven.vip/ks/openstack/Ali-pike.repo
yum clean all && yum makecache #生成缓存

##########################################

echo  '安装nova'
yum install -y openstack-nova-compute

mkdir -p $VHD
chown -R nova:nova $VHD

echo 'nova配置'
echo '#
[DEFAULT]
instances_path='$VHD'
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack@controller
my_ip = '$MyIP'
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
osapi_compute_listen_port=8774

[api_database]
connection = mysql+pymysql://nova:nova@controller/nova_api
[database]
connection = mysql+pymysql://nova:nova@controller/nova

[api]
auth_strategy = keystone
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova

[vnc]
enabled = true
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
novncproxy_base_url = http://'$VncProxy':6080/vnc_auto.html

[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp

[placement]
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller:35357/v3
username = placement
password = placement

[scheduler]
discover_hosts_in_cells_interval = 300

[libvirt]
virt_type = '$Kvm'

#
[neutron]
url = http://controller:9696
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = neutron
service_metadata_proxy = true
metadata_proxy_shared_secret = metadata

#'>/etc/nova/nova.conf
#nova服务 配置开机自动启动
systemctl enable  libvirtd.service openstack-nova-compute.service
#启动
systemctl start  libvirtd.service openstack-nova-compute.service

这样一台计算节点就安装完了,下面我们来验证一下。
在控制节点上执行下面命令 。看到nova-compute 的节点多了,有新加的这一台主机名,且状态是正常enabled 和up的就OK了。

[root@controller ~]# source admin-openstack.sh
[root@controller ~]# openstack compute service list
+----+------------------+-------------+----------+---------+-------+----------------------------+
| ID | Binary           | Host        | Zone     | Status  | State | Updated At                 |
+----+------------------+-------------+----------+---------+-------+----------------------------+
|  1 | nova-scheduler   | controller  | internal | enabled | up    | 2018-01-29T09:48:46.000000 |
|  2 | nova-consoleauth | controller  | internal | enabled | up    | 2018-01-29T09:48:48.000000 |
|  3 | nova-conductor   | controller  | internal | enabled | up    | 2018-01-29T09:48:51.000000 |
|  8 | nova-compute     | controller  | nova     | enabled | up    | 2018-01-29T09:48:46.000000 |
|  9 | nova-compute     | nova-node01 | nova     | enabled | up    | 2018-01-29T09:48:51.000000 |
| 10 | nova-compute     | nova-node02 | nova     | enabled | up    | 2018-01-29T09:48:46.000000 |
+----+------------------+-------------+----------+---------+-------+----------------------------+

你可能感兴趣的:(7)openstack 扩充计算节点)