다음을 통해 공유


Remote R Service for Linux

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Remote R Service for Linux is currently packaged as rtvs-daemon. The daemon is supported and tested on Ubuntu 16.04, 16.10 LTS desktop, server, and Windows Subsystem for Linux running Ubuntu. The bulk of this article provides instructions for setting up Remote R Service on these different systems.

Once you've configured the remote machine, the following steps connect the R Tools for Visual Studio (RTVS) to that service:

  1. Select R Tools > Windows > Workspaces to open the Workspaces window.
  2. Select Add Connection.
  3. Give the connect a name and provide its URL, such as https://localhost:5444 (Windows Subsystem for Linux) or https://public-ip:5444 (Azure container). Select Save when complete.
  4. Select the connection icon or double-click the connection item.
  5. Provide login credentials. The username must be prefixed with <<unix>>\ as in <<unix>>\ruser1 (as required for all connections to Linux remote computers).
  6. If you are using self-signed certificate, you may see a warning. The message provides instructions to correct the warning.

Set up Remote R Service

This section describes the following options:

In each case, the remote computer must have one of the following R interpreters installed:

Physical Ubuntu computer

  1. Once logged into the computer, download the rtvs-daemon tarball:

    wget -O rtvs-daemon.tar.gz https://aka.ms/r-remote-services-linux-binary-current
    tar -xvzf rtvs-daemon.tar.gz
    
  2. Run the install script:

    sudo ./rtvs-install
    

    For a silent automation, use sudo ./rtvs-install -s.

  3. Enable and start the service:

    sudo systemctl enable rtvsd
    sudo systemctl start rtvsd
    
  4. Configure the SSL certificate (required for production). By default, rtvs-daemon uses the ssl-cert-snakeoil.pem and ssl-cert-snakeoil.pem generated by the ssl-cert package. During installation, they're combined into ssl-cert-snakeoil.pfx. For production purposes, use the SSL certificate provided by your administrator. The SSL certificate can be configured by providing a .pfx file and optional import password in: /etc/rtvs/rtvsd.config.json.

  5. (Optional) Check that the service is running:

    ps -A -f | grep rtvsd
    

    If you don’t see a process running under the user name rtvssvc. Start it using the following command:

    sudo systemctl start rtvsd
    
  6. To further configure the rtvs-daemon, see man rtvsd.

Ubuntu Server VM or Data Science VM on Azure

Create a VM

  1. Sign in to the Azure portal.
  2. Navigate to Virtual Machines, then select Add.
  3. In the list of available VM images, search for and select one of the following:
  4. Set the deployment model to Resource manager and select Create.
  5. Choose a name for the VM, provide a username and password (password is required, as SSH public key login isn't supported).
  6. Make any other desired changes to the VM configuration.
  7. Choose a VM size, verify the configuration, and select Create. Once the VM is created, proceed to the next section.

Configure the VM

  1. In the VM's Networking section, add 5444 as an allowed inbound port. To use a different port, change the setting in the RTVS daemon config file (/etc/rtvs/rtvsd.config.json).
  2. (Optional) Set a DNS name; you can also use the IP address.
  3. Connect to the VM using an SSH client, such as PuTTY for Windows.
  4. Follow the instructions for a Physical Ubuntu computer above.

Windows Subsystem for Linux (WSL)

  1. Follow the WSL installation instructions for either Windows 10 or Windows Server.
  2. Start bash on Windows and follow the earlier instructions a Physical Ubuntu computer with one exception. For step 3, start the service using the command rtvsdinstead because WSL currently does not support the systemd/systemctl interfaces.

Local or remote Docker container (clean build)

  1. Create a Docker file with the contents below, which installs the Remote R service daemon and the latest version of R. Note: this script creates a user called "ruser1" with the password "foobar", which you can modify as desired in the final two RUN statements.

    FROM ubuntu:16.04
    
    ARG DEBIAN_FRONTEND=noninteractive
    
    RUN apt-get update \
     && apt-get install -y software-properties-common python-software-properties \
     && apt-get install -y apt-transport-https \
     && rm -rf /var/lib/apt/lists/*
    
    RUN sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list' \
     && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893 \
     && sh -c 'echo "deb https://cran.revolutionanalytics.com/bin/linux/ubuntu xenial/" > /etc/apt/sources.list.d/cran-r.list' \
     && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 \
     && rm -rf /var/lib/apt/lists/* \
     && apt-get clean
    
    RUN apt-get update --fix-missing && apt-get update \
     && apt-get install -y dotnet-dev-1.0.4 libexplain51 libzip4 libc6 git lshw ssl-cert wget \
     && rm -rf /var/lib/apt/lists/*
    
    # install R
    RUN apt-get update && apt-get install -y r-base-dev
    RUN apt upgrade -y
    
    # install rtvs-daemon
    RUN wget -O rtvs-daemon.tar.gz https://aka.ms/r-remote-services-linux-binary-current && tar -xvzf rtvs-daemon.tar.gz && ./rtvs-install -s
    
    RUN useradd --create-home ruser1
    RUN echo "ruser1:foobar" | chpasswd
    
    EXPOSE 5444
    
  2. Build and run the docker file:

    docker build -t myrimage .
    docker run -p 5444:5444 myrimage rtvsd
    
  3. To connect to the contains from RTVS, use https://localhost:5444 as the path, username <<unix>>\ruser1, and password foobar. If the container is running on a remote computer, use https://remote-host-name:5444 as the path instead. The port can be changed by updating /etc/rtvs/rtvsd.config.json.

Container running on Azure Container Instances

  1. Follow the instructions in Local or remote Docker container (clean build) to create the image.

  2. Push the container to Docker hub or Azure Container Repository.

  3. Start the Azure CLI and sign in using the az login command.

  4. Use the az container create command to create the container, using --command-line "rtvsd" if you have not set up the container to run rtvsd as a systemd service. In the command below, the image is expected to be on Docker hub. You can also use Azure Container Repository by adding Container Repository credential arguments to the command line.

    az container create --image myimage:latest --name myaz-container --resource-group myaz-container-res --ip-address public --port 5444 --cpu 2 --memory 4 --command-line "rtvsd"
    
  5. Use the az container list command to check the status. Look for provisioningState: Succeeded.

  6. If the provisioning succeeded, you can now connect to the container. Look for the public IP address, in the ipAddress field, which you use with the credentials in the docker file to connect to the container from RTVS.