计算 网络 存储
操作最低配
server1 4G内存
server2 2G 内存
网络参考
server1 两块网卡 桥接
eth1
BOOTPROTO=none
DEVICE=eth1
ONBOOT=yes
ifup eth1
hostnamectl set-hostname controller
解析
172.25.11.1 controller
172.25.11.2 compute1
172.25.11.3 block1
server2
hostnamectl set-hostname compute1
做好与真机的时间同步 chronyd
vim /etc/chrony.conf
server 172.25.11.250 iburst
allow 172.25/16
chronyc sources -v
server 1 2
server1
yum upgrade
这里禁用了 selinux
yum install mariadb mariadb-server python2-PyMySQL
/etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 172.25.11.1
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
systemctl enable mariadb.service
systemctl start mariadb.service
mysql_secure_installation
mongodb 是用来计算流量收费的 这里不需要安装
消息队列的安装
yum install rabbitmq-server -y
systemctl start rabbitmq-server.service
systemctl enable rabbitmq-server.service
rabbitmqctl add_user openstack openstack
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
rabbitmq-plugins
rabbitmq-plugins enable rabbitmq_management
帐号密码 guest guest
memcached 作认证服务的缓存令牌
可以定义缓存时间,不用占用
yum install memcached python-memcached -y
vim /etc/sysconfig/memcached
注释最后一行
systemctl enable memcached
systemctl start memcached
openstack keystone
使用 mysql创建
mysql -pwestos
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
IDENTIFIED BY 'keystone';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
IDENTIFIED BY 'keystone';
将上面localhost 还为 % 在一次
openssl rand -hex 10
初始化admin token
yum install openstack-keystone httpd mod_wsgi
vim /etc/keystone/keystone.conf
[defalut]
admin_token = 99b18dca176a77a7b4b5
[database]
connection = mysql+pymysql://keystone:keystone@controller/keystone
[token]
provider = fernet
su -s /bin/sh -c "keystone-manage db_sync" keystone
mysql -pwestos
use keystone
show tables;
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
ll /etc/keystone/
有下面就会成功
fernet-keys
启动服务apache
vim /etc/httpd/conf/httpd.conf
/ServerName
ServerName controller
vim /etc/httpd/conf.d/wsgi-keystone.conf
Listen 5000
Listen 35357
<VirtualHost *:5000>
WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
WSGIProcessGroup keystone-public
WSGIScriptAlias / /usr/bin/keystone-wsgi-public
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
ErrorLogFormat "%{cu}t %M"
ErrorLog /var/log/httpd/keystone-error.log
CustomLog /var/log/httpd/keystone-access.log combined
<Directory /usr/bin>
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:35357>
WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
WSGIProcessGroup keystone-admin
WSGIScriptAlias / /usr/bin/keystone-wsgi-admin
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
ErrorLogFormat "%{cu}t %M"
ErrorLog /var/log/httpd/keystone-error.log
CustomLog /var/log/httpd/keystone-access.log combined
<Directory /usr/bin>
Require all granted
</Directory>
</VirtualHost>
systemctl enable httpd
systemctl start httpd
配置服务
yum install python-openstackclient -y
先决条件
less keystone.conf
export OS_TOKEN=99b18dca176a77a7b4b5
export OS_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
openstack service create \
--name keystone --description "OpenStack Identity" identity
openstack endpoint create --region RegionOne \
identity public http://controller:5000/v3
openstack endpoint create --region RegionOne \
identity internal http://controller:5000/v3
openstack endpoint create --region RegionOne \
identity admin http://controller:35357/v3
openstack --help
openstack endpoint list
openstack user list
openstack service list
openstack domain create --description "Default Domain" default
openstack project create --domain default \
--description "Admin Project" admin
openstack user create --domain default \
--password admin admin
openstack role create admin
openstack role add --project admin --user admin admin
openstack project create --domain default \
--description "Service Project" service
openstack project create --domain default \
--description "Demo Project" demo
openstack user create --domain default \
--password demo demo
openstack role create user
openstack role add --project demo --user demo user
参考
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/keystone-users.html
下面参考桑面的 -verify
unset OS_TOKEN OS_URL
openstack --os-auth-url http://controller:35357/v3 \
--os-project-domain-name default --os-user-domain-name default \
--os-project-name admin --os-username admin token issue
admin
vim admin-openrc
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
vim demo-openrc
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
grep -v ^# /etc/keystone/keystone.conf |uniq
/\[token]
下面看你如何使用 如果用管理员使用下面第一个命令
source admin-openrc
source demo-openrc
##############################
. admin-openrc
[root@controller ~]# openstack token issue
+------------+----------------------------------------------------------------------------------+
| Field | Value |
+------------+----------------------------------------------------------------------------------+
| expires | 2019-04-14T04:43:56.179535Z |
| id | gAAAAABcsqx8nWMvP64e9qV6MuFh5Xx02GXnC8iavmPpEGoBJ3wlvqo7UOIbjWGILuPbXBOQAWuZT41O |
| | AnDY7b1C1VPZ9fe1-FbhXU8aE_C6aMSuZX6xvo3CHBc2mYprjTn5eJ5BIuibXidvMNkM0UtzEoYIMZsq |
| | rz_S_bYYGwXmv1A01z6DU1g |
| project_id | 384460d6ae4d4c69b598262b081836d0 |
| user_id | 54dd35e3bed048b995994371d7d4ba93
创建glance
MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'glance';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance'; Query OK, 0 rows affected (0.00 sec)
openstack role add --project service --user glance admin
vim /etc/glance/glance-api.conf
vim /etc/glance/glance-registry.conf
[database]
connection = mysql+pymysql://glance:glance@controller/glance
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
su -s /bin/sh -c "glance-manage db_sync" glance
get cirros-0.3.5-x86_64-disk.img
[root@controller ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| c9c2e3bb-c108-4655-9074-6554f14fa587 | cirros | active |
+--------------------------------------+--------+--------+
计算节点
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/common/get_started_compute.html
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/nova-controller-install.html
MariaDB [(none)]> CREATE DATABASE nova_api;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> CREATE DATABASE nova;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
openstack user create --domain default --password nova nova
vim /etc/nova/nova.conf
[vnc]
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova
[glance]
api_servers = http://controller:9292
[database]
connection = mysql+pymysql://nova:nova@controller/nova
[api_database]
connection = mysql+pymysql://nova:nova@controller/nova_api
[DEFAULT]
enabled_apis = osapi_compute,metadata
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 172.25.11.1
安装和配置计算节点
server2 (compute1) 进行如下操作
yum upgrade
vim /etc/nova/nova.conf
如果这个命令返回了 one or greater 的值,那么你的计算节点支持硬件加速且不需要额外的配置。
如果这个命令返回了 zero 值,那么你的计算节点不支持硬件加速。你必须配置 libvirt 来使用 QEMU 去代替 KVM
- 在 /etc/nova/nova.conf 文件的 [libvirt] 区域做出如下的编辑:
[root@controller ~]# . admin-openrc
[root@controller ~]# openstack compute service list
网络服务
参考
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/common/get_started_networking.html
controller上
yum install openstack-neutron -y
vim /etc/neutron/metadata_agent.ini
这里选择公共网络
vim /etc/neutron/neutron.conf
[DEFAULT]
core_plugin = ml2
service_plugins =
rpc_backend = rabbit
auth_strategy = keystone
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
vim /etc/neutron/plugins/ml2/ml2_conf.ini
vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
vim /etc/neutron/dhcp_agent.ini
为计算节点配置网络服务
compute1
controller
neutron agent-list
neutron ext-list
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/launch-instance-networks-provider.html
计算节点的网络配置
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/neutron-compute-install.html
yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y
vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
vim /etc/neutron/neutron.conf
vim /etc/nova/nova.conf
控制节点上
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/launch-instance-networks-provider.html
openstack security group rule create --proto icmp default
openstack security group rule create --proto tcp --dst-port 22 default
openstack flavor list
[root@controller ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| c9c2e3bb-c108-4655-9074-6554f14fa587 | cirros | active |
+--------------------------------------+--------+--------+
[root@controller ~]# openstack network list
+--------------------------------------+----------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+----------+--------------------------------------+
| 3404c6a4-0fea-4e1a-9da9-a229001ae746 | provider | fcc4e120-5673-478a-a43b-ad5cc39f1d6b |
+--------------------------------------+----------+--------------------------------------+
[root@controller ~]# openstack security group list
+--------------------------------------+---------+------------------------+----------------------------------+
| ID | Name | Description | Project |
+--------------------------------------+---------+------------------------+----------------------------------+
| 1bec09c1-4fc9-4092-b14d-40ca612b5a42 | default | Default security group | b5df2514678d41f58b20788d14968f93 |
+--------------------------------------+---------+------------------------+----------------------------------+
更新虚拟机qemu版本
[root@compute1 qemu]# ls
libcacard-2.5.2-2.1.el7.x86_64.rpm qemu-kvm-common-ev-2.6.0-28.el7.10.1.x86_64.rpm
qemu-img-ev-2.6.0-28.el7.10.1.x86_64.rpm qemu-kvm-ev-2.6.0-28.el7.10.1.x86_64.rpm
compute1:
vim /etc/nova/nova.conf
[libvirt]
cpu_mode = none
systemctl restart openstack-nova-compute
net-id选择 openstack network list 的
openstack server create --flavor m1.nano --image cirros --nic net-id=1bec09c1-4fc9-4092-b14d-40ca612b5a42 --security-group default --key-name mykey server1
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/launch-instance.html
openstack server stop server1
openstack console url show server1
openstack server list
帐号密码
cirros
cubswin:)
controller上免密
ssh cirros@172.25.11.101
使用图形 dashboard
参考
https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/horizon-install.html
里面的timezoen 改为 Asia/Shanghai
这里不能添加网络,修改下面即可
然后访问
http://172.25.11.1/dashboard/auth/login/?next=/dashboard/
计算节点
etc/neutron/plugins/ml2/linux...
[vxlan]
enable_vxlan = True
local_ip = 172.25.11.2
l2_population = True
[root@controller ~]# systemctl restart neutron-server neutron-linuxbridge-agent neutron-dhcp-agent neutron-metadata-agent neutron-l3-agent
首先admin 建立公网 public
demo下建立vm1云主机
然后 建立私网 192.168.0.0
然后建立路由 添加私网端口
再把私有网络在admin下共享出去
再次添加虚拟主机,使用私有网端
再绑定浮动ip即可
systemctl restart neutron-server neutron0linuxbridge-agent netron-dhcp-agent neutron-metadata-agent