夢とガラクタの集積場

落ちこぼれ三流エンジニアである管理人の夢想=『夢』と、潰えた夢=『ガラクタ』の集積場です。

Apache Mesosをrpmでインストールして動作を確認する(その2

こんにちは。

Mesosの起動ファイルの構成などはわかったので、実際に起動させて動作を確認してみます。
とりあえず、Masterのアドレスを起動時のオプションで指定するのではなく環境ファイルに書けるようになったのは非常に大きいですね。

尚、「mesos-master-env.sh.template」によるとコマンドラインで指定するオプションは
すべて環境変数でも設定可能になったとのこと。

1.mesos-masterの設定

mesos-masterはspark1でのみ起動するため、spark1の
「/usr/local/var/mesos/deploy/mesos-master-env.sh.template」のみ「/usr/local/var/mesos/deploy/mesos-master-env.sh」にコピーし、
以下の設定を行います。

■/usr/local/var/mesos/deploy/mesos-master-env.sh

export LD_LIBRARY_PATH=/usr/lib/jvm/java-1.7.0-openjdk.x86_64/jre/lib/amd64/server

# Some options you're likely to want to set:
export MESOS_log_dir=/var/log/mesos

その上で、コマンドラインからdaemonとして起動を行います。

# /usr/local/sbin/mesos-daemon.sh mesos-master

そうするとコマンドラインには何も表示されませんが、mesos-masterプロセスが起動します。
→ 5050ポートで待ち受けが開始していることで確認できます。
http://spark1:5050/にアクセスを行うと、以下の画面が表示されます。

尚、mesos-masterで指定可能なオプションは以下の通り。
「mesos-master-env.sh」で定義する場合には頭に「MESOS_」をつけた値を環境変数として定義しておけばOKのようです。

Usage: mesos-master [...]

Supported options:
  --allocation_interval=VALUE     Amount of time to wait between performing
                                   (batch) allocations (e.g., 500ms, 1sec, etc) (default: 1secs)
  --cluster=VALUE                 Human readable name for the cluster,
                                  displayed in the webui
  --framework_sorter=VALUE        Policy to use for allocating resources
                                  between a given user's frameworks. Options
                                  are the same as for user_allocator (default: drf)
  --[no-]help                     Prints this help message (default: false)
  --ip=VALUE                      IP address to listen on
  --log_dir=VALUE                 Location to put log files (no default, nothing
                                  is written to disk unless specified;
                                  does not affect logging to stderr)
  --logbufsecs=VALUE              How many seconds to buffer log messages for (default: 0)
  --port=VALUE                    Port to listen on (default: 5050)
  --[no-]quiet                    Disable logging to stderr (default: false)
  --roles=VALUE                   A comma seperated list of the allocation
                                  roles that frameworks in this cluster may
                                  belong to.
  --[no-]root_submissions         Can root submit frameworks? (default: true)
  --slaves=VALUE                  Initial slaves that should be
                                  considered part of this cluster
                                  (or if using ZooKeeper a URL) (default: *)
  --user_sorter=VALUE             Policy to use for allocating resources
                                  between users. May be one of:
                                    dominant_resource_fairness (drf) (default: drf)
  --webui_dir=VALUE               Location of the webui files/assets (default: /usr/local/share/mesos/webui)
  --weights=VALUE                 A comma seperated list of role/weight pairs
                                  of the form 'role=weight,role=weight'. Weights
                                  are used to indicate forms of priority.
  --whitelist=VALUE               Path to a file with a list of slaves
                                  (one per line) to advertise offers for;
                                  should be of the form: file://path/to/file (default: *)
  --zk=VALUE                      ZooKeeper URL (used for leader election amongst masters)
                                  May be one of:
                                    zk://host1:port1,host2:port2,.../path
                                    zk://username:password@host1:port1,host2:port2,.../path
                                    file://path/to/file (where file contains one of the above) (default: )

2.mesos-slaveの設定

次はmesos-slaveの設定を行います。
mesos-slaveは「spark1」「spark2」「spark3」で起動するため、3サーバの
「/usr/local/var/mesos/deploy/mesos-slave-env.sh.template」を「/usr/local/var/mesos/deploy/mesos-slave-env.sh」にコピーし、
以下の設定を行います。

■/usr/local/var/mesos/deploy/mesos-slave-env.sh

export LD_LIBRARY_PATH=/usr/lib/jvm/java-1.7.0-openjdk.x86_64/jre/lib/amd64/server

# The mesos master URL to contact. Should be host:port for
# non-ZooKeeper based masters, otherwise a zk:// or file:// URL.
export MESOS_master=spark1:5050

# Other options you're likely to want to set:
export MESOS_log_dir=/var/log/mesos
export MESOS_work_dir=/var/run/mesos
# export MESOS_isolation=cgroups

その上で、コマンドラインからdaemonとして起動を行います。

# /usr/local/sbin/mesos-daemon.sh mesos-slave

Masterと同じようにコマンドラインには何も表示されませんが、mesos-slaveプロセスが起動します。
→ 5051ポートで待ち受けが開始していることで確認できます。
また、masterのWebUIを確認すると以下のようにSlaveプロセスが起動していることが確認できます。

尚、mesos-slaveで指定可能なオプションは以下の通り。
デフォルトではmesosはprocessレベルでのリソース分離となっており、cgroupsは使用していないようです。
実際に使用する際にはcgroups自体をインストールした上で有効化する必要がありそう。
・・・ただ、とりあえずはお預けです。

Usage: mesos-slave [...]

Supported options:
  --attributes=VALUE                         Attributes of machine
  --[no-]cgroups_enable_cfs                  Cgroups feature flag to enable hard limits on CPU resources
                                             via the CFS bandwidth limiting subfeature.
                                             (default: false)
  --cgroups_hierarchy=VALUE                  The path to the cgroups hierarchy root
                                             (default: /cgroup)
  --cgroups_root=VALUE                       Name of the root cgroup
                                             (default: mesos)
  --cgroups_subsystems=VALUE                 List of subsystems to enable (e.g., 'cpu,freezer')
                                             (default: cpu,memory,freezer)
  --[no-]checkpoint                          Whether to checkpoint slave and frameworks information
                                             to disk. This enables a restarted slave to recover
                                             status updates and reconnect with (--recover=reconnect) or
                                             kill (--recover=kill) old executors (default: false)
  --default_role=VALUE                       Any resources in the --resources flag that
                                             omit a role, as well as any resources that
                                             are not present in --resources but that are
                                             automatically detected, will be assigned to
                                             this role. (default: *)
  --disk_watch_interval=VALUE                Periodic time interval (e.g., 10secs, 2mins, etc)
                                             to check the disk usage (default: 1mins)
  --executor_registration_timeout=VALUE      Amount of time to wait for an executor
                                             to register with the slave before considering it hung and
                                             shutting it down (e.g., 60secs, 3mins, etc) (default: 1mins)
  --executor_shutdown_grace_period=VALUE     Amount of time to wait for an executor
                                             to shut down (e.g., 60secs, 3mins, etc) (default: 5secs)
  --frameworks_home=VALUE                    Directory prepended to relative executor URIs (default: )
  --gc_delay=VALUE                           Maximum amount of time to wait before cleaning up
                                             executor directories (e.g., 3days, 2weeks, etc).
                                             Note that this delay may be shorter depending on
                                             the available disk usage. (default: 1weeks)
  --hadoop_home=VALUE                        Where to find Hadoop installed (for
                                             fetching framework executors from HDFS)
                                             (no default, look for HADOOP_HOME in
                                             environment or find hadoop on PATH) (default: )
  --[no-]help                                Prints this help message (default: false)
  --ip=VALUE                                 IP address to listen on
  --isolation=VALUE                          Isolation mechanism, may be one of: process, cgroups (default: process)
  --launcher_dir=VALUE                       Location of Mesos binaries (default: /usr/local/libexec/mesos)
  --log_dir=VALUE                            Location to put log files (no default, nothing
                                             is written to disk unless specified;
                                             does not affect logging to stderr)
  --logbufsecs=VALUE                         How many seconds to buffer log messages for (default: 0)
  --master=VALUE                             May be one of:
                                               zk://host1:port1,host2:port2,.../path
                                               zk://username:password@host1:port1,host2:port2,.../path
                                               file://path/to/file (where file contains one of the above)
  --port=VALUE                               Port to listen on (default: 5051)
  --[no-]quiet                               Disable logging to stderr (default: false)
  --recover=VALUE                            Whether to recover status updates and reconnect with old executors.
                                             Valid values for 'recover' are
                                             reconnect: Reconnect with any old live executors.
                                             cleanup  : Kill any old live executors and exit.
                                                        Use this option when doing an incompatible slave
                                                        or executor upgrade!).
                                             NOTE: If checkpointed slave doesn't exist, no recovery is performed
                                                   and the slave registers with the master as a new slave. (default: reconnect)
  --recovery_timeout=VALUE                   Amount of time alloted for the slave to recover. If the slave takes
                                             longer than recovery_timeout to recover, any executors that are
                                             waiting to reconnect to the slave will self-terminate.
                                             NOTE: This flag is only applicable when checkpoint is enabled.
                                             (default: 15mins)
  --resource_monitoring_interval=VALUE       Periodic time interval for monitoring executor
                                             resource usage (e.g., 10secs, 1min, etc) (default: 1secs)
  --resources=VALUE                          Total consumable resources per slave, in
                                             the form 'name(role):value;name(role):value...'.
  --[no-]strict                              If strict=true, any and all recovery errors are considered fatal.
                                             If strict=false, any expected errors (e.g., slave cannot recover
                                             information about an executor, because the slave died right before
                                             the executor registered.) during recovery are ignored and as much
                                             state as possible is recovered.
                                             (default: true)
  --[no-]switch_user                         Whether to run tasks as the user who
                                             submitted them rather than the user running
                                             the slave (requires setuid permission) (default: true)
  --work_dir=VALUE                           Where to place framework work directories
                                             (default: /tmp/mesos)


・・・と、こういう形でmesos-master、mesos-slaveの起動を行うまでは行きました。
次はZooKeeperを用いたMasterの冗長化か、後は実際にSparkのジョブを動かす形になるので
Hadoop自体のインストールが必要になります。

なので、ここで区切ります。
次回はインストールした、という前提で進めますね。