CentOS7一键安装openstack脚本
注意:有错误的话建议使用同款虚拟机,如果有快照再回到快照再次执行就好了,还有就是网络一定一定要正常,要不然也会有很多问题的。重启之后,建议保存一份快照,并且查看网络是否能使用,很重要很重要!刚配置好,无法使用sudo su - root,所以需要将用户加入sudoer组。我使用的是CentOS-7-x86_64-DVD-2009.iso镜像安装的。直接开启虚拟机就好了,最后使用root依次执行下面
·
第一步、需要一台新的CentOS7虚拟机
一定是要新的,旧的会出现很多很多问题,试了很多很多遍了!!!!!!!!!!!!!!
我使用的是CentOS-7-x86_64-DVD-2009.iso镜像安装的
第二步、配置好后将用户添加到sudoer组
刚配置好,无法使用sudo su - root,所以需要将用户加入sudoer组
1、su
#(输入密码)
2、usermod -aG wheel 用户名
3、visudo
#将下面这一行添加到文件中
%wheel ALL=(ALL) ALL
#重启一遍就好了
4、reboot
第三步、开始安装
重启之后,建议保存一份快照,并且查看网络是否能使用,很重要很重要!!!!!!!!!
ping www.baidu.com
确认上面都准备好后,将下面内容保存为 openstack.sh
#!/bin/bash
# 确保脚本以 root 权限执行
if [ "$(id -u)" -ne 0 ]; then
echo "请以 root 用户身份运行此脚本!"
exit 1
fi
# 停止并禁用防火墙
echo "停止并禁用 firewalld..."
systemctl stop firewalld
systemctl disable firewalld
# 停止并禁用 NetworkManager
echo "停止并禁用 NetworkManager..."
systemctl stop NetworkManager
systemctl disable NetworkManager
# 修改 SELinux 配置
echo "修改 SELinux 配置..."
echo -e "# This file controls the state of SELinux on the system.\n\
# SELINUX= can take one of these three values:\n\
# enforcing - SELinux security policy is enforced.\n\
# permissive - SELinux prints warnings instead of enforcing.\n\
# disabled - No SELinux policy is loaded.\n\
SELINUX=disabled\n\
# SELINUXTYPE= can take one of three values:\n\
# targeted - Targeted processes are protected,\n\
# minimum - Modification of targeted policy. Only selected processes are protected.\n\
# mls - Multi Level Security protection.\n\
SELINUXTYPE=targeted" > /etc/selinux/config
# 清空并重新设置 YUM 源
echo "清空 /etc/yum.repos.d/ 中的所有文件..."
cd /etc/yum.repos.d/
rm -rf *
echo "下载并设置阿里云 CentOS YUM 源..."
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 重建 YUM 缓存
echo "重建 YUM 缓存..."
yum makecache
# 执行系统更新
echo "更新系统..."
yum -y update
# 安装 OpenStack Stein YUM 库
echo "安装 OpenStack Stein YUM 库..."
yum -y install centos-release-openstack-stein
# 检查并确保 YUM 源文件已正确下载
echo "检查 /etc/yum.repos.d/ 目录中的文件..."
REPO_FILES=("CentOS-Base.repo" "CentOS-CR.repo" "CentOS-fasttrack.repo" "CentOS-NFS-Ganesha-28.repo" "CentOS-QEMU-EV.repo" "CentOS-Storage-common.repo" "CentOS-x86_64-kernel.repo" "CentOS-Ceph-Nautilus.repo" "CentOS-Debuginfo.repo" "CentOS-Media.repo" "CentOS-OpenStack-stein.repo" "CentOS-Sources.repo" "CentOS-Vault.repo")
for repo in "${REPO_FILES[@]}"; do
if [ ! -f "/etc/yum.repos.d/$repo" ]; then
echo "缺少文件:/etc/yum.repos.d/$repo,可能是网络问题,请检查并重新执行脚本。"
exit 1
fi
done
# 修改 OpenStack Stein YUM 源配置文件
echo "修改 CentOS-OpenStack-stein.repo 配置..."
cat <<EOF > /etc/yum.repos.d/CentOS-OpenStack-stein.repo
# CentOS-OpenStack-stein.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/Cloud for more
# information
[centos-openstack-stein]
name=CentOS-7 - OpenStack stein
baseurl=http://mirrors.aliyun.com/\$contentdir/\$releasever/cloud/\$basearch/openstack-stein/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud
exclude=sip,PyQt4
[centos-openstack-stein-test]
name=CentOS-7 - OpenStack stein Testing
baseurl=https://buildlogs.centos.org/centos/7/cloud/\$basearch/openstack-stein/
gpgcheck=0
enabled=0
exclude=sip,PyQt4
[centos-openstack-stein-debuginfo]
name=CentOS-7 - OpenStack stein - Debug
baseurl=http://debuginfo.centos.org/centos/7/cloud/\$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud
exclude=sip,PyQt4
[centos-openstack-stein-source]
name=CentOS-7 - OpenStack stein - Source
baseurl=http://vault.centos.org/centos/7/cloud/Source/openstack-stein/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud
exclude=sip,PyQt4
EOF
# 修改 Ceph Nautilus YUM 源配置文件
echo "修改 CentOS-Ceph-Nautilus.repo 配置..."
cat <<EOF > /etc/yum.repos.d/CentOS-Ceph-Nautilus.repo
# CentOS-Ceph-Nautilus.repo
#
# Please see https://wiki.centos.org/SpecialInterestGroup/Storage for more
# information
[centos-ceph-nautilus]
name=CentOS-\$releasever - Ceph Nautilus
baseurl=http://mirrors.aliyun.com/\$contentdir/\$releasever/storage/\$basearch/ceph-nautilus/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage
[centos-ceph-nautilus-test]
name=CentOS-\$releasever - Ceph Nautilus Testing
baseurl=https://buildlogs.centos.org/centos/\$releasever/storage/\$basearch/ceph-nautilus/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage
[centos-ceph-nautilus-source]
name=CentOS-\$releasever - Ceph Nautilus Source
baseurl=http://vault.centos.org/\$contentdir/\$releasever/storage/Source/ceph-nautilus/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage
EOF
# 修改 QEMU EV YUM 源配置文件
echo "修改 CentOS-QEMU-EV.repo 配置..."
cat <<EOF > /etc/yum.repos.d/CentOS-QEMU-EV.repo
# CentOS-QEMU-EV.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/Virtualization for more
# information
[centos-qemu-ev]
name=CentOS-\$releasever - QEMU EV
baseurl=http://mirrors.aliyun.com/\$contentdir/\$releasever/virt/\$basearch/kvm-common/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization
[centos-qemu-ev-test]
name=CentOS-\$releasever - QEMU EV Testing
baseurl=http://buildlogs.centos.org/centos/\$releasever/virt/\$basearch/kvm-common/
gpgcheck=0
enabled=0
EOF
# 修改 NFS Ganesha YUM 源配置文件
echo "修改 CentOS-NFS-Ganesha-28.repo 配置..."
cat <<EOF > /etc/yum.repos.d/CentOS-NFS-Ganesha-28.repo
# CentOS-NFS-Ganesha-28.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/Storage for more
# information
[centos-nfs-ganesha28]
name=CentOS-\$releasever - NFS Ganesha 2.8
baseurl=https://mirrors.aliyun.com/\$contentdir/\$releasever/storage/\$basearch/nfs-ganesha-28/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage
[centos-nfs-ganesha28-test]
name=CentOS-\$releasever - NFS Ganesha 2.8 Testing
baseurl=https://buildlogs.centos.org/centos/\$releasever/storage/\$basearch/nfs-ganesha-28/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage
EOF
# 清除本地 YUM 缓存并重建缓存
echo "清理本地 YUM 缓存并重建缓存..."
yum clean all && yum makecache
# 关机命令
echo "关机中..."
init 0
添加执行权限之后,使用root执行就好了
chmod +x openstack.sh
./openstack.sh
发现关机就说明基本都完成了,然后将下面选项打钩
直接开启虚拟机就好了,最后使用root依次执行下面的两条命令
#下载openstack-packstack
yum -y install openstack-packstack
#安装openstack
packstack --allinone
查看账号密码:
cat keystonerc_admin
直接访问ip地址,然后输入账号密码登录就好了
注意:有错误的话建议使用同款虚拟机,如果有快照再回到快照再次执行就好了,还有就是网络一定一定要正常,要不然也会有很多问题的。
更多推荐
所有评论(0)