首页 > 其他分享 >0. 基础环境,适用于手动安装

0. 基础环境,适用于手动安装

时间:2024-03-27 13:56:02浏览次数:17  
标签:mirrors 手动 适用 etc yum https edu deb 安装

0. 基础环境,适用于手动安装

虽然发行版不同,但是管理方式大多一致,以下未标注发行版,则为通用命令。

Centos镜像:清华源 根据官方指路,使用的2207,默认2009

Rocky镜像:科大源

Debian镜像:清华源

Ubuntu镜像:清华源

1. 配置静态IP

在系统安装时,可引导配置 net.ifnames=0 biosdevname=0​ 使用旧的命名方式,网卡名为 eth0;其次,静态IP也可以在安装的时候直接配置。

RHEL 系

该命令来源是NetworkManager,从7.x已经预置,9.x默认

nmcli c modify eth0 \
	ipv4.addresses 192.168.80.100/24 \
	ipv4.gateway 192.168.80.254 \
	ipv4.dns 223.5.5.5 \
	ipv4.method manual
nmcli c up eth0
# ifdown eth0 ; ifup eth0

Debian系

没有通用的命令,或者自行安装工具,如NetworkManager、netplan

Debian

# vi /etc/network/interfaces
iface eth0 inet static
address 172.16.99.52
netmask 255.255.255.0
gateway 172.16.99.254

重启网络服务生效

Ubuntu

# vi /etc/netplan/00-installer-config.yaml ;如果没得文件,可以用 netplan generate 生成
network:
  ethernets:
    ens18:
      dhcp4: no
      addresses: [172.16.99.53/24]
      gateway4: 172.16.99.254
      nameservers:
        addresses: [223.5.5.5]
  version: 2

加载服务 netplan apply

2. 修改主机名

虚拟机安装,考虑制作为模板,可后期再做此操作

hostnamectl set-hostname k8single

3. 修改 hosts 文件

当前一张网卡,一个主机IP;如果多网卡,此处配置集群使用IP网段;可使用vim编辑,将规划地址一次性写入

echo -e "$(hostname -I) $(hostname)" >> /etc/hosts

4. 配置时间同步

# 举个例子,自行替换,或者手动编辑
sed -i 's/0.centos.pool.ntp.org/ntp.aliyun.com/g' /etc/chrony.conf
sed -i 's|.*centos.pool.ntp.org iburst||' /etc/chrony.conf
# 重启服务
systemctl restart chronyd
# 设置时区
timedatectl set-timezone Asia/Shanghai
timedatectl set-ntp true
timedatectl set-local-rtc 0
chronyc -a makestep

5. 【可选】配置系统镜像源

RHEL系

红帽系因为默认有 fastmirrors 的加持,所以不配置并不太影响使用;目前阿里云有限速,建议使用其他厂商或者院校的镜像源。Debian系建议配置~

cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-anon.repo
yum clean all
yum makecache

Debian系

Debian12

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

Ubuntu22

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

6. 红帽系,关闭selinux;Debian默认没有该功能

setenforce 0
sed -ri 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

7.【可选】关闭防火墙

直接关闭防火墙比较省事,在有安全组和物理安全设备的情况下,系统防火墙可关闭;或者放通需要的 IP 段

# 红帽系
systemctl disable --now firewalld
# Ubuntu
systemctl disable --now ufw

8. 关闭swap

kubelet 自 v1.22 起已开始支持交换分区。自 v1.28 起,仅针对 cgroup v2 支持交换分区; kubelet 的 NodeSwap 特性门控处于 Beta 阶段,但默认被禁用。

sed -ri 's/.*swap.*/#&/' /etc/fstab
swapoff -a && sysctl -w vm.swappiness=0

9. 内核升级

centos 7

目前使用的主流发行版,内核版本均较高,仅 centos 7 需要升级。Ubuntu 20.04+ 内核已经在 5.4

yum install -y yum-utils deltarpm
yum-config-manager --enable centos-kernel
yum update -y
# 重启,清理旧内核信息
reboot
# package-cleanup --oldkernels 清理旧内核,不会清理原始内核,即初始安装内核无法删除
yum remove -y $(rpm -qa|grep kernel | grep -v $(uname -r))

10. 安装常用软件包

RHEL系

yum install -y conntrack ipvsadm ipset jq psmisc iptables curl sysstat libseccomp wget telnet vim net-tools git

Debian系

apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates wget vim git

11. 系统优化

  1. 文件句柄优化

    ulimit -SHn 65535
    cat <<EOF  >> /etc/security/limits.conf 
    * soft nofile 655360
    * hard nofile 131072
    * soft nproc 655350
    * hard nproc 655350
    * soft memlock unlimited
    * hard memlock unlimited
    EOF
    
  2. 内核优化

    cat > /etc/sysctl.d/k8s.conf <<EOF
    net.ipv4.ip_forward = 1
    net.bridge.bridge-nf-call-iptables = 1
    net.bridge.bridge-nf-call-ip6tables = 1
    fs.may_detach_mounts = 1
    vm.overcommit_memory=1
    vm.panic_on_oom=0
    fs.inotify.max_user_watches=89100
    fs.inotify.max_user_instances=8192
    fs.file-max=52706963
    fs.nr_open=52706963
    net.ipv6.conf.all.disable_ipv6=1
    net.netfilter.nf_conntrack_max=2310720
    net.ipv4.tcp_keepalive_time = 600
    net.ipv4.tcp_keepalive_probes = 3
    net.ipv4.tcp_keepalive_intvl =15
    net.ipv4.tcp_max_tw_buckets = 36000
    net.ipv4.tcp_tw_reuse = 1
    net.ipv4.tcp_max_orphans = 327680
    net.ipv4.tcp_orphan_retries = 3
    net.ipv4.tcp_syncookies = 1
    net.ipv4.tcp_max_syn_backlog = 16384
    net.ipv4.ip_conntrack_max = 65536
    net.ipv4.tcp_max_syn_backlog = 16384
    net.ipv4.tcp_timestamps = 0
    net.core.somaxconn = 16384
    EOF
    
  3. ipvs 配置 【可后期从iptables切换到ipvs时再配置】

    cat > /etc/modules-load.d/ipvs.conf <<EOF
    ip_vs
    ip_vs_lc
    ip_vs_wlc
    ip_vs_rr
    ip_vs_wrr
    ip_vs_lblc
    ip_vs_lblcr
    ip_vs_dh
    ip_vs_sh
    ip_vs_fo
    ip_vs_nq
    ip_vs_sed
    ip_vs_ftp
    ip_vs_sh
    nf_conntrack
    ip_tables
    ip_set
    xt_set
    ipt_set
    ipt_rpfilter
    ipt_REJECT
    ipip
    EOF
    
  4. containerd 配置

    cat > /etc/modules-load.d/containerd.conf <<EOF
    overlay
    br_netfilter
    EOF
    
  5. 校验

    # 加载
    sysctl --system
    # 检查,可以重启后再检查一次
    lsmod | grep -e ip_vs -e nf_conntrack
    # 如果报错,手动加载测试
    #modprobe br_netfilter
    #modprobe ip_conntrack
    
    systemctl enable --now systemd-modules-load.service
    

标签:mirrors,手动,适用,etc,yum,https,edu,deb,安装
From: https://www.cnblogs.com/chongxs/p/18098992/0-basic-environment-suitable-for-manual-install

相关文章

  • MYSQL8最新安装教程
    目录安装配置MySql一、下载MySql进入官网:https://dev.mysql.com二、新建文件夹管理Mysql系列文件三、配置my.ini文件四、执行数据库初始化命令五、基础配置六、配置系统环境变量可能会遇到无法启动MYSQL服务的问题:一、尝试删除MySQL服务,重新安装;二、查看端口是否是被占用三、查看......
  • Flink - [02] 安装部署(Standalone)
     一、准备1、角色规划FlinkStandalone角色规划节点名称node01node02node03master○  worker ○○zookeeper○○○   二、部署1、解压:tar-zxvfflink-1.11.2-bin-scala_2.11.tgz2、      — 要养成终生学习的习惯—......
  • SysTrayIcon 改的 python tkinter 最小化至系统托盘,适用TTK
    网上的SysTrayIcon改的,Tk页面最小化至托盘,托盘图标左键单击恢复Tk界面1.点击最小化隐藏至托盘2.托盘图标右键菜单展示,左键返回Tk界面。托盘图标可以自定义,修改了SysTrayIcon更容易调用,Demo窗口加了注释,具体查看_Main类。 代码如下: importwin32api,win32con,wi......
  • Linux系统安装完成之后如何开启root的ssh登录
    Linux系统安装完成之后如何开启root的ssh登录默认情况下,root用户是没有密码的,而且出于安全考虑,SSH服务不允许root用户直接登录。但在某些情况下,你可能需要以root用户身份通过SSH远程登录服务器,或者为root用户设置密码。修改root用户密码首先,登录到Linux系统。如果你是通......
  • mmpretrain安装教程(踩雷记录)
    目录ModuleNotFoundError:Nomodulenamed‘mmcv‘包命令pkgutil报错OSError:CUDA_HOMEenvironmentvariableisnotset.PleasesetittoyourCUDAinstallroot.error:MicrosoftVisualC++14.0orgreaterisrequired.Getitwith"MicrosoftC++BuildTools......
  • openEuler20.03操作系统上安装部署MogDB2.1.1
    openEuler20.03操作系统上安装部署MogDB2.1.1本文出处:https://www.modb.pro/db/378319openEuler操作系统上安装mogdb:下载openEuler镜像文件:openEuler-20.03-LTS-x86_64-dvd.iso可以到各镜像源网站下载:例如:清华源下载地址:https://mirrors.tuna.tsinghua.edu.cn/openeule......
  • 全网最简单最快捷的搭建nextcloud教程(开箱即用),也可以说是保姆级虚拟机安装Ubuntu23.
    nextcloud是一款开源的网盘工具,适用于个人或中小型公司。纯英文的官网很多同行看着云里雾里的,网上的教程也零零散散的,容易踩坑。今天我来发一个最简单最快捷的搭建nextcloud的教程。完全傻瓜化,非docker方式。本质上就是Ubuntu23.10自带nextcloud包,安装最后一步的时候勾选上即......
  • 手工安装部署openGauss3.0一主一备(非om工具安装)
    手工安装部署openGauss3.0一主一备(非om工具安装)本文出处:https://www.modb.pro/db/425385一、操作系统配置(centos7.6)1.关闭防火墙systemctlstopfirewalldsystemctldisablefirewalld2.关闭selinux服务setenforce0vim/etc/selinux/configSELINUX=disabled3.......
  • 关于ch340 的驱动的安装
    什么是ch340  逻辑是这样的,   开发板--->TTL--->ch340---->USB---->PC  开发板<---TTL<---ch340<----USB<----PC 安装ch340驱动是给USB端的系统安装驱动的,或者是开发板,或者是PC,也就是说,我接受ch340通过USB口的信息,需要特定的驱动的,它......
  • Mogdb - 安装报错Failed to encrypt the password for databaseError
    Mogdb-安装报错FailedtoencryptthepasswordfordatabaseError本文出处:https://www.modb.pro/db/418363版本MogdbV2.0.1红旗V6故障现象安装过程中出现报错[GAUSS-50322]:FailedtoencryptthepasswordfordatabaseError:/dbdata/app/mogdb/bin/gs_guc:error......