OnVRTest

Preparation

Ubuntu14.04, KVM(cpu host-passthrough), 16G memory, 8-Core CPU, 200G Disk.

Update/upgrade to newest version of ubuntu:

# apt-get update
# apt-get upgrade -y

Enable root login with the password set as engine123.

# sed -i '/PermitRootLogin without-password/PermitRootLogin yes' /etc/ssh/sshd_config
# service ssh restart

Networking

Using bridged networking in ubuntu:
/etc/network/interfaces content:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual


auto cloudbr0
iface cloudbr0 inet static
        address 10.17.17.2
        netmask 255.255.255.0
        gateway 10.17.17.1
        dns-nameservers 180.76.76.76
        bridge-ports eth0
        bridge_fd 5
        bridge_stp off
        bridge_maxwait 1

# Private network
auto cloudbr1
iface cloudbr1 inet manual
        bridge_ports none
        bridge_fd 5
        bridge_stp off
        bridge_maxwait 1

After configuration, restart the machine.

Repository For CloudStack

Use local directory for holding cloudstack installation packages:

# echo "deb file:/root/CloudStack4.5.1 ./">>/etc/apt/sources.list
# apt-get update

While the directory should contains following packages:

root@ubuntu:~# ls CloudStack4.5.1/
Packages.gz                      cloudstack-cli_4.5.1_all.deb     cloudstack-management_4.5.1_all.deb
cloudstack-agent_4.5.1_all.deb   cloudstack-common_4.5.1_all.deb  cloudstack-usage_4.5.1_all.deb
cloudstack-awsapi_4.5.1_all.deb  cloudstack-docs_4.5.1_all.deb

CloudStack Installation

Management Server

Install Cloudstack-management and mysql via:

# apt-get install cloudstack-management mysql-server

Configure the password of mysql to engine123:

/images/2017_05_03_14_24_56_754x244.jpg

MySql Configuration:

# cat >>/etc/mysql/conf.d/cloudstack.cnf <<EOM
[mysqld]
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'
EOM

# service mysql restart

Initialize the mysql databases via:

# cloudstack-setup-databases cloud:engine123@localhost --deploy-as=root:engine123 -e file -m mymskey44 -k mydbkey00

NFS Service

# mkdir -p /export/primary /export/secondary
# apt-get install nfs-kernel-server
# service nfs-kernel-server start
# cat >>/etc/exports <<EOM
/export  *(rw,async,no_root_squash,no_subtree_check)
EOM
# exportfs -a

Agent

Install clouddstack-agent via:

# apt-get install cloudstack-agent

libvirt:

# vim /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp=1
tcp_port="16509"
auth_tcp="none"

libvirt-bin.conf:

# vim /etc/default/libvirt-bin
libvirtd_opts="-d -l"

qemu.conf for listening all of the window:

# vim /etc/libvirt/qemu.conf
vnc_listen = "0.0.0.0"

Now reboot your machien for taking all of the configurations effects.

Trouble-Shooting

When meeting following issue:

/images/2017_05_03_15_21_42_454x266.jpg Do following commands for restart the service:

# service cloudstack-management status
# service cloudstack-agent status
# service tomcat6 status

# service cloudstack-management stop
# service tomcat6 stop
# service cloudstack-agent stop
# ps -efl | grep java

# service cloudstack-management start
# service cloudstack-management status
# service cloudstack-agent start
# service cloudstack-agent status

OR:

update-rc.d tomcat6 disable
cloudstack-setup-management

systemvm

Edit the configuration, and restart the service of cloudstack management.

/images/2017_05_03_15_27_44_692x195.jpg

/images/2017_05_03_16_01_29_665x68.jpg

# service cloudstack-management restart

Install the systemvm like following:

# /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt -u http://192.168.1.69/systemvm64template-4.5-kvm.qcow2.bz2  -h kvm -F

CloudStack Env

/images/2017_05_03_15_31_47_652x486.jpg

/images/2017_05_03_15_32_28_472x491.jpg

/images/2017_05_03_15_32_47_450x358.jpg

/images/2017_05_03_15_34_53_650x265.jpg

/images/2017_05_03_15_35_16_503x411.jpg

/images/2017_05_03_15_35_26_461x240.jpg

/images/2017_05_03_15_35_37_531x231.jpg

/images/2017_05_03_15_35_57_588x342.jpg

/images/2017_05_03_15_36_19_525x338.jpg

/images/2017_05_03_15_36_30_647x395.jpg

BombServer

New Service Offering:

/images/2017_05_03_16_02_19_405x574.jpg

Template, download from http://192.168.1.69/myubuntu.qcow2:

/images/2017_05_03_16_02_58_720x244.jpg

Start new instance:

/images/2017_05_03_16_03_42_436x386.jpg

/images/2017_05_03_16_03_58_299x244.jpg

/images/2017_05_03_16_04_08_357x316.jpg

/images/2017_05_03_16_04_22_439x415.jpg

/images/2017_05_03_16_04_36_430x449.jpg

Networking:

/images/2017_05_03_16_06_54_760x305.jpg

/images/2017_05_03_16_07_13_746x111.jpg

/images/2017_05_03_16_07_40_800x237.jpg

/images/2017_05_03_16_08_02_429x322.jpg

/images/2017_05_03_16_08_35_717x315.jpg

/images/2017_05_03_16_09_13_717x381.jpg

/images/2017_05_03_16_09_49_479x377.jpg

Now you could ping 10.17.17.13 and log into this machine via this IP.

Exceed Limitation

In Server10.17.17.2:

# vim /etc/security/limits.conf
* soft nofile 1048576
* hard nofile 1048576
root - nofile 1048576
root hard nofile 1048576
root soft nofile 1048576

And add following 3 lines into /etc/sysctl.conf:

# vim /etc/sysctl.conf
fs.file-max=1048576
net.netfilter.nf_conntrack_max = 6553500
net.ipv4.ip_local_port_range= 1024 65535
# sysctl -p /etc/sysctl.conf 
fs.file-max = 1048576
net.netfilter.nf_conntrack_max = 6553500
net.ipv4.ip_local_port_range = 1024 65535

Add it into /etc/rc.local:

# vim /etc/rc.local
modprobe nf_conntrack
sysctl -p /etc/sysctl.conf
exit 0

Do the same things to BombServer and BombClient. Examine via:

# cat /proc/sys/net/netfilter/nf_conntrack_max 
6553500
# ulimit -n
1048576
......

BombServer Setting

In instance 10.17.17.13, download Server-side code and compile:

# wget https://gist.github.com/yongboy/5318930/raw/ccf8dc236da30fcf4f89567d567eaf295b363d47/server.c
$ sudo apt-get install -y libev-dev
$ vim server.c
comment ev.h , replace it into `#include <ev.h>`
$ gcc -o server server.c -lev -lm

Start server via:

# ./server 
start free -m is 
             total       used       free     shared    buffers     cached
Mem:          3009        526       2483          0         16        419
-/+ buffers/cache:         90       2919
Swap:          511          0        511

Client Setting

Use a Ubuntu qcow2 file, start a qemu based vm on 10.17.17.2.

The ubuntu1404origin.qcow2 is modified to have a 10.17.17.190 ip address.

/etc/network/interfaces content:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 10.17.17.190
netmask 255.255.255.0
gateway 10.17.17.1
dns-nameservers 180.76.76.76

Start command:

root@ubuntu:~/testmachine# ls
startmachine.sh  ubuntu1404origin.qcow2
root@ubuntu:~/testmachine# cat startmachine.sh 
qemu-system-x86_64 -net nic,model=virtio,macaddr=52:54:00:12:34:56,vlan=1 -net tap,vlan=1 -net nic,model=virtio,macaddr=52:54:00:12:34:57,vlan=2 -net tap,vlan=2 -net nic,model=virtio,macaddr=52:54:00:12:34:58,vlan=3 -net tap,vlan=3 -net nic,model=virtio,macaddr=52:54:00:12:34:59,vlan=4 -net tap,vlan=4 -net nic,model=virtio,macaddr=52:54:00:12:34:60,vlan=5 -net tap,vlan=5 -net nic,model=virtio,macaddr=52:54:00:12:34:61,vlan=6 -net tap,vlan=6 -net nic,model=virtio,macaddr=52:54:00:12:34:62,vlan=7 -net tap,vlan=7 -net nic,model=virtio,macaddr=52:54:00:12:34:63,vlan=8 -net tap,vlan=8 -hda ./ubuntu1404origin.qcow2 -m 3072 --enable-kvm
# ./startmachine.sh

Login into client machine(10.17.17.190), do following command:

# ifconfig eth1 10.17.17.254/24
# ifconfig eth2 10.17.17.253/24
# ifconfig eth3 10.17.17.252/24
# ifconfig eth4 10.17.17.251/24
# ifconfig eth5 10.17.17.250/24
# ifconfig eth6 10.17.17.249/24
# ifconfig eth7 10.17.17.248/24
# ifconfig eth8 10.17.17.247/24
# ifconfig eth9 10.17.17.246/24
# ./client -h 10.17.17.13 -p 8000 -m 64000 -o 10.17.17.190,10.17.17.254,10.17.17.253,10.17.17.252,10.17.17.251,10.17.17.250,10.17.17.249,10.17.17.248

The client file is downloaded and compile via:

# wget https://gist.github.com/yongboy/5324779/raw/f29c964fcd67fefc3ce66e487a44298ced611cdc/client2.c
# gcc -o client client2.c -levent

When start Bombing the server, the captured image is listed as following:

/images/2017_05_03_17_19_58_324x455.jpg

CS49OnUbuntu1404

MySql Configuration

Configuration for mysql:

# cat >>/etc/mysql/conf.d/cloudstack.cnf <<EOM
> [mysqld]
> innodb_rollback_on_timeout=1
> innodb_lock_wait_timeout=600
> max_connections=350
> log-bin=mysql-bin
> binlog-format = 'ROW'
> EOM
# service mysql restart

Configuration:

# cloudstack-setup-databases cloud:engine123@localhost --deploy-as=root:engine123 -e file -m mymskey44 -k mydbkey00

NFS Server

# mkdir -p /export/primary /export/secondary
# apt-get install nfs-kernel-server
# vim /etc/exports 
/export  *(rw,async,no_root_squash,no_subtree_check)
# service nfs-kernel-server start
# exportfs -a
# showmount -e 127.0.0.1
Export list for 127.0.0.1:
/export *

CloudStack-Agent

安装:

# apt-get install cloudstack-agent

配置libvirt:

# vim /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp=1
tcp_port="16509"
auth_tcp="none"

配置libvirt-bin.conf文件:

# vim /etc/default/libvirt-bin
libvirtd_opts="-d -l"

配置qemu.conf文件,以侦听所有端口:

# vim /etc/libvirt/qemu.conf
vnc_listen = "0.0.0.0"

Systemvm

Install systemvm via:

# /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt -u http://192.168.1.69/systemvm64template-4.6.0-kvm.qcow2.bz2 -h kvm -F

CloudStack Configuration

Zone Type:

/images/2017_05_03_11_40_48_764x641.jpg

Zone:

/images/2017_05_03_11_41_24_597x536.jpg

/images/2017_05_03_11_42_07_575x365.jpg

Click Next:

/images/2017_05_03_11_42_20_576x450.jpg

Guest Traffic:

/images/2017_05_03_11_42_56_654x273.jpg

Pod:

/images/2017_05_03_11_43_28_492x449.jpg

/images/2017_05_03_11_43_43_432x214.jpg

ClusterName:

/images/2017_05_03_11_43_58_504x242.jpg

Host:

/images/2017_05_03_11_44_20_485x391.jpg

Secondary Storage:

/images/2017_05_03_11_45_06_505x355.jpg

Launch zone:

/images/2017_05_03_11_45_29_641x410.jpg

快速搭建MiniKube开发环境

版本

minikube的版本是v0.17.1, 运行于ArchLinux.

镜像准备

感谢万能的防火墙,我们需要手动下载docker镜像到本地:

sudo docker pull  gcr.io/google-containers/kube-addon-manager:v6.3
sudo docker pull gcr.io/google_containers/kubedns-amd64:1.9
sudo docker pull gcr.io/google_containers/kube-dnsmasq-amd64:1.4
sudo docker pull gcr.io/google_containers/exechealthz-amd64:1.2
sudo docker pull  gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1
sudo docker pull gcr.io/google_containers/heapster:v1.2.0
sudo docker pull kubernetes/heapster_influxdb:v0.6
sudo docker pull gcr.io/google_containers/heapster_grafana:v2.6.0-2
sudo docker pull gcr.io/google_containers/pause-amd64:3.0

存储docker镜像并打包的命令如下, 这样一个wget就可取下来所有的镜像:

sudo docker save  gcr.io/google-containers/kube-addon-manager:v6.3 | bzip2>~/serve/addonmanagerv63.tar.bz2
sudo docker save gcr.io/google_containers/kubedns-amd64:1.9|bzip2>~/serve/dns19.tar.bz2
sudo docker save gcr.io/google_containers/kube-dnsmasq-amd64:1.4 |bzip2>~/serve/dnsmasq14.tar.bz2
sudo docker save gcr.io/google_containers/exechealthz-amd64:1.2|bzip2>~/serve/exechealthz12.tar.bz2
sudo docker save  gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1|bzip2>~/serve/dashboard151.tar.bz2
sudo docker save gcr.io/google_containers/heapster:v1.2.0|bzip2>~/serve/heapster.tar.bz2
sudo docker save kubernetes/heapster_influxdb:v0.6|bzip2>~/serve/influx.tar.bz2
sudo docker save gcr.io/google_containers/heapster_grafana:v2.6.0-2|bzip2>~/serve/grafana.tar.bz2
sudo docker save gcr.io/google_containers/pause-amd64:3.0|bzip2>~/serve/pauseamd64.tar.bz2
sudo tar czvf ~/serve/kube.tar.gz ~/serve/*.tar.bz2

下载到本地后,直接用sudo docker load<xxxx.tar.bz2即可安装这些镜像。

minikube

安装minikube的命令为:

$ yaourt minikube

启动的命令为:

# minikube stop && minikube start

CoreOS Cluster On Libvirt

Environment

ArchLinux, libvirt.
Libvirt network(NAT, NOT dhcp), 172.17.8.1/24.

etcd server

On ArchLinux, create a etcd server via following commands:

http://purplepalmdash.github.io/blog/2016/12/21/trycoreos2/

ArchLinux etcd2 Example.

Working Tips On Dimension

背景

最近在帮一个亲戚做企业类网站,最初方案是基于Docker化的WordPress,搭建好以后 一直不闻不问,思想可能是因为WP对于小白用户来说太过于复杂的缘故。

正好今天查看hugo的模板方案时,发现有一个很美观的静态页面叫Dimension, 于是起 了把网站迁移到静态网站上的心思。

Dimension主题预览:

/images/2017_03_17_19_27_38_439x324.jpg

搭建环境

首先从github下载源代码:

$ git clone https://github.com/sethmacleod/dimension.git
$ mkdir Website/themes
$ mv dimension-master Website/themes/dimension
$ cp -ar Website/themes/dimension/exampleSite/* Website/

经过上面的步骤,我们已经设置了模板可工作的DEMO环境,在Website目录下执行以下命令, 分别为编译整个静态网站和预览更改:

$ cd Website
$ hugo
$ sudo python2 -mSimpleHTTPServer 18118

现在打开你的浏览器访问http://localhost:18118,即可看到本地搭建的dimension示例网站。

自定义

如果要创建自己的页面,则hugo new Your-Page.md即可创建出来页面,编辑方法就是针对markdown的编辑。

多语言支持

默认的DEMO提供了对德语和英语的支持,我们只需要删除config.toml文件中的[languages]的字段就可以, 例如删除:

[languages]
[languages.en]
languageName = "English"
weight = 1
title = "Dimension"

logo修改

默认的logo使用的是fontawesome字体,我们可以修改为自定义的图片,需要修改以下两个地方:
config.toml文件:

- logo = "fa-diamond"
- logo = "/images/jqlogo.png"

同时放置jqlogo.png文件于static/images/目录下.

themes/dimension/layouts/index.html文件中需要做对应的修改:

            {{ with .Site.Params.logo }}            
-              <span class="icon {{ . }}"></span>
+	    <img src="{{ . }}" style="padding: 10px 10px 10px 10px;" width="100%">

这样就完成了对logo的修改.

首页滚动字幕

这里主要参考了另一个网站https://robinson-schule.ch/中的解决方案。

$ cd themes/dimension/static/js
$ wget https://robinson-schule.ch/js/quotes.js
$ cd ../css
$ wget https://robinson-schule.ch/css/project.css

接着就可以修改quotes.js文件中关于滚动条的内容,同时在themes/dimension/layouts/index.html文件 中添加:

                <p>{{ .Site.Params.description | safeHTML }}</p>
+		<p id="quotes"></p><script type="text/javascript" src="/js/quotes.js"></script></p>

人物介绍

markdown中可以直接添加html,添加以下的html字段来实现图像的自动圆圈处理:

  <div class="person">
	<div class="personheadshot">
		<img src="/images/yuangong3.jpg" alt="yuangong3" class="circle headshot">
	</div>
	<div class="persondescription">
		<span><b>刘梦之</b></span><br/>
		<span><i>场地保洁主管 / 场地保洁专家 / 某保洁项目组组长</i></span><br/>
		<span>晶巧连续四年优秀员工 (2013 / 2014 / 2015 / 2016)</span>
	</div>
  </div>

这里用到的circle headshot的css定义在project.css文件中:

img.headshot
{
    width: 150px;
    height: 150px;
}
img.circle {
 	border-radius: 50%;
}

div.person等定义也可以在该文件中找到。

完成效果

首页:

/images/2017_03_17_20_06_26_757x605.jpg

about页面:

/images/2017_03_17_20_06_55_649x482.jpg

Enjoy it!!!

延伸阅读

可以考虑hugo的另一个模板效果:

http://themes.gohugo.io/theme/hugo-elate-theme/