#library(snow)
library(doParallel)
library(RMySQL)
workerList <- list(
list(host = "192.168.1.35", port = 10187, rshcmd = "ssh -p 22"),
list(host = "192.168.1.36", port = 10187, rshcmd = "ssh -p 22")
);
cl <- makeCluster(rep(workerList[2],60), type="SOCK" )
# /etc/bashrc: fork: retry: Resource temporarily unavailable
# /etc/bashrc: fork: retry: Resource temporarily unavailable
# /etc/bashrc: fork: retry: Resource temporarily unavailable
# /etc/bashrc: fork: retry: Resource temporarily unavailable
# /etc/bashrc: fork: Resource temporarily unavailable
# /etc/bashrc: fork: retry: Resource temporarily unavailable
# /etc/bashrc: fork: retry: Resource temporarily unavailable
# /etc/bashrc: fork: retry: Resource temporarily unavailable
# /etc/bashrc: fork: retry: Resource temporarily unavailable
# /etc/bashrc: fork: Resource temporarily unavailable
#cl <- makeCluster(workerList, type="SOCK", master="192.168.1.35")
#test
#clusterApplyLB(cl,mp_id,function(mp_id) print(mp_id))
#read info from sql
sql_data<-"select distinct(MP_ID) from DataPower"
conn<-dbConnect(MySQL(),user="",password="",dbname="",host="") #开启数据库连接
data_info<-dbGetQuery(conn,sql_data) #获得原始数据
dbDisconnect(conn) #关闭数据库连接
mp_id = as.numeric(data_info[,1])
registerDoParallel(cl)
system.time(
a <- foreach (x=1:length(mp_id)) %dopar% {
library(RMySQL)
library(nnet)
library(plyr)
library(lattice)
library(e1071)
print('hello!')
#trainAndtest(mp_id[x])
})
stopCluster(cl)
foreach代码记录
最新推荐文章于 2021-03-21 19:43:44 发布