centsos 基本安裝參考指令

#更新
yum update -y && yum autoremove -y

#安裝常用工具,如vim/wget/openssh-server/nslookup/ping/ifconfig
yum install -y git vim wget openssh* nfs-utils nfs-utils-lib open-vm-tools net-tools bind-utils iputils yum-utils

#設定ssh
mkdir -p ~/.ssh
cat <<EOF > ~/.ssh/config
Host *
    StrictHostKeyChecking no
EOF

#關閉swap
SWAPLINE=$(cat /etc/fstab | grep swap | awk '{print $1}' | sed 's/\//\\\//g')
sed -i "s/$SWAPLINE/#$SWAPLINE/g" /etc/fstab 
swapoff -a
free -m

#關閉SELINUX
setenforce 0
sed -i s/^SELINUX=.*$/SELINUX=disabled/ /etc/selinux/config
systemctl disable firewalld.service
systemctl disable libvirtd.service

#Forward Policy
iptables -P FORWARD ACCEPT

#關閉防火牆
iptables -P FORWARD ACCEPT
systemctl stop firewalld
systemctl disable firewalld

#NTP校時
yum install ntp ntpdate ntp-doc -y
cat > /etc/ntp.conf  <<EOL
restrict 127.0.0.1
restrict ::1
server time.stdtime.gov.tw  minpoll 1 maxpoll 3
server tock.stdtime.gov.tw  minpoll 2 maxpoll 3
server watch.stdtime.gov.tw minpoll 3 maxpoll 4
server clock.stdtime.gov.tw minpoll 4 maxpoll 5
server tick.stdtime.gov.tw  minpoll 5 maxpoll 6
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
EOL

systemctl stop ntpd
ntpdate time.stdtime.gov.tw
systemctl enable ntpd
systemctl start ntpd
ntpq -p

修改docker0網段

其中10.172.254.254是Getway,不要自作主張改成 192.168.1.0/24 or 10.172.0.0之類的..

yum install bridge-utils -y

service docker stop
ip link set dev docker0 down
brctl delbr docker0
iptables -t nat -F POSTROUTING


brctl addbr docker0
ip addr add 10.172.254.254/16 dev docker0
ip link set dev docker0 up


cat << EOF > /etc/docker/daemon.json
{
  "bip": "10.172.254.254/16"
}
EOF

systemctl daemon-reload
systemctl restart docker.service
reboot #如果有k8s則需要重開機

refer: https://blog.yowko.com/docker-172-17-ip/

在centos 7上安裝nvidia docker

#安裝 docker-ce
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce-18.06.0.ce -y
systemctl enable docker && systemctl start docker


# 移除舊版nvidia-docker
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo yum remove nvidia-docker

# 加入repositories
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo

# 安裝 nvidia-docker2
sudo yum install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# 測試
docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi

refer: https://github.com/NVIDIA/nvidia-docker

install nfs server on centos

假設cntos ip是172.16.1.1,想要分享的資料夾是/volume1/nfs
只需要用下列指令就可以架設好nfs server

yum install nfs-utils -y
echo "/volume1/nfs 172.16.0.0/16(rw,sync,no_root_squash,no_all_squash)" >> /etc/exports

systemctl enable rpcbind
systemctl enable nfs-server
systemctl enable nfs-lock
systemctl enable nfs-idmap
systemctl start rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap

client端部分只需要:

echo "172.16.1.1:/volume1/nfs /nfs nfs rw 0 0" >> /etc/fstab
mkdir -p /nfs
mount -a

install cuda 10.0 on centos 7

如下:

#安裝必要套件
yum –y update
yum install kernel-devel kernel-headers gcc dkms acpid libglvnd-glx libglvnd-opengl libglvnd-devel pkgconfig pciutils gcc-c++ wget
yum groupinstall "Development Tools" -y

#Nvidia 硬體檢查
lspci | grep -E "VGA|3D"

#Blacklist nouveau
echo "blacklist nouveau" >> /etc/modprobe.d/nvidia-installer-disable-nouveau.conf && echo "options nouveau modeset=0" >> /etc/modprobe.d/nvidia-installer-disable-nouveau.conf

#regenerate the initramfs
dracut /boot/initramfs-$(uname -r).img $(uname -r) --force
reboot

wget http://tw.download.nvidia.com/XFree86/Linux-x86_64/410.78/NVIDIA-Linux-x86_64-410.78.run
bash NVIDIA-Linux-x86_64-410.78.run

#下載cuda
wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux
mv cuda_10.0.130_410.48_linux cuda_10.0.130_410.48_linux.run

#安裝cuda
bash cuda_10.0.130_410.48_linux.run

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64
export CUDA_HOME=/usr/local/cuda-10.0
export PATH=$PATH:/usr/local/cuda-10.0/bin

cd ~/NVIDIA_CUDA-10.0_Samples/1_Utilities/deviceQuery
make
./deviceQuery

cd ~/NVIDIA_CUDA-10.0_Samples/0_Simple/vectorAdd
make
./vectorAdd

centos 7 筆記

安裝chrome, refer

sudo bash -c ‘cat <<EOF > /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
EOF

sudo yum -y install google-chrome-stable

安裝qt5, refer

sudo yum -y install gcc gcc-c++ mesa-libGL-devel mesa-libGLU-devel freeglut-devel
wget http://download.qt.io/archive/qt/5.4/5.4.2/qt-opensource-linux-x64-5.4.2.run
chmod +x qt-opensource-linux-x64-5.4.2.run
sudo ./qt-opensource-linux-x64-5.4.2.run

安裝proj4, refer

sudo yum install epel-release -y
sudo yum install -y proj proj-devel proj-epsg