SAP Analytics Cloud (formerly known as SAP BusinessObjects Cloud) provides the ability to embed an R visualization in a story to enhance 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:
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:
useradd <someuser> passwd <someuser>
<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:
cd /tmp/Rserv 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
Optional step to improve performance
To improve performance of R script execution, create a Rprofile and include the libraries that you use in your Rscript in the file. This will pre-load the libraries that you use most.
sudo su ruser
Add the libraries you use in your script in the .Rprofile and save the file. For eg:
Kill and Restart Rserve process
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.
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 provides R-Server for tenants in US1, US2, EU1, and AP1. Check here for updates and also to get a list of supported packages in hosted R environment.
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, png or html format.