0%

本文参考CAS官方文档,版本号为6.4.x

简介

CAS 使用overlay template方式安装。根据官方文档的描述,overlay template有以下几点好处

  1. 无需下载源代码重头开始开始编译。
  2. 升级版本极其简单方便,只需要调整编译脚本依赖新的CAS版本。
  3. 无需管理整个CAS的源代码,只需要处理本地开发的代码逻辑,从而简化代码维护的工作。
  4. 再次,由于只需要关注本地代码逻辑的变更,而不用管理整个CAS的源码,从而减少了跟踪代码变更的工作量。

首先需要checkout CAS overlay template项目,此项目相当于CAS部署的模板,后续的配置修改开发工作均可基于本项目进行。

安装

首先需要checkout CAS overlay template项目,后续的开发配置工作均可基于本项目进行。

1
2
git clone https://github.com/apereo/cas-overlay-template.git
cd cas-overlay-template && git checkout -b 6.4 origin/6.4

修改src/main/resources下application.yml,添加以下内容禁用SSL认证,否则需要生成jks等秘钥文件

1
2
3
server:
ssl:
enabled: false

执行

1
./gradlew debug

下载依赖完成编译后会输出以下内容

1
2
3
Listening for transport dt_socket at address: 5005
...................................
2021-10-19 15:33:32,114 INFO [org.apereo.cas.web.CasWebApplication] - <Ready to process requests @ [2021-10-19T07:33:32.113Z]>

通过浏览器访问http://localhost:8443/cas/login,输入用户名casuser及密码Mellon登录成功。

useradd

The following command will add a user with name testuser. It will be added to sudo and root group. By default, its home folder will be created and its login shell is bash.

1
useradd -G sudo,root -m -s /bin/bash testuser

userdel

Files in testuser’s home directory will be removed with the home directory itself and its mail spool.

1
userdel -r testuser
1
awk -F="xx" '{print "xxxx " $1 "-" $2}'

本教程所有步骤均来源于OpenCV官网,由于系统环境版本等因素做了微小的改动。

首先安装依赖和编译器等

1
sudo apt update && sudo apt install -y build-essential cmake g++ wget unzip git

下载源码并解压

1
2
3
4
5
6
7
mkdir -p opencv && cd opencv
wget -O opencv.zip https://codeload.github.com/opencv/opencv/zip/4.5.1
wget -O opencv_contrib.zip https://codeload.github.com/opencv/opencv_contrib/zip/4.5.1
unzip opencv.zip
unzip opencv_contrib.zip
mv opencv-4.5.1 opencv
mv opencv_contrib-4.5.1 opencv_contrib

编译

1
2
3
mkdir -p build && cd build
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ../opencv
cmake --build .

自定义编译选项

上面使用的是官方默认的编译配置,OpenCV提供了众多编译选项,其中一些选项默认是开启的,一些是关闭的。具体内容可参考官方指南,由于我本机安装了MiniConda, CUDA和CUDNN等NVIDIA软件包进行GPU推理加速,所以我使用了如下配置。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-DOPENCV_ENABLE_NONFREE=ON \
-DWITH_CUDA=ON \
-DWITH_CUBLAS=ON \
-DWITH_CUDNN=ON \
-DWITH_NVCUVID=ON \
-DOPENCV_DNN_CUDA=ON \
-DENABLE_FAST_MATH=1 \
-DCUDA_FAST_MATH=1 \
-DBUILD_opencv_python3=ON \
-DHAVE_opencv_python3=ON \
-DPYTHON3_EXECUTABLE=$(which python3) \
-DPYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.5.2/modules ../opencv-4.5.2

其中WITH_CUDA, WITH_CUBLAS, OPENCV_DNN_CUDA等为开启CUDA, PYTHON3_XXX为设置python3环境,编译完成后opencv库将安装至python环境中,其他选项可参考官方文档中Deep learning段落。

输出如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
--   NVIDIA CUDA:                   YES (ver 11.4, CUFFT CUBLAS FAST_MATH)
-- NVIDIA GPU arch: 35 37 50 52 60 61 70 75 80 86
-- NVIDIA PTX archs:
--
-- cuDNN: YES (ver 8.2.1)
--
-- OpenCL: YES (no extra features)
-- Include path: /home/user/opencv/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /home/user/miniconda3/envs/yansi/bin/python3 (ver 3.8.13)
-- Libraries: /home/user/miniconda3/envs/yansi/lib/libpython3.8.so (ver 3.8.13)
-- numpy: /home/user/miniconda3/envs/yansi/lib/python3.8/site-packages/numpy/core/include (ver 1.23.0)
-- install path: /home/user/miniconda3/envs/yansi/lib/python3.8/site-packages/cv2/python-3.8

其中需要注意CUDA和cuDNN是不是YES,另外如果要在python中使用opencv的话,则需要注意python的配置是否正确

根据自己的CPU核心数量*2进行编译

1
2
make -j8
sudo make install

#重新加载动态链接库

1
sudo ldconfig

Install Docker Engine on Ubuntu

Uninstall old versions

1
sudo apt-get remove docker docker-engine docker.io containerd runc

Set up the repository

1
2
3
4
5
6
7
8
9
10
sudo apt-get update

sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Install

1
2
3
4
5
6
7
8
9
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

sudo usermod -aG docker $USER

Install Docker Compose

1
2
3
4
5
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

docker-compose --version

Add registry-mirrors and insecure-registry

1
sudo vi /etc/docker/daemon.json

Content

1
2
3
4
{
"registry-mirrors": ["https://registry.docker-cn.com"],
"insecure-registries" : ["myregistrydomain.com:5000"]
}

config docker log driver

The following example sets the log driver to json-file and sets the max-size and max-file options to enable automatic log-rotation.

1
2
3
4
5
6
7
{
"log-driver": "json-file",
"log-opts": {
"max-size": "500m",
"max-file": "3"
}
}

Download jdk-8uXXX-linux-x64.tar.gz from Java SE Development Kit 8 Downloads

Unzip jdk-8uXXX-linux-x64.tar.gz to /usr/lib/jvm

1
2
sudo mkdir /usr/lib/jvm
sudo tar -zxvf jdk-8uXXX-linux-x64.tar.gz -C /usr/lib/jvm

Configure JDK

1
2
3
4
5
6
7
8
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_XXX/bin/java 300  
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_XXX/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.8.0_XXX/bin/jar 300
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.8.0_XXX/bin/javah 300
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.8.0_XXX/bin/javap 300

#if you have multiple java version installed, you have to run this command
sudo update-alternatives --config java

Test

1
java -version

下载安装Miniconda

Miniconda DOC: https://docs.conda.io/en/latest/miniconda.html

本文使用的是最新版Python3.8 for Linux,从清华大学开源软件镜像站下载

1
2
3
4
wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
sh Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
conda list

配置

由于网络原因,使用默认配置下载Anaconda仓库与第三方源软件包时速度过慢,因此建议使用清华镜像
修改HOME目录下的.condarc文件(没有的话则新建),添加如下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

即可添加免费仓库.

运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。
##测试

1
2
3
4
5
6
7
8
conda list
conda create -n testenv --clone base
conda list env
conda activate testenv
conda install django
conda list
conda deactivate
conda env remove -n testenv

修改PyPI 镜像源
临时使用

1
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

设置为默认

1
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Node.js binary distributions are available from NodeSource

1
2
3
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

Install cnpm

1
2
npm config set registry https://registry.npm.taobao.org/
npm install cnpm -g