Ching-Chuan Chen's Blogger

Statistics, Machine Learning and Programming

0%

Installation of Oracle Linux 8

Simply record the scripts to setup Oracle Linux 8.

Putty Settings:

  1. Install Font Noto Mono for Powerline: https://github.com/powerline/fonts/tree/master/NotoMono
  2. Change the font of PuTTy to Noto Mono for Powerline.
  3. (optional) Modify the resolution in Hyper-V VM: sudo grubby --update-kernel=ALL --args="video=hyperv_fb:2560x1440"

A. Setup zsh / SSH-keys

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# install zsh/oh-my-zsh
sudo yum install zsh -y
sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# install powerlevel9k theme
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
sed -i 's~ZSH_THEME=.*~ZSH_THEME="powerlevel9k/powerlevel9k"~g' ~/.zshrc

# install awesome-terminal fonts
git clone https://github.com/gabrielelana/awesome-terminal-fonts.git
cd awesome-terminal-fonts
mv build ~/.fonts
fc-cache -fv ~/.fonts
echo 'POWERLEVEL9K_MODE="awesome-fontconfig"' >> ~/.zshrc
echo 'source ~/.fonts/*.sh' >> ~/.zshrc

# install Plug-ins of zsh
## zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
sed -i 's/^plugins=(/&zsh-syntax-highlighting /' ~/.zshrc
## zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
sed -i 's/^plugins=(/&zsh-autosuggestions /' ~/.zshrc

# SSH-key
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys

B. Install JupyterLab / JupyterHub

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh
bash Anaconda3-2020.11-Linux-x86_64.sh
conda create -n myenv python=3.8 numpy scipy pandas cython jupyterhub jupyterlab scikit-learn fastparquet
conda activate myenv
conda install -c conda-forge nodejs==12.19.0
jupyter labextension install @jupyterlab/hub-extension

mkdir ~/jupyter
cd ~/jupyter

tee jupyterhub_config.py << EOF
c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
c.JupyterHub.bind_url='http://:8000/jupyter'
c.JupyterHub.config_file = '$(pwd)/jupyterhub_config.py'
c.JupyterHub.cookie_secret_file = '$(pwd)/jupyterhub_cookie_secret'
c.JupyterHub.db_url = 'sqlite:///$(pwd)/jupyterhub.sqlite'
c.JupyterHub.data_files_path = '${CONDA_PREFIX}/share/jupyterhub'
c.ConfigurableHTTPProxy.pid_file = '$(pwd)/jupyterhub_proxy.pid'
EOF

sudo tee /etc/systemd/system/jupyterhub.service << EOF
[Unit]
Description=Jupyterhub
After=syslog.target network.target

[Service]
User=jamal
Environment="ANACONDA_BIN_PATH=/home/jamal/anaconda3/envs/myenv/bin"
ExecStart=/bin/bash -c 'PATH=\$ANACONDA_BIN_PATH:\$PATH jupyterhub -f /home/jamal/jupyter/jupyterhub_config.py'

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable jupyterhub
sudo systemctl start jupyterhub

sudo setsebool -P httpd_can_network_connect 1
sudo setsebool -P httpd_can_network_relay 1
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload

Remaining setting refer to Reverse Proxy for JupyterHub and Rstudio Server

C. Build R and install RStudio Server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# install epel
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
# enable powertools(centos name)
sudo yum config-manager --set-enabled ol8_codeready_builder
# install necessary packages for building R
sudo yum install gcc-c++ gcc-gfortran openssl-devel libxml2-devel tcl-devel tk-devel libtiff-devel \
libjpeg-turbo-devel libpng-devel cairo-devel libicu-devel openssl-devel libcurl-devel freeglut \
readline-devel cyrus-sasl-devel libquadmath-devel pcre-devel libX11-devel libXmu-devel libXt-devel pigz \
xorg-x11-server-Xvfb pango-devel java-11-openjdk java-11-openjdk-devel -y
sudo yum install texinfo texinfo-tex texlive texlive-xetex -y

# setup the font Inconsolata
wget https://github.com/googlefonts/Inconsolata/raw/master/fonts/ttf/Inconsolata-Regular.ttf
wget https://github.com/googlefonts/Inconsolata/raw/master/fonts/ttf/Inconsolata-Bold.ttf
wget https://github.com/googlefonts/Inconsolata/raw/master/fonts/ttf/Inconsolata-Light.ttf
wget https://github.com/googlefonts/Inconsolata/raw/master/fonts/ttf/Inconsolata-Medium.ttf
wget https://github.com/googlefonts/Inconsolata/raw/master/fonts/ttf/Inconsolata-Black.ttf
sudo mv *.ttf /usr/share/fonts
sudo fc-cache /usr/share/fonts
wget -q http://mirrors.ctan.org/install/fonts/inconsolata.tds.zip
mkdir inconsolata
unzip inconsolata.tds.zip -d inconsolata
sudo cp -r inconsolata/* /usr/share/texmf
echo 'Map zi4.map\n' | sudo tee -a /usr/share/texlive/texmf-dist/web2c/updmap.cfg
sudo mktexlsr
yes | sudo updmap-sys --enable Map=zi4.map --syncwithtrees --force
sudo updmap -sys

# setup Intel MKL Repo.
sudo yum install yum-utils -y
sudo yum-config-manager --add-repo https://yum.repos.intel.com/setup/intelproducts.repo
sudo rpm --import https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
sudo rm -rf /var/cache/yum/ && yes | sudo yum makecache

# Download Intel MKL
sudo yum install -y intel-mkl-64bit-2020.4-912
sudo tee /etc/ld.so.conf.d/intel.conf << EOF
/opt/intel/mkl/lib/intel64
/opt/intel/lib/intel64
/opt/intel/tbb/lib/intel64/gcc4.8
EOF
sudo ldconfig

# Download R source code
R_VER=4.0.3
wget https://cran.r-project.org/src/base/R-4/R-$R_VER.tar.gz
tar zxvf R-$R_VER.tar.gz

# start building
cd R-$R_VER
export MKLROOT=/opt/intel/compilers_and_libraries/linux
export LD_LIBRARY_PATH=${MKLROOT}/mkl/lib/intel64:/usr/lib64
export MKL="-L${MKLROOT}/mkl/lib/intel64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -fopenmp -lpthread -ldl -lm"
export CFLAGS="-std=gnu99 -g -O3 -march=native -DU_STATIC_IMPLEMENTATION"
export CXXFLAGS="-g -O3 -march=native -DU_STATIC_IMPLEMENTATION"
export CXXSTD=-std=gnu++98
# remember don't include anaconda3/bin
export PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
./configure --prefix=/usr --libdir=/usr/lib64 --with-cairo --with-x=no --enable-R-shlib --enable-shared \
--enable-R-profiling --enable-BLAS-shlib --enable-memory-profiling --with-blas="$MKL" \
--with-lapack --with-tcl-config=/usr/lib64/tcl8.6/tclConfig.sh \
--with-tk-config=/usr/lib64/tkConfig.sh --enable-prebuilt-html
make -j$(nproc)
sudo make install
sudo groupadd ruser
sudo chown -R root:ruser /usr/lib64/R
sudo chmod -R g+w /usr/lib64/R
sudo usermod -a -G ruser jamal
sudo R CMD javareconf
sudo tee /usr/lib64/R/etc/Rprofile.site << EOF
options(bitmapType='cairo')
local({r <- getOption("repos")
r["CRAN"] <- "https://cran.r-project.org"
options(repos=r)})
EOF

sudo yum install compat-openssl10 -y
wget https://download2.rstudio.org/server/centos6/x86_64/rstudio-server-rhel-1.3.1093-x86_64.rpm
sudo yum install rstudio-server-rhel-1.3.1093-x86_64.rpm
sudo chcon -u system_u -r object_r --type=bin_t -R /usr/lib/rstudio-server/bin
sudo systemctl enable rstudio-server
sudo systemctl start rstudio-server

D. Installation of Docker

1
2
3
4
5
6
7
sudo yum install docker-podman
sudo systemctl enable docker
sudo systemctl start docker

sudo firewall-cmd --permanent --zone=trusted --change-interface=docker0
sudo firewall-cmd --permanent --zone=trusted --add-port=4243/tcp
sudo firewall-cmd --reload