从R中启动多个h2o集群

con*_*iii 9 windows cmd r cluster-computing h2o

我的目的是从同一台计算机/服务器上的R内启动两个或多个h2o集群/实例(不是两个或更多节点!),以使多个用户能够同时与h2o连接.此外,我希望能够单独关闭和重新启动集群,也可以从R内部.

我已经知道我无法简单地从R中控制多个h2o集群,因此我尝试从Windows 10中的命令行启动两个集群:

java -Xmx1g -jar h2o.jar -name testCluster1 -nthreads 1  -port 54321
java -Xmx1g -jar h2o.jar -name testCluster2 -nthreads 1  -port 54323
Run Code Online (Sandbox Code Playgroud)

这对我来说很好:

library(h2o)

h2o.init(startH2O = FALSE, ip = "localhost", port = 54321) 
Connection successful!

R is connected to the H2O cluster: 
H2O cluster uptime:         4 minutes 8 seconds 
H2O cluster version:        3.8.3.2 
H2O cluster name:           testCluster 
H2O cluster total nodes:    1 
H2O cluster total memory:   0.87 GB 
H2O cluster total cores:    4 
H2O cluster allowed cores:  1 
H2O cluster healthy:        TRUE 
H2O Connection ip:          localhost 
H2O Connection port:        54321 
H2O Connection proxy:       NA 
R Version:                  R version 3.2.5 (2016-04-14) 

h2o.init(startH2O = FALSE, ip = "localhost", port = 54323)
Connection successful!

R is connected to the H2O cluster: 
H2O cluster uptime:         3 minutes 32 seconds 
H2O cluster version:        3.8.3.2 
H2O cluster name:           testCluster2 
H2O cluster total nodes:    1 
H2O cluster total memory:   0.87 GB 
H2O cluster total cores:    4 
H2O cluster allowed cores:  1 
H2O cluster healthy:        TRUE 
H2O Connection ip:          localhost 
H2O Connection port:        54323 
H2O Connection proxy:       NA 
R Version:                  R version 3.2.5 (2016-04-14) 
Run Code Online (Sandbox Code Playgroud)

现在,我想通过system()命令从R中做同样的事情.

launchH2O <-  as.character("java -Xmx1g -jar h2o.jar -name testCluster -nthreads 1  -port 54321")
system(command = launchH2O, intern =TRUE)
Run Code Online (Sandbox Code Playgroud)

但是我收到一条错误消息:

[1] "Error: Unable to access jarfile h2o.jar"
attr(,"status")
[1] 1
Warning message:
running command 'java -Xmx1g -jar h2o.jar -name testCluster -nthreads 1  -port 54321' had status 1 
Run Code Online (Sandbox Code Playgroud)

system2(command = launchH2O)
Run Code Online (Sandbox Code Playgroud)

我收到一条警告消息,我无法连接群集:

system2(command = launchH2O)
Warning message:
running command '"java -Xmx1g -jar h2o.jar -name testCluster -nthreads 1  -port 54321"' had status 127 

h2o.init(startH2O = FALSE, ip = "localhost", port = 54321)
Error in h2o.init(startH2O = FALSE, ip = "localhost", port = 54321) : 
Cannot connect to H2O server. Please check that H2O is running at http://localhost:54321/
Run Code Online (Sandbox Code Playgroud)

任何想法如何从R内启动/关闭两个或多个h2o集群?先感谢您!

注1:我只使用我的本地Windows设备进行测试,实际上我想在Linux服务器上创建多个h2o集群.

注2:我用R GUI(3.2.5)和R Studio(版本0.99.892)尝试了它,我以管理员身份运行它们.h2o.jar文件位于我的工作目录中,我的Java版本是(Build 1.8.0_91-b14).

注3:系统信息: - h2o&h2o R软件包版本:3.8.3.2 - Windows 10 Home,版本1511 - 16 RAM,Intel Core i5-6200U CPU,2,30 GHz

Dar*_*ook 5

编辑:我已更改为实习生 = FALSE,在下面的示例中,基于评论


您应该只需要更改目录;是否设置 wait=FALSE (在后台运行命令)。

launchH2O <- "java -Xmx1g -jar h2o.jar -name testCluster -nthreads 1 -port 54321"
savewd <- setwd("/path/to/h2ojar/")
system(command = launchH2O, intern =FALSE wait=FALSE)
setwd(savewd)
Run Code Online (Sandbox Code Playgroud)

最后一行,分配给savewd只是为了保留工作目录。或者,这也应该有效:

launchH2O <- "java -Xmx1g -jar /path/to/h2ojar/h2o.jar -name testCluster -nthreads 1 -port 54321"
system(command = launchH2O, intern =FALSE, wait=FALSE)
Run Code Online (Sandbox Code Playgroud)

在 Linux 上,还有另一种方式:

launchH2O <- "bash -c 'nohup java -Xmx1g -jar /path/to/h2ojar/h2o.jar -name testCluster -nthreads 1 -port 54321 &'"
system(command = launchH2O, intern =FALSE)
Run Code Online (Sandbox Code Playgroud)

(因为最后一个命令明确将其置于后台,我认为您不需要设置wait=FALSE.)