LoginSignup
5
4

More than 5 years have passed since last update.

StarClusterの環境構築 作業メモ

Last updated at Posted at 2015-12-14

イントロダクション

このblogの記事によくまとまっています。
StarClusterはMITが開発したツールで、お手軽にAWS EC2上にクラスタマシンを作ってくれます。EC2でクラスタを形成するの案外面倒なのですが、これを使えば作業時間数分でクラスタマシンを立ち上げることができます。

AWS下ごしらえ

  • AWSのアカウントを取得しておく

StarCluster 環境設定

StarClusterのインストール

conda上の仮想環境に構築する場合

conda create -n sc python=2.7 pip
source activate sc
pip install starcluster

condaにもパッケージがあるが、何故かt2.microが使えない様子。

 configファイルの作成

  • starclusterのコンフィグファイルを作成する
  • starcluster helpと叩いて、2を選択すると~/.starcluster/configが自動作成される。
starcluster help
#StarCluster - (http://star.mit.edu/cluster) (v. 0.95.6)
#Software Tools for Academics and Researchers (STAR)
# 中略
#!!! ERROR - config file /home/ubuntu/.starcluster/config does not exist
#
#Options:
#--------
#[1] Show the StarCluster config template
#[2] Write config template to /home/ubuntu/.starcluster/config
#[q] Quit
Please enter your selection: 2

 configファイルの編集

データの転送速度を気にして東京リージョンに設定していますが、それ以外にもアメリカよりも東京リージョンの方がノード間の通信速度が速いことが多いとの噂があります。

starcluster listpublic
#>>> Listing all public StarCluster images...
#中略
#64bit Images:
#--------------
#[0] ami-3f29403e ap-northeast-1 starcluster-base-ubuntu-13.04-x86_64-hvm (HVM-EBS)
#[1] ami-fdd1bffc ap-northeast-1 starcluster-base-ubuntu-13.04-x86_64 (EBS)
#[2] ami-6a04876b ap-northeast-1 starcluster-base-ubuntu-12.04-x86_64 (EBS)
#[3] ami-d22394d3 ap-northeast-1 starcluster-base-ubuntu-11.10-x86_64 (EBS)
#
#total images: 7

t2.microを使いたいため、hvm版を選択する。
spotinstanceでt2.microが使えないため、お試しはEBS版でやる

  • 77行目: CLUSTER_SIZE = 1
  • 93行目: NODE_IMAGE_ID = ami-fdd1bffc
  • 96行目: NODE_INSTANCE_TYPE =t1.micro
  • 111行目: MASTER_INSTANCE_TYPE = t2.micro
  • 114行目: MASTER_IMAGE_ID = ami-3f29403e

77行目でクラスタサイズを指定できる。
その他の設定は、なくてもとりあえず動く。
132行目をuncommentするとスポットインスタンスで動かす様子。
pluginでhadoopも使用可能です。リンク

keyの生成

starcluster createkey mykey -o ~/.ssh/mykey.rsa
#>>> Successfully created keypair: mykey
#>>> fingerprint: <fingerprint>
#>>> keypair written to /home/ubuntu/.ssh/mykey.rsa

alias

starclusterってのが長いので、aliasを追加しておく
echo 'alias sc="starcluster"' >> ~/.bashrc

StarClusterの簡易操作

$ source activate sc
$ sc start mycluster
#> 3.5 minくらいで立ち上がる

# クラスタマシンへのノード追加
sc an mycluster
#> 1個追加 an or addnode
sc an -n 3 mycluster
#> 3個追加
sc an -I t1.micro -b 0.0031 -n 3 mycluster 
#> 最大0.31セントでt1.microのスポットインスタンスを3つ入札

# クラスタマシンのノード削除
sc rn mycluster
#> 1個削除。複数ある場合は最後のノード。 rn or removenode

# クラスタマシンへのssh
sc sm mycluster
#> sm or sshmaster

# クラスタマシンへのファイル送受
sc put /path/to/file/or/dir /path/on/remote/server
sc get /path/on/remote/server /path/to/file/or/dir

# StarClusterの停止
sc stop mycluster
sc stop --terminate-unstoppable mycluster
#> スポットインスタンスは停止できない。オプションをつけるとスポットを削除しながら停止可能

# StarClusterの再起動
sc start -x mycluster
#> status stoppedのマシンを動かすには-xオプションをつける

# StarClusterの削除
sc terminate mycluster

# スポットインスタンスの値段確認
sc shi t1.micro
#> shi or spothistory

# クラスタの確認
sc lc
#> lc or listcluster

未記載コマンド一覧

  • restart, reboot: クラスタを再起動する
  • sshnode, sn: SSH to a cluster node
  • loadbalance, bal: Start the SGE Load Balancer.
  • sshinstance, si: SSH to an EC2 instance
  • listinstances, lsi: List all running EC2 instances
  • listspots, ls: List all EC2 spot instance requests
  • listimages, li: List all registered EC2 images (AMIs)
  • listkeypairs, lk: List all EC2 keypairs
  • removekey, rk: Remove a keypair from Amazon EC2
  • s3image, simg, createimage: Create a new instance-store (S3) AMI from a running EC2 instance
  • ebsimage, eimg: Create a new EBS image (AMI) from a running EC2 instance
  • showimage, shimg: Show all AMI parts and manifest files on S3 for an instance-store AMI
  • downloadimage, di: Download the manifest.xml and all AMI parts for an instance-store AMI
  • removeimage, ri: Deregister an EC2 image (AMI)
  • createvolume, cv: Create a new EBS volume for use with StarCluster
  • listvolumes, lv: List all EBS volumes
  • resizevolume, res: Resize an existing EBS volume
  • removevolume, rv: Delete one or more EBS volumes
  • showconsole, sc: Show console output for an EC2 instance
  • listregions, lr: List all EC2 regions
  • listzones, lz: List all EC2 availability zones in the current region (default: us-east-1)
  • listbuckets, lb: List all S3 buckets
  • showbucket, sb: Show all files in an S3 bucket
  • runplugin, rp: Run a StarCluster plugin on a running cluster
  • shell, sh: Load an interactive IPython shell configured for starcluster development
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4