openstack安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openstack安装相关的知识,希望对你有一定的参考价值。
环境:rhel7.3 配置yum源,软件名:mitake 注意解析,时间同步,设置节点主机名,为 controller 计算节点computer,添加网卡eth1形成双网卡
controller:172.25.35.13
computer:172.25.35.14
#注意:后面vim配置文件信息过多没有贴出来可参考官方中文文档:https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/ 只需注意密码设置即可
[[email protected] network-scripts]# vim ifcfg-eth0
BOOTPROTO=static
DEVICE=eth0
ONBOOT=yes
IPADDR=172.25.35.13
PREFIX=24
[[email protected] network-scripts]# vim ifcfg-eth1
BOOTPROTO=none
DEVICE=eth1
ONBOOT=yes
[[email protected] network-scripts]# ifup eth1 启动无配置eth1网卡
[[email protected] network-scripts]# yum install chrony
[[email protected] network-scripts]# systemctl disable NetworkManager
[[email protected] network-scripts]# vim /etc/chrony.conf 时间和物理机同步
[[email protected] network-scripts]# systemctl restart chronyd
[[email protected] network-scripts]# systemctl enable chronyd
[[email protected] network-scripts]# yum install python-openstackclient
[[email protected] network-scripts]# yum install openstack-selinux
[[email protected] network-scripts]# yum install mariadb
[[email protected] network-scripts]# yum install python2-Pymysql
[[email protected] network-scripts]# systemctl enable mariadb.service
[[email protected] network-scripts]# systemctl start mariadb.service
[[email protected] network-scripts]# yum install rabbitmy-server
[[email protected][[email protected] network-scripts]# systemctl enable rabbitmq-server
[[email protected] network-scripts]# yum install python-openstackclient
[[email protected] my.cnf.d]# vim openstack.cnf
[mysqld]
bind-address = 172.25.35.13
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = ‘SET NAMES utf8‘
character-set-server = utf8
[[email protected] my.cnf.d]# systemctl enable mariadb.service
[[email protected] my.cnf.d]# mysql_secure_installation 初始化数据库密码
[[email protected]controller my.cnf.d]# systemctl enable rabbitmq-server.service
[[email protected] my.cnf.d]# systemctl start rabbitmq-server.service
[[email protected] my.cnf.d]# rabbitmqctl add_user openstack openstack 创建openstack用户
[[email protected] my.cnf.d]# rabbitmqctl set_permissions openstack "." "." ".*"赋予权限
[[email protected] my.cnf.d]# yum install memcached python-memcached
[[email protected] my.cnf.d]# systemctl enable memcached.service
[[email protected] my.cnf.d]# systemctl start memcached.service
[[email protected] my.cnf.d]# vim /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1,::1"
[[email protected] my.cnf.d]# rabbitmq-plugins list
[[email protected] my.cnf.d]# rabbitmq-plugins enable rabbitmq_management
[[email protected] my.cnf.d]# mysql -u root -p 进入数据库
创建 keystone 数据库:建议名称和密码一致
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone. TO ‘keystone‘@‘localhost‘ IDENTIFIED BY ‘keystone‘;
GRANT ALL PRIVILEGES ON keystone. TO ‘keystone‘@‘%‘ IDENTIFIED BY ‘keystone‘;
退出数据库:
生成生成一个随机值在初始的配置中作为管理员的令牌
openssl rand -hex 10
85edd158c03265a1b3d1
[[email protected] my.cnf.d]# mysql -ukeystone -pkeystone 可用新建的用户密码进以下看可否登陆。
[[email protected] my.cnf.d]# yum install openstack-keystone httpd mod_wsgi
定义初始管理令牌的值:
[[email protected] ~]# vim /etc/keystone/keystone.conf
初始化身份认证服务的数据库:
初始化身份认证服务的数据库:
[[email protected] ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone
初始化Fernet keys:
[[email protected] ~]# keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
[[email protected] ~]# vim /etc/httpd/conf/httpd.conf
创建文件 /etc/httpd/conf.d/wsgi-keystone.conf
[[email protected] ~]# vim /etc/httpd/conf.d/wsgi-keystone.conf
Listen 5000Listen 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>
[[email protected] ~]# systemctl enable httpd.service
[[email protected] ~]# systemctl start httpd.service
配置认证令牌:
[[email protected] ~]# export OS_TOKEN=56785451cc7970d2945e 前面生成的令牌
[[email protected] ~]# export OS_URL=http://controller:35357/v3
[[email protected] ~]# export OS_IDENTITY_API_VERSION=3
创建服务实体和身份认证服务:
[[email protected] ~]# openstack service create --name keystone --description "OpenStack Identity" identity
[[email protected] ~]# openstack endpoint create --region RegionOne identity public http://controller:5000/v3
[[email protected] ~]#openstack endpoint create --region RegionOne identity internal http://controller:5000/v3
[[email protected] ~]#openstack endpoint create --region RegionOne identity admin http://controller:35357/v3
[[email protected] ~]# openstack domain create --description "Default Domain" default
[[email protected] ~]# openstack project create --domain default --description "Admin Project" admin
[[email protected] ~]# openstack user create --domain default --password-admin admin
[[email protected] ~]# openstack role create admin
[[email protected] ~]# openstack role add --project admin --user admin admin
[[email protected] ~]# openstack project create --domain default --description "Service Project" service
[[email protected] ~]# openstack project create --domain default --description "Demo Project" demo
[[email protected] ~]# openstack user create --domain default --password demo demo
[[email protected] ~]# openstack role create user
[[email protected] ~]# openstack role add --project demo --user demo user
[[email protected] ~]# unset OS_TOKEN OS_URL
[[email protected] ~]# openstack --os-auth-url http://controller:35357/v3 --os-project-domain-id default --os-user-domain-id default
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# openstack --os-auth-url http://controller:35357/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name demo --os-username demo token issue
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# source admin_openrc
[[email protected] ~]# openstack token issue
[[email protected] ~]# openstack-status
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# openstack-status
[[email protected] ~]# systemctl status openstack-keystone
[[email protected] ~]# systemctl enable httpd
[[email protected] ~]# systemctl restart httpd
[[email protected] ~]# openstack-service status openstack-keystone
[[email protected] ~]# systemctl status openstack-keystone
[[email protected] ~]# yum install -y openstack-utils
[[email protected] ~]# openstack token issue
用数据库连接客户端以 root 用户连接到数据库服务器
[[email protected] ~]# mysql -predhat
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance. TO ‘glance‘@‘localhost‘ IDENTIFIED BY ‘glance‘;
GRANT ALL PRIVILEGES ON glance. TO ‘glance‘@‘%‘ IDENTIFIED BY ‘glance‘;
退出数据库:
[[email protected] ~]# source admin_openrc
[[email protected] ~]# openstack user create --domain default --password glance glance
[[email protected] ~]# openstack role add --project service --user glance admin
[[email protected] ~]# openstack service create --name glance
--description "OpenStack Image" image
[[email protected] ~]# openstack endpoint create --region RegionOne
image public http://controller:9292
[[email protected] ~]# openstack endpoint create --region RegionOne
image internal http://controller:9292
[[email protected] ~]# openstack endpoint create --region RegionOne
image admin http://controller:9292
[[email protected] ~]# yum install openstack-glance
[[email protected] ~]# vim /etc/glance/glance-api.conf
[database]
connection = mysql+pymysql://glance:[email protected]/glance
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[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
[paste_deploy]
flavor = keystone
[[email protected] ~]# vim /etc/glance/glance-registry.conf
[paste_deploy]
flavor = keystone
[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
[database]
connection = mysql+pymysql://glance:[email protected]/glance
[[email protected] ~]# su -s /bin/sh -c "glance-manage db_sync" glance
[[email protected] ~]# systemctl enable openstack-glance-api.service
openstack-glance-registry.service
[[email protected] ~]# systemctl start openstack-glance-api.service openstack-glance-registry.service
[[email protected] ~]# netstat -antlp|grep :9292
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 17700/python2
下载 cirros-0.3.5-x86_64-disk.img
[[email protected] ~]# openstack image create "cirros"
--file cirros-0.3.5-x86_64-disk.img
--disk-format qcow2 --container-format bare
--public
[[email protected] ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 0a5a2b41-d69a-43fc-abe9-a03fd418691a | cirros | active |
+--------------------------------------+--------+--------+
计算节点
[[email protected] ~]# mysql -predhat
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)
MariaDB [(none)]> quit
Bye
[[email protected] ~]# openstack user create --domain default --password nova nova
[[email protected] ~]# openstack role add --project service --user nova admin
[[email protected] ~]# openstack service create --name nova
--description "OpenStack Compute" compute
[[email protected] ~]# openstack endpoint create --region RegionOne
compute public http://controller:8774/v2.1/%(tenant_id)s
[[email protected] ~]# openstack endpoint create --region RegionOne
compute internal http://controller:8774/v2.1/%(tenant_id)s
[[email protected] ~]# openstack endpoint create --region RegionOne
compute admin http://controller:8774/v2.1/%(tenant_id)s
[[email protected] ~]# yum install openstack-nova-api openstack-nova-conductor
openstack-nova-console openstack-nova-novncproxy
openstack-nova-scheduler
[[email protected] ~]# vim /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 172.25.135.13
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api_database]
connection = mysql+pymysql://nova:[email protected]/nova_api
[database]
connection = mysql+pymysql://nova:[email protected]/nova
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack
[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
[vnc]
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[[email protected] ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
[[email protected] ~]# su -s /bin/sh -c "nova-manage db sync" nova
[[email protected] ~]# systemctl enable openstack-nova-api.service
openstack-nova-consoleauth.service openstack-nova-scheduler.service
openstack-nova-conductor.service openstack-nova-novncproxy.service
[[email protected] ~]# systemctl start openstack-nova-api.service
openstack-nova-consoleauth.service openstack-nova-scheduler.service
openstack-nova-conductor.service openstack-nova-novncproxy.service
[[email protected] ~]# openstack compute service list
+----+---------------+------------+----------+---------+-------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated At |
+----+---------------+------------+----------+---------+-------+-----------------+
| 1 | nova- | controller | internal | enabled | up | 2018-12-01T07:2 |
| | conductor | | | | | 6:43.000000 |
| 2 | nova- | controller | internal | enabled | up | 2018-12-01T07:2 |
| | consoleauth | | | | | 6:44.000000 |
| 3 | nova- | controller | internal | enabled | up | 2018-12-01T07:2 |
| | scheduler | | | | | 6:44.000000 |
+----+---------------+------------+----------+---------+-------+-----------------+
[[email protected] ~]# yum install openstack-nova-compute
[[email protected] ~]# vim /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 172.25.135.14
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api_database]
connection = mysql+pymysql://nova:[email protected]/nova_api
[database]
connection = mysql+pymysql://nova:[email protected]/nova
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack
[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
[vnc]
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[[email protected] ~]# egrep -c ‘(vmx|svm)‘ /proc/cpuinfo
[[email protected] ~]# systemctl enable libvirtd.service openstack-nova-compute.service
[[email protected] ~]# systemctl start libvirtd.service openstack-nova-compute.service
[[email protected] ~]# openstack compute service list
+----+---------------+------------+----------+---------+-------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated At |
+----+---------------+------------+----------+---------+-------+-----------------+
| 1 | nova- | controller | internal | enabled | up | 2018-12-01T07:3 |
| | conductor | | | | | 3:13.000000 |
| 2 | nova- | controller | internal | enabled | up | 2018-12-01T07:3 |
| | consoleauth | | | | | 3:04.000000 |
| 3 | nova- | controller | internal | enabled | up | 2018-12-01T07:3 |
| | scheduler | | | | | 3:04.000000 |
| 6 | nova-compute | computer | nova | enabled | up | 2018-12-01T07:3 |
| | | | | | | 3:13.000000 |
+----+---------------+------------+----------+---------+-------+-----------------+
[[email protected] ~]# vim /etc/nova/nova.conf
[[email protected] ~]# mysql -predhat
MariaDB [(none)]> CREATE DATABASE neutron;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘localhost‘
-> IDENTIFIED BY ‘neutron‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘%‘
-> IDENTIFIED BY ‘neutron‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> ^DBye
[[email protected] ~]# openstack user create --domain default --password neutron neutron
[[email protected] ~]# openstack role add --project service --user neutron admin
[[email protected] ~]# openstack service create --name neutron
--description "OpenStack Networking" network
[[email protected] ~]# openstack endpoint create --region RegionOne
network public http://controller:9696
[[email protected] ~]# openstack endpoint create --region RegionOne
network internal http://controller:9696
[[email protected] ~]# openstack endpoint create --region RegionOne
network admin http://controller:9696
[[email protected] ~]# yum install openstack-neutron openstack-neutron-ml2
openstack-neutron-linuxbridge ebtables
[[email protected] ~]# vim /etc/neutron/neutron.conf
[[email protected] ~]# vim /etc/neutron/plugins/ml2/ml2_conf.ini
[[email protected] ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~]# vim /etc/neutron/dhcp_agent.ini
[[email protected] ~]# vim /etc/neutron/metadata_agent.ini
[[email protected] ~]# vim /etc/nova/nova.conf
[[email protected] ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
[[email protected] ~]# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
[[email protected] ~]# systemctl restart openstack-nova-api.service
[[email protected] ~]# systemctl enable neutron-server.service
neutron-linuxbridge-agent.service neutron-dhcp-agent.service
neutron-metadata-agent.service
[[email protected] ~]# systemctl start neutron-server.service
neutron-linuxbridge-agent.service neutron-dhcp-agent.service
neutron-metadata-agent.service
[[email protected] ~]# neutron agent-list
[[email protected] ~]# neutron agent-list
[[email protected] ~]# openstack compute service list
[[email protected] ~]# yum install openstack-neutron-linuxbridge ebtables ipset
[[email protected] ~]# vim /etc/neutron/neutron.conf
[[email protected] ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~]# vim /etc/nova/nova.conf
[[email protected] ~]# systemctl restart openstack-nova-compute.service
[[email protected] ~]# systemctl enable neutron-linuxbridge-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-linuxbridge-agent.service to /usr/lib/systemd/system/neutron-linuxbridge-agent.service.
[[email protected] ~]# systemctl start neutron-linuxbridge-agent.service
[[email protected] ~]# ls
mitaka qemu
[[email protected] ~]# cd qemu/
[[email protected] 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
[[email protected] qemu]# yum install -y *
[[email protected] qemu]# virsh version #版本升级必须,不然起不来
根据库编译:libvirt 2.0.0
使用库:libvirt 2.0.0
使用的 API: QEMU 2.0.0
运行管理程序: QEMU 2.6.0
[[email protected] qemu]# vim /etc/nova/nova.conf
[libvirt]
virt_type = qemu
cpu_mode = none #云主机定在peix上解决办法
[[email protected] qemu]# systemctl restart openstack-nova-compute.service
[[email protected] ~]# neutron subnet-create --name provider --allocation-pool start=172.25.135.200,end=172.25.135.230 provider 172.25.135.0/24
[[email protected] ~]# openstack network list
[[email protected] ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
[[email protected] ~]# source demo_openrc
[[email protected] ~]# ssh-keygen -q -N ""
[[email protected] ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
[[email protected] ~]# openstack keypair list
[[email protected] ~]# openstack security group rule create --proto icmp default
[[email protected] ~]# openstack security group rule create --proto tcp --dst-port 22 default
[[email protected] ~]# openstack flavor list
[[email protected] ~]# openstack image list
[[email protected] ~]# openstack network list
+--------------------------------------+----------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+----------+--------------------------------------+
| 3beaf1bb-eef5-4945-8b6d-363cc85b0bca | provider | aaeb405c-1242-4164-9137-0bdf0e9b7df4 |
+--------------------------------------+----------+--------------------------------------+
[[email protected] ~]# openstack security group list
[[email protected] ~]# openstack server create --flavor m1.tiny --image cirros
--nic net-id=3beaf1bb-eef5-4945-8b6d-363cc85b0bca --security-group default
--key-name mykey provider-instance
[[email protected] ~]# openstack server list
[[email protected] ~]# openstack console url show provider-instance
网页上起云主机http://controller:6080/vnc_auto.html?token=1503968b-b215-4a10-89ed-0bf8f3f955a0
[[email protected] ~]# ssh [email protected] #可以ssh上去
[[email protected] ~]# yum install openstack-dashboard #图形化界面
[[email protected] ~]# vim /etc/openstack-dashboard/local_settings
[[email protected] ~]# systemctl restart httpd.service memcached.service
以上是关于openstack安装的主要内容,如果未能解决你的问题,请参考以下文章