发布时间: 2024-5-29 文章作者: myluzh 分类名称: OpenStack 朗读文章
# yum源加速 [root@openstack-allinone ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup [root@openstack-allinone ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo [root@openstack-allinone ~]# yum clean all [root@openstack-allinone ~]# yum makecache [root@openstack-allinone ~]# yum -y update # 关闭firewalld,selinux,networkmanager [root@openstack-allinone ~]# systemctl disable NetworkManager [root@openstack-allinone ~]# systemctl enable network [root@openstack-allinone ~]# systemctl disable firewalld [root@openstack-allinone ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config # 设置hosts [root@openstack-allinone ~]# vi /etc/hosts 172.16.10.79 node-a node-a.localdomain [root@openstack-allinone ~]# ping node-a 64 bytes from node-a (172.16.10.79): icmp_seq=1 ttl=64 time=0.018 ms # 同步ntp [root@openstack-allinone ~]# yum install -y ntp [root@openstack-allinone ~]# systemctl start ntpd [root@openstack-allinone ~]# ntpdate ntp1.aliyun.com [root@openstack-allinone ~]# systemctl enable ntpd # 重启 [root@openstack-allinone ~]# reboot
# 安装openstack。安装需要一小时左右,不要通过ssh安装会卡住断开连接。 [root@openstack-allinone ~]# yum -y install centos-release-openstack-train [root@openstack-allinone ~]# yum -y install openstack-packstack [root@openstack-allinone ~]# packstack --allinone # 显示 successfully 就是成功了。 [root@openstack-allinone ~]# nova-manage --version 20.6.0
# 如果需要域名访问,在apache的配置文件中添加一行ServerName,然后重启服务即可。 [root@openstack-allinone conf.d]# vi /etc/httpd/conf.d/15-horizon_vhost.conf <VirtualHost *:80> ServerName openstack-allinone ServerName openstack.itho.cn2、获取控制台admin跟demo的密码
[root@openstack-allinone ~]# source keystonerc_admin [root@openstack-allinone ~(keystone_admin)]# cat keystonerc_admin unset OS_SERVICE_TOKEN export OS_USERNAME=admin export OS_PASSWORD='14be1048b02243e8' export OS_REGION_NAME=RegionOne export OS_AUTH_URL=http://172.16.10.79:5000/v3 export PS1='[\u@\h \W(keystone_admin)]\$ ' export OS_PROJECT_NAME=admin export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_IDENTITY_API_VERSION=3 [root@openstack-allinone ~(keystone_admin)]# source keystonerc_demo [root@openstack-allinone ~(keystone_demo)]# cat keystonerc_demo unset OS_SERVICE_TOKEN export OS_USERNAME=demo export OS_PASSWORD='307fba62b22c4293' export PS1='[\u@\h \W(keystone_demo)]\$ ' export OS_AUTH_URL=http://172.16.10.79:5000/v3 export OS_PROJECT_NAME=demo export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_IDENTITY_API_VERSION=3
[root@openstack-allinone conf.d]# ip add 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:50:56:a5:54:20 brd ff:ff:ff:ff:ff:ff inet 172.16.10.79/24 brd 172.16.10.255 scope global noprefixroute ens192 valid_lft forever preferred_lft forever inet6 fe80::250:56ff:fea5:5420/64 scope link valid_lft forever preferred_lft forever 3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 4e:eb:7f:b6:93:f4 brd ff:ff:ff:ff:ff:ff # br-ex 是外部网桥 4: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000 link/ether 8a:f8:c3:ca:48:4b brd ff:ff:ff:ff:ff:ff inet 172.24.4.1/24 scope global br-ex valid_lft forever preferred_lft forever inet6 fe80::88f8:c3ff:feca:484b/64 scope link valid_lft forever preferred_lft forever # br-int 是集成网桥 5: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether fa:8d:97:08:2d:41 brd ff:ff:ff:ff:ff:ff2、新建网络配置
# 配置了物理网络接口 ens192,将其类型设置为 OVSPort,这意味着它是一个 Open vSwitch 端口。OVS_BRIDGE=br-ex 表示这个端口连接到了名为 br-ex 的 Open vSwitch 网桥上。 [root@openstack-allinone ~]# vi ifcfg-ens192 DEVICE=ens192 TYPE=OVSPort DEVICETYPE=ovs OVS_BRIDGE=br-ex ONBOOT=yes # 配置了名为 br-ex 的 Open vSwitch 网桥。DEVICETYPE=ovs 表示这是一个 Open vSwitch 类型的设备。BOOTPROTO=static 表示使用静态 IP 地址配置。 [root@openstack-allinone ~]# vi ifcfg-br-ex DEVICE=br-ex DEVICETYPE=ovs TYPE=OVSBridge BOOTPROTO=static IPADDR=172.16.10.79 NETMASK=255.255.255.0 GATEWAY=172.16.10.1 DNS1=223.5.5.5 ONBOOT=yes3、覆盖原来的配置文件使配置生效
[root@openstack-allinone ~]# cp ifcfg-* /etc/sysconfig/network-scripts/ cp: overwrite ‘/etc/sysconfig/network-scripts/ifcfg-ens192’? y # 重启网络使配置生效 [root@openstack-allinone network-scripts]# systemctl restart network4、查看当前网卡ip
[root@openstack-allinone network-scripts]# ip add 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ovs-system state UP group default qlen 1000 link/ether 00:50:56:a5:54:20 brd ff:ff:ff:ff:ff:ff inet6 fe80::250:56ff:fea5:5420/64 scope link valid_lft forever preferred_lft forever 3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 4e:eb:7f:b6:93:f4 brd ff:ff:ff:ff:ff:ff 5: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether fa:8d:97:08:2d:41 brd ff:ff:ff:ff:ff:ff 6: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000 link/ether 00:50:56:a5:54:20 brd ff:ff:ff:ff:ff:ff inet 172.16.10.79/24 brd 172.16.10.255 scope global br-ex valid_lft forever preferred_lft forever inet6 fe80::1432:19ff:feca:7b49/64 scope link valid_lft forever preferred_lft forever5、 删除原来的路由与网络
# 名称:ext-net # 项目:admin # 供应商网络类型:Flat # 物理网络:ext-net # 启用管理员状态,共享的,外部网络,创建子网7、创建内网(int-net)
# 网络名称:int-net # 启用管理员状态,共享的,创建子网 # 子网名称:ini-subnet # 网络地址:10.10.10.0/24 # IP版本:IPv4 # 网关IP:10.10.10.18、创建路由R1
# 路由名称:R1 # 启用管理员状态 # 外部网络:ext-net # 启动SNAT路径:openstack_web_ui -> 项目 -> 网络 -> 路由 -> R1 -> 接口 -> 增加接口
# 子网:int-net: 10.10.10.0/24 (ini-subnet)9、查看网络状态
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img2、cirros上传到主机
[root@openstack-allinone ~]# ls -l -rw-r--r-- 1 root root 12716032 May 29 16:59 cirros-0.4.0-x86_64-disk.img3、镜像上传到Glance
[root@openstack-allinone ~]# source keystonerc_admin [root@openstack-allinone ~(keystone_admin)]# glance image-create --name cirros001 --disk-format qcow2 --container-format bare --visibility=public < cirros-0.4.0-x86_64-disk.img +------------------+----------------------------------------------------------------------------------+ | Property | Value | +------------------+----------------------------------------------------------------------------------+ | checksum | 443b7623e27ecf03dc9e01ee93f67afe | | container_format | bare | | created_at | 2024-05-29T09:06:28Z | | disk_format | qcow2 | | id | bd34bd52-7b14-4976-859a-78df47385164 | | min_disk | 0 | | min_ram | 0 | | name | cirros001 | | os_hash_algo | sha512 | | os_hash_value | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e | | | 2161b5b5186106570c17a9e58b64dd39390617cd5a350f78 | | os_hidden | False | | owner | 1803d7088dd549e481fb22df2c893808 | | protected | False | | size | 12716032 | | status | active | | tags | [] | | updated_at | 2024-05-29T09:06:28Z | | virtual_size | Not available | | visibility | public | +------------------+----------------------------------------------------------------------------------+4、查看新建的镜像
[root@openstack-allinone ~(keystone_admin)]# glance image-list +--------------------------------------+-----------+ | ID | Name | +--------------------------------------+-----------+ | 99bea781-df04-403c-8131-223247bc4f05 | cirros | | bd34bd52-7b14-4976-859a-78df47385164 | cirros001 | +--------------------------------------+-----------+5、创建实例
# 实例名称crros_test # 镜像源:选择刚刚上传的镜像cirros001 # 实例类型:选择最小的m1.tiny # 网络:ini-net # 安全组:default6、编辑安全组规则
# 规则:SSH # 方向:入向 # 远程:CIDR # CIDR:0.0.0.0/0(2)开启icmp
# 规则:ALL ICMP # 方向:入向 # 远程:CIDR # CIDR:0.0.0.0/07、绑定浮动IP
# 资源池:选择外部网络的 ext-net # 这样就可以获得一个浮动ip,我这边获取到的是172.16.10.158,然后点击关联到对应的实例即可。8、物理网络访问openstack实例测试
# 通了就行 % ping 172.16.10.158 PING 172.16.10.158 (172.16.10.158): 56 data bytes 64 bytes from 172.16.10.158: icmp_seq=0 ttl=62 time=70.720 ms9、结束
发表评论