返回目录
OpenStack脚本controlller端部署
function UserJudgment() {
read -p "当前的主机名为${HOSTNAME},是否修改(y/n):"
echo -n "正在改名....."
dop1=controller
hostnamectl set-hostname ${dop1}
bash
}
function BasicConfig() {
systemctl disable --now firewalld
setenforce 0
echo "192.168.100.10 controller" >>/etc/hosts
echo "192.168.100.20 compute" >>/etc/hosts
}
function MountImage() {
mkdir -p /opt/centos /opt/iaas
echo "/dev/cdrom /opt/centos iso9660 defaults 0 0" >>/etc/fstab
echo "/opt/chinaskills_cloud_iaas.iso /opt/iaas iso9660 defaults 0 0" >>/etc/fstab
mount -a
}
function YUMConfig() {
rm -rf /etc/yum.repos.d/*
touch /etc/yum.repos.d/local.repo
echo -e "[centos]\nname=centos\nbaseurl=file:///opt/centos\nenabled=1\ngpgcheck=0" >>/etc/yum.repos.d/local.repo
echo -e "[iaas]\nname=iaas\nbaseurl=file:///opt/iaas/iaas-repo\nenabled=1\ngpgcheck=0" >>/etc/yum.repos.d/local.repo
yum makecache
}
function FTPConfig() {
yum -y install vsftpd
echo "anon_root=/opt" >>/etc/vsftpd/vsftpd.conf
systemctl start vsftpd && systemctl enable vsftpd
}
function SSHConfig() {
yum install -y expect
systemctl daemon-reload
echo "StrictHostKeyChecking no" >>/etc/ssh/ssh_config
expect -c "
spawn ssh-keygen
expect \"(/root/.ssh/id_rsa):\"
send \"\r\"
expect \"(empty for no passphrase):\"
send \"\r\"
expect \"passphrase again\"
send \"\r\"
expect eof
"
expect -c "
spawn ssh-copy-id 192.168.100.10
expect \"password: \"
send \"000000\r\"
expect eof
"
expect -c "
spawn ssh-copy-id 192.168.100.20
expect \"password: \"
send \"000000\r\"
expect eof
"
}
function IaaSConfig() {
yum install -y iaas-xiandian
sed -i "3c HOST_IP=192.168.100.10" /etc/xiandian/openrc.sh
sed -i "6c HOST_PASS=000000" /etc/xiandian/openrc.sh
sed -i "9c HOST_NAME=controller" /etc/xiandian/openrc.sh
sed -i "12c HOST_IP_NODE=192.168.100.20" /etc/xiandian/openrc.sh
sed -i "15c HOST_PASS_NODE=000000" /etc/xiandian/openrc.sh
sed -i "18c HOST_NAME_NODE=compute" /etc/xiandian/openrc.sh
sed -i "22c network_segment_IP=192.168.100.0/24" /etc/xiandian/openrc.sh
sed -i "26c RABBIT_USER=openstack" /etc/xiandian/openrc.sh
sed -i "29c RABBIT_PASS=000000" /etc/xiandian/openrc.sh
sed -i "33c DB_PASS=000000" /etc/xiandian/openrc.sh
sed -i "37c DOMAIN_NAME=demo" /etc/xiandian/openrc.sh
sed -i "38c ADMIN_PASS=000000" /etc/xiandian/openrc.sh
sed -i "39c DEMO_PASS=000000" /etc/xiandian/openrc.sh
sed -i "42c KEYSTONE_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "46c GLANCE_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "49c GLANCE_PASS=000000" /etc/xiandian/openrc.sh
sed -i "53c NOVA_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "56c NOVA_PASS=000000" /etc/xiandian/openrc.sh
sed -i "60c NEUTRON_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "63c NEUTRON_PASS=000000" /etc/xiandian/openrc.sh
sed -i "66c METADATA_SECRET=000000" /etc/xiandian/openrc.sh
sed -i "69c INTERFACE_IP=192.168.100.10" /etc/xiandian/openrc.sh
sed -i "72c INTERFACE_NAME=ens33" /etc/xiandian/openrc.sh
sed -i "75c Physical_NAME=provider" /etc/xiandian/openrc.sh
sed -i "78c minvlan=101" /etc/xiandian/openrc.sh
sed -i "81c maxvlan=200" /etc/xiandian/openrc.sh
sed -i "85c CINDER_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "88c CINDER_PASS=000000" /etc/xiandian/openrc.sh
sed -i "91c BLOCK_DISK=sdb1" /etc/xiandian/openrc.sh
sed -i "95c SWIFT_PASS=000000" /etc/xiandian/openrc.sh
sed -i "98c OBJECT_DISK=sdb2" /etc/xiandian/openrc.sh
sed -i "101c STORAGE_LOCAL_NET_IP=192.168.100.20" /etc/xiandian/openrc.sh
sed -i "105c HEAT_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "108c HEAT_PASS=000000" /etc/xiandian/openrc.sh
sed -i "112c ZUN_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "115c ZUN_PASS=000000" /etc/xiandian/openrc.sh
sed -i "118c KURYR_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "121c KURYR_PASS=000000" /etc/xiandian/openrc.sh
sed -i "125c CEILOMETER_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "128c CEILOMETER_PASS=000000" /etc/xiandian/openrc.sh
sed -i "132c AODH_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "135c AODH_PASS=000000" /etc/xiandian/openrc.sh
sed -i "139c BARBICAN_DBPASS=000000" /etc/xiandian/openrc.sh
sed -i "142c BARBICAN_PASS=000000" /etc/xiandian/openrc.sh
source /etc/xiandian/openrc.sh
}
function IaaSInstallation() {
iaas-pre-host.sh
iaas-install-mysql.sh
iaas-install-keystone.sh
iaas-install-glance.sh
iaas-install-nova-controller.sh
iaas-install-neutron-controller.sh
iaas-install-dashboard.sh
}
function ResultJudgment() {
source /etc/keystone/admin-openrc.sh
TEST=$(openstack service list | egrep 'placement|keystone|glance|nova|neutron' -wc)
if [ $TEST -eq "5" ]; then
echo -e "\033[32m -------------- controller 控制节点部署完成,服务启动正常 -------------- \033[0m"
else
echo -e '\033[31m ------------ !!!最小化部署失败 !!! --------------- \033[0m'
fi
}
UserJudgment
BasicConfig
MountImage
YUMConfig
FTPConfig
SSHConfig
IaaSConfig
IaaSInstallation
ResultJudgment
OpenStack脚本compute端部署
function UserJudgment() {
read -p "当前的主机名为${HOSTNAME},是否修改(y/n):"
echo -n "正在改名....."
dop1=compute
hostnamectl set-hostname ${dop1}
bash
}
function BasicConfig() {
systemctl disable --now firewalld
setenforce 0
echo "192.168.100.10 controller" >>/etc/hosts
echo "192.168.100.20 compute" >>/etc/hosts
}
function YUMConfig() {
rm -rf /etc/yum.repos.d/*
touch /etc/yum.repos.d/ftp.repo
echo -e "[centos]\nname=centos\nbaseurl=ftp://controller/centos\nenabled=1\ngpgcheck=0" >>/etc/yum.repos.d/ftp.repo
echo -e "[iaas]\nname=iaas\nbaseurl=ftp://controller/iaas/iaas-repo\nenabled=1\ngpgcheck=0" >>/etc/yum.repos.d/ftp.repo
yum makecache
}
function SSHConfig() {
yum install -y expect
systemctl daemon-reload
echo "StrictHostKeyChecking no" >>/etc/ssh/ssh_config
expect -c "
spawn ssh-keygen
expect \"(/root/.ssh/id_rsa):\"
send \"\r\"
expect \"(empty for no passphrase):\"
send \"\r\"
expect \"passphrase again\"
send \"\r\"
expect eof
"
expect -c "
spawn ssh-copy-id 192.168.100.10
expect \"password: \"
send \"000000\r\"
expect eof
"
expect -c "
spawn ssh-copy-id 192.168.100.20
expect \"password: \"
send \"000000\r\"
expect eof
"
}
function IaaSConfig() {
yum install -y iaas-xiandian
scp root@controller:/etc/xiandian/openrc.sh /etc/xiandian
sed -i "69c INTERFACE_IP=192.168.100.20" /etc/xiandian/openrc.sh
source /etc/xiandian/openrc.sh
}
function IaaSInstallation() {
iaas-pre-host.sh
iaas-install-nova-compute.sh
iaas-install-neutron-compute.sh
}
function FixError() {
crudini --set /etc/nova/nova.conf libvirt virt_type qemu
systemctl restart libvirtd.service openstack-nova-compute.service
}
function ResultJudgment() {
scp root@controller:/etc/keystone/admin-openrc.sh /root/
source /root/admin-openrc.sh
TEST=$(openstack compute service list | egrep 'nova-consoleauth|nova-conductor|nova-scheduler|nova-compute' -wc)
if [ $TEST -eq "4" ]; then
echo -e "\033[32m -------------- openstack 最小化部署成功 -------------- \033[0m"
else
echo -e '\033[31m ------------ !!!最小化部署失败 !!! --------------- \033[0m'
fi
rm -rf /root/admin-openrc.sh
}
UserJudgment
BasicConfig
YUMConfig
SSHConfig
IaaSConfig
IaaSInstallation
FixError
ResultJudgment
OpenStack脚本controllor端添加为计算节点
sed -i "12c HOST_IP_NODE=192.168.100.10" /etc/xiandian/openrc.sh
sed -i "18c HOST_NAME_NODE=controller" /etc/xiandian/openrc.sh
iaas-install-nova-compute.sh