openstack pike安裝

節點規劃

準備4臺虛機,分別做Controller,Network,Compute,Middleware。
Controller安裝keystone,glance,nova-api,nova-conductor,nova-scheduler,nova-placement
Network安裝neutron相關組件
Compute安裝nova-compute
Middleware安裝mariadb,rabbitmq,memcache。

網絡規劃

controller
eth0: 192.168.100.111 external
eth1: 10.1.1.1 admim
network
eth0: 192.168.100.114 external
eth1: 10.1.1.4 admin
eth2: 10.2.2.4 tunnel
compute
eth0: 192.168.100.112 external
eth1: 10.1.1.2 admin
eth2: 10.2.2.2 tunnel
middleware (mysql,mq,memcache)
eth1: 10.1.1.3 admin

基礎配置

每個節點都按如下操作
hosts文件
echo "
10.1.1.1 controller
10.1.1.2 compute
10.1.1.3 middleware
10.1.1.4 network
" >>/etc/hosts
配置yum源
yum install -y wget
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install centos-release-openstack-pike -y
yum clean all && yum makecache
時間同步
echo "*/3 * * * * /usr/sbin/ntpdate ntp6.aliyun.com &> /dev/null" > /tmp/crontab
crontab /tmp/crontab

Middleware節點

安裝數據庫
yum install -y mariadb-server
systemctl restart mariadb.service
systemctl enable mariadb.service
安裝rabbitmq
yum install -y erlang rabbitmq-server
systemctl restart rabbitmq-server
systemctl enable rabbitmq-server
創建openstack用戶,并設置密碼
rabbitmqctl add_user openstack 123456
給openstack用戶賦予權限
rabbitmqctl set_permissions openstack "." "." "."
rabbitmqctl set_user_tags openstack administrator
rabbitmqctl list_users
打開RabbitMQ相關插件
/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent
查看RabbitMQ插件
/usr/lib/rabbitmq/bin/rabbitmq-plugins list
安裝memcached
yum install -y memcached python-memcached
配置memcache監聽端口
sed -i 's/OPTIONS
.*/OPTIONS="-l 127.0.0.1,10.1.1.3"/' /etc/sysconfig/memcached
重啟memcache并設置開機啟動
systemctl restart memcached.service
systemctl enable memcached.service
systemctl status memcached.service

Controller節點

安裝keystone

yum -y install openstack-keystone httpd mod_wsgi python-openstackclient openstack-utils
創建keystone庫,并給keystone用戶授權
create database keystone;
grant all privileges on keystone.* to 'keystone'@'localhost' identified by '123456';
grant all privileges on keystone.* to 'keystone'@'%' identified by '123456';
配置/etc/keystone/keystone.conf
cp /etc/keystone/keystone.conf /etc/keystone/keystone.conf.bak
> /etc/keystone/keystone.conf

 openstack-config --set /etc/keystone/keystone.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 openstack-config --set /etc/keystone/keystone.conf database connection mysql://keystone:123456@middleware/keystone
 openstack-config --set /etc/keystone/keystone.conf cache backend oslo_cache.memcache_pool
 openstack-config --set /etc/keystone/keystone.conf cache enabled true
 openstack-config --set /etc/keystone/keystone.conf cache memcache_servers middleware:11211
 openstack-config --set /etc/keystone/keystone.conf memcache servers middleware:11211
 openstack-config --set /etc/keystone/keystone.conf token expiration 3600
 openstack-config --set /etc/keystone/keystone.conf token provider fernet

配置httpd.conf文件
sed -i "s/ServerName www.example.com:80/ServerName controller/" /etc/httpd/conf/httpd.conf
配置keystone與httpd結合
ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
建立identity表結構
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開機啟動
systemctl enable httpd.service
systemctl restart httpd.service
systemctl status httpd.service
創建admin用戶角色

keystone-manage bootstrap --bootstrap-password 123456 --bootstrap-admin-url http://controller:35357/v3 --bootstrap-internal-url http://controller:35357/v3 --bootstrap-public-url http://controller:5000/v3 --bootstrap-region-id RegionOne --bootstrap-username admin --bootstrap-project-name admin --bootstrap-role-name admin --bootstrap-service-name keystone

驗證

openstack project list --os-username admin --os-project-name admin --os-user-domain-id default --os-project-domain-id default --os-identity-api-version 3 --os-auth-url http://controller:5000 --os-password 123456

創建admin用戶環境變量,創建/root/admin-openrc 文件
cat >> /root/admin-openrc <<EOF
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_DOMAIN_ID=default
export OS_USERNAME=admin
export OS_PROJECT_NAME=admin
export OS_PASSWORD=123456
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export OS_AUTH_URL=http://controller:35357/v3
EOF
創建service項目
source /root/admin-openrc
openstack project create --domain default --description "Service Project" service
創建demo項目
openstack project create --domain default --description "Demo Project" demo
創建demo用戶,并設置密碼
openstack user create --domain default demo --password 123456
創建user角色并將demo用戶賦予user角色
openstack role create user
openstack role add --project demo --user demo user
驗證keystone

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 --os-password 123456
openstack --os-auth-url http://controller:5000/v3   --os-project-domain-name default --os-user-domain-name default   --os-project-name demo --os-username demo token issue --os-password 123456

安裝glance

創建glance數據庫
CREATE DATABASE glance;
創建數據庫用戶并賦予權限
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '123456';
創建glance用戶及賦予admin權限
source /root/admin-openrc
openstack user create --domain default glance --password 123456
openstack role add --project service --user glance admin
創建image服務
openstack service create --name glance --description "OpenStack Image service" image
創建glance的endpoint
openstack endpoint create --region RegionOne image public http://controller:9292
openstack endpoint create --region RegionOne image internal http://controller:9292
openstack endpoint create --region RegionOne image admin http://controller:9292
安裝glance相關的軟件包
yum install -y openstack-glance python-glance
配置/etc/glance/glance-api.conf
cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
>/etc/glance/glance-api.conf

 openstack-config --set  /etc/glance/glance-api.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 openstack-config --set  /etc/glance/glance-api.conf database connection  mysql+pymysql://glance:123456@middleware/glance
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken auth_uri  http://controller:5000
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken auth_url  http://controller:35357
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken memcached_servers  middleware:11211
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken auth_type  password
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken project_domain_name  default
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken user_domain_name   default  
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken project_name  service
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken username  glance
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken password  123456
 openstack-config --set  /etc/glance/glance-api.conf paste_deploy flavor  keystone
 openstack-config --set  /etc/glance/glance-api.conf glance_store stores  file,http
 openstack-config --set  /etc/glance/glance-api.conf glance_store default_store  file
 openstack-config --set  /etc/glance/glance-api.conf glance_store filesystem_store_datadir  /var/lib/glance/images/

配置/etc/glance/glance-registry.conf
cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
>/etc/glance/glance-registry.conf

 openstack-config --set  /etc/glance/glance-registry.conf DEFAULT transport_url rabbit://openstack:devops@middleware
 openstack-config --set  /etc/glance/glance-registry.conf database connection  mysql+pymysql://glance:123456@middleware/glance
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken auth_uri  http://controller:5000
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken auth_url  http://controller:35357
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken memcached_servers  middleware:11211  
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken auth_type  password
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken project_domain_name  default
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken user_domain_name  default
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken project_name  service
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken username  glance
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken password 123456
 openstack-config --set  /etc/glance/glance-registry.conf paste_deploy flavor  keystone

同步glance數據庫,初始化glance表結構
/bin/sh -c "glance-manage db_sync" glance
創建鏡像存儲目錄并賦予glance用戶和組權限
mkdir /var/lib/glance/images
chown glance.glance /var/lib/glance/images
chown glance.glance /var/log/glance/api.log
啟動glance服務及設置開機啟動
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl restart openstack-glance-api.service openstack-glance-registry.service
systemctl status openstack-glance-api.service openstack-glance-registry.service
下載測試鏡像文件
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
上傳鏡像到glance
source /root/admin-openrc

glance image-create --name "cirros-0.3.4-x86_64" --file cirros-0.3.4-x86_64-disk.img  --disk-format qcow2 --container-format bare --visibility public --progress

查看鏡像列表:
glance image-list

安裝nova (controller部分)

創建數據庫
create database nova;
create database nova_api;
create database nova_cell0;
數據庫授權
grant all privileges on nova.* to nova@'localhost' identified by '123456';
grant all privileges on nova.* to nova@'%' identified by '123456';
grant all privileges on nova_api.* to nova@'localhost' identified by '123456';
grant all privileges on nova_api.* to nova@'%' identified by '123456';
grant all privileges on nova_cell0.* to nova@'%' identified by '123456';
grant all privileges on nova_cell0.* to nova@'localhost' identified by '123456';
source admin-openrc
創建用戶,分配角色
openstack user create --domain default nova --password 123456
openstack role add --project service --user nova admin
創建compute服務
openstack service create --name nova --description "OpenStack Compute" compute
創建endpoint
openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1/%(tenant_id)s
openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1/%(tenant_id)s
openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1/%(tenant_id)s
創建placement 用戶和服務
openstack user create --domain default placement --password 123456
openstack role add --project service --user placement admin
openstack service create --name placement --description "Placement API" placement
創建placement endpoint
openstack endpoint create --region RegionOne placement admin http://controller:8778
openstack endpoint create --region RegionOne placement public http://controller:8778
openstack endpoint create --region RegionOne placement internal http://controller:8778
安裝nova相關軟件
yum install -y openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api
配置/etc/nova/nova.conf
cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
>/etc/nova/nova.conf

openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis  osapi_compute,metadata
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 10.1.1.1
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron True
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.firewall.NoopFirewallDriver
openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:123456@middleware
openstack-config --set /etc/nova/nova.conf database connection mysql+pymysql://nova:123456@middleware/nova
openstack-config --set /etc/nova/nova.conf api_database connection mysql+pymysql://nova:123456@middleware/nova_api
openstack-config --set /etc/nova/nova.conf scheduler discover_hosts_in_cells_interval -1
openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://controller:5000
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://controller:35357
openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers middleware: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 123456
openstack-config --set /etc/nova/nova.conf keystone_authtoken service_token_roles_required True
openstack-config --set /etc/nova/nova.conf placement auth_url http://controller:35357
openstack-config --set /etc/nova/nova.conf placement memcached_servers middleware:11211
openstack-config --set /etc/nova/nova.conf placement auth_type password
openstack-config --set /etc/nova/nova.conf placement project_domain_name default
openstack-config --set /etc/nova/nova.conf placement user_domain_name default
openstack-config --set /etc/nova/nova.conf placement project_name service
openstack-config --set /etc/nova/nova.conf placement username placement
openstack-config --set /etc/nova/nova.conf placement password 123456
openstack-config --set /etc/nova/nova.conf placement os_region_name RegionOne
openstack-config --set /etc/nova/nova.conf vnc vncserver_listen 192.168.100.111
openstack-config --set /etc/nova/nova.conf vnc vncserver_proxyclient_address 192.168.100.111
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

配置/etc/httpd/conf.d/00-nova-placement-api.conf
添加:
<Directory /usr/bin>
  <IfVersion >= 2.4>
    Require all granted
  </IfVersion>
  <IfVersion < 2.4>
    Order allow,deny
    Allow from all
  </IfVersion>
</Directory>
像下面這樣

<VirtualHost *:8778>
  WSGIProcessGroup nova-placement-api
  WSGIApplicationGroup %{GLOBAL}
  WSGIPassAuthorization On
  WSGIDaemonProcess nova-placement-api processes=3 threads=1 user=nova group=nova
  WSGIScriptAlias / /usr/bin/nova-placement-api
  <IfVersion >= 2.4>
    ErrorLogFormat "%M"
  </IfVersion>
  ErrorLog /var/log/nova/nova-placement-api.log
  <Directory /usr/bin>
    <IfVersion >= 2.4>
      Require all granted
    </IfVersion>
    <IfVersion < 2.4>
      Order allow,deny
      Allow from all
    </IfVersion>
  </Directory>
  SSLEngine On
  SSLCertificateFile ...
  SSLCertificateKeyFile ...
</VirtualHost>

重啟httpd 服務:
systemctl restart httpd.service
同步nova_api數據庫
su -s /bin/sh -c "nova-manage api_db sync" nova
同步nova_cell0數據庫
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
創建cell1
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
確認ova cell0 和 cell1注冊和創建成功
nova-manage cell_v2 list_cells
檢查部署是否正常
nova-status upgrade check
nova-manage cell_v2 discover_hosts
設置開機啟動
systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
重啟服務
systemctl restart openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service

安裝Dashboard

安裝dashboard相關軟件包
yum install -y openstack-dashboard
修改配置文件/etc/openstack-dashboard/local_settings
vim /etc/openstack-dashboard/local_settings
需要該的部分
ALLOWED_HOSTS = ['*',]

CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'middleware:11211',
},
}

OPENSTACK_HOST = "controller"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v2.0" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"

啟動dashboard服務并設置開機啟動
systemctl restart httpd.service memcached.service
systemctl status httpd.service memcached.service

Network節點

創建neutron數據庫
create database neutron;
數據庫授權
grant all privileges on neutron.* to neutron@'localhost' identified by '123456';
grant all privileges on neutron.* to neutron@'%' identified by '123456';
創建用戶
openstack user create --domain default neutron --password 123456
給用戶分配角色
openstack role add --project service --user neutron admin
創建服務
openstack service create --name neutron --description "OpenStack Networking" network
創建端點
openstack endpoint create --region RegionOne network public http://controller:9696
openstack endpoint create --region RegionOne network internal http://controller:9696
openstack endpoint create --region RegionOne network admin http://controller:9696
安裝相關軟件
yum install -y openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables
配置neutron.conf
cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
>/etc/neutron/neutron.conf

 openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin ml2
 openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins router
 openstack-config --set /etc/neutron/neutron.conf DEFAULT allow_overlapping_ips True
 openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
 openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 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 keystone_authtoken auth_uri http://controller:5000
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://controller:35357
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers middleware: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 123456
 openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:123456@middleware/neutron
 openstack-config --set /etc/neutron/neutron.conf nova auth_url http://controller:35357
 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 123456
 openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp

配置ml2_config.ini
cp /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.bak
>/etc/neutron/plugins/ml2/ml2_conf.ini

 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan,vxlan
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge,l2population
 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 tenant_network_types vxlan
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 path_mtu 1500
 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 ml2_type_vxlan vni_ranges  1:1000
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset  True

cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak
>/etc/neutron/plugins/ml2/linuxbridge_agent.ini

openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini DEFAULT debug false
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:eth0
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan True
openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan  local_ip  10.2.2.4
openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan l2_population  True
openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini  agent  prevent_arp_spoofing  True
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

注意provider:eth0,中eth0是外網網卡,一般這里寫的網卡名都是能訪問外網的,如果不是外網網卡,那么VM就會與外界網絡隔離。
local_ip 定義的是隧道網絡,vxLan下 vm-linuxbridge->vxlan ------tun-----vxlan->linuxbridge-vm

配置 /etc/neutron/l3_agent.ini
cp /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini.bak
>/etc/neutron/l3_agent.ini

 openstack-config --set  /etc/neutron/l3_agent.ini  DEFAULT  interface_driver  neutron.agent.linux.interface.BridgeInterfaceDriver
 openstack-config --set  /etc/neutron/l3_agent.ini  DEFAULT  external_network_bridge
 openstack-config --set  /etc/neutron/l3_agent.ini  DEFAULT  debug false

配置/etc/neutron/dhcp_agent.ini
cp /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.bak
>/etc/neutron/dhcp_agent.ini

 openstack-config --set  /etc/neutron/dhcp_agent.ini  DEFAULT  interface_driver  neutron.agent.linux.interface.BridgeInterfaceDriver
 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
 openstack-config --set  /etc/neutron/dhcp_agent.ini  DEFAULT verbose True
 openstack-config --set  /etc/neutron/dhcp_agent.ini  DEFAULT debug false

配置controller節點的/etc/nova/nova.conf,讓compute節點能使用上neutron網絡

 openstack-config --set  /etc/nova/nova.conf  neutron url  http://network:9696
 openstack-config --set  /etc/nova/nova.conf  neutron auth_url  http://controller:35357
 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  123456
 openstack-config --set  /etc/nova/nova.conf  neutron service_metadata_proxy  True
 openstack-config --set  /etc/nova/nova.conf  neutron metadata_proxy_shared_secret  123456

將dhcp-option-force=26,1450寫入/etc/neutron/dnsmasq-neutron.conf
echo "dhcp-option-force=26,1450" >/etc/neutron/dnsmasq-neutron.conf
配置/etc/neutron/metadata_agent.ini
cp /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.bak
>/etc/neutron/metadata_agent.ini

openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT nova_metadata_ip controller
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT metadata_proxy_shared_secret 123456
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT metadata_workers 4
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT verbose  True
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT debug false
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT nova_metadata_protocol http

創建硬鏈接
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
同步數據庫,初始化neutron表結構
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
在controller上重啟nova服務
systemctl restart openstack-nova-api.service
systemctl status openstack-nova-api.service
重啟neutron服務并設置開機啟動
systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service
systemctl restart neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service
systemctl status neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service

openstack network agent list
創建網絡
執行環境變量
source /root/admin-openrc
創建flat模式的public網絡,public是外出網絡,必須是flat模式的
neutron net-create --shared provider --router:external True --provider:network_type flat --provider:physical_network provider
本實驗環境192.168.100.0/24網段可以出外網,就以該網段作為public網段
創建子網
neutron subnet-create provider 192.168.100.0/24 --name provider-sub --allocation-pool start=192.168.100.180,end=192.168.100.190 --dns-nameserver 8.8.8.8 --gateway 192.168.100.180
創建名為private的私有網絡, 網絡模式為vxlan
neutron net-create private --provider:network_type vxlan --router:external False --shared
創建名為private-subnet的私有網絡子網,網段為172.17.1.0, 這個網段就是虛擬機獲取的私有的IP地址
neutron subnet-create private --name private-subnet --gateway 172.17.1.1 172.17.1.0/24
也可以創建多個不同的私有子網絡
如果虛機要能夠訪問外部網絡還需要添加路由
添加路由
neutron router-create router01
將私有網絡的子網加入路由
neutron router-interface-add router01 private-sub
設置public網絡為路由的網關
neutron router-gateway-set router01 provider

Compute節點

安裝相關依賴包
yum install -y openstack-selinux python-openstackclient yum-plugin-priorities openstack-nova-compute openstack-utils
配置nova.conf
cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
>/etc/nova/nova.conf

 openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy  keystone
 openstack-config --set /etc/nova/nova.conf DEFAULT my_ip  10.1.1.2
 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:123456@middleware
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  auth_uri  http://controller:5000
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  auth_url  http://controller:35357
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  memcached_servers  middleware: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 123456
 openstack-config --set /etc/nova/nova.conf placement auth_uri http://controller:5000
 openstack-config --set /etc/nova/nova.conf placement auth_url http://controller:35357
 openstack-config --set /etc/nova/nova.conf placement memcached_servers middleware:11211
 openstack-config --set /etc/nova/nova.conf placement auth_type password
 openstack-config --set /etc/nova/nova.conf placement project_domain_name default
 openstack-config --set /etc/nova/nova.conf placement user_domain_name default
 openstack-config --set /etc/nova/nova.conf placement project_name service
 openstack-config --set /etc/nova/nova.conf placement username placement
 openstack-config --set /etc/nova/nova.conf placement password 123456
 openstack-config --set /etc/nova/nova.conf placement os_region_name RegionOne
 openstack-config --set /etc/nova/nova.conf vnc enabled True
 openstack-config --set /etc/nova/nova.conf vnc keymap en-us
 openstack-config --set /etc/nova/nova.conf vnc vncserver_listen  0.0.0.0
 openstack-config --set /etc/nova/nova.conf vnc vncserver_proxyclient_address  10.1.1.2
 openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url  http://192.168.100.112:6080/vnc_auto.html
 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 libvirt virt_type  qemu
 openstack-config --set /etc/nova/nova.conf libvirt cpu_mode none

設置libvirtd.service 和openstack-nova-compute.service開機啟動
systemctl enable libvirtd.service openstack-nova-compute.service
systemctl restart libvirtd.service openstack-nova-compute.service
systemctl status libvirtd.service openstack-nova-compute.service
到controller上執行驗證
source /root/admin-openrc
openstack compute service list
安裝Neutron
安裝相關軟件包
yum install -y openstack-neutron-linuxbridge ebtables ipset
配置neutron.conf
cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
>/etc/neutron/neutron.conf

 openstack-config --set  /etc/neutron/neutron.conf DEFAULT auth_strategy  keystone
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT advertise_mtu True
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT dhcp_agents_per_network 2
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT control_exchange neutron
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT nova_url http://controller:8774/v2
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken auth_uri  http://controller:5000
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken auth_url  http://controller:35357
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken memcached_servers  middleware: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  123456
 openstack-config --set  /etc/neutron/neutron.conf oslo_concurrency  lock_path  /var/lib/neutron/tmp

配置/etc/neutron/plugins/ml2/linuxbridge_agent.ini
cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak
>/etc/neutron/plugins/ml2/linuxbridge_agent.ini

 openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini DEFAULT debug false
 openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini DEFAULT verbose true
 openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan  enable_vxlan  True
 openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan  local_ip  10.2.2.2
 openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan l2_population  True
 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

配置nova.conf

 openstack-config --set  /etc/nova/nova.conf neutron url  http://network:9696
 openstack-config --set  /etc/nova/nova.conf neutron auth_url  http://controller:35357
 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  123456

重啟和相關服務
systemctl restart openstack-nova-compute.service neutron-linuxbridge-agent.service
systemctl enable neutron-linuxbridge-agent.service neutron-linuxbridge-agent.service

Compute節點搭建完畢,運行nova host-list可以查看新加入的compute節點
如果需要再添加另外一個compute節點,只要重復下Compute節點部部分即可,計算機名和IP地址改下
創建配額命令controller上執行
openstack flavor create m1.tiny --id 1 --ram 1024 --disk 10 --vcpus 1
openstack flavor create m1.small --id 2 --ram 2048 --disk 20 --vcpus 1
openstack flavor create m1.medium --id 3 --ram 4096 --disk 40 --vcpus 2
openstack flavor create m1.large --id 4 --ram 8192 --disk 80 --vcpus 4
openstack flavor create m1.xlarge --id 5 --ram 16384 --disk 160 --vcpus 8
openstack flavor list
登錄dashboard
http://192.168.100.111/dashboard


創建實例

一次選擇“源”->"實例類型"->"網絡" 點擊創建實例
創建一個名為test的實例,上圖中的test1是為了驗證創建過程新建的實例,test是已經創建的實例

實例有了,也分配了IP,此時的實例就可以出外網了,因為前面已經創建了provider網絡,但外網還是不能進來,因為沒有綁定浮動IP。
分配floatingip

浮動IP關聯


創建安全組


驗證


最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 227,882評論 6 531
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,208評論 3 414
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 175,746評論 0 373
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,666評論 1 309
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,477評論 6 407
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 54,960評論 1 321
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,047評論 3 440
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,200評論 0 288
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,726評論 1 333
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,617評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,807評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,327評論 5 358
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,049評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,425評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,674評論 1 281
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,432評論 3 390
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,769評論 2 372

推薦閱讀更多精彩內容