centos AWS shiny server wont resolve - r

Set up using AWS instance running centOS 6.4 with R and shiny server using my Macbook and trying to figure out what is wrong with it as there are issues with this process
# set up AWS Redhat 6.4 instance (dont forget to download .pem)
# set the .pem file into your ~/.ssh/ folder and make sure you chmod the file
chmod 400 ~/.ssh/myshinypemexample.pem
ssh into machine
ssh -i ~/.ssh/myshinypemexample.pem root#yourPublicDNS
# the first time you run this, just press yes, don't be scared :)
# use ec2-user and log into machine
ssh -i ~/.ssh/myshinypemexample.pem ec2-user#yourPublicDNS
Get the EPEL rpm
wget http://mirror.us.leaseweb.net/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm --test
Import the EPEL GPG key
wget https://www.fedoraproject.org/static/0608B895.txt
sudo mv 0608B895.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Verify that the key has been imported.
rpm -qa gpg*
## You should see a line like this: gpg-pubkey-0608b895-4bd22942
Install the rpm
sudo rpm -ivh epel-release-6-8.noarch.rpm
Install shiny server
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
# this gives error and have to install Rcpp and httr manually
wget http://cran.r-project.org/src/contrib/Rcpp_0.11.1.tar.gz
sudo R CMD INSTALL --build Rcpp_0.11.1.tar.gz
wget http://cran.r-project.org/src/contrib/httpuv_1.2.3.tar.gz
sudo R CMD INSTALL --build httpuv_1.2.3.tar.gz
run shiny server again
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
Install Shiny Server
wget http://download3.rstudio.org/centos-5.9/x86_64/shiny-server-1.0.0.42-x86_64.rpm
sudo yum install --nogpgcheck shiny-server-1.0.0.42-x86_64.rpm
# test server
sudo status shiny-server
check location of example shiny app
sudo R -e "system.file('examples/01_hello', package='shiny')"
[1] "/usr/lib64/R/library/shiny/examples/01_hello"
#copy example file from R to /srv as Shiny looks for this location to work
sudo cp -R /usr/lib64/R/library/shiny/examples/01_hello /srv/shiny-server/
MYIP:3838 does not resolve. Why?

Related

Python symbol lookup error when running PyODBC and MySQL in a Docker container. What to do?

I am trying to connect to a MySQL database using PyODBC in a Docker container. When I run the script it gives the error python: symbol lookup error: /usr/local/lib/private/libssl.so.1.1: undefined symbol: EVP_idea_cbc, version OPENSSL_1_1_0.
This is my Dockerfile:
# syntax=docker/dockerfile:1
FROM python:3.10
WORKDIR /app
COPY requirements.txt requirements.txt
ARG PYPI_USERNAME
ARG PYPI_PASSWORD
# Install PyODBC requirements
RUN apt-get update && \
apt-get -y install g++ unixodbc-dev openssl
# Install MySQL ODBC driver
ADD https://dev.mysql.com/get/Downloads/Connector-ODBC/8.0/mysql-connector-odbc-8.0.26-linux-glibc2.12-x86-64bit.tar.gz .
RUN tar -C . -xzvf mysql-connector-odbc-8.0.26-linux-glibc2.12-x86-64bit.tar.gz
RUN cp -r mysql-connector-odbc-8.0.26-linux-glibc2.12-x86-64bit/bin/* /usr/local/bin
RUN cp -r mysql-connector-odbc-8.0.26-linux-glibc2.12-x86-64bit/lib/* /usr/local/lib
RUN myodbc-installer -a -d -n "MySQL ODBC 8.0 Driver" -t "Driver=/usr/local/lib/libmyodbc8w.so"
RUN myodbc-installer -a -d -n "MySQL ODBC 8.0" -t "Driver=/usr/local/lib/libmyodbc8a.so"
# Run pip as a python module to access environment variables in requirements.txt
RUN python -m pip install --no-cache-dir -r requirements.txt
COPY . .
CMD python script.py
After some research it seems to me that the issue stems not from Python but from my libraries being messed up for some reason. I tried installing openssl using apt-get but to no avail. I am at a loss as to how to proceed as this is really not my forte. Any help would be greatly appreciated!

Azure container - simple R plumber deployment question?

I am deploying simple plumber API in Azure container which executes simple SQL query and returns results. Here is my Dockerfile.
# start from the rocker/r-ver:4.0.2 image
# minor change to one branch to test deployment
FROM rocker/r-ver:4.0.2
# install the linux libraries needed for plumber
RUN apt-get update -qq && apt-get install -y \
libssl-dev \
libcurl4-gnutls-dev \
libsodium-dev \
unixodbc-dev \
r-cran-rodbc \
curl\
libxml2-dev
# libiodbc2-dev
# We need to update Dockerfile to install ODBC Driver 17 for SQL Server for
# Ubuntu 20.04 or different version
# here is link: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#ubuntu17
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17
RUN ACCEPT_EULA=Y apt-get install -y mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
# RUN source /etc/bash.bashrc
RUN mkdir -p ~/application
# copy everything from the current directory into the container
COPY "/" "application/"
# I probably do not even have to set up WORKDIR
WORKDIR "application/"
# open port 80 to traffic
EXPOSE 80
# install plumber
RUN R -e "install.packages('plumber')"
RUN R -e "install.packages('renv')"
RUN R -e "install.packages('RODBC')"
RUN R -e 'renv::restore()'
# when the container starts, start the main.R script
ENTRYPOINT ["Rscript", "execute_plumber.R"]
API works fine. However, when I connect to container, run R and execute library(RODBC) I get back error about library not found. This is puzzling since it is already mentioned in Dockerfile, but maybe it has something to do with renv. I proceed with installation install.packages('RODBC') and it generates error which I can fix by running apt-get install unixodbc-dev and apt-get install r-cran-rodbc. Those lines are again already present in Dockerfile. Then when I try to connect to SQL server I get error about driver. And again I can fix it by re-executing lines from Dockerfile (related to SQL Server 17 driver).
So I am puzzled why I need to re-execute some items already present in Dockerfile. Or maybe when I click "Connect" in Azure it actually connects me to host and not to container?

Starting container process caused \”exec: \\\”R\\\”: executable file not found in $PATH\”: unknown”}

I installed shinyproxy using docker-compose.
When going to my shiny app, I am running into the error:
Status code: 500
Message: Failed to start container
and when checking into error message I see:
starting container process caused \"exec: \\"R\\": executable file not found in $PATH\": unknown"}
I am not sure to understand what it means.
In case that helps, the last lines of my Shiny Dockerfile are:
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/root/app')"]
and in my application.yml the container-cmd line is
container-cmd: ["R", "-e", "shiny::runApp('/root/app')"]
Do you see any wrong spelling?
Also as an FYI but don't know if that's useful information, I noticed that:
- There is no R folder in my folder: /usr/lib
- And there is no R folder in /usr/bin/.
And I don't understand why.
Thanks for your help !
EDIT1:
I just installed R and now I see R in the /usr/bin/ folder but still nothing in /usr/lib and still same error message.
EDIT2:
I don't understand one thing, I see the R packages being installed in /usr/local/lib/R BUT
I see nothing in this folder after docker-compose up is done:
$ cd /usr/local/lib
$ ls
$
EDIT3:
As requested, I attach below the Dockerfile for my RStudio container and the Dockerfile for Shiny container:
RStudio Dockerfile:
FROM rocker/tidyverse:3.6.1
## Create directories
RUN mkdir -p /rstudio
RUN mkdir -p /rscripts
RUN R -e "install.packages(c('rvest','shiny','DT', 'digest', 'RCurl', 'caTools', 'bitops', 'httr', 'curl', 'stringr', 'mailR', 'xlsx', 'knitr', 'kableExtra' ,'rmarkdown', 'data.table', 'RSelenium'), repos = 'http://cran.us.r-project.org')"
Shiny Dockerfile:
FROM rocker/shiny:3.5.1
RUN apt-get update && apt-get install libcurl4-openssl-dev libv8-3.14-dev -y &&\
mkdir -p /var/lib/shiny-server/bookmarks/shiny &&\
mkdir -p /root/app
# Download and install library
RUN R -e "install.packages(c('mailR', 'shinydashboard', 'shinyjs', 'V8', 'DT', 'shiny', 'rvest', 'dplyr', 'htmltools', 'promises', 'jsonlite', 'data.table', 'rlang', 'xml2', 'digest', 'XML','rmarkdown'))"
# copy the app to the image
COPY app /root/app
COPY Rprofile.site /usr/local/lib/R/etc
# make all app files readable (solves issue when dev in Windows, but building in Ubuntu)
RUN chmod -R 755 /root/app
RUN chmod -R 755 /usr/local/lib/R/etc
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/root/app')"]

Shiny server installation on REHL 7 AWS

I followed these commands to install R and Shiny server on REHL 7 AWS.
sudo yum update
yum install wget gcc pcre-devel libXt-devel cairo-devel pango-devel
pango libpng-devel curl-devel unixODBC-devel python-devel java-1.8.0-
openjdk-devel xz-devel
yum groupinstall "Development tools"
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make -f Makefile-libbz2_so
make clean
make
make -n install
make install
cd ~
wget https://cran.r-project.org/src/base/R-3/R-3.3.2.tar.gz
tar -xzvf R-3.3.2.tar.gz
cd R-3.3.2
./configure --with-readline=no --with-x=no
make
make install
cp -r /usr/local/bin/R /usr/local/sbin/R
cp -r /usr/local/bin/Rscript /usr/local/sbin/Rscript
--Installing R packages
R
install.packages(c('shiny', 'rmarkdown', 'Cairo', 'png', 'rJava',
'RCurl'))
--Changing folder permissions
chmod 777 -R /usr/local/bin
chmod 777 -R /usr/local/sbin
chmod 777 -R /usr/local/lib64/R
chmod 777 -R /usr/local/lib64/R/library
chmod 777 /usr/local/lib64/R/etc/ldpaths
--shiny server installation
wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-
1.5.1.834-rh5-x86_64.rpm
sudo yum install --nogpgcheck shiny-server-1.5.1.834-rh5-x86_64.rpm
R CMD javareconf
chmod 777 /usr/local/lib64/R/etc/ldpaths
Everything ran fine with some warnings. But the shiny-server.service file is missing. When I try to execute
systemctl restart shiny-server
it says: Failed to restart shiny-server.service: Unit not found.
I also tried installing the newer version of R (3.4.1) and Shiny server(shiny-server-1.5.3.838-rh5-x86_64.rpm) but I am still getting the same error. This is the message I got when I installed shiny server:
/var/tmp/rpm-tmp.kIBODd: line 62: initctl: command not found
/var/tmp/rpm-tmp.kIBODd: line 65: initctl: command not found
Verifying : shiny-server-1.5.1.834-1.x86_64
1/1
Installed:
shiny-server.x86_64 0:1.5.1.834-1
Also I noticed that shiny-server.service is missing in /etc/systemd/system folder. Has anyone resolved this or knows how to resolve this?
I had the same problem.
As suggested in https://github.com/rstudio/shiny-server/issues/316,
entering these three lines manually solved it for me:
sudo cp /opt/shiny-server/config/systemd/shiny-server.service /etc/systemd/system/
sudo systemctl enable shiny-server
sudo systemctl restart shiny-server

R studio not working on ubuntu 16.04

I converted to Ubuntu today, but have a problems launching R studio. I installed R through the command prompt like this:
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/">> /etc/apt/sources.list'
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install r-base
I cheked if R was installed proper by typing R and then exiting by q(save="no").
I installed R studio through the command prompt by
sudo apt-get install gdebi-core
wget https://download2.rstudio.org/rstudio-server-0.99.902-amd64.deb
sudo gdebi rstudio-server-0.99.902-amd64.deb
But this doesn't work and i can't find the launch button or open R studio.
Afterwards i tried to remove it and install it through the website but doesn't work either. What should i do?
There is no lauch button -- you connect to port 8787 on the machine running RStudio Server.
In other words, type http://localhost:8787 in the address bar of your browser. You should see a login screen with the RStudio logo. This connects you to your RStudio Server.
If you want to run the Desktop version you need to install the other available .deb package.
For those on Ubuntu 16.10, or who prefer to use the desktop version of RStudio, you may wish to follow the solution posted by Mike Williamson reproduced below:
1) Get the latest R Studio Daily Build here, though note that it's not necessarily stable.
2) Install, chaning the name of the package to the one you downloaded - perhaps easiest if you go to your Downloads directory - and you'll probably find that there are missing packages:
$ sudo dpkg -i rstudio-1.0.124-amd64.deb
3) Download the missing packages (the lack of which causes the installation to fail):
$ wget http://ftp.ca.debian.org/debian/pool/main/g/gstreamer0.10/libgstreamer0.10-0_0.10.36-1.5_amd64.deb
$ wget http://ftp.ca.debian.org/debian/pool/main/g/gst-plugins-base0.10/libgstreamer-plugins-base0.10-0_0.10.36-2_amd64.deb
4) Install them:
$ sudo dpkg -i libgstreamer0.10-0_0.10.36-1.5_amd64.deb
$ sudo dpkg -i libgstreamer-plugins-base0.10-0_0.10.36-2_amd64.deb
5) Make sure they don't get over-written at the next software update:
$ sudo apt-mark hold libgstreamer-plugins-base0.10-0
$ sudo apt-mark hold libgstreamer0.10
6) Install RStudio (changing name to the version you downloaded):
sudo gdebi rstudio-1.1.5-amd64.deb
7) Launch RStudio:
rstudio

Resources