云服务器上青岛oj的安装

这是我搭建好的oj:NYIST_ACM_OJ

获取root权限

sudo passwd root   #然后输入密码
su root 

更换源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份源文件
sudo vim /etc/apt/sources.list #将里面的内容随便用下面一个代替
##163的加速源
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
#deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
#deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
#deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
#deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
#deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
#deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
## 阿里云加速源
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
#deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
## 腾讯加速源
deb http://mirrors.cloud.tencent.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.cloud.tencent.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.cloud.tencent.com/ubuntu/ xenial-updates main restricted universe multiverse
#deb http://mirrors.cloud.tencent.com/ubuntu/ xenial-proposed main restricted universe multiverse
#deb http://mirrors.cloud.tencent.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial-updates main restricted universe multiverse
#deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial-proposed main restricted universe multiverse
#deb-src http://mirrors.cloud.tencent.com/ubuntu/ xenial-backports main restricted universe multiverse

sudo apt-get update  #更新源

安装相关软件

sudo apt-get update && sudo apt-get install -y vim python-pip curl git

pip install docker-compose

sudo curl -sSL https://get.daocloud.io/docker | sh #安装docker

更换docker镜像

sudo vim /etc/docker/daemon.json #新建文件,加入以下内容
###
{
     
    "registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
}
###
#重启守护进程
sudo systemctl daemon-reload
sudo systemctl restart docker

安装OJ

#到空间大的位置,我放在root家目录下
git clone -b 2.0 https://github.com/QingdaoU/OnlineJudgeDeploy.git && cd OnlineJudgeDeploy#克隆代码

docker-compose up -d #启动服务,在root用户下运行

安装ssh

sudo apt-get update
sudo apt-get install openssh-server
gedit /etc/ssh/ssh_config
#注释掉 PermitRootLogin without-password
#加入 PermitRootLogin yes
service ssh start #启动

ps:使用ssh软件连接服务器,即可远程访问。
云服务器上青岛oj的安装_第1张图片

可能出现的问题

docker-compose up解决错误ERROR: Couldn’t connect :参考博客

ps:根据网速情况,大约5到30分钟就

可以自动搭建完成,全程无需人工干预。

等命令执行完成,然后运行 docker ps -a,当看到所有的容器的状态没有 unhealthy 或者Exited (x) xxx 就代表 OJ 已经启动成功。

题库

  • 文件中已经收集了一些题

  • 免费下载题的网址:http://loj.ac

  • 可以购买题的网址:http://tk.hustoj.com/

  • 出题方法是将上面的提到的题,修改题面

  • 举办比赛可以去购买一些题,一元一道(划不来)

管理

  • 可以查看docker相关操作手册

    docker ps  #显示所有的容器
    docker stop name
    docker start name
    
    docker ps # 查看所有正在运行容器
    docker stop containerId # containerId 是容器的ID
    
    docker ps -a # 查看所有容器
    docker ps -a -q # 查看所有容器ID
    
    docker stop $(docker ps -a -q) #  stop停止所有容器
    docker  rm $(docker ps -a -q) #   remove删除所有容器
    
    sudo /etc/init.d/nginx stop #停止nginx
    #强制停止
    sudo ps -ef | grep nginx  # 查询nginx PID 此处为28444
    #sudo netstat -a | grep 28444
    sudo kill -quit 28444 #关闭nginx
    
    sudo /etc/init.d/nginx start #启动ngnix
    

导入旧版本数据

  • zip的测试数据包移动到OnlineJudgeDeploy/data/backend/test_case下解压

    unzip   testcase.zip  #解压
    
  • 制old_json到某一目录(root权限)

    docker cp old_data.json oj-backend:/app/utils/ 
    docker exec -it oj-backend /bin/sh
    cd utils
    python3 migrate_data.py old_data.json
    

这是中文帮助文档:

here

你可能感兴趣的:(#,招新,#,Ubuntu,#,虚拟机,oj)