centos7 手动安装OpenStack

文章目录

    • 准备
      • 环境
        • 修改Host
        • 防火墙和selinux
        • 时间同步
      • maridadb
      • 消息队列
      • memcache
    • Keystone
      • 报错
        • 同步数据库报错
    • Glance
      • 报错
    • Nova
    • Neutron
    • Horizon

我现在日常安装OSmmp。
不想删ubuntu里面的,也不太会删除。。干脆重新装,这次用centos7,这个看起来比较简洁。
(图片文件夹是openstack-3)
我觉得这个更靠谱一些,比之前ubuntu手动装好多了,奇怪的报错也少了。

准备

环境是

  • centos 7
  • 6G RAM
  • 4核 CPU
  • 35G 硬盘

老规矩先换源,用阿里源
先备份再下载

su
mv /etc/yum.repos.d/CentOS-Base.repo /home/kang/Desktop/mydir/CentOS-Base.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

更新缓存

yum clean all
yum makecache

环境

第一节

修改Host

设置主机名和映射

hostnamectl set-hostname controller

编辑/etc/hosts,添加

192.168.119.130 controller

防火墙和selinux

关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl statuc firewalld.service

关闭selinux,修改/etc/sysconfig/selinuxSELINUX=enfoecinf改为SELINUX=disabled,保存,重启才会生效。

时间同步

安装chrony

yum install chrony -y

直接用阿里云的时间服务器,编辑配置文件/etc/chrony.conf

server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
allow 192.168.119.130

设置开机启动

systemctl restart chronyd.service
systemctl status chronyd.service
systemctl enable chronyd.service
systemctl list-unit-files |grep chronyd.service

设置时区

timedatectl set-timezone Asia/Shanghai
chronyc sources
timedatectl status

image-1
安装openstack-rocky的仓库,再更新一下缓存

yum install centos-release-openstack-rocky -y
yum clean all
yum makecache

执行yum update -y更新软件。
很慢很慢,更新一半不弄了,太慢了。
然后安装客户端相关软件

yum install python-openstackclient openstack-selinux -y

我觉得可能是源的问题,下载还是慢。

maridadb

yum install mariadb mariadb-server MySQL-python python2-PyMySQL -y

配置密码

mysql_secure_installation

可能会报错

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory")
Enter current password for root (enter for none): 

因为服务没打开,打开一下就行了。systemctl start/status/stop mariadb.service
编辑配置文件/etc/my.cnf.d/mariadb_openstack.cnf,这里好像需要新建,添加如下内容

[mysqld]
bind-address = 0.0.0.0
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
init-connect = 'SET NAMES utf8'

设置开机自启动

systemctl restart mariadb.service
systemctl status mariadb.service 
systemctl enable mariadb.service 
systemctl list-unit-files |grep mariadb.service

消息队列

安装兔子

yum install rabbitmq-server -y

启动和设置自启动

systemctl start rabbitmq-server.service
systemctl status rabbitmq-server.service
systemctl enable rabbitmq-server.service
systemctl list-unit-files |grep rabbitmq-server.service

创建密码,配置权限

rabbitmqctl add_user openstack openstack
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
rabbitmqctl set_permissions -p "/" openstack ".*" ".*" ".*"

启动插件,重启服务

rabbitmq-plugins list

rabbitmq-plugins enable rabbitmq_management
systemctl restart rabbitmq-server.service
rabbitmq-plugins list
lsof -i:15672

memcache

Keystone

CentOS7安装OpenStack(Rocky版)-02.安装Keyston认证服务组件(控制节点)

创建数据库

CREATE DATABASE KEYSTONE;

授权

GRANT ALL PRIVILEGES ON KEYSTONE.* TO 'keystone'@'localhost' IDENTIFIED BY 'openstack';
GRANT ALL PRIVILEGES ON KEYSTONE.* TO 'keystone'@'%' IDENTIFIED BY 'openstack';

安装,慢死了

yum install openstack-keystone httpd mod_wsgi -y

编辑配置文件/etc/keystone/keystone.conf,修改两处

...
[database]
connection=mysql+pymysql://keystone:openstack@controller/KEYSTONE
...
[token]
provider=fernet
...

同步数据库

su -s /bin/sh -c "keystone-manage db_sync" keystone

初始化fernet令牌

keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone

然后就是配置httpd,用了这么久终于能用httpd了,编辑/etc/httpd/conf/httpd.conf ,添加ServerName controller
创建快捷方式

ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/

启动服务,开机自启动

systemctl start httpd.service
systemctl enable httpd.service

创建keystone服务实体和身份认证服务,不会有回显 ,可以cat /var/log/keystone/keystone.log查看。管理员密码是admin。

keystone-manage bootstrap --bootstrap-password admin --bootstrap-admin-url http://controller:5000/v3/ --bootstrap-internal-url http://controller:5000/v3/ --bootstrap-public-url http://controller:5000/v3/ --bootstrap-region-id RegionOne

编写~/.admin-openrc文件

export OS_PROJECT_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3

应用并查看

source .admin-openrc
env |grep OS_

创建服务项目

openstack project create --domain default --description "Service Project" service

创建一个demo项目

openstack project create --domain default --description "Demo Project" demo

创建demo用户,密码是demo

openstack user create --domain default --password-prompt demo

创建并添加角色

openstack role create user
openstack role add --project demo --user demo user

在命令行测试使用admin请求token,会有回显说明成功。

openstack --os-auth-url http://controller:5000/v3 \
  --os-project-domain-name Default --os-user-domain-name Default \
  --os-project-name admin --os-username admin token issue

新增一个demo用户脚本~/.demo-openrc

export OS_PROJECT_DOMAIN_NAME=Default
export OS_PROJECT_NAME=demo
export OS_USER_DOMAIN_NAME=Default
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

至此完毕。

报错

同步数据库报错

同步数据库的时候如果报错

2020-02-26 16:45:34.073 7296 ERROR keystone     raise errorclass(errno, errval)
2020-02-26 16:45:34.073 7296 ERROR keystone OperationalError: (pymysql.err.OperationalError) (1045, u"Access denied for user 'keystone'@'controller' (using password: YES)") (Background on this error at: http://sqlalche.me/e/e3q8)
2020-02-26 16:45:34.073 7296 ERROR keystone 

可能是密码错了,这里要注意在刚才配置文件中写的connection=mysql+pymysql://keystone:keystone@controller/KEYSTONE,其中强调的部分是数据库的密码,最后是数据库的名字。这个密码是什么呢,是授权的时候GRANT ALL PRIVILEGES ON KEYSTONE.* TO ‘keystone’@‘localhost’ IDENTIFIED BY ‘openstack’;这里强调的部分,这两个要一致。
这时候再重新同步数据库就没问题了。可以通过查看日志输出看结果。

Glance

CentOS7安装OpenStack(Rocky版)-03.安装Glance镜像服务组件(控制节点)

创建数据库授权

CREATE DATABASE GLANCE;
GRANT ALL PRIVILEGES ON GLANCE.* TO 'glance'@'localhost' IDENTIFIED BY 'openstack';
GRANT ALL PRIVILEGES ON GLANCE.* TO 'glance'@'localhost' IDENTIFIED BY 'openstack';

创建glance用户,密码是openstack

openstack user create --domain default --password-prompt glance

添加管理员权限

openstack role add --project service --user glance admin

创建镜像服务实体

openstack service create --name glance --description "OpenStack Image" image

添加endpoint

openstack endpoint create --region RegionOne image public http://192.168.119.130:9292
openstack endpoint create --region RegionOne image internal http://192.168.119.130:9292
openstack endpoint create --region RegionOne image admin http://192.168.119.130:9292

要先确认一下python版本,我是2.7.5,然后安装glance

yum install openstack-glance python-glance python-glanceclient -y

编辑配置文件/etc/glance/glance-api.conf

[database]
connection=mysql+pymysql://glance:openstack@controller/GLANCE
...
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url=http://controller:5000
auth_url=http://controller:35357
memcached_servers = controller:11211
auth_type=password
user_domain_name=Default
username=glance
password=openstack
project_name=service
...
[paste_deploy]
flavor = keystone
...
[paste_deploy]
stores=file,http
default_store=file
filesystem_store_datadir=/var/lib/glance/images/

再修改配置文件/etc/glance/glance-registry.conf

[database]
connection=mysql+pymysql://glance:openstack@controller/GLANCE
...
[keystone_authtoken]
auth_url=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=openstack
...
[paste_deploy]
flavor = keystone

同步数据库

su -s /bin/sh -c "glance-manage db_sync" glance

重启服务,开机自启动

systemctl start openstack-glance-api.service openstack-glance-registry.service
systemctl enable openstack-glance-api.service openstack-glance-registry.service

然后可以用一个镜像试一下glance,用cirros,先下载镜像,不过一般下不下来

wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img

然后切换管理员脚本,上传镜像

openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public

报错

这时候报错了
HTTPInternalServerError (HTTP 500)

查看glance的api日志,如下

DiscoveryFailure: Could not find versioned identity endpoints when attempting to 巴拉巴拉。Unable to establish connection to http: //controller :35357 巴拉巴拉

想想也是,跟着这个教程的确没配置35357端口。
修改glance的两个配置文件,分别在[keystone_authtoken]添加auth_uri=http://controller:35357,重启glance两个服务,再次执行创建镜像,就可以了。

Nova

CentOS7安装OpenStack(Rocky版)-04.安装Nova计算服务(控制节点)

创建数据库

CREATE DATABASE NOVA_API;
CREATE DATABASE NOVA;
CREATE DATABASE NOVA_cell0;
CREATE DATABASE PLACEMENT;

授权

GRANT ALL PRIVILEGES ON NOVA_API.* TO 'nova'@'localhost' IDENTIFIED BY 'openstack';
GRANT ALL PRIVILEGES ON NOVA_API.* TO 'nova'@'%' IDENTIFIED BY 'openstack';

GRANT ALL PRIVILEGES ON NOVA.* TO 'nova'@'localhost' IDENTIFIED BY 'openstack';
GRANT ALL PRIVILEGES ON NOVA.* TO 'nova'@'%' IDENTIFIED BY 'openstack';

GRANT ALL PRIVILEGES ON NOVA_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'openstack';
GRANT ALL PRIVILEGES ON NOVA_cell0.* TO 'nova'@'%' IDENTIFIED BY 'openstack';

GRANT ALL PRIVILEGES ON PLACEMENT.* TO 'nova'@'localhost' IDENTIFIED BY 'openstack';
GRANT ALL PRIVILEGES ON PLACEMENT.* TO 'nova'@'%' IDENTIFIED BY 'openstack';

创建用户,密码openstack

openstack user create --domain default --password-prompt nova

添加角色创建实体

openstack role add --project service --user nova admin
openstack service create --name nova --description "OpenStack Compute" compute

创建API端点

openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1

这个版本多了个placement,密码是openstack。

openstack user create --domain default --password-prompt placement
openstack role add --project service --user placement admin
openstack service create --name placement --description "Placement API" placement

创建端点

openstack endpoint create --region RegionOne placement internal http://controller:8774
openstack endpoint create --region RegionOne placement public http://controller:8774
openstack endpoint create --region RegionOne placement admin http://controller:8774

安装nova服务

yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api -y

配置过程直接写成sh脚本吧

openstack-config --set  /etc/nova/nova.conf DEFAULT enabled_apis  osapi_compute,metadata
openstack-config --set  /etc/nova/nova.conf DEFAULT my_ip 192.168.119.130
openstack-config --set  /etc/nova/nova.conf DEFAULT use_neutron  true 
openstack-config --set  /etc/nova/nova.conf DEFAULT firewall_driver  nova.virt.firewall.NoopFirewallDriver
openstack-config --set  /etc/nova/nova.conf DEFAULT transport_url  rabbit://openstack:openstack@controller
openstack-config --set  /etc/nova/nova.conf api_database connection  mysql+pymysql://nova:openstack@controller/NOVA_API
openstack-config --set  /etc/nova/nova.conf database connection  mysql+pymysql://nova:openstack@controller/NOVA
openstack-config --set  /etc/nova/nova.conf placement_database connection  mysql+pymysql://placement:openstack@controller/PLACEMENT
openstack-config --set  /etc/nova/nova.conf api auth_strategy  keystone 
openstack-config --set  /etc/nova/nova.conf keystone_authtoken auth_url  http://controller:5000/v3
openstack-config --set  /etc/nova/nova.conf keystone_authtoken memcached_servers  controller:11211
openstack-config --set  /etc/nova/nova.conf keystone_authtoken auth_type  password
openstack-config --set  /etc/nova/nova.conf keystone_authtoken project_domain_name  default 
openstack-config --set  /etc/nova/nova.conf keystone_authtoken user_domain_name  default
openstack-config --set  /etc/nova/nova.conf keystone_authtoken project_name  service 
openstack-config --set  /etc/nova/nova.conf keystone_authtoken username  nova 
openstack-config --set  /etc/nova/nova.conf keystone_authtoken password  openstack
openstack-config --set  /etc/nova/nova.conf vnc enabled true
openstack-config --set  /etc/nova/nova.conf vnc server_listen '$my_ip'
openstack-config --set  /etc/nova/nova.conf vnc server_proxyclient_address '$my_ip'
openstack-config --set  /etc/nova/nova.conf glance api_servers  http://controller:9292
openstack-config --set  /etc/nova/nova.conf oslo_concurrency lock_path  /var/lib/nova/tmp 
openstack-config --set  /etc/nova/nova.conf placement region_name RegionOne
openstack-config --set  /etc/nova/nova.conf placement project_domain_name Default
openstack-config --set  /etc/nova/nova.conf placement project_name service
openstack-config --set  /etc/nova/nova.conf placement auth_type password
openstack-config --set  /etc/nova/nova.conf placement user_domain_name Default
openstack-config --set  /etc/nova/nova.conf placement auth_url http://controller:5000/v3
openstack-config --set  /etc/nova/nova.conf placement username placement
openstack-config --set  /etc/nova/nova.conf placement password openstack
openstack-config --set  /etc/nova/nova.conf scheduler discover_hosts_in_cells_interval 300

执行egrep -v “#|$” /etc/nova/nova.conf查看是否配置好。
由于有个bug,一个配置文件需要自己配置一下,/etc/httpd/conf.d/00-nova-placement-api.conf,添加


   = 2.4>
      Require all granted
   
   
      Order allow,deny
      Allow from all
   

重启服务

systemctl restart httpd.service

同步nova-api和placement数据库

su -s /bin/sh -c "nova-manage api_db sync" nova

此时如果报错类似错误,是数据库密码不对,检查nova配置文件中密码有没有写对,数据库的密码有没有设置正确。

OperationalError: (pymysql.err.OperationalError) (1045, u"Access denied for user 'placement'@'controller' (using password: YES)") (Background on this error at: http://sqlalche.me/e/e3q8)

注册cell0数据库,创建cell1单元。

su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova

初始化nova数据库

su -s /bin/sh -c "nova-manage db sync" nova

检查是否成功

su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova

奇怪的是,没有找到nova_cell0这个数据库在哪里设置,本来我用的是NOVA_CELL0,但是没有地方修改,他报错说是NOVA_cell0,就把数据库改成NOVA_cell0了。
启动服务和开机自启动,有五个服务。

systemctl start openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service 
systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service

Neutron

CentOS7安装OpenStack(Rocky版)-06.安装Neutron网络服务(控制节点)
难受,上次就是在这里然后开始无限报错了。
创建数据库

CREATE DATABASE NEUTRON;
GRANT ALL PRIVILEGES ON NEUTRON.* TO 'neutron'@'localhost' IDENTIFIED BY 'openstack';
Query OK, 0 rows affected (0.00 sec)
GRANT ALL PRIVILEGES ON NEUTRON.* TO 'neutron'@'%' IDENTIFIED BY 'openstack';

创建用户

openstack user create --domain default --password-prompt neutron

添加角色,创建实体

openstack role add --project service --user neutron admin
openstack service create --name neutron --description "OpenStack Networking" network

创建API端点

openstack endpoint create --region RegionOne network internal http://controller:9696
openstack endpoint create --region RegionOne network public http://controller:9696
openstack endpoint create --region RegionOne network admin http://controller:9696

安装neutron,老规矩,很慢。

yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y

快速配置一下,还是用sh脚本实现吧,保存成s.sh

openstack-config --set  /etc/neutron/neutron.conf database connection  mysql+pymysql://neutron:openstack@controller/NEUTRON 
openstack-config --set  /etc/neutron/neutron.conf DEFAULT core_plugin  ml2  
openstack-config --set  /etc/neutron/neutron.conf DEFAULT service_plugins 
openstack-config --set  /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:openstack@controller
openstack-config --set  /etc/neutron/neutron.conf DEFAULT auth_strategy  keystone  
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken www_authenticate_uri  http://controller:5000
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken auth_url  http://controller:5000
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken memcached_servers  controller:11211
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken auth_type  password  
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken project_domain_name default  
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken user_domain_name  default  
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken project_name  service  
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken username  neutron  
openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken password  openstack  
openstack-config --set  /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_status_changes  True  
openstack-config --set  /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_data_changes  True  
openstack-config --set  /etc/neutron/neutron.conf nova auth_url  http://controller:5000
openstack-config --set  /etc/neutron/neutron.conf nova auth_type  password 
openstack-config --set  /etc/neutron/neutron.conf nova project_domain_name  default  
openstack-config --set  /etc/neutron/neutron.conf nova user_domain_name  default  
openstack-config --set  /etc/neutron/neutron.conf nova region_name  RegionOne  
openstack-config --set  /etc/neutron/neutron.conf nova project_name  service  
openstack-config --set  /etc/neutron/neutron.conf nova username  nova  
openstack-config --set  /etc/neutron/neutron.conf nova password  openstack  
openstack-config --set  /etc/neutron/neutron.conf oslo_concurrency lock_path  /var/lib/neutron/tmp

执行sh s.sh就可以配置。
查看配置是否成功egrep -v ‘($|#)’ /etc/neutron/neutron.conf
配置etc/neutron/plugins/ml2/ml2_conf.ini,这里只放脚本内容了。

openstack-config --set  /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers  flat,vlan
openstack-config --set  /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types 
openstack-config --set  /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers  linuxbridge
openstack-config --set  /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers  port_security
openstack-config --set  /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks  provider 
openstack-config --set  /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset  True 

查看配置egrep -v ‘($|#)’ /etc/neutron/plugins/ml2/ml2_conf.ini
配置/etc/neutron/plugins/ml2/linuxbridge_agent.ini

openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings  provider:eno16777736
openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan  enable_vxlan  False
openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup  enable_security_group  True 
openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup  firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

查看egrep -v ‘($|#)’ /etc/neutron/plugins/ml2/linuxbridge_agent.ini
配置/etc/neutron/dhcp_agent.ini

openstack-config --set   /etc/neutron/dhcp_agent.ini DEFAULT  interface_driver  linuxbridge
openstack-config --set   /etc/neutron/dhcp_agent.ini DEFAULT  dhcp_driver  neutron.agent.linux.dhcp.Dnsmasq
openstack-config --set   /etc/neutron/dhcp_agent.ini DEFAULT  enable_isolated_metadata  True

查看生效egrep -v ‘($|#)’ /etc/neutron/dhcp_agent.ini
配置/etc/neutron/metadata_agent.ini

openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT nova_metadata_host controller
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT metadata_proxy_shared_secret neutron

查看生效egrep -v ‘($|#)’ /etc/neutron/metadata_agent.ini
配置计算服务使用网络服务,需要配置/etc/nova/nova.conf文件。

openstack-config --set  /etc/nova/nova.conf  neutron url http://controller:9696
openstack-config --set  /etc/nova/nova.conf  neutron auth_url http://controller:5000
openstack-config --set  /etc/nova/nova.conf  neutron auth_type password
openstack-config --set  /etc/nova/nova.conf  neutron project_domain_name default
openstack-config --set  /etc/nova/nova.conf  neutron user_domain_name default
openstack-config --set  /etc/nova/nova.conf  neutron region_name RegionOne
openstack-config --set  /etc/nova/nova.conf  neutron project_name service
openstack-config --set  /etc/nova/nova.conf  neutron username neutron
openstack-config --set  /etc/nova/nova.conf  neutron password openstack
openstack-config --set  /etc/nova/nova.conf  neutron service_metadata_proxy true
openstack-config --set  /etc/nova/nova.conf  neutron metadata_proxy_shared_secret neutron

查看生效egrep -v ‘($|#)’ /etc/nova/nova.conf
初始化安装网络插件

ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini

同步数据库

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

会有如下回显

INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
  Running upgrade for neutron ...
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> kilo
。
。
。
INFO  [alembic.runtime.migration] Running upgrade a84ccf28f06a -> 7d9d8eeec6ad
INFO  [alembic.runtime.migration] Running upgrade 7d9d8eeec6ad -> a8b517cff8ab
INFO  [alembic.runtime.migration] Running upgrade a8b517cff8ab -> 3b935b28e7a0
INFO  [alembic.runtime.migration] Running upgrade 3b935b28e7a0 -> b12a3ef66e62
INFO  [alembic.runtime.migration] Running upgrade b12a3ef66e62 -> 97c25b0d2353
INFO  [alembic.runtime.migration] Running upgrade 97c25b0d2353 -> 2e0d7a8a1586
INFO  [alembic.runtime.migration] Running upgrade 2e0d7a8a1586 -> 5c85685d616d
  OK

重启nova_api服务

systemctl restart openstack-nova-api.service

启动服务,开机自启动

systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service

这样好像这个Neutron服务就弄好了。
验证Neutron服务安装完成:

  • 执行admin-openrc脚本,指行openstack extension list --network查看加载的网络插件。
  • openstack network agent list

+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| ID                                   | Agent Type         | Host       | Availability Zone | Alive | State | Binary                    |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| 579a1cc6-49f9-4492-9886-b9d833991680 | Linux bridge agent | controller | None              | :-)   | UP    | neutron-linuxbridge-agent |
| d11ea856-c5e4-4c7b-b963-7a218b47538b | Metadata agent     | controller | None              | :-)   | UP    | neutron-metadata-agent    |
| d1d47b80-2c30-43cb-829f-7a86c9e1ada9 | DHCP agent         | controller | nova              | :-)   | UP    | neutron-dhcp-agent        |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+

Horizon

CentOS7安装OpenStack(Rocky版)-07.安装horizon服务组件(控制节点dashboard)
然后就是安装dashboard了。

yum install openstack-dashboard -y

编辑配置文件/etcc/openstack-dashboard/local_settings,确认一下配置

ALLOWED_HOSTS = ['*', ]
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
OPENSTACK_API_VERSIONS = {
    "identity": 3,
    "image": 2,
    "volume": 2,
}
OPENSTACK_HOST = "controller"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "default"
CACHES = {
    'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
         'LOCATION': 'controller:11211',
    }
}
OPENSTACK_NEUTRON_NETWORK = {
    'enable_router': False,
    'enable_quotas': False,
    'enable_distributed_router': False,
    'enable_ha_router': False,
    'enable_fip_topology_check': False,
    'enable_lb': False,
    'enable_firewall': False,
    'enable_': False,
}
TIME_ZONE = "Asia/Shanghai"

==注意的是,如果在上面的enable_router设置为False的话,dashboard面板里面就不会显示路由选项,我觉得把它设置为True好。还有
再修改配置文件/etc/httpd/conf.d/openstack-dashboard.conf,增加WSGIApplicationGroup %{GLOBAL}
重启Web服务。

systemctl restart httpd.service memcached.service

然后测试一下,打开192.168.119.130/dashboard,输入domain=default username=admin password=admin登录。
至此基本的服务功能就已经全部实现了,剩下的的Cinder、Swift等服务就按需部署了,没啥用了。

你可能感兴趣的:(云计算)