如何在操作系统,远程R工作区和RStudio服务器中选择R服务器的R作为默认值?

时间:2018-01-27 21:02:33

标签: r linux azure

所以我在Linux(Ubuntu)上设置了一个Azure Data Science虚拟机,我在终端上执行了以下操作,以启用Remote R工作区,RStudio Server,R Server Operationalization和hadoop:

sudo apt update
sudo apt -y upgrade

# Hadoop is installed but doesn't seem to appear on the PATH or have its environment variable set by default
sudo echo "" >> ~/.bashrc
sudo echo "export PATH="'$'"PATH:/opt/hadoop/hadoop-2.7.4/bin" >> ~/.bashrc
sudo echo "export HADOOP_HOME=/opt/hadoop/hadoop-2.7.4" >> ~/.bashrc
#
source ~/.bashrc

#Setting up a password as none exists to begin with because of private key selection in the installation
#RStudio Server requires a password though
"MyPassword\nMyPassword\n" | sudo passwd sshuser

#Unfortunately hadoop fails on Data Science Virtual Machine
#error: mkdir: Call From IM-DSonUbuntu/192.168.5.4 to localhost:9000 failed on connection exception: java.net.ConnectException: Connection refused; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused
# hadoop fs -mkdir /user/RevoShare/rserve2
# hadoop fs -chmod uog+rwx /user/RevoShare/rserve2
sudo mkdir -p /var/RevoShare/rserve2
sudo chmod uog+rwx /var/RevoShare/rserve2
# hadoop fs -mkdir /user/RevoShare/sshuser
# hadoop fs -chmod uog+rwx /user/RevoShare/sshuser
sudo mkdir -p /var/RevoShare/sshuser
sudo chmod uog+rwx /var/RevoShare/sshuser

#Setting up R Server Operationalisation
cd /opt/microsoft/mlserver/9.2.1/o16n
sudo dotnet Microsoft.MLServer.Utils.AdminUtil/Microsoft.MLServer.Utils.AdminUtil.dll -silentoneboxinstall MyPassword


#They say this Data Science Virtual Machine already has RStudio Server, but even though the port 8787 is open, it's nowhere to be found! So installing it now, and after the installation it's accessible by refreshing the page that failed before.
#Perhaps it's not installed then? Or a service is not running like it shoudl?
#https://www.rstudio.com/products/rstudio/download-server/
wget https://download2.rstudio.org/rstudio-server-1.1.414-amd64.deb
yes | sudo gdebi rstudio-server-1.1.414-amd64.deb
#They are small, leave them for debug reasons - lets have evidence the script run thus far.
#sudo rm rstudio-server-1.1.414-amd64.deb

# Remote R workspace Service needs dotnet sdk
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt update
sudo apt -y install dotnet-sdk-2.0.0
sudo apt install libxml2-dev

#Downloading and installing the Remote R service
wget -O rtvs-daemon.tar.gz https://aka.ms/r-remote-services-linux-binary-current
tar -xvzf rtvs-daemon.tar.gz
sudo ./rtvs-install -s
sudo systemctl enable rtvsd
sudo systemctl start rtvsd
#sudo rm rtvs-daemon.tar.gz
#sudo rm rtvs-install

#Fixing Remote R: For some reason, even though 'sudo systemctl enable rtvsd' runs, after every reboot the service won't become automatically active. So let's fix that.
wget https://sa0im0general.blob.core.windows.net/general-blob-container/StartRemoteRAfterReboot.sh
sudo mv StartRemoteRAfterReboot.sh /var/RevoShare/StartRemoteRAfterReboot.sh

sudo /sbin/shutdown -r 5

sudo chown root /etc/rc.local
sudo chmod 755 /etc/rc.local
sudo systemctl enable rc-local.service
sudo -s
sudo find /etc/ -name "rc.local" -exec sed -i 's/exit 0//g' {} \;
sudo echo "" >> /etc/rc.local
sudo echo "sh /var/RevoShare/StartRemoteRAfterReboot.sh" >> /etc/rc.local
sudo echo "exit 0" >> /etc/rc.local
exit

我也一个接一个地试过这些,看看它是否对RStudio服务器有任何影响(它没有,但即使它确实如此,我想要一个全球解决方案来处理Remote R工作区服务和R服务器操作化,不仅是RStudio服务器):

#Configuring RStudio Server to see the R Server R
sudo echo "rsession-which-r=/opt/microsoft/mlserver/9.2.1/bin/R/R" >> /etc/rstudio/rserver.conf

export RSTUDIO_WHICH_R=/opt/microsoft/mlserver/9.2.1/bin/R/R
sudo echo "RSTUDIO_WHICH_R=/opt/microsoft/mlserver/9.2.1/bin/R/R" >> ~/.profile
source ~/.profile
sudo echo "RSTUDIO_WHICH_R=/opt/microsoft/mlserver/9.2.1/bin/R/R" >> ~/.bashrc
source ~/.bashrc

sudo echo "PATH=$PATH:/opt/microsoft/mlserver/9.2.1/bin/R" >> ~/.bashrc
export PATH=$PATH:/opt/microsoft/mlserver/9.2.1/bin/R
source ~/.bashrc

问题在于,即使“哪个R”指向R服务器的R,即键入“sudo R”,也会显示消息“正在加载Microsoft R Server软件包,版本9.2.1”。并且会加载像RevoScaleR这样的软件包,其他一切都不能这样做。

  1. 使用http://THE-IP-GOES-HERE.westeurope.cloudapp.azure.com:8787访问RStudio服务器并使用初始用户(“sshuser”)(或与任何其他用户一起登录)登录将不会加载R服务器和RevoScaleR rx功能不可用< / p>

  2. 使用我的本地Visual Studio 2017通过“工作区”选项卡上的“添加连接”访问远程工作区,加载MRO并说:

  3.   

    已安装的R版本:

        [0] Microsoft R Open '3.4.1.1347' (Default)
    
    1. 最后,当我使用R服务器的操作系统并使用“mrsdeploy”软件包的“remoteLogin()”登录时,RevoScaleR等R服务器软件包不再被加载,因此诸如“rxSummary(〜。,data = iris)”之类的东西会失败错误'无法找到功能“rxSummary”'
    2. 当我从azure部署“Linux上的机器学习服务器9.2.1(Ubuntu)”时发生了同样的事情。

      我不想只使用常规的开源R,我希望能够使用R服务器 - 这就是我部署这个VM的原因。我怎样才能让所有东西加载R Server的R,而不是Microsoft R Open? (就像我可以使用“R”从终端那样做)

      由于我已经尝试了所有这些以及R服务器在控制台中加载的事实,我的思想现在转到了权限。可能是默认情况下,Data Science VM没有允许这些权限的正确权限吗? 我不知所措。

1 个答案:

答案 0 :(得分:1)

RStudio Server安装在Ubuntu DSVM上,但默认情况下禁用该服务,因为它不支持SSL。您可以使用 systemctl enable rstudio-server 启用它,然后使用 systemctl start rstudio-server 启动它。

RStudio Server使用与Microsoft R Server相同的R,但.libPaths不同,这就是您无法加载MRS包的原因。您需要手动设置.libPaths以使它们匹配。