2016-07-18 180 views
6

La mia intenzione è avviare due o più cluster/istanze h2o (non due o più nodi!) dall'interno di R sullo stesso computer/server per consentire a più utenti di connettersi con h2o a lo stesso tempo. Inoltre, voglio essere in grado di spegnere e riavviare i cluster separatamente, anche dall'interno R.Avviare più cluster h2o dall'interno R

So già che non posso controllare più cluster h2o semplicemente da R, quindi ho provato ad avviare due cluster dalla riga di comando in Windows 10:

java -Xmx1g -jar h2o.jar -name testCluster1 -nthreads 1 -port 54321 
java -Xmx1g -jar h2o.jar -name testCluster2 -nthreads 1 -port 54323 

Questo funziona bene per me:

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) 

Ora, voglio fare lo stesso dall'interno R tramite il comando di sistema().

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

ma ottengo un messaggio di errore:

[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 

Cercando

system2(command = launchH2O) 

ottengo un messaggio di avvertimento e non sono in grado di connettersi con il cluster:

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/ 

Qualche idea su come iniziare/scattare utdown due o più cluster h2o dall'interno di R? Grazie in anticipo!

Nota 1: Sto solo utilizzando il mio dispositivo Windows locale per il test, in realtà voglio creare più cluster h2o su un server Linux.

Nota 2: Ho provato con R GUI (3.2.5) e R Studio (versione 0.99.892) e li ho eseguiti come amministratore. Il file h2o.jar si trova nella mia directory di lavoro e la mia versione di Java è (Build 1.8.0_91-b14).

Nota 3: Informazioni di sistema: - h2o h2o & versione del pacchetto R: 3.8.3.2 - Windows 10 Casa, versione 1511 - 16 di RAM, processore Intel Core i5-6200U CPU con 2,30 GHz

+0

Considerare l'esecuzione di linux, anche come guest di vm. Generalmente aumenta la produttività quando si lavora con l'open source. IMO win dev machine ha senso solo quando ti schieri su quella piattaforma, cioè azzurro. – jangorecki

risposta

3

EDIT: ho cambiato internare = FALSE, negli esempi di seguito, sulla base dei commenti


Si dovrebbe solo bisogno di cambiare directory; è o non l'impostazione wait = FALSE (per eseguire il comando in background).

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) 

L'ultima riga, e l'assegnazione di savewd è solo per preservare la directory di lavoro.In alternativa questo dovrebbe anche funzionare:

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

Quando su Linux, c'è un altro modo:

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

(Perché l'ultimo comando mette esplicitamente in background, non credo che è necessario impostare wait=FALSE.)

+0

Ciao Darren, grazie per la rapida risposta. La buona notizia è che ora posso avviare un cluster dall'interno R. La cattiva notizia è che R si blocca non appena eseguo "system (command = launchH2O, intern = TRUE, wait = FALSE)". Infatti, R non si blocca ma mi dice che è occupato. Solo dopo aver spento il cluster tramite il mio browser (ip: 54321), R si ferma di nuovo in coda ... hai un'idea? PS: Ho usato un altro percorso per la directory di lavoro ma questo ovviamente funziona bene da quando il cluster inizia ... – Constantin

+0

Ho capito - devi impostare intern = FALSE poiché l'interprete attende nel caso tu abbia impostato intern = TRUE, anche se wait è impostato su FALSE. Quindi funziona system (command = launchCluster1, intern = FALSE, wait = FALSE). Ti dispiacerebbe spiegare come spegnere nuovamente i cluster via cmd? – Constantin

+0

@Constantin Dovrebbe essere solo 'h2o.shutdown()' da R, quando è connesso al cluster. –