增加dashboard - horizon (controller)--图形化控制台
安装包 yum install -y openstack-dashboard
编辑配置文件
vim /etc/openstack-dashboard/local_settings //更改或增加
OPENSTACK_HOST = "controller"
ALLOWED_HOSTS = ['*', ]
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': '127.0.0.1:11211',
} }
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_API_VERSIONS = {
"identity": 3,
"volume": 2,
}
TIME_ZONE = "Asia/Chongqing"
重启服务 systemctl restart httpd.service memcached.service
此时可以去访问了 http://controller/dashboard 使用账号admin或者demon用户登陆即可,密码为前期准备的时候用mkpasswd生成的密码3qiVpzU2x域为default
增加block storage - 前期准备 (controller)
block storage又叫做cinder,用来给openstack提供存储服务,比如我们在阿里云购买一台云主机,同时想购买容量大的磁盘,通常叫做云盘,这个云盘就是block storage。
创建库并授权cinder用户
mysql -uroot -ptn1Pi6Ytm
> CREATE DATABASE cinder;
> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'O3bwbpoZ3';
> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'O3bwbpoZ3';
执行初始化脚本
source admin-openrc.sh
创建cinder用户 (密码为hf8LX9bow)
openstack user create --domain default --password-prompt cinder
添加admin角色
openstack role add --project service --user cinder admin
创建cinder和cinderv2 实例
openstack service create --name cinder \
--description "OpenStack Block Storage" volume
openstack service create --name cinderv2 \
--description "OpenStack Block Storage" volumev2
创建块存储服务api终端
openstack endpoint create --region RegionOne volume public http://controller:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volume internal http://controller:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volume admin http://controller:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(tenant_id\)s
增加block storage - 安装和配置 (controller)
安装包 yum install -y openstack-cinder python-cinderclient
编辑配置文件 vim /etc/cinder/cinder.conf //更改或增加
[database]
connection = mysql://cinder:O3bwbpoZ3@controller/cinder
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.163.249
verbose = True
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = hf8LX9bow
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = o3NXovnz5
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
同步数据 su -s /bin/sh -c "cinder-manage db sync" cinder
配置compute使用块存储
vim /etc/nova/nova.conf
[cinder]
os_region_name=RegionOne
启动服务
systemctl restart openstack-nova-api.service
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
增加block storage - 配置storage节点 (compute)
我们理应需要再准备一台单独的机器来做storage服务的,但是为了节省资源,我们就那compute节点和storage节点共用。这里需要为compute(storage)节点再增加一块磁盘(/dev/sdb)作为存储磁盘。
安装lvm yum install -y lvm2
启动服务
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service
创建物理卷 pvcreate /dev/sdb
创建卷组 vgcreate cinder-volumes /dev/sdb
编辑配置文件 vim /etc/lvm/lvm.conf
devices {
filter = [ "a/sdb/", "r/.*/"]
说明: 如果还有第三块磁盘,应该再加上
filter = [ "a/sda/", "a/sdb/", "r/.*/"]
安装包 yum install -y openstack-cinder targetcli python-oslo-policy
编辑配置文件 vim /etc/cinder/cinder.conf
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.163.246
enabled_backends = lvm
glance_host = controller
verbose = True
[database]
connection = mysql://cinder:O3bwbpoZ3@controller/cinder
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = o3NXovnz5
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = hf8LX9bow
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
增加block storage - 启动和验证
启动服务 (compute)
systemctl enable openstack-cinder-volume.service target.service
systemctl start openstack-cinder-volume.service target.service
验证操作 (controller)
1. 执行初始化脚本
source admin-openrc.sh
2. 列出服务
cinder service-list
运行实例 - 创建公网网络 (controller)
执行初始化脚本
source admin-openrc.sh
创建网络
neutron net-create public --shared --provider:physical_network public \
--provider:network_type flat
创建子网(为了不和虚拟机的DHCP服务产生冲突先关闭虚拟机的DHCP服务)
neutron subnet-create public 192.168.163.0/24 --name public \
--allocation-pool start=192.168.163.10,end=192.168.163.30 \
--dns-nameserver 218.85.157.99 --gateway 192.168.163.2
说明:这里的公网,实际上是虚拟机用的那个网段,我们暂时把它作为公网,在这里因为涉及到dhcp服务,会和局域网内的路由器上的dhcp服务产生冲突,所以需要先把路由器上的dhcp服务关掉。
运行实例 - 创建key (controller)
执行初始化脚本
source demo-openrc.sh
生成密钥
ssh-keygen -q -N ""
nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
验证密钥
nova keypair-list
增加安全组规则
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
允许ssh 访问
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
运行实例 - 配置实例选项 (controller)
执行初始化脚本
source demo-openrc.sh
列出实例类型
nova flavor-list
列出所有镜像
nova p_w_picpath-list
列出可用网络
neutron net-list
列出安全组
nova secgroup-list
运行实例
nova boot --flavor m1.tiny --p_w_picpath cirros --nic net-id=PUBLIC_NET_ID \
--security-group default --key-name mykey public
说明:这里的PUBLIC_NET_ID需要替换为可用网络里面public网络的id
检测实例状态
nova list
使用vnc连接(使用下面命令可以列出vnc的连接)
nova get-vnc-console public novnc
得到返回链接,可使用浏览器直接访问
http://controller:6080/vnc_auto.html?token=7d13571f-1ba3-4ccd-8d91-1f17befc46da
验证网络(在实例里面)
ping -c 4 192.168.163.2
远程连接实例
首先用nova list 查看实例的ip(假如为192.168.163.11)
验证ip
ping -c4 192.168.163.11
远程ssh登录 ssh cirros@192.168.163.11
运行实例 - 增加云盘 (controller)
先执行初始化脚本
source demo-openrc.sh
创建一个2G的云盘,名字为volume1
cinder create --display-name volume1 2
列出所有云盘
cinder list
把云盘挂到实例中
nova volume-attach INSTANCE_NAME VOLUME_ID
#如果实例已经flase需要重新启动
说明:INSTACE_NAME可以用nova list查看,VOLUME_ID就是用cinder list查看到的云盘id
列出已经挂上的云盘
nova volume-list
然后登陆到实例
ssh cirros@192.168.163.11
查看云盘
sudo fdisk -l