Openstack Basic

 

Openstack

虛擬機nova與計算與Openstack http://docs.openstack.org/html5

Cloud Computing

Iaas: Infrastructure as a Service 針對運維人員 Paas: Platform as a Service 針對研發人員 Saas: Software as a Service 針對agent openv switch: 虛擬機的基於軟件的軟件交換機 異步消息隊列協議: 控制平臺經過異步消息隊列來控制各物理主機和虛擬主機. 公有云: 雲供應商提供的, 供各個組織使用的 私有云: 公司內部部署的雲環境並僅在公司內部中使用 混合雲: 本身內部組建了私有云, 而且並從公有云中的註冊的虛擬機環境, 使兩者集成. 雲計算: 一種按需付費的一種模式, 突出了經過網絡的一種服務 IAAS公有云提供商: 阿里雲和青雲,UCcloud PAAS一站式開發環境: sinaAppEngine; docker 提升資源使用率 桌面虛擬化: 瘦客機, VDI解決方案 應用虛擬化: Citrix xenapp, 使用瀏覽器來交付應用. Citrix 的ICA協議node

Openstack

Python研發, 以完備功能爲目標的. 各公司若是利用openstack來進行管理平臺, 須要對其作二次開發. ASF: Apache Software Foundation. 開發的CloudStack VMs on demand: 1. provisioning 2.snopshotting Volumes; Networks; Multi-tenancy: quotas for different users; user can be associated with multiple tenants Object Storage for VM images and arbitratry filespython

版本遷移

2010 10.21 Austin版本 2014 Apr17 Icehouse 版本發佈mysql

組件

Compute (Nava) since Austin Networking(Neutron, Quantum): since Folsom Object Storage(swift): since Austin. Swift自己是分佈式文件系統 Block Storage(Cinder): 提供後端大量的塊設備, since Folsom. Identity(Keystone): since Essex Image Service(Glance): 映像文件管理. 能夠經過glance本地存儲也能夠經過swift高可用文件系統進行存儲 since Bexar Dashboard(Horizon): since Essex Telemetry/Metering(Ceilometer): Havana Release. 對各虛擬機的個數據指標進行檢測的接口 Orchestration(Heat): 從私有云到公有云結合, 實現混合雲.linux

Keystone

基於token認證. kvs, memcache. 沒有用戶名,密碼. 一組隨機密碼, 客戶端端和服務器端, 都預存這組密碼 Identity認證: kvs, pam, sql, ldap, etc catalog: 編錄, 存儲這種RESTful風格的API調用uri RESTful: 輕量級的RPC()機制, 基於http://ip:port/port/ 調用基於uri進行 policy backend: 基於用戶策略的虛擬機使用策略ios

Nova Compute

操做從隊列中取得, 並將指令調用發送給隊列. 生產消息, 生產者. nova conductor: 完成數據庫中的數據更新 nova database: 一個關係型數據庫 queue: 提供一箇中央管理的異步消息管理隊列. 一般爲RabbitMQ nova-api: RESTful API. nova-compute: 真正的一個守護進程, 經過hyperviosor API來建立和管理虛擬機 nova-scheduler: 對消息隊列中的請求進行調度來決定能夠運行在哪一個虛擬機上 nova-console/novncproxy/nova-consoleauth: 提供鏈接接口 nova-network:migrate to Neutron nova-volume: 管理持久存儲. Migrated to Cinderc++

Glacnce

glance-api:鏡像管理, 方便實時遷移. 接受API call glance-registry:處理查詢, 存儲images的metadata glance-database:處理存儲git

Neutron

網絡鏈接管理的工具 neutron-server: API, 根據請求來決定調用哪一個neutron plugin plugins/agents: 作真正的實際操做, 例如插入, 拔出端口, 建立網絡相關的操做程序員

Cinder

提供持久存儲 cinder-api: 接受請求, 並路由請求到cinder-volume cinder-volume: 讀取寫入cinder-database中 cinder-scheduler: 選擇可使用的塊空間 cinder database: 存儲數據狀態

swift

swift-proxy實際就是分佈式存儲. account: 帳號管理 container: 容器管理 object: 存儲對象管理

技術支持方案

Message Queue: RabbitMQ, Qpid, ZeroMQ Virtualization: xapi+xcp, xapi+xenServer,libvirt+KVM, libvirt+QEMU, libvirt+LXC, libvirt+vmware iSCSI back-end: LVM+IET, LVM+tgt, Xen Storage Manager, SAN(Solaris, HP, SolidFire), NexentaStor, NetApp, Ceph, Sheepdog Database: MySQL, PostgreSQL, sqlite(API) Web server: Apache, Nginx Session Cache: memcache, any Django-support database backend (MySQL, PostgreSQL, sqlite)

Openstack部署

db: mysql, mariadb, postgress mq:rabbitmq, qpid, zeromq Openstack基礎部署: Controller Node: keystone(identity), glance, nova(nova-api, nova-schedular), horizon Compute Node: nova, hypervisor AMQP: Advanced Message Queeu Protocol Mirantis: 一個提供openstack的組織 keystone默認端口35357 準備開啓IP轉發和source route verfication

net.ipv4.ip_forward=1
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0

安裝基本包

yum install -y python-pip gcc gcc-c++ make libtool patch automake python-devel libxsit-devel MySQL-python openssl-devel libudev-devel git wget libvirt-python libvirt qemu-kvm gedit python-numdisplay device-mapper bridge-utils libffi-devel libffi lrzsz

yum install libxml2-devel
yum install libxslt-devel
yum install libyaml-devel

下載各組件的源碼包

wget https://launchpad.net/keystone/icehouse/2014.1/+download/keystone-2014.1.tar.gz --no-check-certificate
wget https://launchpad.net/nova/icehouse/2014.1/+download/nova-2014.1.tar.gz --no-check-certificate
wget https://launchpad.net/glance/icehouse/2014.1/+download/glance-2014.1.tar.gz --no-check-certificate
wget https://launchpad.net/horizon/icehouse/2014.1/+download/horizon-2014.1.tar.gz --no-check-certificate
wget https://launchpad.net/neutron/icehouse/2014.1/+download/neutron-2014.1.tar.gz --no-check-certificate
wget https://launchpad.net/cinder/icehouse/2014.1/+download/cinder-2014.1.tar.gz --no-check-certificate

查看依賴包, 解壓縮以後查看requirements.txt文檔 使用pip安裝依賴包

for i in `ls *.gz`;do tar -xf $i;done
cat */requirements.txt|sort -n|uniq >>openstack.txt
pip install -r openstack.txt -i http://pypi.v2ex.com/simple
pip install -r openstack.txt -i http://pypi.doubanio.com/simple

對於不兼容的版本, 到pypi.zenlogic.net/simple 下載相應的python源碼

python setup.py build 
python setup.py install

安裝數據庫和消息隊列

mysql-server rabbitmq-server
mysqladmin -u root password nsadm
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
修改默認字符集
[mysqld]
default-storage-engine = innodb
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8

# 查看字符集已經被設置
create database demo;
show create database demo;

查看消息隊列的組件

/usr/lib/rabbitmq/bin/rabbitmq-plugins list
/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management
service rabbitmq-server start
192.168.48.131:15672/ 
guest/guest
rabbitmq默認監聽在5672端口

方法2

name=openstack
baseurl=https://repos.fedorapeople.org/repos/openstack/EOL/openstack-icehouse/epel-6/
gpgcheck=0
enabled=1
yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install openstack-utils
yum -y install openstack-selinux
yum -y upgrade
reboot

Keystone

keystone提供了一下兩個主要得功能: 用戶與認證: 用戶權限與用戶行爲跟蹤 服務目錄: 提供一個服務目錄, 包括全部服務項與相關API的斷電

部署安裝keystone

安裝keystone

yum install openstack-keystone python-keystoneclient

建立keystone配置目錄

mkdir /etc/keystone
cp /root/keystone-2014.1/etc/* /etc/keystone
cp keystone.conf.sample keystone.conf
cp logging.conf.sample logging.conf

建立證書

keystone-manage pki_setup --keystone-user root --keystone-group root
/etc/keystone/ssl/certs/openssl.conf
chown -R root:root /etc/keystone/ssl

建立數據庫

create database keystone;
grant all on keystone.* to keystone@'192.168.0.0/255.255.0.0' identified by 'keystone';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';
驗證用戶
mysql -h 192.168.48.131 -u keystone -pkeystone

修改keystone.conf文件

openssl rand -hex 10
admin_token=b3ad09610cad1330a497
debug=true
verbose=true
log_file=keystone.log
log_dir=/var/log/keystone
connection = mysql://keystone:keystone@192.168.48.131/keystone

同步數據庫

keystone-manage db_sync
mysql -ukeystone -pkeystone -h 192.168.48.131 -e "use keystone;show tables"

啓動keystone

keystone-all --config-file=/etc/keystone/keystone.conf

配置環境變量

export OS_SERVICE_TOKEN=b3ad09610cad1330a497
export OS_SERVICE_ENDPOINT=http://192.168.48.131:35357/v2.0

建立用戶admin

 keystone user-create --name=admin --pass=admin --email=admin@openstack.com
 +----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |       admin@openstack.com        |
| enabled  |               True               |
|    id    | b070096c3b9e4a9399fa0534fe188ff0 |
|   name   |              admin               |
| username |              admin               |
+----------+----------------------------------+

查看用戶

keystone user-list

建立admin的角色

keystone role-create --name=admin
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|    id    | ed35ddcd2d744b14a2902536f6775b81 |
|   name   |              admin               |
+----------+----------------------------------+

建立admin租戶

keystone tenant-create --name=admin --description="Admin Tenant"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |           Admin Tenant           |
|   enabled   |               True               |
|      id     | b6c5cd0aefee44bbb8a990a221810f77 |
|     name    |              admin               |
+-------------+----------------------------------+

關聯用戶角色和租戶

keystone user-role-add --user=admin --tenant=admin --role=admin

建立dashboard的用戶demo

 keystone user-create --name=demo --pass=demo --email=keystone@openstack.com
 keystone tenant-create --name=demo --description="Demo Tenant"
 keystone user-role-add --user=demo --tenant=demo --role=_member_

建立keystone服務

eystone service-create --name=keystone --type=identity --description="OpenStack Identity"

建立keystone服務的endpoint, 服務端點

keystone endpoint-create --service-id=7815fd4d7c6c422e8cf28d2c9f9be053 --publicurl=http://192.168.48.131:5000/v2.0 --internalurl=hhtp://192.168.48.131:5000/v2.0 --adminurl=http://192.168.48.131:35357/v2.0

刪除內容能夠直接keystone delete便可

keystone delete <ID> 

獲取token

keystone --os-username=keystone --os-password=keystone --os-auth-url=http://192.168.48.131:35357/v2.0 token-get

建立環境變量文件keystone-admin

export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL=http://192.168.48.131:35357/v2.0

Glance

Openstack Image服務可用於發現、註冊及檢索虛擬機映像(image),它提供了一個RESTful的API,可以讓用戶查詢VM映像的元數據及經過HTTP請求獲取映像,並可讓python程序員經過客戶端類在python代碼中完成相似的全部任務。VM映像文件能夠存儲在各種存儲中,如普通的文件系統、對象存儲系統(如Openstack Object Storage)、S3存儲及HTTP(僅做爲獲取映像文件之用,而不能寫於此中建立映像文件)等。 安裝glance

yum install -y openstack-glance

建立glance數據庫

create database glance;
grant all on glance.* to glance@'192.168.0.0/255.255.0.0' identified by 'glance';
grant all on glance.* to glance@'localhost' identified by 'glance';

配置glance-api, 提供給其餘服務用於查詢glance鏡像

verbose=True
debug=True
default_store=file
connection=mysql://glance:glance@192.168.48.131/glance

修改glance-registry.conf文件

verbose=True
debug=True
log_file=/var/log/glance/registry.log
backlog=4096
connection=mysql://glance:glance@192.168.48.131/glance

同步數據庫

glance-manage db_sync
mysql -h 192.168.48.131 -uglance -pglance -e "use glance;show tables;"

集成rabitmq和glance, 修改glance-api

notifier_strategy = rabbit
rabbit_host=192.168.48.131
rabbit_port=5672
rabbit_use_ssl=false
rabbit_userid=guest
rabbit_password=guest
rabbit_virtual_host=/
rabbit_notification_exchange=glance
rabbit_notification_topic=notifications
rabbit_durable_queues=False

修改glance-api 添加keystone相關信息

[keystone_authtoken]
auth_host=192.168.48.131
auth_port=35357
auth_protocol=http
admin_tenant_name= admin
admin_user= admin
admin_password= admin
[paste_deploy]
flavor=keystone

修改glance-registry.conf添加keystone相關信息

[keystone_authtoken]
auth_host=192.168.48.131
auth_port=35357
auth_protocol=http
admin_tenant_name= admin
admin_user= admin
admin_password= admin
[paste_deploy]
flavor=keystone

建立glance的keysthone服務

keystone service-create --name=glance --type=image --description="OpenStack Image Service"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |     OpenStack Image Service      |
|   enabled   |               True               |
|      id     | 1b64541cad8042f3a018515da6f3819e |
|     name    |              glance              |
|     type    |              image               |
+-------------+----------------------------------+

建立glance的keystone endpoint

keystone endpoint-create \
--service-id=1b64541cad8042f3a018515da6f3819e \
--publicurl=http://192.168.48.131:9292 \
--internalurl=http://192.168.48.131:9292 \
--adminurl=http://192.168.48.131:9292
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
|   adminurl  |    http://192.168.48.131:9292    |
|      id     | 5e13f54b6d68434cb7509c6618542618 |
| internalurl |    http://192.168.48.131:9292    |
|  publicurl  |    http://192.168.48.131:9292    |
|    region   |            regionOne             |
|  service_id | 1b64541cad8042f3a018515da6f3819e |
+-------------+----------------------------------+

啓動glance服務

glance-api --config-file=/etc/glance/glance-api.conf
glance-registry --config-file=/etc/glance/glance-registry.conf 
service openstack-glance-api start
service openstack-glance-registry start

建立glance鏡像

glance image-create --name "cirros-0.3.4" --disk-format qcow2 --container-format bare --is-public True --file cirros-0.3.4-x86_64-disk.img
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2016-10-14T09:04:27                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | 4399d215-7873-4c8a-b158-d0f9ccc25bb3 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | cirros-0.3.4                         |
| owner            | b6c5cd0aefee44bbb8a990a221810f77     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| updated_at       | 2016-10-14T09:04:27                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+
image-create命令至少要接受三個參數:--name、--container_format及--disk_format。其中--disk_format用於指明磁盤映像文件的格式,包括raw、qcow二、vhd、vmdk、iso、vdi、aki(amazon kernel image)、ari(amazon ramdisk image)及ami(amazon machine image)等。--container_format用於標明映像文件是否包含了虛擬機的元數據信息,然而,目前Compute服務並未使用此信息,所以,在不肯定的狀況能夠將其指定爲bare,而合用的格式主要有bare(沒有container或元數據信息)、ovf、aki、ari或ami幾種。

鏡像元數據

architecture:hypervisor必須支持的CPU架構,如x86_6四、arm等; hypervisor_type:hypervisor類型,其可以使用的值包括xen、qemu、kvm、lxc、uml、vmware、hyperv及powervm; vm_mode:定義虛擬機模式,即應用於虛擬機的host/guest ABI;例如hvm、xen、uml、exe等;

xenAPI還有其專用的兩個屬性能夠定義: auto_disk_config:布爾型屬性值,true表示在虛擬機實例啓動前磁盤的根分區將被自動調整; os_type:image中安裝的操做系統類型,如linux、windows等,XenAPI可以根據此屬性值來執行不一樣的操做,如爲windows建立fat32格式的交換分區、限制其主機名稱少於16個字符等;

vmware_ostype:VMware GuestID,用於描述映像文件中的操做系統類型;vmware所支持的類型較多,能夠參照thinkvirt.com獲取詳細信息;默認值爲otherGuest; vmware_image_version:目前未使用,默認值爲1; VMware API也有以下三個專用屬性能夠定義: vmware_adaptertype:定義hypervisor使用的虛擬SCSI或IDE接口類型,其有效值爲lsiLogic、busLogic及ide;

本地glance鏡像文件放在

/var/lib/glance/images/

獲取鏡像途徑

CirrOS 由Scott Moser維護的一系列用於測試目的的微型虛擬機映像,登陸名爲cirros,下載地址爲https://launchpad.net/cirros/+download。在QEMU或KVM中測試時,官方建議使用QCOW2格式的映像文件。 Ubuntu Canonical官方提供了基於Ubuntu的系列映像,登陸名爲ubuntu,下載地址爲http://uec-images.ubuntu.com/。在QEMU或KVM中部署時,建議使用QCOW2格式的映像文件。 Fedora Fedora官方提供了預製的Fedora JEOS映像,下載地址爲http://berrange.fedorapeople.org/images,目前最新的是爲x8664平臺提供爲的QCOW2格式的映像f17-x8664-openstack-sda.qcow2。 OpenSUSE和SLES11映像 經過SUSE Studio(http://susestudio.com/)能夠很方便地爲OpenSUSE和SLES11構建與OpenStack兼容的虛擬應用,好比建立一個OpenSUSE12.1的JEOS映像。 Rackspace雲生成器鏡像 Rackspace雲生成器(https://github.com/rackerjoe/oz-image-build)提供了多種發行版預製的預製映像,如RedHat、CentOS、Fedora及Ubuntu等。

製做鏡像工具

Oz(KVM):Oz是可以爲常見Linux發行版建立映像文件的命令行工具,Rackspace就是使用Oz建立的映像文件。在Fedora Project的wiki中,提供了使用Oz建立映像文件的案例,具體請參照https://fedoraproject.org/wiki/Getting_started_with_OpenStack_Nova#Building_an_Image_With_Oz

VMBuilder(KVM,Xen):VMBuilder可以爲不一樣的hypervisor建立虛擬機映像文件,它是一個腳本,可以自動收集所需的資源爲虛擬機建立映像文件。Ubuntu爲之提供了一個使用案例,具體請參照https://help.ubuntu.com/12.04/serverguide/jeos-and-vmbuilder.html

VeeWee(KVM):VeeWee一般用於建立Vagrant虛擬工做環境,一種基於Virtualbox、VMware、AWS等虛擬化技術的虛擬化工具。VeeWee也能夠用於建立KVM映像。

imagefactory:Aeolus項目的一款工具,用於自動化建立、轉換及爲不一樣的雲服務商上海映像文件,支持Openstack雲。

元數據服務或配置驅動(config drive)

Openstack支持的映像文件必須可以由Openstack獲取到其元數據信息,如ssh公鑰以及用戶在請求映像文件時提交的用戶數據等。這些元數據信息能夠經過元數據服務或配置驅動獲取,最簡單的方式莫過於在映像中安裝cloud-init程序。cloud-init用於爲雲實例提供配置及定製功能,項目的地址爲https://launchpad.net/cloud-init

支持對磁盤映像大小進行調整

虛擬機映像文件的磁盤大小由建立映像時的初始大小決定,然而Openstack須要在啓動實例時經過指定不一樣的flavor來使用不一樣大小的磁盤空間。例如,有着磁盤初始大小爲5G的映像文件,在用於建立實例時使用了m1.small這個flavor,虛擬機實例將須要一個大小爲10G的主盤。調整實例的磁盤大小時,經過在其尾部填0來完成。

映像文件的分區大小也須要可以根據用戶的須要在實例啓動時進行調整,不然,在實例啓動後,爲了可以訪問由flavor的配置指定的超出磁盤原始大小的其它空間就不得不手動去調整分區大小。所以,在實例啓動時,映像文件須要運行一個腳本以修改分區表,並運行相應的程序(如resize2fs等)調整文件系統,使得其可以適應新的分區大小。

會話保持: 一致性哈希算法

會話複製: 好比tomcat的cluster的標籤, session在集羣中複製. 複製開銷很大

會話共享: memcache

Horizon

Openstack的dashboard 安裝

yum install -y memcached python-memcached mod_wsgi openstack-dashboard

dashboard依賴於Member角色 修改配置文件/etc/opentstack-dashboard/local_settings

OPENSTACK_HOST = "192.168.48.131"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v2.0" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_"
ALLOWED_HOSTS = ['example.com', 'localhost','192.168.48.131']

會話控制 會話保持: Nginx的一致性hash算法 會話複製: Tomcat中的cluster標籤打開 會話共享: Memcache 啓動memcache啓動httpd便可

Nova

配置網橋br0, eth0 安裝網橋管理工具

yum install bridge-utils

安裝nova

yum install openstack-nova

虛擬機目錄

/var/lib/nova/instances

建立nova數據庫

create database nova;
grant all on nova.* to nova@'192.168.48.0/255.255.255.0' identified by 'nova';
nova-manage db sync
my_ip=192.168.48.131

配置rabbitmq

rabbit_host=192.168.48.131
rabbit_port=5672
rabbit_hosts=$rabbit_host:$rabbit_port
rabbit_use_ssl=false
rabbit_userid=guest
rabbit_password=guest

配置keystone

auth_strategy=keystone
[keystone_authtoken]
auth_host=192.168.48.131
auth_port=35357
auth_protocol=http
auth_uri=http://192.168.48.131:5000
auth_version=v2.0

admin_user=admin
admin_password=admin
admin_tenant_name=admin

配置vnc

novncproxy_base_url=http://192.168.48.131:6080/vnc_auto.html
vncserver_listen=0.0.0.0
vncserver_proxyclient_address=192.168.48.131
vnc_enabled=true

建立nova的service

keystone service-create --name=nova --type=compute --description="Openstack Compute"

建立nova的endpoint

keystone endpoint-create \
--service-id=d5d77cd173e34b4a8d9c83e753bb17f7 \
--publicurl=http://192.168.48.131:8774/v2/%\(tenant_id\)s \
--internalurl=http://192.168.48.131:8774/v2/%\(tenant_id\)s \
--adminurl=http://192.168.48.131:8774/v2/%\(tenant_id\)s
note: nova api 偵聽在8774端口

配置spice用於圖形窗口

修改nova.conf

[spice]
html5proxy_base_url=http://192.168.48.131:6082/spice_auto.html
server_listen=0.0.0.0
server_proxyclient_address=192.168.48.131
enabled=true
keymap=en-us

安裝spice服務

yum install spice-server spice-client spice-protocol spice-html5
service openstack-nova-api restart
service openstack-nova-cert  restart
service openstack-nova-compute restart
service openstack-nova-consoleauth restar
service openstack-nova-consoleauth restart
service openstack-nova-scheduler restart
service openstack-nova-spicehtml5proxy restart

關閉iptables

修改nova.conf文件

firewall_driver=nova.virt.libvirt.firewall.NoopFirewallDriver

neutron

nova-network-->quantum --> neutron l2 l3 l4-l7 支持. SDN: software define network, 軟件定義網絡 l4-l7目前使用haproxy來實現 目前二層使用 linuxbridge/ovs 安裝libvirt會默認建立virbr0 安裝軟件包openstack-neutron

yum install openstack-neutron 

配置neutron, neutron.conf

[DEFAULT]
verbose = True
debug = True
log_file = neutron.log
log_dir = /var/log/neutron
core_plugin = ml2
service_plugins = router
auth_strategy = keystone
rabbit_host = 192.168.48.131
rabbit_password = guest
rabbit_port = 5672
rabbit_userid = guest
rabbit_virtual_host = /
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
nova_url = http://192.168.48.131:8774/v2
nova_admin_username = admin
nova_admin_tenant_id = b6c5cd0aefee44bbb8a990a221810f77
nova_admin_password = admin
nova_admin_auth_url = http://192.168.48.131:35357/v2.0

[keystone_authtoken]
auth_host = 192.168.48.131
auth_port = 35357
auth_protocol = http
admin_tenant_name = admin
admin_user = admin
admin_password = admin

[database]
connection = mysql://neutron:neutron@192.168.48.131:3306/neutron

core_plugin = ml2 抽象了一層, 使得底層能夠即便用linux網橋也使用ovs 配置nova與neutron相關的配置

network_api_class=nova.network.neutronv2.api.API
linuxnet_interface_driver=nova.network.linux_net.LinuxBridgeInterfaceDriver
neutron_url=http://192.168.48.131:9696
neutron_admin_username=admin
neutron_admin_password=admin
neutron_admin_tenant_id=b6c5cd0aefee44bbb8a990a221810f77
neutron_admin_tenant_name=admin
neutron_admin_auth_url=http://192.168.48.131:5000/v2.0
use_cow_images=false
vif_plugging_is_fatal=false
vif_plugging_timeout=10
firewall_driver=nova.virt.firewall.NoopFirewallDriver

flat: 扁平網絡, ESXI, 一個網段. 廣播包對性能產生影響. VLAN: 私有云, 4096 GRE: 公有云, 系能並不理想 vxlan: VLAN模型的擴展 安裝neutron插件

 yum install openstack-neutron-ml2
 yum install openstack-neutron-linuxbridge

配置/etc/neutron/plugins/ml2/ml2.conf.ini

type_drivers = flat
tenant_network_types = flat
mechanism_drivers = linuxbridge
enable_security_group = True

配置/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini

network_vlan_ranges = physnet1
physical_interface_mappings = physnet1:eth0
enable_security_group = True

neutron插件配置入口

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

測試

nova-novncproxy --config-file=/etc/nova/nova.conf

建立neutron服務

keystone service-create --name neutron --type network --description "Openstack Networking"
keystone endpoint-create \
> --service-id=6110c24335324e5d89fa4be8fd50ac0d \
> --publicurl=http://192.168.48.131:9696 \
> --internalurl=http://192.168.48.131:9696 \
> --adminurl=http://192.168.48.131:9696

neutron建立網絡

neutron net-create --tenant-id ba5a6fc890fe448bbeab70368dea9c20 demo_net --shared --provider:network_type flat --provider:physical_network physnet1
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | 0638b3c3-7c5e-47ce-b067-719a4b38159e |
| name                      | demo_net                             |
| provider:network_type     | flat                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  |                                      |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | ba5a6fc890fe448bbeab70368dea9c20     |
+---------------------------+--------------------------------------+

查看neutron network 服務狀態

neutron net-list
+--------------------------------------+----------+---------+
| id                                   | name     | subnets |
+--------------------------------------+----------+---------+
| 0638b3c3-7c5e-47ce-b067-719a4b38159e | demo_net |         |
+--------------------------------------+----------+---------+

修改/etc/libvirt/qemu.conf

cgroup_device_acl = [
    "/dev/null", "/dev/full", "/dev/zero",
    "/dev/random", "/dev/urandom",
    "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
    "/dev/rtc","/dev/hpet","/dev/net/tun",
]

重啓libvirtd

service libvirtd restart

配置dhcp-agent(optional)

修改配置/etc/neutron/dhcp_agent.ini

debug = True
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
use_namespaces = False
dhcp_confs = $state_path/dhcp

此處有問題, 須要補充dhcp.DNSmasq的配置 刪除默認網橋

virsh net-list
virsh net-destroy default
virsh net-undefine default

Cinder

配置cinder.conf 添加數據庫信息

[DEFAULT]
rabbit_host=192.168.48.131
rabbit_port=5672
rabbit_userid=guest
rabbit_password=guest
rabbit_virtual_host=/
rpc_backend=rabbit
state_path=/var/lib/cinder
auth_strategy=keystone
debug=true
verbose=true
log_file=cinder.log
log_dir=/var/log/cinder
nfs_shares_config=/etc/cinder/nfs_shares
nfs_mount_point_base=$state_path/mnt
volume_driver=cinder.volume.drivers.nfs.NfsDriver
[BRCD_FABRIC_EXAMPLE]
[database]
connection=mysql://cinder:cinder@192.168.48.131/cinder
[fc-zone-manager]
[keymgr]
[keystone_authtoken]
auth_host=192.168.48.131
auth_port=35357
auth_protocol=http
auth_uri=http://192.168.48.131:5000
admin_user=admin
admin_password=admin
admin_tenant_name=admin
[matchmaker_redis]
[matchmaker_ring]
[oslo_messaging_amqp]
[profiler]
[ssl]

同步數據庫

cinder-manage db sync

建立keystone service endpoint

keystone service-create --name=cinder --type=volume --description="Openstack Block Storage"
keystone endpoint-create \
> --service-id=980f3b2fe7164491aa84935c4b69b8dd \
> --publicurl=http://192.168.48.131:8776/v1/%\(tenant_id\)s \
> --internalurl=http://192.168.48.131:8776/v1/%\(tenant_id\)s \
> --adminurl=http://192.168.48.131:8776/v1/%\(tenant_id\)s
+-------------+---------------------------------------------+
|   Property  |                    Value                    |
+-------------+---------------------------------------------+
|   adminurl  | http://192.168.48.131:8776/v1/%(tenant_id)s |
|      id     |       340328a8661148bc800b061179335560      |
| internalurl | http://192.168.48.131:8776/v1/%(tenant_id)s |
|  publicurl  | http://192.168.48.131:8776/v1/%(tenant_id)s |
|    region   |                  regionOne                  |
|  service_id |       980f3b2fe7164491aa84935c4b69b8dd      |
+-------------+---------------------------------------------+

安裝nfs

yum install nfs-utils rpcbind 

vi /etc/exports

/data/nfs       192.168.48.0/24(rw,no_root_squash)

重啓nfs服務

service rpcbind restart
service nfs restart

編輯文件/etc/cinder/nfs_shares

192.168.48.131:/data/nfs

部署glusterfs

下載glusterfs的源

baseurl=http://buildlogs.centos.org/centos/6/storage/x86_64/gluster-3.7/
baseurl=http://mirrors.163.com/centos/6.8/storage/x86_64/gluster-3.7/

啓動glusterd服務

service glusterd start

建立gluster存儲對象

gluster volume create cinder-01 replica 2 192.168.48.131:/data/glusterfs/exp1 192.168.48.131:/data/glusterfs/exp2 force

查看存儲卷的信息

gluster volume info

啓動卷

gluster volume start cinder-01

修改cinder.conf文件, 指明使用clusterfsDriver

volume_driver=cinder.volume.drivers.glusterfs.GlusterfsDriver
glusterfs_shares_config=/etc/cinder/glusterfs_shares
glusterfs_mount_point_base=$state_path/mnt

編輯掛載配置文件/etc/cinder/glusterfs_shares

192.168.48.131:/cinder-01

計算節點

部署nova-compute和neutron-linuxbridge-agent便可 思科的三層交換. 核心層交換: 防火牆. 匯聚層交換: 交換機 接入層交換: Server與交換機的鏈接

運維環境

flume fluentd logstash flume + stom + kafka + hdfs + rundesk

製做image鏡像

http://docs.openstack.org/image-guide/index.html 建立虛擬磁盤文件

qemu-img create -f qcow2 /tmp/centos.qcow2 10G

建立虛擬機

virt-install --virt-type kvm --name centos --ram 1024 \
  --disk /tmp/centos.qcow2,format=qcow2 \
  --network network=default \
  --graphics vnc,listen=0.0.0.0 --noautoconsole \
  --os-type=linux --os-variant=rhel7 \
  --location=/data/isos/CentOS-7-x86_64-NetInstall-1511.iso

導出xml配置文件

virsh dumpxml centos 

使用cloud-init 獲取公鑰

yum install cloud-init

cloud-init生成/etc/cloud/cloud.cfg

user: admin

在/etc/rc.d/rc.local中添加以下腳原本獲取公鑰

 if [ ! -d /root/.ssh ]; then
  mkdir -p /root/.ssh
  chmod 700 /root/.ssh
fi

# Fetch public key using HTTP
ATTEMPTS=30
FAILED=0
while [ ! -f /root/.ssh/authorized_keys ]; do
  curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key \
    > /tmp/metadata-key 2>/dev/null
  if [ \$? -eq 0 ]; then
    cat /tmp/metadata-key >> /root/.ssh/authorized_keys
    chmod 0600 /root/.ssh/authorized_keys
    restorecon /root/.ssh/authorized_keys
    rm -f /tmp/metadata-key
    echo "Successfully retrieved public key from instance metadata"
    echo "*****************"
    echo "AUTHORIZED KEYS"
    echo "*****************"
    cat /root/.ssh/authorized_keys
    echo "*****************"
  fi
done

禁止zeroconf 路由

echo "NOZEROCONF=yes" >>/etc/sysconfig/network

配置控制檯

RHEL6, grub

serial --unit=0 --speed=115200
terminal --timeout=10 console serial 
kernel ... console=tty, console=ttyS0, 115200n8

RHEL7, grub2 編輯/etc/default/grub並配置GRUP_CMDLINE_LINUX選項, 而且刪除rhgb quiet的內核參數

GRUB_CMDLINE_LINUX="crashkernel=auto console=tty0 console=ttyS0,115200n8"

執行grub2-mkconfig產生配置文件

grub2-mkconfig -o /boot/grub2/grub.cfg

清理mac 地址的詳細信息

virt-sysprep -d centos

刪除本地虛擬機

virsh undefine centos

http://www.chenshake.com/

陳沙克的博客

 

 

 

 

 

 

 

 

 

附錄

Rabitmq

修改密碼

rabbitmqctl change_password guest guest
相關文章
相關標籤/搜索