配置环境

以下步骤介绍了在 Oracle Private Cloud Appliance 上安装 Oracle Cloud Native Environment 之前如何配置环境。

我们假设已经预配了以下资源:

  • 租户中的区间。
  • 区间中具有 DNS 标签的虚拟云网络 (VCN)(在此 VCN 中启用了使用 DNS 主机名)。
  • 三个 Worker 节点、一个控制节点和一个操作员节点的计算实例。

设置代理

在所有节点上设置代理 vars in etc bashrc,以便所有将来的 shell 会话都将受益于代理环境变量。使用以下项替换适当的代理服务器名称和端口:http://proxy-host:proxy-port

if [ ! -f /etc/bashrc.bak ]; then
 cp -p /etc/bashrc /etc/bashrc.bak
else
 cp -p /etc/bashrc.bak /etc/bashrc
fizz=/tmp/ocne.setup.sh.on_host_to_be_setup
cat <<EOD > $zz
export http_proxy=http://proxy-host:proxy-port
export https_proxy=http://proxy-host:proxy-port
# substitute your domain name for "dm.com"
HOSTNAME=`hostname`
first_3_octets_of_LAN=`nslookup $HOSTNAME.dm.com | grep Address | tail -1 | sed -e 's/Address: //' -e 's/\.[0-9]*$//'`
export 
no_proxy='localhost,127.0.0.1,.proxy-host,.oraclecorp.com,.oraclevcn.com,$first_3_octets_of_LAN.0/24,.svc,/var/run/crio/crio.sock,10.96.0.0/12'EOD
cat $zz >> /etc/bashrc

应用操作系统更新

应用 OS 修补程序来确保所有节点的安全性和功能是最新的。

确定您的 OS。

Identify Oracle Linux major release 
uname -a | sed -e 's/.*\.el//' -e 's/^\(.\).*/\1/'

如果此命令的结果为 8,则运行的是 Oracle Linux 8。如果运行的是 Oracle Linux 7,请使用 yum 而非 dnf,不要传递附加参数 --best --allowerasing

例如,如果指令显示:

yum --setopt=keepcache=1 xyz

如果您在 Oracle Linux 7 上运行,则应运行以下命令:

dnf --best --setopt=keepcache=1 --allowerasing xyz

在配置 yum 并可能使用 dnf 来识别代理服务器后,在所有节点上应用 OS 更新。

if [ ! -f /etc/yum.conf.bak ]; then
 cp /etc/yum.conf /etc/yum.conf.bak
else
 cp /etc/yum.conf.bak /etc/yum.conf
fi
echo proxy=http://proxy-host:proxy-port >> /etc/yum.conf
if [ -d /etc/dnf ]; then
 if [ ! -f /etc/dnf/dnf.conf.bak ]; then
 sudo cp /etc/dnf/dnf.conf /etc/dnf/dnf.conf.bak
 else
 sudo cp /etc/dnf/dnf.conf.bak /etc/dnf/dnf.conf
 fi
 cp /etc/dnf/dnf.conf.bak /tmp/dnf.conf
 echo proxy=http://proxy-host:proxy-port:80 >> /tmp/dnf.conf
 sudo mv /tmp/dnf.conf /etc/dnf/dnf.conf
fi
dnf --best --setopt=keepcache=1 --allowerasing update -y
reboot

在所有节点上配置资料档案库

在所有节点上配置 yum 系统信息库。

configure repos 
# if we are on OEL7, do the following:
sudo yum-config-manager --enable ol7_olcne15 ol7_kvm_utils ol7_addons ol7_latest ol7_UEKR6
sudo yum-config-manager --disable ol7_olcne14 ol7_olcne13 ol7_olcne12 ol7_olcne11 ol7_olcne
ol7_developer
# but if we are on Oracle Linux 8, do the following:
sudo dnf -y install oracle-olcne-release-el8
sudo yum config-manager --enable ol8_olcne15 ol8_addons ol8_baseos_latest ol8_appstream 
ol8_UEKR6
sudo yum config-manager --disable ol8_olcne12 ol8_olcne13 ol8_olcne14 ol8_developer

安装 Chrony

#Install chrony on all nodes.
sudo dnf --best --setopt=keepcache=1 --allowerasing -y install chrony
sudo systemctl enable --now chronyd.service

禁用所有节点上的交换

no swap 
swapoff -a
if [ ! -f /etc/fstab.bak ]; then
 sudo cp /etc/fstab /etc/fstab.bak
fi
cat /etc/fstab.bak | sed '/[\t ]swap[\t ]/d' > /tmp/fstab
echo diff /etc/fstab.bak /tmp/fstab
diff /etc/fstab.bak /tmp/fstab
sudo cp /tmp/fstab /etc/fstab
echo cat /etc/fstab
cat /etc/fstab

在操作员节点上配置防火墙

operator node firewall 
sudo firewall-cmd --add-port=8091/tcp --permanent
sudo firewall-cmd --reload

在 Worker 节点上配置防火墙

worker node firewall 
sudo firewall-cmd --zone=trusted --add-interface=cni0 --permanent
sudo firewall-cmd --add-port=8090/tcp --permanent
sudo firewall-cmd --add-port=10250/tcp --permanent
sudo firewall-cmd --add-port=10255/tcp --permanent
sudo firewall-cmd --add-port=8472/udp --permanent
sudo firewall-cmd --add-masquerade --permanent
sudo systemctl restart firewalld.service

配置子网安全列表入站规则

您必须调整子网安全列表以允许新集群上的 Oracle Cloud Native Environment 和 Kubernetes 流量。
  1. 向下钻取到安全列表以添加入站规则。
  2. 将入站规则添加到节点计算实例所用子网的安全列表中,以允许在必要端口上进行流量传输。
  3. 允许到以下端口的通信:
    • 2379-2380
    • 6443-6444
    • 8090-8091
    • 8472
    • 10250-10252
    • 10255