잡다한 IT

Linux (CentOS 7), R / Rserve 설치하기

ssamhago 2023. 3. 30. 14:06
728x90
320x100

R

 

R 설치하기

yum 툴을 사용하여 R설치를 진행할 수 있다.

# yum install R

 

 

설치완료 후, R명령을 입력하여 R 콘솔을 실행 할 수 있다.

# R

R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_MONETARY failed, using "C"
6: Setting LC_PAPER failed, using "C"
7: Setting LC_MEASUREMENT failed, using "C"

 

 

Rserve 설치하기
# install.packages('Rserve' , , 'http://www.rforge.net/')

※ 설치도중에 "cannot find -lssl"  에러가 발생된다면,  openssl-devel 를 설치하고 에러가 발생하지 않는다면
그냥 넘어가면 된다.  ( # yum install openssl-devel )

 

 

설치가 완료되면 R콘솔에서 Rserve를 실행한다.

> library(Rserve)
> Rserve()

Starting Rserve:
/usr/lib64/R/bin/R CMD /usr/lib64/R/library/Rserve/libs//Rserve

R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_MONETARY failed, using "C"
6: Setting LC_PAPER failed, using "C"
7: Setting LC_MEASUREMENT failed, using "C"
Rserv started in daemon mode.
>
>

 

 

원격 호출을 사용하려면 설정 추가가 필요하다.

/etc 폴더로 이동후 vi 명령어를 통해 "Rserv.conf" 파일을 생성하고, 내용은 다음과 같이 구성한다.

# vi Rserv.conf
remote enable
port 6311
plaintext enable
auth required
pwdfile /etc/Ruser.txt
encoding utf8

 

 

/etc/Ruser.txt ( userid / userpw  계정을 추가한다.)

# vi Ruser.txt
userid userpw

 

 

외부에서 6311 포트 사용을 위해 방화벽 작업으로 접속을 허용해야 한다.

# firewall-cmd --permanent --zone=public --add-port=6311/tcp
# firewall-cmd --reload

 

 

Rserve 의 구성이 바뀌었으므로, 프로세스를 kill 하고 다시 실행해야 한다.

# ps -ef | grep Rserve

root  23819          1  0 13:38 ? 00:00:00 /usr/lib64/R/library/Rserve/libs//Rserve
root  24966  30888  0 13:57 pts/2 00:00:00 grep --color=auto Rserve

# kill -9 23819

 

 

R콘솔에서 Rserve를 실행한다.

> library(Rserve)
> Rserve(port=6311, args="--RS-conf /etc/Rserv.conf --no-save")

Starting Rserve on port 6311 :
/usr/lib64/R/bin/R CMD /usr/lib64/R/library/Rserve/libs//Rserve --RS-conf /etc/Rserv.conf --no-save --R S-port 6311

R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_MONETARY failed, using "C"
6: Setting LC_PAPER failed, using "C"
7: Setting LC_MEASUREMENT failed, using "C"
Rserv started in daemon mode.
>
>

 

 

※ 참고블로그 : https://andang72.blogspot.com/2019/02/r.html

728x90
반응형