openstack⾃动化搭建脚本
Openstack平台部署+节点扩容
1)搭建脚本
1 #!/bin/bash
2 #openstack私有云平台部署
3 #脚本使⽤前提:三台虚拟机openstack(ip地址:192.168.1.10,⾄少7G内存,50G硬盘),nova01(ip地址:192.168.1.11⾄少4G内存,100G硬盘),扩容⽤nova02(ip地址:192.168.1.12⾄少4G内存,100G硬盘);yum源正常;本次部署为精简版安装
4 source /root/moudle.sh
5while :
6do
7echo">>>>>####_menu_>>>>>>####"
8echo"1.openstack服务器环境部署与检查"
va环境部署与检查"
10echo"3.openstack服务安装与登录"
11echo"4.openstack节点扩容"
it"
13echo">>>>>>>>>>>>>####"
14 read -p "请输⼊您要部署的服务(1|2|3|4|5):"select
15if [ "$select" == "1" ];then
16 env_openstack
17elif [ "$select" == "2" ];then
18 env_nova
19elif [ "$select" == "3" ];then
20 install_openstack
21elif [ "$select" == "4" ];then
22 ext_nova
23elif [ "$select" == "5" ];then
24 exit
25else
26echo"I AM SORRY"
27sleep2
28fi
二代身份证办理29done
2)脚本模块
1 #!/bin/bash
制药工程专业就业方向2 #函数定义
3 env_openstack()
4 {
5 hostnamectl set-hostname openstack
6hostname openstack
7sleep1
8echo"1.主机名已同步"
9
10echo"192.168.1.10 openstack
11192.168.1.11 nova01
12192.168.1.12 nova02
13" >> /etc/hosts
14sleep1
15echo"2.域名已同步"
16
17sed -i '/search/d' /f
18sleep1
19echo"3.域名解析服务器已指定"
20
21sed -i '7 s/gateway/192.168.1.254/' /f #1.254是真机ip
22 systemctl restart chronyd
23sleep5
24if [ `chronyc sources -v | tail -1 | awk'{print $1}'` == ^* ];then
25echo"4.时间同步成功"
26else
27echo'>>时间未同步,请检查'
28fi
29
30echo"[local_repo]
31 name=CentOS-$releasever - Base海清的老公是谁
32 baseurl="ftp://192.168.1.254/centos-1804"
33 enabled=1
34 gpgcheck=0
35 [extras]
36 name=extras
37 baseurl="ftp://192.168.1.254/extras/"
38 enabled=1
39 gpgcheck=0
40 [openstack1]
41 name=openstack1
42 baseurl="ftp://192.168.1.254/openstack/rhel-7-server-openstack-10-rpms"
43 enabled=1
44 gpgcheck=0
45 [openstack2]
46 name=openstack2
47 baseurl="ftp://192.168.1.254/openstack/rhel-7-server-openstack-10-devtools-rpms"
48 enabled=1
49 gpgcheck=0
50" > /pos.po
51sleep1
寒食节为了纪念谁52if [ `yum repolist | tail -1 | awk'{print $2}'` == "10,670" ];then
53echo"5.yum源配置成功"
54else
55echo">>yum源有问题"
56fi
57
58yum remove firewalld-* &>/dev/null;yum remove NetworkManager &>/dev/null
59sleep1
60echo"6.已卸载firewalld和NetworkManager"
61sleep1
62if [ `cat /etc/sysconfig/network-scripts/ifcfg-eth0 | awk -F'"''/ONBOOT/{print $2}'` == "yes" ];then
63echo"7work冲突解决"
64else
65echo">>#network冲突"
66fi
67sleep1
68ping -c 3192.168.1.11 &>/dev/null && ping -c 3192.168.1.12 &>/dev/null && echo"8.⽹络畅通" || echo">>请检查⽹络"
69sleep1
70echo"环境依赖包安装,请稍等..."
71sleep1
72yum -y install python-setuptools &> /dev/null && echo"9.依赖包安装成功,环境配置完毕,请进⾏下⼀步,安装openstack服务"
73sleep1.5
74 }
75
76 env_nova()
77 {
78 read -p "请输⼊主机名尾号(01|02):" a
79 hostnamectl set-hostname nova$a
80hostname nova$a
81sleep1
82echo"1.主机名已同步"
83
84echo"192.168.1.10 openstack
85192.168.1.11 nova01
86192.168.1.12 nova02
87" >> /etc/hosts
88sleep1
89echo"2.域名已同步"
90
91sed -i '/search/d' /f
92sleep1
93echo"3.域名解析服务器已指定"
94王承渲是哪里人
95sed -i '7 s/gateway/192.168.1.254/' /f #1.254是真机ip
96 systemctl restart chronyd
97sleep5
98if [ `chronyc sources -v | tail -1 | awk'{print $1}'` == "^*" ];then
99echo"4.时间同步成功"
100else
101echo'>>时间未同步,请检查'
102fi
103
104echo"[local_repo]
105 name=CentOS-$releasever - Base
106 baseurl="ftp://192.168.1.254/centos-1804"
107 enabled=1
108 gpgcheck=0
109 [extras]
110 name=extras
111 baseurl="ftp://192.168.1.254/extras/"
112 enabled=1
113 gpgcheck=0
114 [openstack1]
115 name=openstack1
116 baseurl="ftp://192.168.1.254/openstack/rhel-7-server-openstack-10-rpms"
117 enabled=1
118 gpgcheck=0
119 [openstack2]
120 name=openstack2
121 baseurl="ftp://192.168.1.254/openstack/rhel-7-server-openstack-10-devtools-rpms"
122 enabled=1
123 gpgcheck=0
124" > /pos.po
125sleep1
小说推荐吧126if [ `yum repolist | tail -1 | awk'{print $2}'` == "10,670" ];then
127echo"5.yum源配置成功"
128else
129echo">>yum源有问题"
本文标签:安装 环境 脚本 部署 密码 服务器 搭建
130fi
131yum remove firewalld-* &>/dev/null;yum remove NetworkManager &>/dev/null
132sleep1
133echo"6.已卸载firewalld和NetworkManager"
134sleep1
135if [ `cat /etc/sysconfig/network-scripts/ifcfg-eth0 | awk -F'"''/ONBOOT/{print $2}'` == "yes" ];then
136echo"7work冲突解决"
137else
138echo">>#network冲突"
139fi
140sleep1
141ping -c 3192.168.1.10 &>/dev/null && ping -c 3192.168.1.12 &>/dev/null && echo"8.⽹络畅通" || echo">>请检查⽹络"
142
143echo"环境依赖包安装,请稍等..."
144yum -y install python-setuptools qemu-kvm libvirt-daemon libvirt-daemon-driver-qemu libvirt-client &> /dev/null && echo"9.依赖包安装成功,环境配置完毕,请进⾏下⼀步" 145sleep1.5
146 }
147
148 install_openstack()
149 {
150yum -y install openstack-packstack
151 cd /root/
152 packstack --gen-answer-file=answer.ini
153sed -i '42 s/=y/=n/' answer.ini
154sed -i '45 s/=y/=n/' answer.ini
155sed -i '49 s/=y/=n/' answer.ini
156sed -i '53 s/=y/=n/' answer.ini
157sed -i '75 s/=/=192.168.1.254/' answer.ini
158sed -i '98 s/1.10/1.11/' answer.ini
159sed -i '102 s/1.10/1.10,192.168.1.11/' answer.ini
160sed -i '333 s/=.*$/=a/' answer.ini
161sed -i '840 s/=vx/=flat,vx/' answer.ini
162sed -i '910 s/=/=physnet1:br-ex/' answer.ini
163sed -i '921 s/=/=br-ex:eth0/' answer.ini
164sed -i '1179 s/=y/=n/' answer.ini
165echo"开始安装请耐⼼等待⼤约"
166 packstack --answer-file=answer.ini
167sed -i '/WSGIProcessGroup apache/a WSGIApplicationGroup %{GLOBAL}' /etc/httpd/conf.f
168 apachectl graceful
169echo"安装成功!欢迎使⽤,请访问以下⽹址192.168.1.10进⾏访问,账户密码为您的应答⽂件设置"
170 }
171
172 ext_nova()
173 {
174 cd /root/
175sed -i '98 s/1.11/1.11,192.168.1.12/' answer.ini
176sed -i '102 s/1.11/1.11,192.168.1.12/' answer.ini
177echo"开始安装请耐⼼等待⼤约"
178 packstack --answer-file=answer.ini
179sed -i '/WSGIProcessGroup apache/a WSGIApplicationGroup %{GLOBAL}' /etc/httpd/conf.f
180 apachectl graceful
181echo"扩容成功!欢迎使⽤,请访问以下⽹址192.168.1.10进⾏访问,账户密码>为您的应答⽂件设置"
182 }
本文发布于:2024-11-26 05:12:48,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
- 上一篇: 中兴GPON OLT开局配置指南(C220 V1.1.2)
- 下一篇: 深信服系统集成(网络传播版)
发布评论