CentOS基本设置

Linux · 2024-01-04

镜像站

https://mirrors.ustc.edu.cn/help/centos.html

https://mirror.tuna.tsinghua.edu.cn/help/centos/

# CentOS 7  TsingHua
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
    -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos|g' \
    -i.bak \
    /etc/yum.repos.d/CentOS-*.repo
# CentOS 7 USTC
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
         -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
         -i.bak \
         /etc/yum.repos.d/CentOS-Base.repo
         
# CentOS 8  TsingHua
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
    -e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos|g' \
    -i.bak \
    /etc/yum.repos.d/CentOS-*.repo
## CentOS 8 USTC
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
         -e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
         -i.bak \
         /etc/yum.repos.d/CentOS-Stream-AppStream.repo \
         /etc/yum.repos.d/CentOS-Stream-BaseOS.repo \
         /etc/yum.repos.d/CentOS-Stream-Extras.repo \
         /etc/yum.repos.d/CentOS-Stream-PowerTools.repo
# 更新
yum makecache

版本查询

cat /etc/issue  #查看版本

cat /etc/redhat-release  #查看CentOS版本
cat /etc/centos-release  #

cat /proc/version
uname -a 

IP 和DNS设置

vi /etc/sysconfig/network-scripts/ifcfg-ens32   
YPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens18
UUID=9a4735de-d018-45bc-8684-4be62f23968e
DEVICE=ens18
ONBOOT=yes
IPADDR=10.10.15.171
NETMASK=255.255.255.0
GATEWAY=10.10.15.1
DNS1=223.5.5.5
DNS2=180.76.76.76

重启

systemctl restart network

JDK设置

下载地址

https://www.oracle.com/java/technologies/downloads/archive/

解压到服务器

tar -zxvf jdk-11.0.20_linux-x64_bin.tar.gz

生成JRE

cd jdk-11.0.20
bin\jlink --module-path jmods --add-modules java.desktop --output jre

增加环境变量

vi /etc/profile

#set java environment
JAVA_HOME=/usr/java/jdk-11.0.20
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

生效

source /etc/profile

Linux CentOS
Theme Jasmine by Kent Liao