Skip to content

RServe installation

This guide provides instructions for system administrators to install, configure, deploy, and manage R and Rserve backend service.

Overview

Rserve is a lightweight R backend for code execution and integration, designed for use with other services.

Requirements

  • R version 4.0 or newer
  • Ubuntu/Linux operating system with admin access

Installation

  1. Install R:
sudo apt update
sudo apt install -y r-base
  1. Install Rserve package:

Start R and install Rserve and other R packages:

sudo R
install.packages("Rserve")
install.packages("knitr")
install.packages("pander")
install.packages("dbplyr")
install.packages("RClickhouse")
q()

Deployment

Run the following command to start Rserve in daemon mode:

R CMD Rserve --no-save --RS-enable-remote

Systemd

Create a systemd file.

cd /etc/systemd/system
sudo nano rserve.service

Add the following content to the rserve.service file:

[Unit]
Description=Rserve daemon

[Service]
User = bao-admin
ExecStart=/usr/bin/R CMD Rserve --no-save

Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

Enable the service on startup and start the service.

sudo systemctl daemon-reload
sudo systemctl enable rserve
sudo systemctl start rserve