본문 바로가기
Biz/Analysis

RStudio Server: 서버 구성과 관리

by 조병희 2016. 7. 17.

RStudio 아래의 두개 파일 외에 딱히 설정 것이 없다.

/etc/rstudio/rserver.conf

/etc/rstudio/rsession.conf

설정 파일을 수정한 후에는 전체적으로 설정을 확인하기 위해 체크가 필요하다.

$ sudo rstudio-server verify-installation

네트워크 포트와 주소

기본적으로 RStudio 웹접속을 위해 8787 사용하는 이는 /etc/rstudio/rserver.conf 에서 www-port 설정이 가능하다.

www-port=80

By default RStudio binds to address 0.0.0.0 (accepting connections from any remote IP). You can modify this behavior using the www-address entry. For example:

www-address=127.0.0.1

Note that after editing the /etc/rstudio/rserver.conf file you should always restart the server to apply your changes (and validate that your configuration entries were valid). You can do this by entering the following command:

$ sudo rstudio-server restart

외부 라이브러리

You can add elements to the default LD_LIBRARY_PATH for R sessions (as determined by the R ldpaths script) by adding an rsession-ld-library-path entry to the server config file. This might be useful for ensuring that packages can locate external library dependencies that aren't installed in the system standard library paths. For example:

rsession-ld-library-path=/opt/local/lib:/opt/local/someapp/lib

R 버전 명시

By default RStudio Server runs against the version of R which is found on the system PATH (using which R). You can override which version of R is used via the rsession-which-r setting in the server config file. For example, if you have two versions of R installed on the server and want to make sure the one at /usr/local/bin/R is used by RStudio then you would use:

rsession-which-r=/usr/local/bin/R

Note again that the server must be restarted for this setting to take effect.

사용자 제한 설정

There are a number of settings which place limits on which users can access RStudio and the amount of resources they can consume. This file does not exist by default so if you wish to specify any of the settings below you should create the file.

To limit the users who can login to RStudio to the members of a specific group, you use the auth-required-user-group setting. For example:

auth-required-user-group=rstudio_users

추가 설정

There is a separate /etc/rstudio/rsession.conf configuration file that enables you to control various aspects of R sessions (note that as with rserver.conf this file does not exist by default). These settings are especially useful if you have a large number of potential users and want to make sure that resources are balanced appropriately.

세션 타임아웃

By default if a user hasn't issued a command for 2 hours RStudio will suspend that user's R session to disk so they are no longer consuming server resources (the next time the user attempts to access the server their session will be restored). You can change the timeout (including disabling it by specifying a value of 0) using the session-timeout-minutes setting. For example:

session-timeout-minutes=30

Note that a user's session will never be suspended while it is running code (only sessions which are idle will be suspended).

패키지 라이브러리 경로

By default RStudio sets the R_LIBS_USER environment variable to ~/R/library. This ensures that packages installed by end users do not have R version numbers encoded in the path (which is the default behavior). This in turn enables administrators to upgrade the version of R on the server without reseting users installed packages (which would occur if the installed packages were in an R-version derived directory).

If you wish to override this behavior you can do so using the r-libs-user settings. For example:

r-libs-user=~/R/packages

CRAN Repository

Finally, you can set the default CRAN repository for the server using the r-cran-repos setting. For example:

r-cran-repos=https://mirrors.nics.utk.edu/cran/

Note again that the above settings should be specified in the /etc/rstudio/rsession.conf file (rather than the aforementioned rserver.conf file).

 

시작과 종료

If you installed RStudio using a package manager binary (e.g. a Debian package or RPM) then RStudio is automatically registred as a deamon which starts along with the rest of the system. On Debian, Ubuntu, and RedHat/CentOS 6 this registration is performed using an Upstart script at /etc/init/rstudio-server.conf. On other systems including RedHat/CentOS 5 an init.d script is installed at /etc/init.d/rstudio-server.

To manually stop, start, and restart the server you use the following commands:

$ sudo rstudio-server stop

$ sudo rstudio-server start

$ sudo rstudio-server restart

세션 관리

There are a number of administrative commands which allow you to see what sessions are active and request suspension of running sessions (note that session data is not lost during a suspend).

To list all currently active sessions:

$ sudo rstudio-server active-sessions

To suspend an individual session:

$ sudo rstudio-server suspend-session <pid>

To suspend all running sessions:

$ sudo rstudio-server suspend-all

The suspend commands also have a "force" variation which will send an interrupt to to the session to request the termination of any running R command:

$ sudo rstudio-server force-suspend-session <pid>

$ sudo rstudio-server force-suspend-all

The force-suspend-all command should be issued immediately prior to any reboot so as to preserve the data and state of active R sessions accross the restart.

서버 오프라인과 온라인 변경

If you need to perform system maintenance and want users to receive a friendly message indicating the server is offline you can issue the following command:

$ sudo rstudio-server offline

When the server is once again available you should issue this command:

$ sudo rstudio-server online

버전 업그레이드

If you perform an upgrade of RStudio Server using a package manager binary (e.g. a Debian package or RPM) and a version of RStudio Server is currently running, then the upgrade process will also ensure that active sessions are immediately migrated to the new version. This includes the following behavior:

  • Running R sessions are suspended so that future interactions with the server automatically launch the updated R session binary
  • Currently connected browser clients are notified that a new version is available and automatically refresh themselves.
  • The core server binary is restarted

 

출처:

https://support.rstudio.com/hc/en-us/articles/200552316-Running-with-a-Proxy/

https://support.rstudio.com/hc/en-us/articles/200532327-Configuring-the-Server

 

'Biz > Analysis' 카테고리의 다른 글

계획구매와 비계획구매  (0) 2023.06.15
R에서 아스키문자(ascii)로 된 구분자 처리  (0) 2019.03.23
RStudio Server with a Proxy  (0) 2016.07.17
Shiny에서 SparkR 실행하기  (0) 2016.03.28
RStudio 에서 Spark 사용하기  (1) 2016.03.26

댓글