SAP Analytics Cloud(formerly SAP BusinessObjects Cloud) provides the ability to embed an R visualization in a story to enhance the insights available to the business user.
This blog will cover how to setup R-Server on Linux for use with SAP Analytics Cloud. The setup involves the following steps:
- Install gcc, openssl, and R on Linux
- Generate ssl certificate
- Install and configure RServ package
- Setup RServe in SAP Analytics Cloud
- Add additional R packages
Step 1: Install gcc, openssl and R
This step is different depending upon what version of Linux flavor is being used. I’ve documented the steps for Suse12 x86_64 version. Check the version of your Linux distribution using command relevant for your OS.
First step is to find the version of gcc corresponding to your Linux version. To find your version of gcc:
- Open the following URL in a browser window: http://download.opensuse.org/repositories/devel:/gcc/
- Make note of the entry that matches Linux version you are using. In my case, the version of Suse is SLE-12.
- Run the commands below one at a time. Substitute <version> with your Linux version.
zypper ar http://download.opensuse.org/repositories/devel:/gcc/<version>/ devel-gcc
If prompted to trust the key, choose option ‘a’
Note: If there are any error prompts like the one below, choose option ‘i’ to ignore the errors.
zypper install gcc
- Find your version from http://download.opensuse.org/repositories/devel:/languages:/R:/released/
- Run the following commands in your Linux console one at a time. Substitute <version> with the Linux version you are using. In my example the <version> is SLE_12_SP1.
zypper addrepo -f http://download.opensuse.org/repositories/devel:/languages:/R:/released/<version> R-base
zypper install R-base R-base-devel
- Run the following commands in Linux console:
zypper install openssl
zypper install openssl-devel
Step 2: Generate SSL Certificates
- Navigate to /tmp or a directory of your choice.
- Run the following commands:
openssl genrsa -out Rserve.key 2048
openssl req -new -key Rserve.key -out Rserve.csr
When you create the CSR you will need to enter some information for the certificate, everything is optional.
openssl x509 -req -days <numdays> -in Rserve.csr -signkey Rserve.key -out Rserve.crt
Replace <numdays> with the number of days for eg: 365
- Save the Rserve.crt file to your local computer (or copy all the text). You will need to import this file in SAP Analytics Cloud later.
Step 3: Install and configure RServ package
Create RServe config file
- Make the workspace directory which will be /tmp/Rserv/workspace.
- Create a file called Rserv.conf under /etc directory using vi or other text editor with the following contents:
qap disable 6311
Note: The config is customizable if desired. Here are what the options mean:
workdir: directory for temp files in R to be created and used.
remote: whether you need remote access. This must be ‘enable’ to be used in SAP Analytics Cloud
auth: whether the username / password fields will be checked. ‘required’ is recommended
plaintext: use plaintext when passing credential information. ‘disable’ is highly recommended
port: default port for non-encrypted connection. Default is 6311.
maxsendbuf: maximum send buffer size. 0 is the default and it means unlimited.
tls.key: path to the key
tls.cert: path to the certificate
tls.port: port for an encrypted connection
We use ‘qap disable’ to disable the normal un-encrypted port(6311 in this case). Remove this if you want to use it.
- Run the R shell using the command below:
- In the R shell run the commands below to Install Rserve
Running ‘install.packages(“Rserve”)’ prompts you to chose a mirror for download. Choose the closest geographical location for best results.
Use q() to close the R shell
Create secondary user
It’s good idea to create a secondary user with less privileges to run Rserve to minimize the damage that can be done by a malicious user.
Create a new Linux user and set the password. We will use the user/password in Step 4 later. Choose any that you like but they must be consistent with the followed steps.
After closing the R shell run the following commands:
<create a password through the prompts>
Give the user access to the workspace folder. To run R in SAP Analytics Cloud we require some temporary files to be created so this user needs to be able to write to the work directory (ie. /tmp/Rserv/workspace)
Run the commands below:
chown -R <someuser> workspace
We also want to restrict the user from accessing the authentication keys. Run the command below to change security setting on the folder:
chmod -R 700 CA
We can now change Rserve configuration so that the commands execute as the restricted user we just created. Run the command below to gid and uid numbers for the user we created.
Make note of the gid and uid (numbers)
Edit the /etc/Rserv.conf file and add the following lines:
Run the command below to start RServe
R CMD Rserve
Step 4: Setup R-server in SAP Analytics Cloud
We are not ready to configure SAP Analytics Cloud to use the R-Server.
- Log into SAP Analytics Cloud
- Choose System >> Administration option
- Edit(pencil icon in the top right) the RServe configuration:
host: <hosname or IP address of R server machine>
certificate: <paste your certificate(from step 2), or upload the saved certificate file>
username: <Linux user running RServe. See step 3>
password: <Password for Linux user running RServe. See step 3>
- Click “Check Configuration” to verify a connection can be made.
- If the verification step is successful, save the connection.
Step 5: Add additional R packages
Once the connection is successful we can install the additional R packages required for SAP Analytics Cloud. Specifically we will Install “ggplot2”, “jsonlite”, “bit64”, “data.table” packages.
If you used SUSE, we have to install c++, which is required for ggplot2.
- Run the command below to install c++
zypper in gcc-c++
- In Linux console type R to run the R shell.
- Type the following command:
install.packages(c(“ggplot2”, “jsonlite”, “bit64”, “data.table”))
- Restart Rserve after installing the packages using the steps below:
ps -ef | grep Rserve
kill <pid> (where pid is the process id for RServe)
- Run: R CMD Rserve
You are now ready to embed your R visualizations in your SAP Analytics Cloud story.
Q: Where do I install R-Server Installed?
A: The R-Server can be installed on-premise or in the cloud(AWS, Azure etc). If it’s installed on-premise, the R-Server port(6312 in my case) must be exposed to internet so that SAP Analytics Cloud can connect to it.
Q: Can I install the server in Windows instead of Linux?
A: At the moment on R-Server deployed on Linux is supported. While technically Windows installation is possible and may work, we haven’t tested this configuration internally.
Q: Will SAP provide a hosted R-Server ?
A: SAP doesn’t provide a hosted R-Server. We may look to provide this in the future.
Q: Can I choose other flavors of Linux or does the install have to be on Suse?
A: Yes, you can choose other Linux flavors like Redhat or Ubuntu. I will update the blog with detailed steps to install on these Linux distributions at later time.
Q: What versions of R are supported?
A: See table below for minimum supported versions. At the time of writing the R version that is installed using the steps above is 3.4.0.
Q: What R packages are supported?
A: We support R packages that output in svg or png format. Other output types(eg. html) are not supported.