问题:想在借用的服务器上安装Rstudio server(服务器安装了R4.2.0版本),但无管理员权限,并且也无权限执行 Docker 命令,只能选用Jupyter + R 内核方案。
步骤:
bash
# 安装 miniconda(用户空间)
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda
source ~/miniconda/bin/activate
# 创建环境
conda create -n r-env python=3.9
conda activate r-env
# 安装 Jupyter
conda install -c conda-forge jupyter -y
# 安装 R 内核
conda install -c conda-forge r-irkernel
R -e "IRkernel::installspec()"
# 启动 Jupyter
jupyter notebook --no-browser --port=8889
启动jupyter后,如果出现以下问题:
fail to get yarn configuration. /usr/bin/node: relocation error: /lib64/libnode.so.93: symbol FIPS_selftest, version OPENSSL_1_1_0g not defined in file libcrypto.so.1.1 with link time reference
原因:看起来是系统自带的`/usr/bin/node`(Node.js)与系统openssl库版本不兼容。
解决方式:使用conda安装的nodejs
bash
conda install -c conda-forge nodejs -y
重新启动Jupyter即可,Jupyter Notebook成功启动并正在运行后,以下为访问 Jupyter Notebook 的步骤:
1. 在您的本地电脑上创建 SSH 隧道 :
打开一个新的终端窗口(在您的本地电脑上,不是服务器上),运行:
bash
ssh -N -L 8889:localhost:8889 您的用户名@服务器IP地址 -p 端口号
例如:
bash
ssh -N -L 8889:localhost:8889 yanzijun@192.168.1.100 -p 13579
2. 在浏览器中访问 Jupyter :
打开您本地电脑上的浏览器,访问以下 URL(token在启动jupyter输出内容里):
http://localhost:8889/tree?token=9e44dc508cca5f7b57be9dfffe334093f0abbb6e36fa9ef0
注意:
不要关闭终端窗口 :服务器上的终端窗口(运行 Jupyter 的那个)必须保持打开状态,Jupyter 服务才能继续运行。如果您需要关闭终端但保持 Jupyter 运行,可以使用 nohup,
这样 Jupyter 会在后台运行,输出会保存到 jupyter.log
文件中。当完成工作后,在运行 Jupyter 的终端窗口中按Ctrl+C
一次则为停止服务,Ctrl+C
两次为强制停止。
bash
nohup jupyter notebook --no-browser --port=8889 > jupyter.log 2>&1 &