마라톤(marathon)을 로컬 모드/확장형으로 설치/실행하는 예이다.


 

 마라톤 상태를 저장하려면 주키퍼가 필요하다. 주키퍼를 설치하고 주키퍼를 실행한다.

 

$ wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz


$ tar xf zookeeper-3.4.8.tar.gz 


$ cd ~/zookeeper-3.4.8/


$ mv conf/zoo_sample.cfg conf/zoo.cfg

 

$ vi conf/zoo.cfg

# The number of milliseconds of each tick

tickTime=2000

# The number of ticks that the initial

# synchronization phase can take

initLimit=10

# The number of ticks that can pass between

# sending a request and getting an acknowledgement

syncLimit=5

# the directory where the snapshot is stored.

# do not use /tmp for storage, /tmp here is just

# example sakes.

dataDir=/var/zookeeper

# the port at which the clients will connect

clientPort=2181

# the maximum number





$ sudo bin/zkServer.sh start

Starting zookeeper ... STARTED



마라톤 바이너리 파일(libmesos.so)을 lib 공통 폴더에 복사한다. 


$ sudo cp ~/mesos/build/src/.libs/libmesos.so /usr/lib

 

이렇게 하지 않으면 마라톤 실행이 되지 않는다. 


Failed to load native Mesos library from

java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library:

at java.lang.Runtime.load0(Runtime.java:806)

at java.lang.System.load(System.java:1086)

at org.apache.mesos.MesosNativeLibrary.load(MesosNativeLibrary.java:159)

at org.apache.mesos.MesosNativeLibrary.load(MesosNativeLibrary.java:188)

at org.apache.mesos.MesosSchedulerDriver.<clinit>(MesosSchedulerDriver.java:61)

at mesosphere.marathon.MarathonSchedulerDriver$.newDriver(MarathonSchedulerDriver.scala:81)

at mesosphere.marathon.MesosSchedulerDriverFactory.createDriver(SchedulerDriverFactory.scala:28)

at mesosphere.marathon.DebugModule$MetricsBehavior$$anonfun$invoke$1.apply(DebugConf.scala:62)

at mesosphere.marathon.metrics.Metrics.timed(Metrics.scala:27)

at mesosphere.marathon.DebugModule$MetricsBehavior.invoke(DebugConf.scala:61)

at mesosphere.marathon.MarathonSchedulerService.liftedTree1$1(MarathonSchedulerService.scala:282)

at mesosphere.marathon.MarathonSchedulerService.onElected(MarathonSchedulerService.scala:267)

at mesosphere.marathon.DebugModule$MetricsBehavior$$anonfun$invoke$1.apply(DebugConf.scala:62)

at mesosphere.marathon.metrics.Metrics.timed(Metrics.scala:27)

at mesosphere.marathon.DebugModule$MetricsBehavior.invoke(DebugConf.scala:61)

at mesosphere.marathon.core.leadership.CandidateImpl$4.onGroupChange(CandidateImpl.java:177)

at mesosphere.marathon.core.leadership.CandidateImpl.offerLeadership(CandidateImpl.java:212)

at mesosphere.marathon.MarathonSchedulerService$$anonfun$mesosphere$marathon$MarathonSchedulerService$$offerLeadership$1$$anonfun$apply$2.apply(MarathonSchedulerService.scala:370)

at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)

at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)

at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)

at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)

at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)

at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)

at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

 




마라톤을 설치한다. 


$ wget http://downloads.mesosphere.com/marathon/v1.1.1/marathon-1.1.1.tgz 

$ tar xf marathon-1.1.1.tgz 

$ cd ~/marathon-1.1.1

$ ./bin/start --master local --zk zk://localhost:2181/marathon 

 [2017-04-26 23:31:17,081] INFO All services up and running. (mesosphere.marathon.Main$:main)






데모로 아래 링크를 참조해서 Hello Marathon를 하나 생성한다.


https://mesosphere.github.io/marathon/docs/application-basics.html


하나의 application을 만들 수 있지만, scale application을 할 수 없다. 로컬 모드라서...






로컬 모드가 아니라 이미 설치된 메소스와 연동한다. 아래와 같이 zookeeper 연동하면 잘 작동한다. 




./bin/start --master zk://zk1:2181,zk2:2181/mesos --zk zk://zk1:2181,zk2:2181/marathon



scala application을 눌러 cpu50개를 사용하는 job을 생성한다. 







그리고, 메소스 내부는 아래와 같이 애플리케이션을 다양하게 사용됨을 확인할 수 있다.






정상적으로 동작하는지 테스트해본다.




curl -X POST http://마라톤_장비:8080/v2/apps -d @basic-3.json -H "Content-type: application/json"


{

  "id": "basic-3",

  "cmd": "python3 -m http.server 8080",

  "cpus": 0.5,

  "mem": 32.0,

  "container": {

    "type": "DOCKER",

    "docker": {

      "image": "python:3",

      "network": "BRIDGE",

      "portMappings": [

        { "containerPort": 8080, "hostPort": 0 }

      ]

    }

  }

}



http-json으로 app 생성을 요청해 본다.


$ curl -X POST http://마라톤-ip:8080/v2/apps -d @basic-4.json -H "Content-type: application/json"


{"id":"/basic-4","cmd":"python3 -m http.server 8080","args":null,"user":null,"env":{},"instances":5,"cpus":0.5,"mem":32,"disk":0,"executor":"","constraints":[],"uris":[],"fetch":[],"storeUrls":[],"ports":[0],"portDefinitions":[{"port":0,"protocol":"tcp","labels":{}}],"requirePorts":false,"backoffSeconds":1,"backoffFactor":1.15,"maxLaunchDelaySeconds":3600,"container":{"type":"DOCKER","volumes":[],"docker":{"image":"python:3","network":"BRIDGE","portMappings":[{"containerPort":8080,"hostPort":0,"servicePort":0,"protocol":"tcp","labels":{}}],"privileged":false,"parameters":[],"forcePullImage":false}},"healthChecks":[],"readinessChecks":[],"dependencies":[],"upgradeStrategy":{"minimumHealthCapacity":1,"maximumOverCapacity":1},"labels":{},"acceptedResourceRoles":null,"ipAddress":null,"version":"2017-04-28T13:59:01.853Z","residency":null,"tasksStaged":0,"tasksRunning":0,"tasksHealthy":0,"tasksUnhealthy":0,"deployments":[{"id":"c6c8a6db-5e25-49ed-aaae-9d902dcf2744"}],










참고 문서 : https://mesosphere.github.io/marathon/docs/application-basics.html

Posted by '김용환'
,