星期一, 4月 17, 2017

OpenStack Install with CentOS

bg 重裝...Orz



安裝文件參考
https://www.hkitblog.com/?p=28724

vSwitch觀念影片
https://youtu.be/7x-JzMDN6Wc


很重要,必看***Introduction to Open vSwitch (OVS)
https://www.youtube.com/watch?v=rYW7kQRyUvA

心得:
0. 要用對外網路,不要用預設的命令,改用 (https://www.rdoproject.org/networking/neutron-with-existing-external-network/)
packstack --allinone --provision-demo=n --os-neutron-ovs-bridge-mappings=extnet:br-ex --os-neutron-ovs-bridge-interfaces=br-ex:eth0 --os-neutron-ml2-type-drivers=vxlan,flat
以上會加入vswitch,之後才能對vm內外互通。
After completion, given a single machine with a current IP of 192.168.122.212 (我的主機是192.168.0.226)/24 via DHCP with gateway of 192.168.122.11(192.168.0.1):
Make /etc/sysconfig/network-scripts/ifcfg-br-ex resemble:
DEVICE=br-ex
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=192.168.122.212 0.226 # Old eth0 IP since we want the network restart to not 
                       # kill the connection, otherwise pick something outside your dhcp range
NETMASK=255.255.255.0  # your netmask
GATEWAY=192.168.122.1  0.1 # your gateway
DNS1=192.168.122.1   0.1  # your nameserver
ONBOOT=yes
The file above will move the network parameters from eth0 to br-ex. 
Make /etc/sysconfig/network-scripts/ifcfg-eth0 resemble (no BOOTPROTO!):
Note: if on Centos7, the file could be /etc/sysconfig/network-scripts/ifcfg-enp2s0 and DEVICE should be enp2s0
DEVICE=eth0
TYPE=OVSPort
DEVICETYPE=ovs
OVS_BRIDGE=br-ex
ONBOOT=yes
It is also possible to use a bond. In that case /etc/sysconfig/network-scripts/ifcfg-bond0 may look like this:
DEVICE=bond0
DEVICETYPE=ovs
TYPE=OVSPort
OVS_BRIDGE=br-ex
ONBOOT=yes
BONDING_MASTER=yes
BONDING_OPTS="mode=802.3ad"
This means, we will bring up the interface and plug it into br-ex OVS bridge as a port, providing the uplink connectivity.
Restart the network service
# reboot
or, alternatively:
# service network restart
Now, create the external network with Neutron.
# . keystonerc_admin
# neutron net-create external_network --provider:network_type flat --provider:physical_network extnet  --router:external
Please note: "extnet" is the L2 segment we defined with –os-neutron-ovs-bridge-mappings above.
You need to create a public subnet with an allocation range outside of your external DHCP range and set the gateway to the default gateway of the external network.
Please note: 192.168.122.10.1/24 is the router and CIDR we defined in /etc/sysconfig/network-scripts/ifcfg-br-ex for external connectivity.
# neutron subnet-create --name public_subnet --enable_dhcp=False --allocation-pool=start=192.168.122.100.200,end=192.168.122.200.210 \
                        --gateway=192.168.122.10.1 external_network 192.168.122.00.0/24

接下來的,也許可以在圖形化介面做了
Get a cirros image, not provisioned without demo provisioning:
curl http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img | glance \
         image-create --name='cirros image' --visibility=public --container-format=bare --disk-format=qcow2
That's all you need to do from admin perspective to allow your users to connect their private networks to the outside world. Now let's switch to the user.
Since you haven't created a user yet:
openstack project create --enable internal
openstack user create --project internal --password foo --email bar@corp.com --enable internal
Now, let's switch to the newly created user:
# export OS_USERNAME=internal
# export OS_TENANT_NAME=internal
# export OS_PASSWORD=foo
Then create a router and set its gateway using the external network created by the admin in one of previous steps:
# neutron router-create router1
# neutron router-gateway-set router1 external_network
Now create a private network and a subnet in it, since demo provisioning has been disabled:
# neutron net-create private_network
# neutron subnet-create --name private_subnet private_network 192.168.100.0/24
Finally, connect your new private network to the public network through the router, which will provide floating IP addresses.
# neutron router-interface-add router1 private_subnet
Easiest way to the network and to launch instances is via horizon, which was set up by packstack.

1. 如果instance建不起來,有kvm錯誤,要先確定bios有打開虛擬化功能
2. 預設對外ip無法通訊,要設定floating IP前,先確定vSwitch網卡設定是否ok,可參考

https://www.hkitblog.com/?p=28801

3.






Meteor框架記錄

Meteor框架跟django框架很類似,但也有很多不同的地方,如
  1. meteor框架的架構主要是會分成client及server,資料庫的部分使用mongodb的collection(這部分的程式碼是可以共用的)。
  2. 檔案架構如下,其中imports目錄下的程式碼meteor不會主動載入,需要匯入的時候使用import語法匯入

  • client
  • server
  • imports
  • public
  1. 在各個目錄下面,會需要設計許多html網頁樣板,meteor會自動掃描樣板整合。
  2. 網頁樣板中的(只要一份)、(只要一份)、
  3. 在各個目錄下面,會需要設計許多javascript程式,用來輔助樣板功能
  4. 在路由的部分,可使用iron router及flow router,如果沒有要整合其他的前端框架,使用iron router 就可以了


Meteor應用設計流程如下:

  1. 可利用bootstrap,規劃設計各個版面先
  2. 把版面改成meteor樣板
  3. 設定路由
  4. 針對各個頁面去設計mongodb的集合
  5. 針對各個js, 設計輔助功能, 利用meteor語法讀取資料,配製版面
  6. 設計表單,針對表單的相關js設計事件處理方法,讀取表單的資料新增到mongodb集合中
  7. 基本工能測試服務後,移除不安全的套件
  8. 移除 autopublish功能,修改程式碼加入公開集合操作的函式,加強安全性

Meteor好用套件:
  1. bootstrape
  2. iron router
  3. huston admin
  4. accounts-ui
  5. accounts-password