预备环境
目前不支持CentOS8 支持CentOS7.x使用的镜像centos7.7-mini
安装完成可以关闭selinux 也可以不关闭
创建用户
1 | sudo useradd -s /bin/bash -m stack |
2 | echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack |
安装
设置环境变量
如果您使用的是非英语语言环境,请确保您/etc/environment已填充:
1 | LANG=en_US.utf-8 |
2 | LC_ALL=en_US.utf-8 |
更新系统
1 | yum update -y |
查看最新版本号
1 | https://releases.openstack.org/ |
稳定版本为train yum 源搜索稳定版本为
1
centos-release-openstack-train
配置源
1 | sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak |
1 | # CentOS-Base.repo |
2 | # |
3 | # The mirror system uses the connecting IP address of the client and the |
4 | # update status of each mirror to pick mirrors that are updated to and |
5 | # geographically close to the client. You should use this for CentOS updates |
6 | # unless you are manually picking other mirrors. |
7 | # |
8 | # If the mirrorlist= does not work for you, as a fall back you can try the |
9 | # remarked out baseurl= line instead. |
10 | # |
11 | # |
12 | |
13 | |
14 | [base] |
15 | name=CentOS-$releasever - Base |
16 | baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/ |
17 | #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os |
18 | enabled=1 |
19 | gpgcheck=1 |
20 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7 |
21 | |
22 | #released updates |
23 | [updates] |
24 | name=CentOS-$releasever - Updates |
25 | baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/ |
26 | #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates |
27 | enabled=1 |
28 | gpgcheck=1 |
29 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7 |
30 | |
31 | |
32 | |
33 | #additional packages that may be useful |
34 | [extras] |
35 | name=CentOS-$releasever - Extras |
36 | baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/ |
37 | #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras |
38 | enabled=1 |
39 | gpgcheck=1 |
40 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7 |
41 | |
42 | |
43 | |
44 | #additional packages that extend functionality of existing packages |
45 | [centosplus] |
46 | name=CentOS-$releasever - Plus |
47 | baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/ |
48 | #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus |
49 | gpgcheck=1 |
50 | enabled=0 |
51 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7 |
安装openstack
注意官网给出的CentOS 安装方式实测不行
1 | sudo yum install -y https://rdoproject.org/repos/rdo-release.rpm |
2 | sudo yum update -y |
3 | sudo yum install -y openstack-packstack |
4 | sudo packstack --allinone |
设置启动
1 | yum install openstack-utils -y |
第一种操作方式
1 | openstack-service --help |
2 | openstack-service list |
3 | openstack-service restart openstack-ceilometer-polling |
openstack-service 实际是一个shell脚本,底层实际调用的是centos的systemctl工具,因此我们也可以使用systemctl工具来重启服务
自启动
1 | systemctl enable openstack-ceilometer-polling |
使用systemctl列出所有openstack服务
1 | systemctl list-unit-files --type=service --ful --no-legend --no-pager | egrep "^(openstack|neutron|quantum)" | grep -v 'neutron-.*-cleanup' | grep enable |
查看指定服务当前的运行状态
1 | systemctl status openstack-ceilometer-polling |
重启指定服务
1 | systemctl restart openstack-ceilometer-polling |
停止指定服务
1 | systemctl stop openstack-ceilometer-polling |
卸载脚本
1 | #!/usr/bin/bash |
2 | # Warning! Dangerous step! Destroys VMs |
3 | for x in $(virsh list --all | grep instance- | awk '{print $2}') ; do |
4 | virsh destroy $x ; |
5 | virsh undefine $x ; |
6 | done ; |
7 | |
8 | # Warning! Dangerous step! Removes lots of packages, including many |
9 | # which may be unrelated to RDO. |
10 | yum remove -y nrpe "*nagios*" puppet ntp ntp-perl ntpdate "*openstack*" \ |
11 | "*nova*" "*keystone*" "*glance*" "*cinder*" "*swift*" \ |
12 | mysql mysql-server httpd "*memcache*" scsi-target-utils \ |
13 | iscsi-initiator-utils perl-DBI perl-DBD-MySQL ; |
14 | |
15 | ps -ef | grep -i repli | grep swift | awk '{print $2}' | xargs kill ; |
16 | |
17 | # Warning! Dangerous step! Deletes local application data |
18 | rm -rf /etc/nagios /etc/yum.repos.d/packstack_* /root/.my.cnf \ |
19 | /var/lib/mysql/ /var/lib/glance /var/lib/nova /etc/nova /etc/swift \ |
20 | /srv/node/device*/* /var/lib/cinder/ /etc/rsync.d/frag* \ |
21 | /var/cache/swift /var/log/keystone ; |
22 | |
23 | umount /srv/node/device* ; |
24 | killall -9 dnsmasq tgtd httpd ; |
25 | setenforce 1 ; |
26 | vgremove -f cinder-volumes ; |
27 | losetup -a | sed -e 's/:.*//g' | xargs losetup -d ; |
28 | find /etc/pki/tls -name "ssl_ps*" | xargs rm -rf ; |
29 | for x in $(df | grep "/lib/" | sed -e 's/.* //g') ; do |
30 | umount $x ; |
31 | done |