4.5 NOVA计算服务安装
· 下载源码包
wget https://launchpad.net/nova/essex/2012.1/+download/nova-2012.1.tar.gz -P /opt
· 安装依赖包
yum install -y python-amqplib python-carrot python-lockfile python-gflags python-netaddr python-suds python-paramiko python-feedparser python-eventlet python-greenlet python-paste
pip install Cheetah==2.4.4 python-daemon==1.5.5 Babel==0.9.6 routes==1.12.3 lxml==2.3 PasteDeploy==1.5.0 sqlalchemy-migrate==0.7.2 SQLAlchemy==0.7.3 WebOb==1.0.8
· 解压并安装NOVA计算服务
cd /opt
tar xf nova-2012.1.tar.gz
cd nova-2012.1
python setup.py install
rm -f ../nova-2012.1.tar.gz
4.6 NOVA计算服务配置
· 建立NOVA服务配置文件存放目录
mkdir /etc/nova
· 建立NOVA服务启动用户
useradd -s /sbin/nologin -m -d /var/log/nova nova
· 在/etc/nova建立nova.conf作为NOVA服务配置文件,内容如下:
[DEFAULT]
auth_strategy=keystone
bindir=/usr/bin
pybasedir=/var/lib/nova
connection_type=libvirt
debug=True
lock_path=/var/lock/nova
log-dir=/var/log/nova
my_ip=60.12.206.105
ec2_host=$my_ip
ec2_path=/services/Cloud
ec2_port=8773
ec2_scheme=http
glance_host=$my_ip
glance_port=9292
glance_api_servers=$glance_host:$glance_port
image_service=nova.image.glance.GlanceImageService
metadata_host=$my_ip
metadata_port=8775
network_manager=nova.network.manager.FlatDHCPManager
osapi_path=/v1.1/
osapi_scheme=http
rabbit_host=192.168.1.2
rabbit_password=openstack
rabbit_port=5672
rabbit_userid=guest
root_helper=sudo
s3_host=$my_ip
s3_port=3333
sql_connection=mysql://root:openstack@192.168.1.2/nova
state_path=/var/lib/nova
use_ipv6=False
use-syslog=False
verbose=True
ec2_listen=$my_ip
ec2_listen_port=8773
metadata_listen=$my_ip
metadata_listen_port=8775
osapi_compute_listen=$my_ip
osapi_compute_listen_port=8774
osapi_volume_listen=$my_ip
osapi_volume_listen_port=8776
keystone_ec2_url=http://$my_ip:5000/v2.0/ec2tokens
dhcpbridge=$bindir/nova-dhcpbridge
dhcpbridge_flagfile=/etc/nova/nova.conf
public_interface=eth0
routing_source_ip=60.12.206.99
fixed_range=10.0.0.0/24
flat_interface=eth1
flat_network_bridge=b41
force_dhcp_release=True
libvirt_type=kvm
libvirt_use_virtio_for_bridges=True
iscsi_helper=ietadm
iscsi_ip_address=$my_ip
novncproxy_base_url=http://$my_ip:6080/vnc_auto.html
· 在/etc/init.d/下建立名为nova-compute的NOVA-COMPUTE服务启动脚本,内容如下:
#!/bin/sh
#
# openstack-nova-compute OpenStack Nova Compute Worker
#
# chkconfig: - 20 80
# description: Compute workers manage computing instances on host
# machines. Through the API, commands are dispatched
# to compute workers to:
# * Run instances
# * Terminate instances
# * Reboot instances
# * Attach volumes
# * Detach volumes
# * Get console output
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $syslog
# Default-Stop: 0 1 6
# Short-Description: OpenStack Nova Compute Worker
# Description: Compute workers manage computing instances on host
# machines. Through the API, commands are dispatched
# to compute workers to:
# * Run instances
# * Terminate instances
# * Reboot instances
# * Attach volumes
# * Detach volumes
# * Get console output
### END INIT INFO
. /etc/rc.d/init.d/functions
suffix=compute
prog=openstack-nova-$suffix
exec="/usr/bin/nova-$suffix"
config="/etc/nova/nova.conf"
pidfile="/var/run/nova/nova-$suffix.pid"
logfile="/var/log/nova/$suffix.log"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/nova/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon --user nova --pidfile $pidfile "$exec --config-file=$config --logfile=$logfile &>/dev/null & echo $! > $pidfile"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
· 在/etc/init.d/下建立名为nova-network的NOVA-NETWORK服务启动脚本,内容如下:
#!/bin/sh
#
# openstack-nova-network OpenStack Nova Network Controller
#
# chkconfig: - 20 80
# description: The Network Controller manages the networking resources
# on host machines. The API server dispatches commands
# through the message queue, which are subsequently
# processed by Network Controllers.
# Specific operations include:
# * Allocate Fixed IP Addresses
# * Configuring VLANs for projects
# * Configuring networks for compute nodes
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $syslog
# Default-Stop: 0 1 6
# Short-Description: OpenStack Nova Network Controller
# Description: The Network Controller manages the networking resources
# on host machines. The API server dispatches commands
# through the message queue, which are subsequently
# processed by Network Controllers.
# Specific operations include:
# * Allocate Fixed IP Addresses
# * Configuring VLANs for projects
# * Configuring networks for compute nodes
### END INIT INFO
. /etc/rc.d/init.d/functions
suffix=network
prog=openstack-nova-$suffix
exec="/usr/bin/nova-$suffix"
config="/etc/nova/nova.conf"
pidfile="/var/run/nova/nova-$suffix.pid"
logfile="/var/log/nova/$suffix.log"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/nova/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon --user nova --pidfile $pidfile "$exec --config-file=$config --logfile=$logfile &>/dev/null & echo $! > $pidfile"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
· 配置sudo
在/etc/sudoers.d/建立nova文件,内容如下:
Defaults:nova !requiretty
Cmnd_Alias NOVACMDS = /bin/aoe-stat,
/bin/chmod,
/bin/chmod /var/lib/nova/tmp/*/root/.ssh,
/bin/chown,
/bin/chown /var/lib/nova/tmp/*/root/.ssh,
/bin/dd,
/bin/kill,
/bin/mkdir,
/bin/mount,
/bin/umount,
/sbin/aoe-discover,
/sbin/ifconfig,
/sbin/ip,
/sbin/ip6tables-restore,
/sbin/ip6tables-save,
/sbin/iptables,
/sbin/iptables-restore,
/sbin/iptables-save,
/sbin/iscsiadm,
/sbin/kpartx,
/sbin/losetup,
/sbin/lvcreate,
/sbin/lvdisplay,
/sbin/lvremove,
/sbin/pvcreate,
/sbin/route,
/sbin/tune2fs,
/sbin/vconfig,
/sbin/vgcreate,
/sbin/vgs,
/usr/bin/fusermount,
/usr/bin/guestmount,
/usr/bin/socat,
/bin/cat,
/usr/bin/tee,
/usr/bin/qemu-nbd,
/usr/bin/virsh,
/usr/sbin/brctl,
/usr/sbin/dnsmasq,
/usr/sbin/ietadm,
/usr/sbin/radvd,
/usr/sbin/tgtadm,
/usr/sbin/vblade-persist
nova ALL = (root) NOPASSWD: SETENV: NOVACMDS
chmod 0440 /etc/sudoers.d/nova
· 配置polkit策略
在/etc/polkit-1/localauthority/50-local.d/建立50-nova.pkla,内容如下:
[Allow nova libvirt management permissions]
Identity=unix-user:nova
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
· 配置启动脚本:
chmod 755 /etc/init.d/nova-compute
chmod 755 /etc/init.d/nova-network
mkdir /var/run/nova
mkdir -p /var/lib/nova/instances
mkdir /var/lock/nova
chown nova:root /var/run/nova
chown -R nova:nova /var/lib/nova
chown nova:root /var/lock/nova
· 配置MYSQL数据库
在控制节点mysql执行如下语句:
grant all on nova.* to root@'192.168.1.%' identified by 'openstack';
· 启动NOVA相关服务
/etc/init.d/nova-compute start
/etc/init.d/nova-network start
· 更改iptables允许vnc连接
iptables -I INPUT -d 60.12.206.99 -p tcp -m multiport --dports 5900:6000 -j ACCEPT
作者:趣云团队-yz