{"id":2735,"date":"2021-08-10T22:18:58","date_gmt":"2021-08-10T13:18:58","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2735"},"modified":"2021-09-22T10:03:49","modified_gmt":"2021-09-22T01:03:49","slug":"nomad-%ea%b0%80%ec%a7%80%ea%b3%a0-%eb%86%80%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2735","title":{"rendered":"nomad \uac00\uc9c0\uace0 \ub180\uae30 (\uc0bd\uc9c8\uae30)"},"content":{"rendered":"<h1>nomad \uac00\uc9c0\uace0 \ub180\uae30 (\uc0bd\uc9c8\uae30)<\/h1>\n<p><a href=\"https:\/\/tech.kakao.com\/2017\/01\/25\/nomad\/\">\ucc38\uc870<\/a><br \/>\n<a href=\"https:\/\/great-stone.github.io\/hashicorp\/nomad\/Nomad-on-Windows\/\">\ucc38\uc870<\/a><br \/>\n<a href=\"https:\/\/learn.hashicorp.com\/tutorials\/nomad\/get-started-install\">\ucc38\uc870<\/a><\/p>\n<h2>\ubaa9\ud45c<\/h2>\n<p>\ud14c\uc2a4\ud2b8\uc6a9 nomad \uc11c\ubc84\ub97c \uc0dd\uc131\ud558\uace0, \uc5ec\ub7ec \uae30\ub2a5\ub4e4\uc744 \ud655\uc778\ud574 \ubd05\ub2c8\ub2e4.<\/p>\n<h2>nomad \uc124\uce58<\/h2>\n<p><code>AWS AMI<\/code> \uc778\uc2a4\ud134\uc2a4\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.<br \/>\n\uba54\ubaa8\ub9ac\ub294 1G \ub85c \ud569\ub2c8\ub2e4.<\/p>\n<p>\ub0b4 IP \ub85c\ubd80\ud130\uc758 \ubaa8\ub4e0 \uc811\uc18d\uc744 \ud5c8\uc6a9\ud558\ub3c4\ub85d \ubcf4\uc548\uadf8\ub8f9\uc744 \uc124\uc815\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<p>\uc544\ub798 \uba85\ub839\uc73c\ub85c nomad \ub97c \uc124\uce58\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">wget https:\/\/releases.hashicorp.com\/nomad\/1.1.3\/nomad_1.1.3_linux_amd64.zip\nunzip nomad_1.1.3_linux_amd64.zip\nsudo mv nomad \/usr\/bin\/\n\nnomad version<\/code><\/pre>\n<p>\ud14c\uc2a4\ud2b8\uc6a9\uc774\ubbc0\ub85c, \ud55c \uc11c\ubc84\uc5d0 Server\/Client \ub97c \ud55c\ubc88\uc5d0 \ud65c\uc131\ud654 \ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">mkdir -p nomad\/config\n\nvi nomad\/config\/nomad.hcl\n-----------------------------------------\ndatacenter = &quot;dc1&quot;\ndata_dir   = &quot;\/home\/ec2-user\/nomad\/data&quot;\nbind_addr  = &quot;0.0.0.0&quot;\n\nserver {\n  enabled          = true\n  bootstrap_expect = 1\n}\n\nclient {\n  enabled           = true\n}\n-----------------------------------------<\/code><\/pre>\n<p>nomad Server\/Client \ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<p>nomad client \ub294 root \uad8c\ud55c\uc774 \ud544\uc694\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">sudo nomad agent -config=nomad\/config\/nomad.hcl\n==&gt; WARNING: Bootstrap mode enabled! Potentially unsafe operation.\n==&gt; Loaded configuration from \/home\/ec2-user\/nomad\/conf\/nomad.hcl\n==&gt; Starting Nomad agent...\n==&gt; Nomad agent configuration:\n\n       Advertise Addrs: HTTP: 172.31.9.202:4646; RPC: 172.31.9.202:4647; Serf: 172.31.9.202:4648\n            Bind Addrs: HTTP: 0.0.0.0:4646; RPC: 0.0.0.0:4647; Serf: 0.0.0.0:4648\n                Client: true\n             Log Level: INFO\n                Region: global (DC: dc1)\n                Server: true\n               Version: 1.1.3\n\n==&gt; Nomad agent started! Log data will stream in below:\n\n    \/\/ skip logs\n    2021-08-10T13:21:08.439Z [INFO]  client: node registration complete<\/code><\/pre>\n<p>http:\/\/&lt;nomad \uc11c\ubc84 \ud37c\ube14\ub9ad \uc544\uc774\ud53c&gt;:4646\/ \uc5d0 \ube0c\ub77c\uc6b0\uc800\ub85c \uc811\uc18d\ud574 \ubcf4\uba74 \uc6f9UI \ub97c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-10-01.png\"><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-10-01.png\" alt=\"\" \/><\/a><\/p>\n<h2>Job \uc0dd\uc131<\/h2>\n<p>\uc6f9UI \uc5d0\uc11c Job \uc744 \uc0dd\uc131\ud558\ub294 \uac83\ub3c4 \uac00\ub2a5\ud558\uc9c0\ub9cc, CLI \uc5d0\uc11c \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<p>JDK 11 \uc744 \uc124\uce58\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">sudo yum install java-11-amazon-corretto-headless -y\njava -version<\/code><\/pre>\n<p>JDK \uc124\uce58 \ud6c4 JDK \ub97c \uc778\uc2dd\uc2dc\ud0a4\uae30 \uc704\ud574,<br \/>\nnomad server \ub97c \uc7ac\uc2dc\uc791\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">vi hello.nomad<\/code><\/pre>\n<pre><code class=\"language-nomad\">job &quot;hello&quot; {\n  datacenters = [&quot;dc1&quot;]\n  type = &quot;service&quot;\n\n  group &quot;helloGroup&quot; {\n    network {\n      port &quot;lb&quot; { static = 8080 }\n    }\n\n    # Define a task to run\n    task &quot;helloTask&quot; {\n      driver = &quot;java&quot;\n\n      config {\n        jar_path = &quot;local\/TestPublic-0.0.1-SNAPSHOT.jar&quot;\n        jvm_options = [&quot;-Xmx128m&quot;,&quot;-Xms128m&quot;]\n      }\n\n      service {\n        name = &quot;helloService&quot;\n        port = &quot;lb&quot;\n      }\n\n      resources {\n        cpu = 500         # 500 Mhz\n        memory = 200      # 200 MB\n      }\n\n      # \uc6d0\uaca9\uc5d0\uc11c \ub2e4\uc6b4\ubc1b\uc544\uc57c \ud569\ub2c8\ub2e4.\n      artifact {\n        source = &quot;https:\/\/github.com\/skyer9\/TestPublic\/raw\/master\/TestPublic-0.0.1-SNAPSHOT.jar&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n<pre><code class=\"language-bash\">nomad run hello.nomad<\/code><\/pre>\n<pre><code class=\"language-bash\">nomad job status\nID     Type     Priority  Status   Submit Date\nhello  service  50        running  2021-08-11T12:32:25Z<\/code><\/pre>\n<pre><code class=\"language-bash\">nomad job status hello\nID            = hello\nName          = hello\nSubmit Date   = 2021-08-11T12:32:25Z\nType          = service\nPriority      = 50\nDatacenters   = dc1\nNamespace     = default\nStatus        = running\nPeriodic      = false\nParameterized = false\n\nSummary\nTask Group  Queued  Starting  Running  Failed  Complete  Lost\nhelloGroup  0       0         1        18      1         0\n\nLatest Deployment\nID          = c4a7c82c\nStatus      = successful\nDescription = Deployment completed successfully\n\nDeployed\nTask Group  Desired  Placed  Healthy  Unhealthy  Progress Deadline\nhelloGroup  1        1       1        0          2021-08-11T12:42:42Z\n\nAllocations\nID        Node ID   Task Group  Version  Desired  Status    Created     Modified\n69efa88a  09537228  helloGroup  6        run      running   6m8s ago    5m52s ago<\/code><\/pre>\n<p>http:\/\/&lt;nomad \uc11c\ubc84 \ud37c\ube14\ub9ad \uc544\uc774\ud53c&gt;:8080\/hello \uc5d0 \uc811\uc18d\ud558\uba74,<br \/>\n\uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc774 \uc791\ub3d9\ud558\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>\ud3ec\ud2b8\uac00 \uace0\uc815\uc774\uba74?<\/h2>\n<p>\ud3ec\ud2b8\uac00 \uace0\uc815\uc774\ub2e4?<\/p>\n<p>Client \ub178\ub4dc\uc5d0 \uba54\ubaa8\ub9ac\uac00 \ub9ce\uc774 \ub0a8\uc544\ub3c4,<br \/>\n\ud3ec\ud2b8\ucda9\ub3cc \ub54c\ubb38\uc5d0 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ub450\uac1c \uc774\uc0c1 \ubabb \uc62c\ub9b0\ub2e4&#8230;&#8230;<\/p>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-11-01.png\"><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-11-01.png\" alt=\"\" \/><\/a><\/p>\n<p>\uadf8\ub798\uc11c, nomad \ub294 \ud3ec\ud2b8\ub97c \ub79c\ub364\ud560\ub2f9 \ud558\ub294 \uac83\uc774 \ub514\ud3f4\ud2b8\uc785\ub2c8\ub2e4.<\/p>\n<h2>\ud3ec\ud2b8 \ub79c\ub364\ud560\ub2f9<\/h2>\n<p><a href=\"https:\/\/dzone.com\/articles\/deploying-spring-cloud-microservices-on-hashicorps\">\ucc38\uc870<\/a><\/p>\n<p><code class=\"kb-btn\">port &quot;http&quot; {}<\/code>, <code>port = &quot;http&quot;<\/code> \ub85c \ud3ec\ud2b8\ub97c \ub79c\ub364\ud560\ub2f9 \ud558\ub3c4\ub85d \ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">vi hello.nomad<\/code><\/pre>\n<pre><code class=\"language-nomad\">job &quot;hello&quot; {\n  datacenters = [&quot;dc1&quot;]\n  type = &quot;service&quot;\n\n  group &quot;helloGroup&quot; {\n    network {\n      port &quot;http&quot; {}        # \ud3ec\ud2b8 \ub79c\ub364\ud560\ub2f9\n      port &quot;https&quot; {}       # \ud3ec\ud2b8 \ub79c\ub364\ud560\ub2f9\n      # port &quot;lb&quot; { static = 8080 }\n    }\n\n    count = 1\n\n    # Define a task to run\n    task &quot;helloTask&quot; {\n      driver = &quot;java&quot;\n\n      config {\n        jar_path = &quot;local\/TestPublic-0.0.2-SNAPSHOT.jar&quot;\n        jvm_options = [&quot;-Xmx128m&quot;,&quot;-Xms128m&quot;]\n      }\n\n      service {\n        name = &quot;helloService&quot;\n        # port = &quot;lb&quot;\n        port = &quot;http&quot;\n      }\n\n      resources {\n        cpu = 500         # 500 Mhz\n        memory = 200      # 200 MB\n      }\n\n      # \uc6d0\uaca9\uc5d0\uc11c \ub2e4\uc6b4\ubc1b\uc544\uc57c \ud569\ub2c8\ub2e4.\n      artifact {\n        source = &quot;https:\/\/github.com\/skyer9\/TestPublic\/raw\/master\/TestPublic-0.0.2-SNAPSHOT.jar&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n<p>\uc2a4\ud504\ub9c1 \ubd80\ud2b8 \uc571\uc758 \uc124\uc815\ud30c\uc77c\uc744 \uc218\uc815\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<p>Nomad \ub294 <code>NOMAD_HOST_PORT_http<\/code> \ub610\ub294 <code>NOMAD_HOST_PORT_https<\/code> \ub77c\ub294 \ud658\uacbd\ubcc0\uc218\uc5d0 \ud560\ub2f9\ub41c \ud3ec\ud2b8\ub97c \ubcf4\ub0b4\uc90d\ub2c8\ub2e4.<\/p>\n<p>\ubcf4\ub0b4\uc900 \ud3ec\ud2b8\ub85c \uc11c\ubc84\ub97c \uc124\uc815\ud569\ub2c8\ub2e4.<\/p>\n<p>application.yml<\/p>\n<pre><code class=\"language-yaml\">server:\n  port: ${NOMAD_HOST_PORT_http:8080}<\/code><\/pre>\n<pre><code class=\"language-bash\">nomad run hello.nomad<\/code><\/pre>\n<p>nomad server \ub85c\uadf8\uc5d0\uc11c \uc544\ub798 \ub0b4\uc6a9\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>alloc_id=24e79171-cf3a-2712-9e38-782b8d775575<\/code> \uc5d0\uc11c <code>alloc_id<\/code> \ub97c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-text\">2021-08-12T04:38:34.294Z [INFO]  client.alloc_runner.task_runner.task_hook.logmon.nomad: opening fifo: alloc_id=24e79171-cf3a-2712-9e38-782b8d775575 task=helloTask path=\/home\/ec2-user\/nomad\/data\/alloc\/24e79171-cf3a-2712-9e38-782b8d775575\/alloc\/logs\/.helloTask.stdout.fifo @module=logmon timestamp=2021-08-12T04:38:34.294Z\n2021-08-12T04:38:34.294Z [INFO]  client.alloc_runner.task_runner.task_hook.logmon.nomad: opening fifo: alloc_id=24e79171-cf3a-2712-9e38-782b8d775575 task=helloTask @module=logmon path=\/home\/ec2-user\/nomad\/data\/alloc\/24e79171-cf3a-2712-9e38-782b8d775575\/alloc\/logs\/.helloTask.stderr.fifo timestamp=2021-08-12T04:38:34.294Z<\/code><\/pre>\n<p>\ud655\uc778\ub41c <code>alloc_id<\/code> \ub85c \ub85c\uadf8\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">nomad alloc logs 24e79171-cf3a-2712-9e38-782b8d775575\n\n......\n2021-08-12 04:38:42.169  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 21660 (http) with context path &#039;&#039;\n2021-08-12 04:38:42.204  INFO 1 --- [           main] c.e.testpublic.TestPublicApplication     : Started TestPublicApplication in 5.93 seconds (JVM running for 7.14)<\/code><\/pre>\n<h2>\uc560\ud50c\ub9ac\ucf00\uc774\uc158 2\uac1c \uc774\uc0c1 \uc2e4\ud589<\/h2>\n<p><a href=\"https:\/\/linuxhint.com\/run_consul_server_docker\/\">\ucc38\uace0<\/a><\/p>\n<p>2\uac1c \uc774\uc0c1\uc758 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc2e4\ud589\ud558\uae30 \uc704\ud574\uc11c\ub294 <code>Consul<\/code> \uc774 \ud544\uc694\ud569\ub2c8\ub2e4.<\/p>\n<p>Consul \uc744 \uc124\uce58\ud558\uae30 \uc704\ud574 <code>Docker<\/code> \ub97c \uc124\uce58\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">sudo yum install docker -y\ndocker -v\nsudo service docker start\nsudo systemctl enable docker.service<\/code><\/pre>\n<pre><code class=\"language-bash\"># sudo docker run -d --name consul -p 8500:8500 -p 8600:8600\/udp consul\nsudo docker run -d --name consul -p 8500:8500 -p 8600:8600 -p 8600:8600\/udp consul\n\n# &lt;\uc11c\ube44\uc2a4\uba85&gt;.service.dc1.consul.\ndig @127.0.0.1 -p 8600 helloService.service.dc1.consul. ANY<\/code><\/pre>\n<p>http:\/\/&lt;\uc778\uc2a4\ud134\uc2a4 \ud37c\ube14\ub9ad \uc544\uc774\ud53c&gt;:8500\/ \uc5d0 \uc811\uc18d\ud558\uba74 Consul \uc758 \uc6f9UI \ub97c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">vi nomad\/config\/nomad.hcl\n-----------------------------------------\ndatacenter = &quot;dc1&quot;\ndata_dir   = &quot;\/home\/ec2-user\/nomad\/data&quot;\nbind_addr  = &quot;0.0.0.0&quot;\n\nserver {\n  enabled          = true\n  bootstrap_expect = 1\n}\n\nclient {\n  enabled           = true\n}\n\n# \ub514\ud3f4\ud2b8 \uc124\uc815\uc785\ub2c8\ub2e4.\n# (\uc124\uc815\ud30c\uc77c\uc5d0 \ucd94\uac00\ud560 \ud544\uc694\ub294 \uc5c6\uc2b5\ub2c8\ub2e4.)\nconsul {\n  address = &quot;127.0.0.1:8500&quot;\n\n  server_service_name = &quot;nomad&quot;\n  client_service_name = &quot;nomad-client&quot;\n\n  auto_advertise = true\n\n  server_auto_join = true\n  client_auto_join = true\n}\n-----------------------------------------<\/code><\/pre>\n<p><code>count = 2<\/code> \ub85c \ub450\uac1c\uc758 \uc571\uc774 \uc2e4\ud589\ub429\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">vi hello.nomad<\/code><\/pre>\n<pre><code class=\"language-nomad\">job &quot;hello&quot; {\n  datacenters = [&quot;dc1&quot;]\n  type = &quot;service&quot;\n\n  group &quot;helloGroup&quot; {\n    network {\n      port &quot;http&quot; {}\n      port &quot;https&quot; {}\n      # port &quot;lb&quot; { static = 8080 }\n    }\n\n    count = 2\n\n    # Define a task to run\n    task &quot;helloTask&quot; {\n      driver = &quot;java&quot;\n\n      config {\n        jar_path = &quot;local\/TestPublic-0.0.2-SNAPSHOT.jar&quot;\n        jvm_options = [&quot;-Xmx128m&quot;,&quot;-Xms128m&quot;]\n      }\n\n      service {\n        name = &quot;helloService&quot;\n        # port = &quot;lb&quot;\n        port = &quot;http&quot;\n      }\n\n      resources {\n        cpu = 500         # 500 Mhz\n        memory = 200      # 200 MB\n      }\n\n      # \uc6d0\uaca9\uc5d0\uc11c \ub2e4\uc6b4\ubc1b\uc544\uc57c \ud569\ub2c8\ub2e4.\n      artifact {\n        source = &quot;https:\/\/github.com\/skyer9\/TestPublic\/raw\/master\/TestPublic-0.0.2-SNAPSHOT.jar&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n<p>\ub450\uac1c\uc758 \uc571\uc774 \uc2e4\ud589\ub429\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">nomad run hello.nomad<\/code><\/pre>\n<p>\uc544\ub798 \uba85\ub839\uc73c\ub85c \ub85c\uadf8\ud30c\uc77c\uc758 \uacbd\ub85c\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">ps -efH\n\n......\nroot      3154     1  0 04:25 ?        00:00:00   \/usr\/sbin\/sshd -D\nroot      3197  3154  0 04:26 ?        00:00:00     sshd: ec2-user [priv]\nec2-user  3231  3197  0 04:26 ?        00:00:00       sshd: ec2-user@pts\/0\nec2-user  3232  3231  0 04:26 pts\/0    00:00:00         -bash\nroot      6668  3232  0 05:05 pts\/0    00:00:00           sudo nomad agent -config=nomad\/config\/nomad.hcl\nroot      6669  6668  3 05:05 pts\/0    00:00:10             nomad agent -config=nomad\/config\/nomad.hcl\nroot      7122  6669  0 05:10 pts\/0    00:00:00               \/usr\/bin\/nomad logmon\nroot      7130  6669  0 05:10 pts\/0    00:00:00               \/usr\/bin\/nomad logmon\nroot      7138  6669  0 05:10 ?        00:00:00               \/usr\/bin\/nomad executor {&quot;LogFile&quot;:&quot;\/home\/ec2-user\/nomad\/data\/alloc\/cd67a9b6-6512-f4d0-98c0-2490de85cc72\/helloTask\/executor.out&quot;,&quot;LogLevel&quot;:&quot;debug&quot;,&quot;FSIsolation&quot;:true}\nnobody    7172  7138 40 05:10 ?        00:00:02                 \/usr\/lib\/jvm\/java-11-amazon-corretto.x86_64\/bin\/java -Xmx128m -Xms128m -jar local\/TestPublic-0.0.2-SNAPSHOT.jar\nroot      7143  6669  0 05:10 ?        00:00:00               \/usr\/bin\/nomad executor {&quot;LogFile&quot;:&quot;\/home\/ec2-user\/nomad\/data\/alloc\/1eb14579-f0ab-4310-5b92-36d16c2b3cab\/helloTask\/executor.out&quot;,&quot;LogLevel&quot;:&quot;debug&quot;,&quot;FSIsolation&quot;:true}\nnobody    7205  7143 40 05:10 ?        00:00:02                 \/usr\/lib\/jvm\/java-11-amazon-corretto.x86_64\/bin\/java -Xmx128m -Xms128m -jar local\/TestPublic-0.0.2-SNAPSHOT.jar<\/code><\/pre>\n<p>Consul \uc6f9UI \ub97c \uc774\uc6a9\ud574 \uc2e4\ud589\uc911\uc778 \uc571\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>http:\/\/&lt;\uc778\uc2a4\ud134\uc2a4 \ud37c\ube14\ub9ad \uc544\uc774\ud53c&gt;:8500\/<\/p>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-12-01.png\"><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-12-01.png\" alt=\"\" \/><\/a><\/p>\n<h2>\ub85c\ub4dc\ubc38\ub7f0\uc2f1 \ubc0f \uc11c\ube44\uc2a4 URL \uc0dd\uc131<\/h2>\n<p><a href=\"https:\/\/learn.hashicorp.com\/tutorials\/nomad\/load-balancing-haproxy\">\ucc38\uc870<\/a><\/p>\n<p>\ub79c\ub364\ud3ec\ud2b8\ub97c \ud560\ub2f9\ud588\uae30\ub54c\ubb38\uc5d0 \uc0ac\uc6a9\uc790\uac00 \uc811\uc18d\ud558\uae30 \uc5b4\ub824\uc6cc\uc84c\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>HAProxy<\/code> \ub97c \uc774\uc6a9\ud574 <code>\ub85c\ub4dc\ubc38\ub7f0\uc2f1<\/code> \ubc0f <code>\uc11c\ube44\uc2a4 URL \uc0dd\uc131<\/code> \ub450\uac00\uc9c0 \ud544\uc694\ud55c \uae30\ub2a5\uc744 \ucd94\uac00\ud574 \ubd05\ub2c8\ub2e4.<\/p>\n<p><code>env<\/code>, <code>check<\/code> \ub97c \ucd94\uac00\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">vi hello.nomad<\/code><\/pre>\n<pre><code class=\"language-nomad\">job &quot;hello&quot; {\n  datacenters = [&quot;dc1&quot;]\n  type = &quot;service&quot;\n\n  group &quot;helloGroup&quot; {\n    network {\n      port &quot;http&quot; {}\n      port &quot;https&quot; {}\n      # port &quot;lb&quot; { static = 8080 }\n    }\n\n    count = 2\n\n    # Define a task to run\n    task &quot;helloTask&quot; {\n      driver = &quot;java&quot;\n\n      config {\n        jar_path = &quot;local\/TestPublic-0.0.2-SNAPSHOT.jar&quot;\n        jvm_options = [&quot;-Xmx128m&quot;,&quot;-Xms128m&quot;]\n      }\n\n      env {\n        PORT    = &quot;${NOMAD_PORT_http}&quot;\n        NODE_IP = &quot;${NOMAD_IP_http}&quot;\n      }\n\n      service {\n        name = &quot;helloService&quot;\n        # port = &quot;lb&quot;\n        port = &quot;http&quot;\n\n        check {\n          type     = &quot;http&quot;\n          path     = &quot;\/hello&quot;     # health check \uc6a9 url\n          interval = &quot;2s&quot;\n          timeout  = &quot;2s&quot;\n        }\n      }\n\n      resources {\n        cpu = 500         # 500 Mhz\n        memory = 200      # 200 MB\n      }\n\n      # \uc6d0\uaca9\uc5d0\uc11c \ub2e4\uc6b4\ubc1b\uc544\uc57c \ud569\ub2c8\ub2e4.\n      artifact {\n        source = &quot;https:\/\/github.com\/skyer9\/TestPublic\/raw\/master\/TestPublic-0.0.2-SNAPSHOT.jar&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n<pre><code class=\"language-bash\">vi haproxy.nomad<\/code><\/pre>\n<pre><code class=\"language-nomad\">job &quot;haproxy&quot; {\n  region      = &quot;global&quot;\n  datacenters = [&quot;dc1&quot;]\n  type        = &quot;service&quot;\n\n  group &quot;haproxy&quot; {\n    count = 1\n\n    network {\n      port &quot;http&quot; {\n        static = 8080\n      }\n\n      port &quot;haproxy_ui&quot; {\n        static = 1936\n      }\n    }\n\n    task &quot;haproxy&quot; {\n      driver = &quot;docker&quot;\n\n      config {\n        image        = &quot;haproxy:2.0&quot;\n        network_mode = &quot;host&quot;\n\n        volumes = [\n          &quot;local\/haproxy.cfg:\/usr\/local\/etc\/haproxy\/haproxy.cfg&quot;,\n        ]\n      }\n\n      service {\n        name = &quot;haproxy&quot;\n\n        check {\n          name     = &quot;alive&quot;\n          type     = &quot;tcp&quot;\n          port     = &quot;http&quot;\n          interval = &quot;10s&quot;\n          timeout  = &quot;2s&quot;\n        }\n      }\n\n      template {\n        data = &lt;&lt;EOF\ndefaults\n   mode http\n   timeout connect 5s\n   timeout client 1m\n   timeout server 1m\n\nfrontend stats\n   bind *:1936\n   stats uri \/\n   stats show-legends\n   no log\n\nfrontend http_front\n   bind *:8080\n   default_backend http_back\n\nbackend http_back\n    balance roundrobin\n    server-template mywebapp 1-10 _helloservice._tcp.service.consul resolvers consul    resolve-opts allow-dup-ip resolve-prefer ipv4 check\n\nresolvers consul\n  nameserver consul 127.0.0.1:8600\n  accepted_payload_size 8192\n  hold valid 5s\nEOF\n\n        destination = &quot;local\/haproxy.cfg&quot;\n      }\n\n      resources {\n        cpu    = 200\n        memory = 128\n      }\n    }\n  }\n}<\/code><\/pre>\n<pre><code class=\"language-bash\">nomad run hello.nomad\nnomad run haproxy.nomad<\/code><\/pre>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-13-01.png\"><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-13-01.png\" alt=\"\" \/><\/a><\/p>\n<p>http:\/\/&lt;\uc778\uc2a4\ud134\uc2a4 \ud37c\ube14\ub9ad \uc544\uc774\ud53c&gt;:1936\/ \uc5d0 \uc811\uc18d\ud558\uba74 haproxy \uc5d0\uc11c \uc778\uc2dd\ud55c \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>http:\/\/&lt;\uc778\uc2a4\ud134\uc2a4 \ud37c\ube14\ub9ad \uc544\uc774\ud53c&gt;:8080\/hello \uc5d0 \uc811\uc18d\ud558\uc5ec <code>8080<\/code> \ud3ec\ud2b8\uc5d0\uc11c \uc11c\ube44\uc2a4\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>TODO<\/h2>\n<p>\uc774 \ud074\ub7ec\uc2a4\ud130\ub97c 2000\ub300 \uc124\uce58\ud574\uc57c \ud55c\ub2e4\uba74 bash \ub85c \ub178\uac00\ub2e4\ub97c \ud574\uc57c \ud558\ub098?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nomad \uac00\uc9c0\uace0 \ub180\uae30 (\uc0bd\uc9c8\uae30) \ucc38\uc870 \ucc38\uc870 \ucc38\uc870 \ubaa9\ud45c \ud14c\uc2a4\ud2b8\uc6a9 nomad \uc11c\ubc84\ub97c \uc0dd\uc131\ud558\uace0, \uc5ec\ub7ec \uae30\ub2a5\ub4e4\uc744 \ud655\uc778\ud574 \ubd05\ub2c8\ub2e4. nomad \uc124\uce58 AWS AMI \uc778\uc2a4\ud134\uc2a4\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4. \uba54\ubaa8\ub9ac\ub294 1G \ub85c \ud569\ub2c8\ub2e4. \ub0b4 IP \ub85c\ubd80\ud130\uc758 \ubaa8\ub4e0 \uc811\uc18d\uc744 \ud5c8\uc6a9\ud558\ub3c4\ub85d \ubcf4\uc548\uadf8\ub8f9\uc744 \uc124\uc815\ud574 \uc90d\ub2c8\ub2e4. \uc544\ub798 \uba85\ub839\uc73c\ub85c nomad \ub97c \uc124\uce58\ud574 \uc90d\ub2c8\ub2e4. wget https:\/\/releases.hashicorp.com\/nomad\/1.1.3\/nomad_1.1.3_linux_amd64.zip unzip nomad_1.1.3_linux_amd64.zip sudo mv nomad \/usr\/bin\/ nomad version \ud14c\uc2a4\ud2b8\uc6a9\uc774\ubbc0\ub85c, \ud55c \uc11c\ubc84\uc5d0 Server\/Client\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2735\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-2735","post","type-post","status-publish","format-standard","hentry","category-nomad"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2735"}],"version-history":[{"count":74,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2735\/revisions"}],"predecessor-version":[{"id":3443,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2735\/revisions\/3443"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}