给实验室服务器更新debian,R和Rstudio

59

1. 服务器debian升级

由于最新版rstudio server需要debian10,而服务器是debian9。因此给服务器升级一下

lsb_release -a
# -------
# No LSB modules are available.
# Distributor ID:	Debian
# Description:	Debian GNU/Linux 9.9 (stretch)
# Release:	9.9
# Codename:	stretch
# -------
uname -mrs
# -------
# Linux 4.9.0-9-amd64 x86_64
# -------
cat /etc/os-release #查看服务器版本,可以看到是debian9
# -------
# PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
# NAME="Debian GNU/Linux"
# VERSION_ID="9"
# VERSION="9 (stretch)"
# ID=debian
# HOME_URL="https://www.debian.org/"
# SUPPORT_URL="https://www.debian.org/support"
# BUG_REPORT_URL="https://bugs.debian.org/
# -------
apt-get update && apt-get upgrade #更新系统到最新
cd /etc/apt
cp sources.list sources.list.bak3.debian9.20230107 #备份一下实验室之前的sources.list
# 因为在更新的时候有很多抱错,所以我更新了实验室服务器的sources.list到阿里云的源
apt-get update && apt-get upgrade # 很成功,没有报错
sudo apt full-upgrade
# ---------
# # 实验室服务器的源,保存为sources.list.bak3.debian9.20230107.labused
# deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
# deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
# deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security stretch/updates main contrib non-free
# deb https://mirrors.tongji.edu.cn/CRAN/bin/linux/debian stretch-cran35/
# deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu stretch stable
# deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian stretch stable
# # 阿里云的debian9源,链接是https://developer.aliyun.com/mirror/
# deb https://mirrors.aliyun.com/debian/ stretch main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ stretch main non-free contrib
# deb https://mirrors.aliyun.com/debian-security stretch/updates main
# deb-src https://mirrors.aliyun.com/debian-security stretch/updates main
# deb https://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
# # 阿里云的debian10源
# deb https://mirrors.aliyun.com/debian/ buster main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ buster main non-free contrib
# deb https://mirrors.aliyun.com/debian-security buster/updates main
# deb-src https://mirrors.aliyun.com/debian-security buster/updates main
# deb https://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
# deb https://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
# ---------
lsb_release -a
# -------------
# No LSB modules are available.
# Distributor ID:	Debian
# Description:	Debian GNU/Linux 9.13 (stretch)
# Release:	9.13
# Codename:	stretch
# -------------
apt --purge autoremove
reboot
cp sources.list.bak4.debian10.20230107 sources.list
apt-get update && apt-get upgrade -y#再次更新系统
sudo apt full-upgrade #升级系统q
sudo reboot
sudo apt --purge autoremove
# 更新完毕 看看效果
lsb_release -a
# No LSB modules are available.
# Distributor ID:	Debian
# Description:	Debian GNU/Linux 10 (buster)
# Release:	10
# Codename:	buster
uname -mrs
# Linux 4.19.0-23-amd64 x86_64 #比我云服务器版本都新了
cat /etc/os-release
# PRETTY_NAME="Debian GNU/Linux 10 (buster)"
# NAME="Debian GNU/Linux"
# VERSION_ID="10"
# VERSION="10 (buster)"
# VERSION_CODENAME=buster
# ID=debian
# HOME_URL="https://www.debian.org/"
# SUPPORT_URL="https://www.debian.org/support"
# BUG_REPORT_URL="https://bugs.debian.org/"

2. 安装rstudio-server

sudo apt-get install r-base
sudo apt-get install gdebi-core
wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2022.12.0-353-amd64.deb
sudo gdebi rstudio-server-2022.12.0-353-amd64.deb
# 安装成功,简直太丝滑了
# 现在可以通过http://10.10.81.248:8787/访问
# 我在我自己的账户下用conda建了一个R环境,然后修改以下文件
vim /etc/rstudio/rserver.conf
# -----
# # Server Configuration File
# rsession-which-r=/home/caigui/miniconda3/envs/R/bin/R
# rsession-ld-library-path=/home/caigui/miniconda3/envs/R/lib
# -----
# 这样rstuido登陆就可以用这个环境下的R包了
# 这样就可以使用服务器上的rstuio server处理单细胞数据了
# ps:经过实践,使用我自己的用户登陆的时候可以正常安装R包,其它用户就没试了,有问题再说吧。

3. 20241010update:升级rstudio-server的R版本

# 不要在旧的r版本的conda环境中更新r,特别慢,慢到成功不了!
# 最快的是,创建个新环境安装新版本r,并需要修改上面/etc/rstudio/rserver.conf文件
# 修改后如下
# Server Configuration File
rsession-which-r=/home/caigui/mambaforge/envs/r4.4/bin/R
rsession-ld-library-path=/home/caigui/mambaforge/envs/r4.4/lib
# 修改后使用如下命令重启服务后,远程连接即可使用新版本r
sudo systemctl restart rstudio-server
# 注,修改镜像源直接在lab服务器登陆我的账号,修改文件如下即可
vim ~/.Rprofile 
options(BioC_mirror="https://mirrors.pku.edu.cn/bioconductor")
options(repos = c(CRAN="https://mirrors.pku.edu.cn/CRAN/"))

4. rstudio-server的R安装软件

登陆rstudio-server后安装各种不成功,但在linux中使用mamba安装就还好,……

5. 20241024update: 升级rstudio-server

https://posit.co/download/rstudio-server/

更新r到4.4后,旧版的rstudio-server因为版本太老,不能正确显示Plotss面板。 最新版rstudio-server只提供了debian11和debian12的下载链接,而我的服务器是debian10。 决定先不升级服务器,而是从源头构建Build from source

  • 源头构建,失败
# 查看自己debian版本
lsb_release -a #debian10
# 目前rstudio-server版本
# 2022.12.0 Build 353


# 下载最新版
# https://posit.co/download/rstudio-server/  —————— Build from source
wget https://github.com/rstudio/rstudio/tarball/v2024.09.0+375
tar -zxvf v2024.09.0+375

cd ~/rstudio/rstudio-rstudio-c8fc7ae
mkdir build
cd build
cmake .. -DRSTUDIO_TARGET=Server -DCMAKE_BUILD_TYPE=Release
# 报错,未解决
  • debian10 upgrad to debian11
# debian10 升级 debian11
lsb_release -a
# No LSB modules are available.
# Distributor ID:	Debian
# Description:	Debian GNU/Linux 10 (buster)
# Release:	10
# Codename:	buster

# 更新debian10到debian11

# 删掉了这些老旧的源,否则一直导致下一步update和upgrade报错
sudo rm /etc/apt/sources.list.d/*

# 先更新debian10到debian10最新版
sudo apt-get update
sudo apt-get upgrade # 有一些报错,运行以下两行命令修复(删除一下)
sudo apt --fix-broken install
sudo apt autoremove
# 重新运行upgrade
sudo apt-get upgrade
sudo apt full-upgrade

# 更换源文件
cd /etc/apt
# 备份旧的
cp sources.list sources.list.debian10.20241024
# 建立新的
rm sources.list
vim sources.list 
# 粘贴进https://developer.aliyun.com/mirror/ 的debian11 bullseye文件

# 升级debian11
sudo apt-get update
sudo apt full-upgrade # 升级过程比较漫长,蓝屏时需要点下回车键

# clear
sudo apt --purge autoremove
# 更新完毕 看看效果
lsb_release -a
uname -mrs
cat /etc/os-release
# No LSB modules are available.
# Distributor ID:	Debian
# Description:	Debian GNU/Linux 11 (bullseye)
# Release:	11
# Codename:	bullseye
# Linux 5.10.0-33-amd64 x86_64
# PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
# NAME="Debian GNU/Linux"
# VERSION_ID="11"
# VERSION="11 (bullseye)"
# VERSION_CODENAME=bullseye
# ID=debian
# HOME_URL="https://www.debian.org/"
# SUPPORT_URL="https://www.debian.org/support"
# BUG_REPORT_URL="https://bugs.debian.org/"
# (base)
  • 下载最新版rstudio-server并安装
sudo apt-get install r-base
sudo apt-get install gdebi-core

wget https://download2.rstudio.org/server/focal/amd64/rstudio-server-2024.09.0-375-amd64.deb

sudo gdebi rstudio-server-2024.09.0-375-amd64.deb
sudo systemctl restart rstudio-server
# 更新成功,plot也可以用了