2016年10月22日 星期六

To remove a compute host in OpenStack

Environment:
*OpenStack version: mitaka


請先從Horizon上停用該Compute Host

在Compute Host停止及停用以下的服務
systemctl stop openstack-ceilometer*
systemctl stop neutron*
systemctl stop openstack-nova*

systemctl disable openstack-ceilometer*
systemctl disable neutron*
systemctl disable openstack-nova*


使用OpenStack的cmd來刪除Compute Host(請先載入OpenStack admin環境 source keystonerc_admin)

# 列出compute service的id
openstack compute service list | grep 'nova-compute' | grep '{{compute host}}' | awk '{print $2}'

# 刪除compute service
openstack compute service delete {{service id}}

# 列出neutron agent的id
neutron agent-list | grep '{{compute host}}' | awk '{print $2}'

# 刪除neutron agent
neutron agent-delete {{agent id}}

由於資料庫中還殘存著記錄, 這讓本人覺得非常的不舒服, 於是本人又進了資料庫把以下相關的資料都清除掉

# 清除nova資料庫中與Compute Host有關的記錄
set @compute_host = '{{compute host}}';

DELETE FROM `compute_nodes` WHERE `hypervisor_hostname`=@compute_host;
DELETE FROM `service` WHERE `host`=@compute_host;

# 清除neutron資料庫中與Compute Host有關的記錄
set @compute_host = '{{compute host}}';

DELETE FROM `agents` WHERE `host`=@compute_host;
DELETE FROM `ml2_gre_endpoints` WHERE `host`=@compute_host;
DELETE FROM `ml2_port_binding_levels` WHERE `host`=@compute_host;
DELETE FROM `ml2_port_bindings` WHERE `host`=@compute_host;
DELETE FROM `ml2_vxlan_endpoints` WHERE `host`=@compute_host;

最後記得去所有的機器把有關這台Compute Host的iptables policy清除喔

2016年10月21日 星期五

To add a compute host in OpenStack

Environment:
*OpenStack version: mitaka
*Packstack version: 8.0.0-1.el7


Packstack在安裝Control Host時會建立SSL金鑰及憑証, 但如果安裝時把Control Host排除在外, 這些檔案就不會被複製到Compute Host, 需手動複製到Compute Host, 所以請將以下檔案複製到Compute Host相對的位置
/etc/pki/tls/certs/packstack_cacert.crt
/etc/pki/tls/certs/ssl_amqp_nova.crt
/etc/pki/tls/private/ssl_amqp_nova.key
/etc/pki/tls/certs/ssl_amqp_neutron.crt
/etc/pki/tls/private/ssl_amqp_neutron.key

由於Compute Host在服務啟動時會連接到Control Host, 但我們不會更動Control Host的設定, 會造成服務無法啟動令安裝失敗, 因此請在Control Host准許以下防火牆的規則
INPUT -s {{compute host new}}/32 -p udp -m multiport --dport 4789 -m comment --comment "003 neutron tunnel port incoming" -j ACCEPT
INPUT -s {{compute host new}}/32 -p tcp -m multiport --dport 3260 -m comment --comment "003 cinder incoming" -j ACCEPT
INPUT -s {{compute host new}}/32 -p tcp -m multiport --dport 3306 -m comment --comment "003 mariadb incoming" -j ACCEPT
INPUT -s {{compute host new}}/32 -p tcp -m multiport --dport 5671,5672 -m comment --comment "003 amqp incoming" -j ACCEPT
INPUT -s {{compute host new}}/32 -p tcp -m multiport --dport 27017 -m comment --comment "003 mongodb-server incoming" -j ACCEPT

接著就可以執行Packstack安裝, 請記得把Control Host及其他的Compute Host加入EXCLUDE_SERVERS裡, 否則之前的設定會被洗掉
packstack --answer-file={{answer file}}
*有時packstack在設定網路時不知為何無法停止網路介面, 因而安裝失敗, 此時再重新執行一次安裝就可正常完成安裝
*如果安裝停止很久, 有可能是服務無法正常啟動, 請至compute host new上檢查服務的記錄(/var/log/neutron, /var/log/nova)

為了能讓使用者的Instance正常遷移, 請在Compute Host准許以下防火牆的規則
INPUT -s {{compute host other}}/32 -p tcp -m multiport --dport 16509,49152:59215 -m comment --comment "nova qemu migration incoming" -j ACCEPT
同時在其他的Compute Host准許以下防火牆的規則
INPUT -s {{compute host new}}/32 -p tcp -m multiport --dport 16509,49152:59215 -m comment --comment "nova qemu migration incoming" -j ACCEPT

因為我同時設定Compute Host為Network Host, 請在Compute Host准許以下防火牆的規則
INPUT -s {{compute host other}}/32 -p udp -m multiport --dport 4789 -m comment --comment "003 neutron tunnel port incoming" -j ACCEPT
同時在其他的Compute Host准許以下防火牆規則
INPUT -s {{compute host new}}/32 -p udp -m multiport --dport 4789 -m comment --comment "003 neutron tunnel port incoming" -j ACCEPT

2016年2月25日 星期四

docker swarm

Node and role:
* Manage: Swarm manager and consul server container are run on this server
* Node: Swarm agent is run on this server

Prerequisties:
* docker version 1.9 or above
* docker node has unique hostname (key-value store use it)
* docker node with linux kernel 3.16 or above
* key-value store (swarm support consul, etcd or zookeeper, here we use consul)
* Properly configured engine daemon (only on swarm nodes)
** -H unix:///var/run/docker.sock -H tcp://{{node_ip|0.0.0.0}}:2375 --cluster-advertise={{node_ip}}:2375 --cluster-sotre=consul:{{consul_ip}}:8500

First, start a consul server, the consul server must be accessed by all of the swarm nodes
Manage# docker run -d -p 8500:8500 progrium/consul -server -bootstrap

The run swarm agent and join current swam cluster
Node# docker run -d swarm join consul://{{consul_ip}}:8500 --advertise={{node_ip}}:2375

At last, you can manage your swarm cluster via container.
Start a swarm manage and expose the swarm API server.
(It can be any server, even on your laptop, the only requirement is it can access to key-value store and swarm nodes)
(Any machine)# docker run -d -p 3375:2375 swarm manage consul://{{consul_ip}}:8500

You can manage your swarm cluster through these two command as following:
* Method 1:
# docker -H {{swarm_manage}}:3375 
* Method 2:
export DOCKER_HOST={{swarm_manage}}:3375
docker 

2014年8月28日 星期四

dnsmasq with gpxe can not get the filename

Recently I used dnsmasq for pxeboot my virtual machine.
The virtual machine was boot with gPXE.
And it can fetch the IP address, but can't fetch the filename.
Then I captured the network package.
The server did send the filename operation to client.
But the client did not use it.
I can't figure out what happened.
After I added the option "dhcp-no-override" and everything just fine.

kickstart include file

Recently I have to setup multiple server.
Most of them have the same content.
So I tried to separate the same part into a file
And include them if I need it.

install
skipx
text
#cmdline

## install source
url --url=http://{{server}}/distro/centos/6.5/x86_64

## include common install setting
%include http://{{server}}/kickstart/install.ks

## disk operation
zerombr yes
bootloader --location=mbr --append="rhgb quiet"
clearpart --all --initlabel
autopart


%packages
## include common package list
%include http://{{server}}/kickstart/packages.ks


%post
## include commom post script
%include http://{{server}}/kickstart/post.ks

## include some category post script
%include http://{{server}}/kickstart/post-some-category.ks

## write your special script here
echo "done!!"

%end


pxelinux boot menu with include file

The default configuration
default menu.c32
timeout 100
totaltimeout 600
ontimeout LOCAL_BOOT
prompt 0

menu title PXE menu

label LOCAL_BOOT
    menu default
    menu label ^Local Boot
    localboot 0

menu include pxelinux.cfg/basic.menu


The "basic.menu" content
label BASIC_SERVER
    menu label Basic CentOS 6.5 ^Server
    kernel centos/6.5/x86_64/isolinux/vmlinuz
    append initrd=centos/6.5/x86_64/isolinux/initrd.img ksdevice=bootif ks=http://server.ip/centos_6_5_kickstart_server
    ipappend 2

label BASIC_DESKTOP
    menu label Basic CentOS 6.5 ^Desktop
    kernel centos/6.5/x86_64/isolinux/vmlinuz
    append initrd=centos/6.5/x86_64/isolinux/initrd.img ksdevice=bootif ks=http://server.ip/centos_6_5_kickstart_desktop
    ipappend 2

Disable vncserver authentication

Add the option "-SecurityTypes none" to the VNC command
Suggest to listen on localhost connection if you do not want to have any authentication.
To listen on localhost connection only, add the option "-localhost" to the VNC command