HackToday Walk Blog


  • Home

  • Tags

  • Archives

  • Search

Install from Source - Mesos 集群

Posted on 2016-09-12
  1. 安装build和运行环境依赖
1
2
3
4
5
6
7
8
# Install the latest OpenJDK.
$ sudo apt-get install -y openjdk-8-jdk

# Install autotools (Only necessary if building from git repository).
$ sudo apt-get install -y autoconf libtool

# Install other Mesos dependencies.
$ sudo apt-get -y install build-essential python-dev libcurl4-nss-dev libsasl2-dev libsasl2-modules maven libapr1-dev libsvn-dev zlib1g-dev
  1. 编译 mesos
1
2
3
4
5
6
7
8
9
10
11
# Change working directory.
$ cd mesos

# Bootstrap (Only required if building from git repository).
$ ./bootstrap

# Configure and build.
$ mkdir build
$ cd build
$ ../configure
$ make

其中遇到的问题
对于找不到jar的处理: http://www.linuser.com/thread-2057-1-1.html

  1. 生成运行框架(例子)
1
2
3
4
5
6
7
8
9
10
11
# Run test suite.
$ make check

4. 运行mesos
$ cd build

# Start mesos master (Ensure work directory exists and has proper permissions).
$ sudo ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos

# Start mesos agent (Ensure work directory exists and has proper permissions).
$ sudo ./bin/mesos-agent.sh --master=127.0.0.1:5050 --work_dir=/var/lib/mesos

安装/运行 zookeeper

  1. 下载安装包 (其实这一步是不需要的,因为mesos的build 中集成了zookeeper,
    参见 https://mesosphere.com/blog/2013/08/01/distributed-fault-tolerant-framework-apache-mesos-html/
    其中的介绍, 可以直接进入 /build/3rdparty/zookeeper-3.4.*, 调到步骤2)
1
wget http://apache.fayea.com/zookeeper/stable/zookeeper-3.4.9.tar.gz
  1. 创建 conf/zoo.cfg
1
2
3
tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181
  1. 启动zookeeper in standalone mode
1
$ bin/zkServer.sh start
  1. 验证zookeeper 可以正常工作
1
$ bin/zkCli.sh -server 127.0.0.1:2181

运行 help , ls / 命令等

对于安装zookeeper 后,mesos需要向zookeeper注册,所以原来的mesos 启动的命令需要修改如下:

1
2
$ ./bin/mesos-master.sh --zk=zk://localhost:2181/mesos    --work_dir=/var/lib/mesos  --quorum=1
$ ./bin/mesos-agent.sh --master=zk://localhost:2181/mesos --work_dir=/var/lib/mesos

应用docker containerizers,为了使用docker 容器化,我们需要使用 –containerizers=docker,mesos
主要是 agent 启动参数修改,具体如下:

1
sudo ./bin/mesos-agent.sh --master=zk://localhost:2181/mesos  --work_dir=/var/lib/mesos --containerizers=docker,mesos

因为agent 修改了,启动时候可能报错,执行以下 sudo rm -rf /var/lib/mesos/meta/slaves/latest 就行了

安装/运行 marathon

  1. 安装有两种方式,一种是源码安装,另外一个是release tarball 安装
1
2
3
4
- option1:build  from  source
https://github.com/mesosphere/marathon
- option 2: tarball install
wget http://downloads.mesosphere.com/marathon/v1.1.1/marathon-1.1.1.tgz
  1. 启动marathon
1
$ sudo MESOS_NATIVE_JAVA_LIBRARY=/home/kennan/mesos-1.0.1/build/src/.libs/libmesos-1.0.1.so ./bin/start  --master zk://localhost:2181/mesos   --zk zk://localhost:2181/marathon

如果mesos没有注册到zookeeper 也就是 standalone mode 方式,比如 local 方式 或者 http://host:port ,命令如下:

1
$ sudo MESOS_NATIVE_JAVA_LIBRARY=/home/kennan/mesos-1.0.1/build/src/.libs/libmesos-1.0.1.so ./bin/start  --master local  --zk zk://localhost:2181/marathon

使用Unified Containerizer
为了减少对docker dameon的依赖,mesos引入了unified containerizer,通过对docker registry 的curl请求, 内部的isolators需要开启来支持对应的隔离。(取代docker的对于容器创建隔离的部分)。所以,为了使用这个功能,相应的agent运行的命令修改如下:

1
sudo ./bin/mesos-agent.sh --master=zk://localhost:2181/mesos  --work_dir=/var/lib/mesos --containerizers=mesos --image_providers=appc,docker --isolation=filesystem/linux,docker/runtime

测试:

1
2
3
4
5
6
/mesos-1.0.1/build/src$ sudo ./mesos-execute  --master=localhost:5050   --name=test   --docker_image=library/redis  --shell=false

$ sudo docker run -ti --net=host redis redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

比如,我们运行nginx,不在使用默认image里的entrypoint和cmd,而是这里自己制定:

1
sudo ./mesos-execute  --master=localhost:5050   --name=test2   --docker_image=library/nginx  --shell=true --command="nginx -g 'daemon off;'"

访问 http://127.0.0.1/ 就可以看到nginx 页面了

更多参考资料:

  1. http://mesos.apache.org/documentation/latest/operational-guide/
  2. mesos containerizers
    http://mesos.apache.org/documentation/latest/containerizer/
  3. zookeeper 介绍
    http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html
  4. Unified Containerizer
    https://github.com/apache/mesos/blob/master/docs/container-image.md

DC-OS 安装体验

Posted on 2016-09-12

本文主要尝试如何快速的创建一个 DC/OS 的开发测试集群

  1. 安装virtualbox
    下载链接 https://www.virtualbox.org/wiki/Downloads
    根据不同的平台来安装不同的格式包,比如rpm
    下载pack:
1
Oracle_VM_VirtualBox_Extension_Pack-5.0.26-108824.vbox-extpack 进行安装,点击安装
  1. 安装vagrant
    也是根据不同的平台来安装
    下载链接 https://www.vagrantup.com/downloads.html

注意 1,2步骤有坑的地方是,不同的版本组合会有问题,比如我安装的时候使用的1.8.4 最新的virtualbox 5.1.4
vagrant是不能识别virtualbox provider的,具体错误是:
No Usable default provider could be found for your system

这个是因为有滞后支持的现象的,所以在安装的时候,根据安装需求的时候需要>=的版本跨度不要太大

  1. clone dcos-agent repo
1
git clone https://github.com/dcos/dcos-vagrant
  1. 安装 Vagrant Host Manager插件
1
vagrant plugin install vagrant-hostmanager
  1. 下载DC/OS installer
1
https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh?_ga=1.153462449.848392970.1471186149

这里是1.8.2版本

  1. 配置DC/OS installer
1
2
export DCOS_GENERATE_CONFIG_PATH=dcos_generate_config.sh
export DCOS_CONFIG_PATH=etc/config-1.8.yaml
  1. 配置DC/OS的机器类型
1
cp VagrantConfig.yaml.example VagrantConfig.yaml
  1. 下载VM的基础镜像
1
vagrant box add https://downloads.dcos.io/dcos-vagrant/metadata.json

但是这里我发现另外的机器下载很慢,于是进入链接,先下载镜像 https://downloads.dcos.io/dcos-vagrant/dcos-centos-virtualbox-0.7.0.box
下载到路径 /root/dcos-centos-virtualbox-0.7.0.box

下面的格式修改如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"name": "mesosphere/dcos-centos-virtualbox",
"description": "Base image on which to install Mesosphere DC/OS on VirtualBox",
"versions": [
{
"version": "0.7.0",
"status": "active",
"description_markdown": "Enable IPv4 forwarding",
"providers": [
{
"name": "virtualbox",
"url": "/root/dcos-centos-virtualbox-0.7.0.box",
"checksum_type": "sha1",
"checksum": "fc9d5a6a99ecb70aee67d4b68b8b6a48563e57cb"
}
]
}
]
}

执行:

1
vagrant box add metadata.json
  1. 可选的配置: Configure 认证,(默认安装是使用OAuth,支持Google,Github, or Microsoft)
    这个会在第一次登陆的时候提示认证,当然你也可以配置不同认证,参考 https://dcos.io/docs/1.7/administration/id-and-access-mgt/managing-authentication/#authentication-opt-out

  2. 部署集群

比如 vagrant up m1 a1 p1 boot

上面的对应的是:
m1 master节点
a1 agent private节点
p1 agent public 节点
boot boot节点

更多参考: https://github.com/dcos/dcos-vagrant/blob/master/VagrantConfig.yaml.example

  1. 扩展集群
    增加 agent node
1
2
vagrant up a2
vagrant up p2

减少节点

1
2
vagrant destroy -f a1
vagrant destroy -f p1

删除整个集群

1
vagrant destroy -f
  1. 简单的测试集群工作,

创建一个nginx 的 job

Selenium python UI Test

Posted on 2016-08-14

python中如何容易的使用selenium来进行APP的测试,可以从如下考虑:

  1. Python中有个方便的库进行快速的集成和测试,py.test,pytest支持一系列的插件,其中就包含了 对于selenium的支持,使用方式如下:
1
2
3
4
def test_example(selenium):
    selenium.get('http://www.example.com')

py.test --driver Firefox
  1. Selenium广泛使用的远程测试是使用Remote Driver,具体如下:
1
    py.test --driver Remote --host selenium.hostname --port 5555 --capability browserName firefox

一般测试使用例子如下(远程测试):

1
py.test --base-url http://10.221.83.203:8081 --driver Remote --host 10.15.240.120 --capability browserName firefox

3.如果采用了marker方式,可以指定运行某类测试:

1
py.test --base-url http://10.221.83.203:8081 --driver Remote --host 10.15.240.120 --capability browserName firefox  -m negative

这里就只会运行 pytest.mark.negative 类型的测试

python中如何容易的使用selenium来进行APP的测试,可以从如下考虑:

  1. Python中有个方便的库进行快速的集成和测试,py.test,pytest支持一系列的插件,其中就包含了 对于selenium的支持,使用方式如下:
1
2
3
4
def test_example(selenium):
    selenium.get('http://www.example.com')

py.test --driver Firefox
  1. Selenium广泛使用的远程测试是使用Remote Driver,具体如下:
1
    py.test --driver Remote --host selenium.hostname --port 5555 --capability browserName firefox

一般测试使用例子如下(远程测试):

1
py.test --base-url http://10.221.83.203:8081 --driver Remote --host 10.15.240.120 --capability browserName firefox

3.如果采用了marker方式,可以指定运行某类测试:

1
py.test --base-url http://10.221.83.203:8081 --driver Remote --host 10.15.240.120 --capability browserName firefox  -m negative

这里就只会运行 pytest.mark.negative 类型的测试

Selenium Headless Automated Testing

Posted on 2016-08-14

关于ubuntu的介绍如下:

http://www.installationpage.com/selenium/how-to-run-selenium-headless-firefox-in-ubuntu/

  1. 如果使用的是yum源系统,安装如下的包:
1
yum install xorg-x11-server-Xvfb.x86_64
  1. 然后执行如下,启动xvfb服务:
1
Xvfb :10 -ac
  1. 在系统中以headless方式启动centos
1
2
export DISPLAY=:10
firefox
  1. 执行selenium测试:
    python code 如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0

# Create a new instance of the Firefox driver
driver = webdriver.Firefox()

# go to the baidu home page
driver.get("http://www.baidu.com")

# the page is ajaxy so the title is originally this:
print driver.title

# find the element that's name attribute is q (the baidu search box)
inputElement = driver.find_element_by_name("wd")

# type in the search
inputElement.send_keys("cheese!")

# submit the form (although baidu automatically searches now without submitting)
inputElement.submit()

try:
# we have to wait for the page to refresh, the last thing that seems to be updated is the title
WebDriverWait(driver, 10).until(EC.title_contains("cheese!"))

# You should see "cheese! - baidu Search"
print driver.title

finally:
driver.quit()

运行如下:
百度一下,你就知道
cheese!_百度搜索

UTC的Datetime和ISO处理

Posted on 2016-08-14

问题1, Django中集成了相应的函数来处理这种转化如下

参考 http://www.dannysite.com/blog/122/

1
2
3
4
5
>>> from django.utils.timezone import utc
>>> from django.utils.timezone import localtime
>>> now = datetime.datetime.utcnow().replace(tzinfo=utc)
>>> localtime(now)
datetime.datetime(2013, 12, 5, 0, 3, 13, 122000, tzinfo= CST+8:00:00 STD>)

问题2, 还有一种情况,对应的是ISO8601 字符串,要转化成对应的datetime对象
一种是用iso8601包,但是这种情况下需要单独通过pip安装iso8601,
参考:https://julien.danjou.info/blog/2015/python-and-timezones

1
2
>>> import iso8601
>>> iso8601.parse_date(utcnow().isoformat())

还有一种方式是用传统的python的dateutil包:
参考:http://stackoverflow.com/questions/969285/how-do-i-translate-a-iso-8601-datetime-string-into-a-python-datetime-object

1
2
import dateutil.parser
yourdate = dateutil.parser.parse(datestring)

如果本身不是字符串,而是对应的datetime对象,可以直接使用 https://docs.djangoproject.com/en/1.9/topics/i18n/timezones/
localtime来处理

问题3, 如果需要特殊的处理,可以写custom的 template filter,具体如下:
https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/

这种方式可以处理普通的template中无法处理的情况

USB数据恢复的几种方法

Posted on 2016-07-06

这几天帮别人解决数据恢复的事情,USB盘文件无法识别,全都是乱码,无法识别目录,发现有一篇文章写得很好【1】
当然还是靠那篇文章中强大的一款软件搞定,觉得特别有帮助。

参考资料:

  1. http://blog.sciencenet.cn/blog-781100-974887.html

youtube技术视频的下载方法

Posted on 2016-07-06

因为youtube有些技术视频非常好,有时候很需要下载到自己的手机上随时看,那么某乎上有些介绍如【1】
网上也有些推荐如:

1) http://www.clipconverter.cc/
2) http://en.savefrom.net/

参考资料:

  1. https://www.zhihu.com/question/22247271

exFAT格式的移动硬盘在Windows 7下无法写

Posted on 2016-07-02

前段时间使用的Mac格式化的exFAT格式的移动硬盘,发现无法创建文件和删除文件,原来需要检查修复一下就可以了,

具体如下:
管理员权限运行cmd,执行下面的命令即可:

chkdsk 盘符 /F

参考:

http://blog.chenxu.me/post/detail?id=1fa055ec-b46a-4437-a92f-a5d1596ad654

编译内核及其Kernel Perf工具记录

Posted on 2016-06-20

最近在尝试编译安装最新的4.6.1内核,遇到一些问题,记录如下:

  1. 编译内核的错误: Alert: /dev/disk/by-uuid/** does not exist

    这个主要原因是相应的driver没有编译进内核导致。主要是相应的顺序错误, make install 是最后一步,不能在模块编译安装前运行。

1
2
3
4
5
6
7
make

make modules

make modules_install

make install
  1. 对应的perf tool对应的ubuntu安装包没有相应的内核的版本,需要自己编译
    步骤;
1
2
3
4
5
cd /usr/src/linux-4.6.1
cd tools/perf

make
make install

参考资料:

http://askubuntu.com/questions/50145/how-to-install-perf-monitoring-tool
http://stackoverflow.com/questions/34473447/custom-linux-kernel-build-failure-in-vmware-workstation
https://lkml.org/lkml/2016/5/3/3

Linux, Windows, Mac之间的文件共享和迁移

Posted on 2016-06-20

最近在打算把原来Mac上面的一些资料迁移到我的Windows机器上,碰到了几个问题纪录一下:

  1. exfat, ntfs的问题

最初我打算是用我的移动硬盘作为载体,把Mac上的资料Copy到Windows上,问题来了,原来的移动硬盘格式是NTFS的,Mac下面,
这种格式默认是只支持读,不可写,当然可以借助第三方工具做这个,但是会有相应的格式损坏的风险,所以打算从原生角度开展,
exfat是一种windows visa开始支持的,但是我的Windows机器是XP,exfat的支持微软官方提供了相应的驱动。

  1. windows Mac 文件之间传输的网络方式

从windows XP 访问Mac, 根据我的实验,即使在Mac上设置了共享和读写权限,以及保证和XP是同一个workgroup,还是无法访问,
防火墙里也有对应的File sharing 允许规则,参看这个帖子:
https://social.technet.microsoft.com/Forums/en-US/daea5819-f6fa-4273-9203-51051c12f4d5/-winxp-osx-?forum=windowsxpzhchs

网上微软论坛也没给出解决,估计问题比较难定位
类似的参考link,具体没有时间细细研究:

http://forums.macrumors.com/threads/windows-8-1-cant-access-share-on-mac-with-valid-credentials.1807636/
http://forums.macrumors.com/threads/windows-7-can-see-but-not-access-os-x-share.1638263/

从Mac访问windows XP比较简单,按照windows的共享目录的设置,然后打开Finder,Command+K打开,输入smb://,就可以访问了

  1. Ubuntu Linux exfat挂载
    Ubuntu默认的是没有安装对应的exfat驱动,需要运行下面的命令安装驱动
1
sudo apt-get install exfat-fuse exfat-utils

这里为什么提到Ubuntu的exfat,因为最后我采用的方式,是安装了一个Ubuntu
16.04的虚拟机,然后安装了对应的exfat驱动支持,通过usb挂载方式,这样虚拟机就可以访问了移动硬盘了。
接下来就需要通过虚拟机的共享目录方式(virtualbox 需要安装对应的增强功能,才能挂载对应的vboxsf文件类型),
实现虚拟机和windows XP主机的文件访问,从而可以将移动硬盘的资料拷贝到windows XP的目录中。

  1. 其他的云方案,暂时没有考虑,因为自己的需求比较简单,杀鸡不用牛刀。

参考资料:

  1. http://techmeasy.blogspot.com/2012/07/add-support-for-exFAT-in-Windows-XP.html
  2. http://www.liqi.name/windows-xp-7-mac-os-x-network-share/
  3. http://askubuntu.com/questions/451364/how-to-enable-exfat-in-ubuntu-14-04
1…567…26

Kai Qiang Wu

This is a place for thinking and writing

253 posts
32 tags
GitHub
© 2020 Kai Qiang Wu
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4
Visitor Total Visit