查看主机
sudo virsh list --all
sudo virsh snapshot-list compute-cs8
sudo virsh snapshot-revert compute-cs8 init3
ssh root@172.24.1.xx
source /root/keystonerc_admin
1、在 OpenStack 云平台创建名为 project12-xxxx 的项目,并查询项目列表信息。(5分)
openstack project create --description "xxxx test project" project12-xxxx
openstack project list
2、在 OpenStack 云平台创建名为 clouduser12-xxxx 的用户,该用户属于 project12-xxxx 项目,并设置用户密码为 redhat2012,查询用户列表信息。(5分)
openstack user create clouduser12-xxxx --password-prompt
openstack role add --project project12-xxxx --user clouduser12-xxxx _member_
openstack user list#
openstack user create --domain default --project project12-xxxx --password redhat2012 clouduser12-xxxx
3、将 cirros 镜像上传到 OpenStack 云平台,镜像名为 cloudimage12-xxxx,并查看镜像列表信息。在 /root 和 /opt 目录下,使用镜像文件 cirros-0.5.1-x86_64-disk.img。(5分)
curl -O http://172.31.32.11/11/%e6%9d%a8%e5%af%85%e5%86%ac/%e5%b7%a5%e5%85%b7%e5%92%8c%e9%95%9c%e5%83%8f/cirros-0.5.1-x86_64-disk.img
ll -h
source /root/keystonerc_admin
cd /opt/
openstack image create "cloudimage12-xxxx" --file cirros-0.5.1-x86_64-disk.img --disk-format qcow2 --container-format bare --public#如果文件在/root或者/opt下:openstack image create --disk-format qcow2 --container-format bare --public --file /root/cirros-0.5.1-x86_64-disk.img cloudimage12-xxxx
openstack image list
4、在 OpenStack 云平台创建名为 router12-xxxx 路由器,查询路由器信息。(5分)
openstack router create router12-xxxx
openstack router show router12-xxxx
openstack router list
5、在 OpenStack 云平台创建名为 pri_xxxx 的私有网络,子网名称为 pri-subnet-xxxx,网络地址 10.1.2.0/24,网关 10.1.2.254,并将网络连接到路由器 router12-xxxx(网络类型geneve) 。(15分)
openstack network create pri_xxxx --provider-network-type geneve
openstack subnet create pri-subnet-xxxx --network pri_xxxx --subnet-range 10.1.2.0/24 --gateway 10.1.2.254 --dns-nameserver 192.168.100.1
openstack router add subnet router12-xxxx pri-subnet-xxxx
6、在 OpenStack 云平台创建名为 public-xxxx 的共有网络,子网名称为 public-subnet-xxxx, 网络地址 172.31.32…0/24,网关172.31.32.254,DNS 为172.31.32.254并将网络连接到路由器 router12-xxxx 。(可以使用extnet接口映射)(15分)
cat /root/openstack-answer.txt | grep -i phy
openstack network create --provider-physical-network extnet --provider-network-type flat --external public-xxxx
openstack subnet create public-subnet-xxxx --network public-xxxx --subnet-range 172.31.32.0/24 --allocation-pool start=172.31.32.100,end=172.31.32.120 --gateway 172.24.1.254 --dns-nameserver 172.31.32.254 --no-dhcp
nmcli
cat /etc/sysconfig/network-scripts/ifcfg-br-ex
openstack router set router12-xxxx --external-gateway public-xxxx
7、创建安全组规则和密钥,安全组规则名为 secgroup12-xxxx,设置安全组规则,允许 icmp 和 ssh 协议。创建密钥 mykey12-xxxx。(10分)
openstack security group create secgroup12-xxxx
openstack security group rule create --ingress --ethertype IPv4 --protocol icmp secgroup12-xxxx
openstack security group rule create --ingress --protocol tcp --dst-port 22:22 --ethertype IPv4 secgroup12-xxxx
ll /root/.ssh/
#创建密钥 如果已经存在,则不用执行
ssh-keygen -q -N ""
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey12-xxxx
8、创建 cirros12.tiny 云主机类型(vcpu为1,内存为128m,磁盘1g),使用 cloudimage12-xxxx 镜像,使用 secgroup12-xxxx 安全组, mykey-xxxx 密钥,启动云主机,名称为 cloud12-xxxx,云主机私有网络为 pri_xxxx 。(15分)
# 查看网络和镜像
openstack network list
openstack flavor list
openstack image list
openstack flavor create --id 6 --vcpus 1 --ram 128 --disk 1 cirros12.tiny
netID=$(openstack network list | grep pri_xxxx | awk '{ print $2}')
echo $netID
openstack server create --flavor cirros12.tiny --image cloudimage12-xxxx --security-group secgroup12-xxxx --nic net-id=$netID --key-name mykey-xxxx --network pri_xxxx cloud12-xxxx
# 另
openstack server create --flavor cirros12.tiny --image cloudimage12-xxxx --security-group secgroup12-xxxx --key-name mykey-xxxx --network pri_xxxx --boot-volume-size 1 --name cloud12-xxxx
9、在 OpenStack 云平台创建浮动 IP 地址,附加给 cloud12-xxxx 云主机。(10分)
openstack floating ip create public
openstack server add floating ip cloud12-xxxx ip地址
openstack floating ip list
# 另
network_id=$(openstack network show public -f value -c id)
floating_ip=$(openstack floating ip create $network_id -f value -c floating_ip_address)
openstack server add floating ip cloud12-xxxx $floating_ip
10、创建磁盘 disk12-xxxx,大小为1g,附加给云主机 cloud12-xxxx。(5分)
openstack volume create --size 1 disk12-xxxx
openstack server add volume cloud12-xxxx disk12-xxxxip netns
ip netns exec 查询id 地址
ip netns exec 查询id ssh cirros@地址
lsblk
fdisk /dev/vdb
# 另openstack volume create --size 1 --name disk12-xxxx
cloud_host_id=$(openstack server show cloud12-xxxx -f value -c id)
disk_id=$(openstack volume show disk12-xxxx -f value -c id)
cloud_host_id=$(openstack server show cloud12-xxxx -f value -c id)
disk_id=$(openstack volume show disk12-xxxx -f value -c id)
11、创建对象存储容器 container12-xxxx,上传文件(自定义)到容器。(5分)
openstack container create container12-xxxx
openstack object create container12-xxxx example.txt < example.txtyum repolist
curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
ip a
#改一下网络地址 35分钟
进入Edit a connection,在选择:edit,更改dns servers为172.24.1.254
# 重新激活网络nmcli conn up enpls0
yum repolist
yum -y install docker-ce --enablerepo=docker-ce-stable
# 第二个窗口yum repolist
yum -y install podman
systemctl enable docker --now
docker search centos | grep stream
docker search centos | grep stream