二进制安装Kubernetes(k8s)v1.31.1

打印 上一主题 下一主题

主题 837|帖子 837|积分 2511

二进制安装Kubernetes(k8s)v1.31.1

介绍

https://github.com/cby-chen/Kubernetes 开源不易,帮助点个star,谢谢了
kubernetes(k8s)二进制高可用安装部署,支持IPv4+IPv6双栈。

剧烈建议在Github上查看文档 !!!

Github出问题会更新文档,而且后续尽可能第一时间更新新版本文档 !!!

手动项目所在:https://github.com/cby-chen/Kubernetes

1.情况

主机名称IP所在阐明软件192.168.1.60外网节点下载各种所需安装包Master01192.168.1.31master节点kube-apiserver、kube-controller-manager、kube-scheduler、etcd、
kubelet、kube-proxy、nfs-client、haproxy、keepalived、nginxMaster02192.168.1.32master节点kube-apiserver、kube-controller-manager、kube-scheduler、etcd、
kubelet、kube-proxy、nfs-client、haproxy、keepalived、nginxMaster03192.168.1.33master节点kube-apiserver、kube-controller-manager、kube-scheduler、etcd、
kubelet、kube-proxy、nfs-client、haproxy、keepalived、nginxNode01192.168.1.34node节点kubelet、kube-proxy、nfs-client、nginxNode02192.168.1.35node节点kubelet、kube-proxy、nfs-client、nginx192.168.1.36VIP网段
物理主机:192.168.1.0/24
service:10.96.0.0/12
pod:172.16.0.0/12
安装包已经整理好:https://mirrors.chenby.cn/https://github.com/cby-chen/Kubernetes/releases/download/v1.31.1/kubernetes-v1.31.1.tar
1.1.k8s底子系统情况设置

1.2.设置IP
  1. # 注意!
  2. # 若虚拟机是进行克隆的那么网卡的UUID和MachineID会重复
  3. # 需要重新生成新的UUIDUUID和MachineID
  4. # UUID和MachineID重复无法DHCP获取到IPV6地址
  5. ssh root@192.168.1.153 "rm -rf /etc/machine-id; systemd-machine-id-setup;reboot"
  6. ssh root@192.168.1.158 "rm -rf /etc/machine-id; systemd-machine-id-setup;reboot"
  7. ssh root@192.168.1.159 "rm -rf /etc/machine-id; systemd-machine-id-setup;reboot"
  8. ssh root@192.168.1.160 "rm -rf /etc/machine-id; systemd-machine-id-setup;reboot"
  9. ssh root@192.168.1.161 "rm -rf /etc/machine-id; systemd-machine-id-setup;reboot"
  10. #
  11. # 查看当前的网卡列表和 UUID:
  12. # nmcli con show
  13. # 删除要更改 UUID 的网络连接:
  14. # nmcli con delete uuid <原 UUID>
  15. # 重新生成 UUID:
  16. # nmcli con add type ethernet ifname <接口名称> con-name <新名称>
  17. # 重新启用网络连接:
  18. # nmcli con up <新名称>
  19. # 更改网卡的UUID
  20. # 先配置静态IP之后使用ssh方式配置不断连
  21. ssh root@192.168.1.153 "nmcli con delete uuid 628b03ed-3c1e-32ea-b001-eb5b8ac73285;nmcli con add type ethernet ifname ens18 con-name ens18;nmcli con up ens18"
  22. ssh root@192.168.1.158 "nmcli con delete uuid 628b03ed-3c1e-32ea-b001-eb5b8ac73285;nmcli con add type ethernet ifname ens18 con-name ens18;nmcli con up ens18"
  23. ssh root@192.168.1.159 "nmcli con delete uuid 628b03ed-3c1e-32ea-b001-eb5b8ac73285;nmcli con add type ethernet ifname ens18 con-name ens18;nmcli con up ens18"
  24. ssh root@192.168.1.160 "nmcli con delete uuid 628b03ed-3c1e-32ea-b001-eb5b8ac73285;nmcli con add type ethernet ifname ens18 con-name ens18;nmcli con up ens18"
  25. ssh root@192.168.1.161 "nmcli con delete uuid 628b03ed-3c1e-32ea-b001-eb5b8ac73285;nmcli con add type ethernet ifname ens18 con-name ens18;nmcli con up ens18"
  26. # 参数解释
  27. #
  28. # ssh ssh root@192.168.1.31
  29. # 使用SSH登录到IP为192.168.1.31的主机,使用root用户身份。
  30. #
  31. # nmcli con delete uuid 708a1497-2192-43a5-9f03-2ab936fb3c44
  32. # 删除 UUID 为 708a1497-2192-43a5-9f03-2ab936fb3c44 的网络连接,这是 NetworkManager 中一种特定网络配置的唯一标识符。
  33. #
  34. # nmcli con add type ethernet ifname ens18 con-name ens18
  35. # 添加一种以太网连接类型,并指定接口名为 ens18,连接名称也为 ens18。
  36. #
  37. # nmcli con up ens18
  38. # 开启 ens18 这个网络连接。
  39. #
  40. # 简单来说,这个命令的作用是删除一个特定的网络连接配置,并添加一个名为 ens18 的以太网连接,然后启用这个新的连接。
  41. # 修改静态的IPv4地址
  42. ssh root@192.168.1.153 "nmcli con mod ens18 ipv4.addresses 192.168.1.31/24; nmcli con mod ens18 ipv4.gateway  192.168.1.1; nmcli con mod ens18 ipv4.method manual; nmcli con mod ens18 ipv4.dns "8.8.8.8"; nmcli con up ens18"
  43. ssh root@192.168.1.158 "nmcli con mod ens18 ipv4.addresses 192.168.1.32/24; nmcli con mod ens18 ipv4.gateway  192.168.1.1; nmcli con mod ens18 ipv4.method manual; nmcli con mod ens18 ipv4.dns "8.8.8.8"; nmcli con up ens18"
  44. ssh root@192.168.1.159 "nmcli con mod ens18 ipv4.addresses 192.168.1.33/24; nmcli con mod ens18 ipv4.gateway  192.168.1.1; nmcli con mod ens18 ipv4.method manual; nmcli con mod ens18 ipv4.dns "8.8.8.8"; nmcli con up ens18"
  45. ssh root@192.168.1.160 "nmcli con mod ens18 ipv4.addresses 192.168.1.34/24; nmcli con mod ens18 ipv4.gateway  192.168.1.1; nmcli con mod ens18 ipv4.method manual; nmcli con mod ens18 ipv4.dns "8.8.8.8"; nmcli con up ens18"
  46. ssh root@192.168.1.161 "nmcli con mod ens18 ipv4.addresses 192.168.1.35/24; nmcli con mod ens18 ipv4.gateway  192.168.1.1; nmcli con mod ens18 ipv4.method manual; nmcli con mod ens18 ipv4.dns "8.8.8.8"; nmcli con up ens18"
  47. # 参数解释
  48. #
  49. # ssh root@192.168.1.154
  50. # 使用SSH登录到IP为192.168.1.154的主机,使用root用户身份。
  51. #
  52. # "nmcli con mod ens18 ipv4.addresses 192.168.1.31/24"
  53. # 修改ens18网络连接的IPv4地址为192.168.1.31,子网掩码为 24。
  54. #
  55. # "nmcli con mod ens18 ipv4.gateway 192.168.1.1"
  56. # 修改ens18网络连接的IPv4网关为192.168.1.1。
  57. #
  58. # "nmcli con mod ens18 ipv4.method manual"
  59. # 将ens18网络连接的IPv4配置方法设置为手动。
  60. #
  61. # "nmcli con mod ens18 ipv4.dns "8.8.8.8"
  62. # 将ens18网络连接的IPv4 DNS服务器设置为 8.8.8.8。
  63. #
  64. # "nmcli con up ens18"
  65. # 启动ens18网络连接。
  66. #
  67. # 总体来说,这条命令是通过SSH远程登录到指定的主机,并使用网络管理命令 (nmcli) 修改ens18网络连接的配置,包括IP地址、网关、配置方法和DNS服务器,并启动该网络连接。
  68. # 没有固定IPv6选择不配置即可
  69. ssh root@192.168.1.31 "nmcli con mod ens18 ipv6.addresses fc00:43f4:1eea:1::10; nmcli con mod ens18 ipv6.gateway fc00:43f4:1eea:1::1; nmcli con mod ens18 ipv6.method manual; nmcli con mod ens18 ipv6.dns "2400:3200::1"; nmcli con up ens18"
  70. ssh root@192.168.1.32 "nmcli con mod ens18 ipv6.addresses fc00:43f4:1eea:1::20; nmcli con mod ens18 ipv6.gateway fc00:43f4:1eea:1::1; nmcli con mod ens18 ipv6.method manual; nmcli con mod ens18 ipv6.dns "2400:3200::1"; nmcli con up ens18"
  71. ssh root@192.168.1.33 "nmcli con mod ens18 ipv6.addresses fc00:43f4:1eea:1::30; nmcli con mod ens18 ipv6.gateway fc00:43f4:1eea:1::1; nmcli con mod ens18 ipv6.method manual; nmcli con mod ens18 ipv6.dns "2400:3200::1"; nmcli con up ens18"
  72. ssh root@192.168.1.34 "nmcli con mod ens18 ipv6.addresses fc00:43f4:1eea:1::40; nmcli con mod ens18 ipv6.gateway fc00:43f4:1eea:1::1; nmcli con mod ens18 ipv6.method manual; nmcli con mod ens18 ipv6.dns "2400:3200::1"; nmcli con up ens18"
  73. ssh root@192.168.1.35 "nmcli con mod ens18 ipv6.addresses fc00:43f4:1eea:1::50; nmcli con mod ens18 ipv6.gateway fc00:43f4:1eea:1::1; nmcli con mod ens18 ipv6.method manual; nmcli con mod ens18 ipv6.dns "2400:3200::1"; nmcli con up ens18"
  74. # 参数解释
  75. #
  76. # ssh root@192.168.1.31
  77. # 通过SSH连接到IP地址为192.168.1.31的远程主机,使用root用户进行登录。
  78. #
  79. # "nmcli con mod ens18 ipv6.addresses fc00:43f4:1eea:1::10"
  80. # 使用nmcli命令修改ens18接口的IPv6地址为fc00:43f4:1eea:1::10。
  81. #
  82. # "nmcli con mod ens18 ipv6.gateway fc00:43f4:1eea:1::1"
  83. # 使用nmcli命令修改ens18接口的IPv6网关为fc00:43f4:1eea:1::1。
  84. #
  85. # "nmcli con mod ens18 ipv6.method manual"
  86. # 使用nmcli命令将ens18接口的IPv6配置方法修改为手动配置。
  87. #
  88. # "nmcli con mod ens18 ipv6.dns "2400:3200::1"
  89. # 使用nmcli命令设置ens18接口的IPv6 DNS服务器为2400:3200::1。
  90. #
  91. # "nmcli con up ens18"
  92. # 使用nmcli命令启动ens18接口。
  93. #
  94. # 这个命令的目的是在远程主机上配置ens18接口的IPv6地址、网关、配置方法和DNS服务器,并启动ens18接口。
  95. # 查看网卡配置
  96. # nmcli device show ens18
  97. # nmcli con show ens18
  98. [root@localhost ~]#  cat /etc/NetworkManager/system-connections/ens18.nmconnection
  99. [connection]
  100. id=ens18
  101. uuid=97445eea-70e8-47a7-8be4-a707de271f5e
  102. type=ethernet
  103. interface-name=ens18
  104. timestamp=1716705021
  105. [ethernet]
  106. [ipv4]
  107. address1=192.168.1.31/24,192.168.1.1
  108. dns=8.8.8.8;
  109. method=manual
  110. [ipv6]
  111. addr-gen-mode=default
  112. method=auto
  113. [proxy]
  114. [root@localhost ~]#
  115. # 参数解释
  116. # 1. `[connection]`:
  117. #    - `id`: 连接的唯一标识符,用于内部引用。
  118. #    - `uuid`: 连接的通用唯一标识符(UUID),确保在系统中的唯一性。
  119. #    - `type`: 指定连接的类型,本例中为以太网。
  120. #    - `interface-name`: 网络接口的名称(`ens18`),表示与此连接关联的物理或逻辑网络接口。
  121. #    - `timestamp`: 时间戳,指示连接配置上次修改的时间。
  122. # 2. `[ethernet]`:
  123. #    - 通常包含以太网特定的配置设置,如MAC地址或链路速度。
  124. # 3. `[ipv4]`:
  125. #    - `address1`: 以CIDR表示法指定IPv4地址和子网掩码(`192.168.1.31/24`)。还包括网关IP(`192.168.1.1`)。
  126. #    - `dns`: 指定要使用的DNS服务器(本例中为`8.8.8.8`),提供将域名转换为IP地址的手段。
  127. #    - `method`: 指定获取IPv4地址的方法。在本例中,设置为手动,表示IP地址是静态配置的。
  128. # 4. `[ipv6]`:
  129. #    - `addr-gen-mode`: 指定IPv6地址生成模式。设置为默认,通常意味着地址是根据接口的MAC地址生成的。
  130. #    - `method`: 指定获取IPv6地址的方法。在本例中,设置为自动,表示使用DHCPv6或SLAAC等协议进行自动配置。
  131. # 5. `[proxy]`:
  132. #    - 通常用于配置代理设置,如HTTP或SOCKS代理。
复制代码
1.3.设置主机名
  1. hostnamectl set-hostname k8s-master01
  2. hostnamectl set-hostname k8s-master02
  3. hostnamectl set-hostname k8s-master03
  4. hostnamectl set-hostname k8s-node01
  5. hostnamectl set-hostname k8s-node02
  6. # 参数解释
  7. #
  8. # 参数: set-hostname
  9. # 解释: 这是hostnamectl命令的一个参数,用于设置系统的主机名。
  10. #
  11. # 参数: k8s-master01
  12. # 解释: 这是要设置的主机名,将系统的主机名设置为"k8s-master01"。
复制代码
1.4.设置yum源
  1. # 其他系统的源地址
  2. # https://help.mirrors.cernet.edu.cn/
  3. # 对于私有仓库
  4. sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://mirror.centos.org/\$contentdir|baseurl=http://192.168.1.123/centos|g' -i.bak  /etc/yum.repos.d/CentOS-*.repo
  5. # 对于 Ubuntu
  6. sed -i 's/cn.archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
  7. # epel扩展源
  8. sudo yum install -y epel-release
  9. sudo sed -e 's!^metalink=!#metalink=!g' \
  10.     -e 's!^#baseurl=!baseurl=!g' \
  11.     -e 's!https\?://download\.fedoraproject\.org/pub/epel!https://mirror.nju.edu.cn/epel!g' \
  12.     -e 's!https\?://download\.example/pub/epel!https://mirror.nju.edu.cn/epel!g' \
  13.     -i /etc/yum.repos.d/epel{,-testing}.repo
  14. # 对于 CentOS 7
  15. sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
  16.          -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirror.nju.edu.cn/centos|g' \
  17.          -i.bak \
  18.          /etc/yum.repos.d/CentOS-*.repo
  19. # 对于 CentOS 8
  20. sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
  21.          -e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirror.nju.edu.cn/centos|g' \
  22.          -i.bak \
  23.          /etc/yum.repos.d/CentOS-*.repo
  24. # 对于CentOS 9
  25. cat <<'EOF' > /etc/yum.repos.d/centos.repo
  26. [baseos]
  27. name=CentOS Stream $releasever - BaseOS
  28. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/$basearch/os
  29. # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream&arch=$basearch&protocol=https,http
  30. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  31. gpgcheck=1
  32. repo_gpgcheck=0
  33. metadata_expire=6h
  34. countme=1
  35. enabled=1
  36. [baseos-debuginfo]
  37. name=CentOS Stream $releasever - BaseOS - Debug
  38. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/$basearch/debug/tree/
  39. # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-debug-$stream&arch=$basearch&protocol=https,http
  40. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  41. gpgcheck=1
  42. repo_gpgcheck=0
  43. metadata_expire=6h
  44. enabled=0
  45. [baseos-source]
  46. name=CentOS Stream $releasever - BaseOS - Source
  47. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/source/tree/
  48. # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-source-$stream&arch=source&protocol=https,http
  49. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  50. gpgcheck=1
  51. repo_gpgcheck=0
  52. metadata_expire=6h
  53. enabled=0
  54. [appstream]
  55. name=CentOS Stream $releasever - AppStream
  56. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/$basearch/os
  57. # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-$stream&arch=$basearch&protocol=https,http
  58. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  59. gpgcheck=1
  60. repo_gpgcheck=0
  61. metadata_expire=6h
  62. countme=1
  63. enabled=1
  64. [appstream-debuginfo]
  65. name=CentOS Stream $releasever - AppStream - Debug
  66. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/$basearch/debug/tree/
  67. # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-debug-$stream&arch=$basearch&protocol=https,http
  68. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  69. gpgcheck=1
  70. repo_gpgcheck=0
  71. metadata_expire=6h
  72. enabled=0
  73. [appstream-source]
  74. name=CentOS Stream $releasever - AppStream - Source
  75. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/source/tree/
  76. # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-source-$stream&arch=source&protocol=https,http
  77. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  78. gpgcheck=1
  79. repo_gpgcheck=0
  80. metadata_expire=6h
  81. enabled=0
  82. [crb]
  83. name=CentOS Stream $releasever - CRB
  84. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/$basearch/os
  85. # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream&arch=$basearch&protocol=https,http
  86. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  87. gpgcheck=1
  88. repo_gpgcheck=0
  89. metadata_expire=6h
  90. countme=1
  91. enabled=1
  92. [crb-debuginfo]
  93. name=CentOS Stream $releasever - CRB - Debug
  94. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/$basearch/debug/tree/
  95. # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-debug-$stream&arch=$basearch&protocol=https,http
  96. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  97. gpgcheck=1
  98. repo_gpgcheck=0
  99. metadata_expire=6h
  100. enabled=0
  101. [crb-source]
  102. name=CentOS Stream $releasever - CRB - Source
  103. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/CRB/source/tree/
  104. # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-source-$stream&arch=source&protocol=https,http
  105. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  106. gpgcheck=1
  107. repo_gpgcheck=0
  108. metadata_expire=6h
  109. enabled=0
  110. EOF
  111. cat <<'EOF' > /etc/yum.repos.d/centos-addons.repo
  112. [highavailability]
  113. name=CentOS Stream $releasever - HighAvailability
  114. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/HighAvailability/$basearch/os
  115. # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-$stream&arch=$basearch&protocol=https,http
  116. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  117. gpgcheck=1
  118. repo_gpgcheck=0
  119. metadata_expire=6h
  120. countme=1
  121. enabled=0
  122. [highavailability-debuginfo]
  123. name=CentOS Stream $releasever - HighAvailability - Debug
  124. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/HighAvailability/$basearch/debug/tree/
  125. # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-debug-$stream&arch=$basearch&protocol=https,http
  126. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  127. gpgcheck=1
  128. repo_gpgcheck=0
  129. metadata_expire=6h
  130. enabled=0
  131. [highavailability-source]
  132. name=CentOS Stream $releasever - HighAvailability - Source
  133. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/HighAvailability/source/tree/
  134. # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-source-$stream&arch=source&protocol=https,http
  135. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  136. gpgcheck=1
  137. repo_gpgcheck=0
  138. metadata_expire=6h
  139. enabled=0
  140. [nfv]
  141. name=CentOS Stream $releasever - NFV
  142. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/NFV/$basearch/os
  143. # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-$stream&arch=$basearch&protocol=https,http
  144. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  145. gpgcheck=1
  146. repo_gpgcheck=0
  147. metadata_expire=6h
  148. countme=1
  149. enabled=0
  150. [nfv-debuginfo]
  151. name=CentOS Stream $releasever - NFV - Debug
  152. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/NFV/$basearch/debug/tree/
  153. # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-debug-$stream&arch=$basearch&protocol=https,http
  154. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  155. gpgcheck=1
  156. repo_gpgcheck=0
  157. metadata_expire=6h
  158. enabled=0
  159. [nfv-source]
  160. name=CentOS Stream $releasever - NFV - Source
  161. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/NFV/source/tree/
  162. # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-source-$stream&arch=source&protocol=https,http
  163. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  164. gpgcheck=1
  165. repo_gpgcheck=0
  166. metadata_expire=6h
  167. enabled=0
  168. [rt]
  169. name=CentOS Stream $releasever - RT
  170. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/RT/$basearch/os
  171. # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-$stream&arch=$basearch&protocol=https,http
  172. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  173. gpgcheck=1
  174. repo_gpgcheck=0
  175. metadata_expire=6h
  176. countme=1
  177. enabled=0
  178. [rt-debuginfo]
  179. name=CentOS Stream $releasever - RT - Debug
  180. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/RT/$basearch/debug/tree/
  181. # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-debug-$stream&arch=$basearch&protocol=https,http
  182. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  183. gpgcheck=1
  184. repo_gpgcheck=0
  185. metadata_expire=6h
  186. enabled=0
  187. [rt-source]
  188. name=CentOS Stream $releasever - RT - Source
  189. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/RT/source/tree/
  190. # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-source-$stream&arch=source&protocol=https,http
  191. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  192. gpgcheck=1
  193. repo_gpgcheck=0
  194. metadata_expire=6h
  195. enabled=0
  196. [resilientstorage]
  197. name=CentOS Stream $releasever - ResilientStorage
  198. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/ResilientStorage/$basearch/os
  199. # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-$stream&arch=$basearch&protocol=https,http
  200. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  201. gpgcheck=1
  202. repo_gpgcheck=0
  203. metadata_expire=6h
  204. countme=1
  205. enabled=0
  206. [resilientstorage-debuginfo]
  207. name=CentOS Stream $releasever - ResilientStorage - Debug
  208. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/ResilientStorage/$basearch/debug/tree/
  209. # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-debug-$stream&arch=$basearch&protocol=https,http
  210. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  211. gpgcheck=1
  212. repo_gpgcheck=0
  213. metadata_expire=6h
  214. enabled=0
  215. [resilientstorage-source]
  216. name=CentOS Stream $releasever - ResilientStorage - Source
  217. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/ResilientStorage/source/tree/
  218. # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-source-$stream&arch=source&protocol=https,http
  219. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
  220. gpgcheck=1
  221. repo_gpgcheck=0
  222. metadata_expire=6h
  223. enabled=0
  224. [extras-common]
  225. name=CentOS Stream $releasever - Extras packages
  226. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/SIGs/$releasever-stream/extras/$basearch/extras-common
  227. # metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-$stream&arch=$basearch&protocol=https,http
  228. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
  229. gpgcheck=1
  230. repo_gpgcheck=0
  231. metadata_expire=6h
  232. countme=1
  233. enabled=1
  234. [extras-common-source]
  235. name=CentOS Stream $releasever - Extras packages - Source
  236. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/SIGs/$releasever-stream/extras/source/extras-common
  237. # metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-source-$stream&arch=source&protocol=https,http
  238. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
  239. gpgcheck=1
  240. repo_gpgcheck=0
  241. metadata_expire=6h
  242. enabled=0
  243. EOF
复制代码
1.6.选择性下载需要工具
  1. # 对于 Ubuntu
  2. apt update && apt upgrade -y && apt install -y wget psmisc vim net-tools nfs-kernel-server telnet lvm2 git tar curl
  3. # 对于 CentOS 7
  4. yum update -y && yum -y install  wget psmisc vim net-tools nfs-utils telnet yum-utils device-mapper-persistent-data lvm2 git tar curl
  5. # 对于 CentOS 8
  6. yum update -y && yum -y install wget psmisc vim net-tools nfs-utils telnet yum-utils device-mapper-persistent-data lvm2 git network-scripts tar curl
  7. # 对于 CentOS 9
  8. yum update -y && yum -y install wget psmisc vim net-tools nfs-utils telnet yum-utils device-mapper-persistent-data lvm2 git tar curl
复制代码
1.7.关闭防火墙
  1. # 下载必要工具
  2. yum -y install createrepo yum-utils wget epel*
  3. # 下载全量依赖包
  4. repotrack createrepo wget psmisc vim net-tools nfs-utils telnet yum-utils device-mapper-persistent-data lvm2 git tar curl gcc keepalived haproxy bash-completion chrony sshpass ipvsadm ipset sysstat conntrack libseccomp
  5. # 删除libseccomp
  6. rm -rf libseccomp-*.rpm
  7. # 下载libseccomp
  8. wget http://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/libseccomp-2.5.1-1.el8.x86_64.rpm
  9. # 创建yum源信息
  10. createrepo -u -d /data/centos7/
  11. # 拷贝包到内网机器上
  12. scp -r /data/centos7/ root@192.168.1.31:
  13. scp -r /data/centos7/ root@192.168.1.32:
  14. scp -r /data/centos7/ root@192.168.1.33:
  15. scp -r /data/centos7/ root@192.168.1.34:
  16. scp -r /data/centos7/ root@192.168.1.35:
  17. # 在内网机器上创建repo配置文件
  18. rm -rf /etc/yum.repos.d/*
  19. cat > /etc/yum.repos.d/123.repo  << EOF
  20. [cby]
  21. name=CentOS-$releasever - Media
  22. baseurl=file:///root/centos7/
  23. gpgcheck=0
  24. enabled=1
  25. EOF
  26. # 安装下载好的包
  27. yum clean all
  28. yum makecache
  29. yum install /root/centos7/* --skip-broken -y
  30. #### 备注 #####
  31. # 安装完成后,可能还会出现yum无法使用那么再次执行
  32. rm -rf /etc/yum.repos.d/*
  33. cat > /etc/yum.repos.d/123.repo  << EOF
  34. [cby]
  35. name=CentOS-$releasever - Media
  36. baseurl=file:///root/centos7/
  37. gpgcheck=0
  38. enabled=1
  39. EOF
  40. yum clean all
  41. yum makecache
  42. yum install /root/centos7/*.rpm --skip-broken -y
  43. #### 备注 #####
  44. # 安装 chrony 和 libseccomp
  45. # yum install /root/centos7/libseccomp-2.5.1*.rpm -y
  46. # yum install /root/centos7/chrony-*.rpm -y
复制代码
1.8.关闭SELinux
  1. # 下载必要工具
  2. yum -y install createrepo yum-utils wget epel*
  3. # 下载全量依赖包
  4. repotrack wget psmisc vim net-tools nfs-utils telnet yum-utils device-mapper-persistent-data lvm2 git network-scripts tar curl gcc keepalived haproxy bash-completion chrony sshpass ipvsadm ipset sysstat conntrack libseccomp
  5. # 创建yum源信息
  6. createrepo -u -d /data/centos8/
  7. # 拷贝包到内网机器上
  8. scp -r centos8/ root@192.168.1.31:
  9. scp -r centos8/ root@192.168.1.32:
  10. scp -r centos8/ root@192.168.1.33:
  11. scp -r centos8/ root@192.168.1.34:
  12. scp -r centos8/ root@192.168.1.35:
  13. # 在内网机器上创建repo配置文件
  14. rm -rf /etc/yum.repos.d/*
  15. cat > /etc/yum.repos.d/123.repo  << EOF
  16. [cby]
  17. name=CentOS-$releasever - Media
  18. baseurl=file:///root/centos8/
  19. gpgcheck=0
  20. enabled=1
  21. EOF
  22. # 安装下载好的包
  23. yum clean all
  24. yum makecache
  25. yum install /root/centos8/* --skip-broken -y
  26. #### 备注 #####
  27. # 安装完成后,可能还会出现yum无法使用那么再次执行
  28. rm -rf /etc/yum.repos.d/*
  29. cat > /etc/yum.repos.d/123.repo  << EOF
  30. [cby]
  31. name=CentOS-$releasever - Media
  32. baseurl=file:///root/centos8/
  33. gpgcheck=0
  34. enabled=1
  35. EOF
  36. yum clean all
  37. yum makecache
  38. yum install /root/centos8/*.rpm --skip-broken -y
复制代码
1.9.关闭交换分区
  1. # 下载必要工具
  2. yum -y install createrepo yum-utils wget epel*
  3. # 下载全量依赖包
  4. repotrack wget psmisc vim net-tools nfs-utils telnet yum-utils device-mapper-persistent-data lvm2 git tar curl
  5. # 创建yum源信息
  6. createrepo -u -d centos9/
  7. # 拷贝包到内网机器上
  8. scp -r centos9/ root@192.168.1.31:
  9. scp -r centos9/ root@192.168.1.32:
  10. scp -r centos9/ root@192.168.1.33:
  11. scp -r centos9/ root@192.168.1.34:
  12. scp -r centos9/ root@192.168.1.35:
  13. # 在内网机器上创建repo配置文件
  14. rm -rf /etc/yum.repos.d/*
  15. cat > /etc/yum.repos.d/123.repo  << EOF
  16. [cby]
  17. name=CentOS-$releasever - Media
  18. baseurl=file:///root/centos9/
  19. gpgcheck=0
  20. enabled=1
  21. EOF
  22. # 安装下载好的包
  23. yum clean all
  24. yum makecache
  25. yum install /root/centos9/*.rpm --skip-broken -y
复制代码
1.10.网络设置(俩种方式二选一)

[code]# Ubuntu忽略,CentOS执行,CentOS9不支持方式一# 方式一# systemctl disable --now NetworkManager# systemctl start network && systemctl enable network# 方式二cat > /etc/NetworkManager/conf.d/calico.conf  /etc/chrony.conf  /etc/chrony.conf > /etc/security/limits.conf  /etc/modules-load.d/ipvs.conf
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

温锦文欧普厨电及净水器总代理

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表