Install Rstudio-server in CentOS release 6.10 (Final)
1. down load rstudio-server-rhel-1.2.5042-x86_64.rpm
2.sudo yum install rstudio-server-rhel-1.2.5042-x86_64.rpm
Resolving Dependencies
--> Running transaction check
---> Package rstudio-server.x86_64 0:1.2.5042-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================
Package Arch Version Repository Size
===============================================
Installing:
rstudio-server x86_64 1.2.5042-1 /rstudio-server-rhel-1.2.5042-x86_64 341 M
Transaction Summary
===============================================
Install 1 Package(s)
Total size: 341 M
Installed size: 341 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : rstudio-server-1.2.5042-1.x86_64 1/1
groupadd: group 'rstudio-server' already exists
rstudio-server start/running, process 91848
Verifying : rstudio-server-1.2.5042-1.x86_64 1/1
Installed:
rstudio-server.x86_64 0:1.2.5042-1
Complete!
3. edit /etc/rstudio/rserver.conf
rsession-which-r=/usr/local/bin/R
www-port=8787
4. 然后悲剧地发现R之前编译时没加--enable-R-shlib
$sudo rstudio-server verify-installation
25 Dec 2020 11:35:07 [rserver] ERROR Unable to find libR.so in expected locations within R Home directory /usr/local/lib64/R; LOGGED FROM: bool rstudio::core::r_util::{anonymous}::detectRLocationsUsingR(const string&, rstudio::core::FilePath*, rstudio::core::FilePath*, rstudio::core::config_utils::Variables*, std::string*, const string&) /var/lib/jenkins/workspace/IDE/open-source-pipeline/v1.2-patch/src/cpp/core/r_util/REnvironmentPosix.cpp:552
25 Dec 2020 11:35:08 [rserver] ERROR R shared library (/usr/local/lib64/R/lib/libR.so) not found. If this is a custom build of R, was it built with the --enable-R-shlib option?; LOGGED FROM: bool rstudio::core::r_util::{anonymous}::validateREnvironment(const EnvironmentVars&, const rstudio::core::FilePath&, std::string*) /var/lib/jenkins/workspace/IDE/open-source-pipeline/v1.2-patch/src/cpp/core/r_util/REnvironmentPosix.cpp:368
R shared library (/usr/local/lib64/R/lib/libR.so) not found. If this is a custom build of R, was it built with the --enable-R-shlib option?
5.之前的R装的包太多,不想破坏,于是安装同版本R到别的路径
./configure --enable-R-shlib --prefix=/xxx/xxx/tools/R/R-3.2.2
...
R is now configured for x86_64-pc-linux-gnu
Source directory: .
Installation directory: /xxx/xxx/tools/R/R-3.2.2
C compiler: gcc -std=gnu99 -g -O2
Fortran 77 compiler: gfortran -g -O2
C++ compiler: g++ -g -O2
C++ 11 compiler: g++ -std=c++0x -g -O2
Fortran 90/95 compiler: gfortran -g -O2
Obj-C compiler:
Interfaces supported: X11, tcltk
External libraries: readline
Additional capabilities: NLS
Options enabled: shared R library, shared BLAS, R profiling
Capabilities skipped: PNG, JPEG, TIFF, cairo, ICU
Options not enabled: memory profiling
Recommended packages: yes
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: you cannot build PDF versions of the R manuals
configure: WARNING: you cannot build PDF versions of vignettes and help pages
6.以为这样再make&make install就结束了? 太天真了. 意想不到的意外正在后面等着.
$make
...
installing 'sysdata.rda'
make[4]: Leaving directory `/xxx/xxx/install_log/R/R-3.2.2/src/library/tools'
Error in parse(n = -1, file = file, srcfile = NULL, keep.source = FALSE) :
invalid multibyte character in parser at line 35075
Error: unable to load R code in package 'tools'
Execution halted
这里的invalid multibyte character in parser at line 35075 来自于之前的一个软件的骚操作使用了GBK字符集, 所以正好由$export LANG="zh_CN.GBK" 触发了错误
后面换'干净'的terminal才正常:
conftest.c: In function 鈥榤ain鈥�:
conftest.c:4: warning: implicit declaration of function 鈥楯NI_CreateJavaVM鈥�
make[2]: *** [conftest.o] Error 1
make[2]: Leaving directory `/tmp/Rjavareconf.tGqgEM'
Unable to compile a JNI program
JAVA_HOME : /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.221.x86_64/jre
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /xxx/xxx/install_log/R/R-3.2.2
Done.
验证:
$ls tools/R/R-3.2.2
bin lib64 share
$ tools/R/R-3.2.2/bin/R
R version 3.2.2 (2015-08-14) -- "Fire Safety"
...
> .libPaths()
[1] "/xxx/xxx/tools/R/R-3.2.2/lib64/R/library"
> q('no')
遗留问题: 因为之前R是装在/usr/local/bin/R, 这导致无法通过$export PATH=$PATH:/xxx/xxx/R/R-3.2.2/bin 使用新安装的
--
ok,到这里为止, R重新装好了.
重新配置rstudio-server后, rstudio-server test-config , rstudio-server verify-installation 都没问题.
然后sudo rstudio-server start 就rstudio-server start/running, process 132020, 和sudo rstudio-server status输出的一样.
--
然后配置防火墙
sudo /etc/init.d/iptables status
Table: nat
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination
1 DOCKER all -- 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT)
num target prot opt source destination
1 MASQUERADE all -- 172.17.0.0/16 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
1 DOCKER all -- 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL
Chain DOCKER (2 references)
num target prot opt source destination
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 DOCKER all -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
5 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
Chain DOCKER (1 references)
num target prot opt source destination
可以看到分nat和filter 两部分.
$sudo iptables -I INPUT -p tcp --dport 8787 -j ACCEPT
$sudo service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
--
sudo /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
--
$sudo iptables -I INPUT -p tcp --dport 8787 -j ACCEPT
--
$sudo /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8787
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 REJECT all -- 0.0.0.0/0