compute节点 shell脚本一键部署(Q版)
注意变量:
vi openrc.sh
HOST_IP=
HOST_NAME=controller
HOST_IP_NODE=
HOST_NAME_NODE=compute
RABBIT_USER=openstack
RABBIT_PASS=
DB_PASS=
DOMAIN_NAME=default
ADMIN_PASS=
DEMO_PASS=
KEYSTONE_DBPASS=
GLANCE_DBPASS=
GLANCE_PASS=
NOVA_DBPASS=
NOVA_PASS=
NEUTRON_DBPASS=
NEUTRON_PASS=
#!/bin/bash
source openrc.sh
#配置主机名
echo "配置主机名"
sleep 3
ip=`ifconfig |grep -w inet|awk 'NR==1{print$2}'`
if [[ $ip == $HOST_IP ]];then
hostnamectl set-homename $HOST_NAME
else
hostnamectl set-homename $HOST_NAME_NODE
fi
#配置映射
echo "配置映射"
sleep 3
echo "$HOST_IP $HOST_NAME" >> /etc/hosts
echo "$HOST_IP_NODE $HOST_NAME_NODE" >> /etc/hosts
#配置防火墙和SELinux
echo "配置防火墙和SELinux"
iptables -F
iptables -X
iptables -Z
/usr/sbin/iptables-save
#配置时间同步服务
echo "配置时间同步服务"
sleep 3
yum install -y chrony
name=`hostname`
if [[ $name == $HOST_NAME ]];then
sed -i '3,6s/^/#/g' /etc/chrony.conf
echo "local stratum 10" >>/etc/chrony.conf
echo "server controller iburst" >>/etc/chrony.conf
echo "allow 10.32.24.0/23" >>/etc/chrony.conf
systemctl enable chronyd.service
systemctl start chronyd.service
else
sed -i '3,6s/^/#/g' /etc/chrony.conf
echo "local stratum 10" >>/etc/chrony.conf
echo "server controller iburst" >>/etc/chrony.conf
systemctl enable chronyd.service
systemctl start chronyd.service
chronyc sources
fi
#更新yum源
更新yum源
sleep 3
yum upgrade -y
rm -rfv /etc/yum.repos.d/C*
#配置DNS
配置DNS
yum install -y bind
sed -i -e '13,14s/^/\/\//g' \
-e '19s/^/\/\//g' \
-e '31s/yes/no/g' \
-e '33s/yes/no/g' \
-e '34s/yes/no/g' \
-e '37s/^/\/\//g' \
-e '39s/^/\/\//g' \
-e '41s/^/\/\//g' \
-e '42s/^/\/\//g' /etc/named.conf
yum install -y openstack-config
yum install -y crudini
rpm -ivh openstack-utils-2015.21+git.1451948894.092baf8-9.1.noarch.rpm
#配置nova服务
echo "配置nova服务"
yum install -y openstack-nova-compute
openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:$NOVA_PASS@$HOST_IP
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 10.32.24.82
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron True
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://$HOST_IP:5000
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://$HOST_IP:35357
openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers $HOST_IP:11211
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password password
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name $DOMAIN_NAME
openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name $DOMAIN_NAME
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
openstack-config --set /etc/nova/nova.conf keystone_authtoken password $NOVA_PASS
openstack-config --set /etc/nova/nova.conf vnc enabled True
openstack-config --set /etc/nova/nova.conf vnc server_listen 0.0.0.0
openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address $HOST_IP_NODE
openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url http://$HOST_IP:6080/vnc_auto.html
openstack-config --set /etc/nova/nova.conf glance api_servers http://$HOST_IP:9292
openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp
openstack-config --set /etc/nova/nova.conf placement os_region_name RegionOne
openstack-config --set /etc/nova/nova.conf placement project_domain_name Default
openstack-config --set /etc/nova/nova.conf placement project_name service
openstack-config --set /etc/nova/nova.conf placement auth_type password
openstack-config --set /etc/nova/nova.conf placement user_domain_name Default
openstack-config --set /etc/nova/nova.conf placement auth_url http://$HOST_IP:35357/v3
openstack-config --set /etc/nova/nova.conf placement username placement
openstack-config --set /etc/nova/nova.conf placement password $NOVA_PASS
systemctl start libvirtd.service openstack-nova-compute.service
systemctl enable libvirtd.service openstack-nova-compute.service
#配置neutron服务
echo "配置neutron服务"
yum install openstack-neutron-linuxbridge ebtables ipset -y
openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:000000@$HOST_IP
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_uri http://$HOST_IP:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://$HOST_IP:35357
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers $HOST_IP:11211
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password 000000
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:eth1
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip $INTERFACE_IP
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
openstack-config --set /etc/nova/nova.conf neutron url http://$HOST_IP:9696
openstack-config --set /etc/nova/nova.conf neutron auth_url http://$HOST_IP:35357
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password 000000
systemctl restart openstack-nova-compute.service