前言:不积硅步,无以至千里;不积小流,无以成江海
废话不多说上来直接开干
创建实例
创建网络
openstack network create --share --external --provider-physical-network provider \
--provider-network-type flat ex-network
--share指定网络为公共网络 --external指定网络为外部网络
创建一个公共网络的外部网络,该网络的物理网络提供者是provider,提供者的网络类型的扁平的,网络名称ex-network
external 外部的
创建子网(2层网络)
openstack subnet create --network ex-network --allocation-pool \
start=172.16.183.200,end=172.16.183.210 --dns-nameserver 172.16.183.1 \
--gateway 172.16.183.1 --subnet-range 172.16.183.0/24 ex-subnetwork
创建子网,它的父网是ex-network,地址池172.16.283.200-172.16.183.210,dns和网关是172.16.183.1,
子网掩码255.255.255.0,子网名称ex-subnetwork
--network指定父网络 --subnet指定子网网段
subnet子网 allocation分配 pool水池
创建配置方案
openstack flavor creat --id 0 --vcups 1 --ram 64 --disk 1 m1.nano
创建一个名为m1.nano方案,id=0,cpu一核,64MB内存,1G的磁盘
创建密钥对
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
启用~/.ssh/id_rsa.pub/的公钥,起名mykey
创建安全组规则
openstack security group rule create --proto icmp default
openstack security group rule create --prote tcp --dst-port 22 default
创建默认安全组规则,启用icmp协议,启用22端口
修改nova配置文件,避免实例创建时报错
vif_pluggin_is_fatal = false 处理超时异常时的方式
vif_pluggin_is_fatal = 0 等待事件的最大时间
创建启动实例
openstack server create --flavor m1.nano --image cirros --nic net-id=自己网络的id openstack network list 查看 \
--srcurity-group default --key-name mykey cirros-instance1
创建启动一个cirros-instance1的实例,用的方案是m1.nano,用的镜像是cirros,用的网络是ex——network,用的默认安全组,用的一个叫mykey的密钥对
查看实例
oepnstack server list
若实例处于active状态且由ip地址则创建成功
修改实例远程桌面无法进入的bug
进入实例所在的节点
vi /etc/nova/nova.conf
[libvirt]
virt_type = qemu
cpu_mode = none
然后硬重启实例即可
安装cinder组件
控制节点
创库授权
create database cinder;
grant all privileges on cinder.* to 'cinder'@'localhost' identified by '000000';
grant all privileges on cinder.* to 'cinder'@'%' identified by '000000';
创建用户
openstack user create --domain default --password 000000 cinder
把admin角色关联到用户,项目
openstack role add --project service --user cinder admin
创建服务实体
注意这里,要创建两个服务
openstack service creat --name cinderv2 --description 'Openstack Block Storage' volumev2
openstack service creat --name cinderv3 --description 'Openstack Block Storage' volumev3
创建相关端点
有v2、v3两个服务相应的相关端点就要翻倍
openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%(project_id)s
openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%(project_id)s
openstack endpoint create --region RegionOne volumev2 public http://controller/v2/%(project_id)s
openstack endpoint create --region RegionOne volumev3 admin http://controller/v3/%(project_id)s
openstack endpoint create --region RegionOne volumev3 internal http://controller/v3/%(project_id)s
oepnstack endpoint create --region RegionOne volumev3 public http://controller/v3/%(project_id)s
安装软件包
yum install openstack-cinder -y
编辑相应配置文件
vi /etc/cinder/cinder.conf
[database]
connection = mysql+pymysql://cinder:000000@controller/cinder
[DEFAULT]
transport_servers = rabbit://openstack:000000@controller
auth_strategy = keystone
my_ip = 192.168.200.100
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
auth_type = password
memcached_servcer = controller:11211
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
passoword = 000000
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[cinder]
os_region_name = RegionOne 启用块存储的区域
同步数据库
su -s /bin/sh -c 'cinder-manage db sync' cinder
重启服务并设置为开机自启
计算节点
首先增加一块硬盘
安装相应软件包
yum install lvm2 device-mapper-persistent-data -y
启用LVM元数据服务,设置为开机自启
systemctl start lvm2-lvmetad
systemctl enablev lvm2-lvmetad
创建lvm类型物理卷
pvcreate /dev/sdb
创建卷组
vgcreate cinder-volumes /dev/sdb
配置过滤器,让块存储卷只有实例能访问
在第132行设置
filter = ['a/sda/', a/sdb/, r/.*/]
r/.*/拒绝任何的设备
安装相应软件包
yum install openstack-cinder targetcli python-keystone -y
修改相应配置文件
[database]
connection = mysql+pymysql://cinder:000000@controller/cinder
[DEFAULT]
transport_url = rabbit://openstack:000000@controller
auth_strategy = keystone
glance_api_servers = http://controller:9292
enabled_backends = lvm 启用lvm后端存储管理
my_ip = 192.168.200.101
[keystone_authtoken]
www_authenticate_uri = http;//controller:5000
auth_url = http://controller:5000
auth_type = password
memcached_servers = controller:11211
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = 000000
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver 卷驱动
volume_group = cinder-volumes 卷组名
target_protocol = iscsi 启用iscsi协议
target目标 protocol协议
target_helper = lioadm
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
重启服务并设置为开机自启
芜湖,还差一个对象存储组件openstack的二周目学习就算结束了。这里立一个flag 三周目把neutron之前的内容记下来(真是件振奋人心的事呢?! ? )