升級系統到centos7.9

2022-01-25 A 阿牛哥

公司有centos7.2和centos7.7系統百十臺,因辦公軟體的需要,要把所有的系統升級到centos7.9,百度了一下,還是覺得配置本地yum源比較合適,然後就是批量升級的操作了,別人建議使用ansible,可我沒學會,算了就使用py寫寫吧,步驟如下:

使用py批量登陸升級,因為root密碼都一樣,伺服器端可以聯網,客戶端皆不可以聯網
192.168.137.101 192.168.160.131 yum源伺服器,ftp192.168.160.129     客戶端,原來的系統centos7.2  3.10.0-327.el7.x86_64192.168.160.133     客戶端,原來的系統centos7.7  3.10.0-1062.el7.x86_64

CentOS-7-x86_64-DVD-2009.iso 掛載

可以使用CentOS-7-x86_64-Everything-2009.iso

然後複製裡面的內容到本地目錄

創建目錄mkdir -p /data/CentOS7.9
mount /dev/cdrom /mnt (因為是vmware 直接掛載的,所以才這麼操作,如果你是直接複製iso到伺服器上的話,那你需要執行mount -t iso9660 -o loop /root/CentOS-7-x86_64-DVD-2009.iso /mnt)
複製光碟內容到指定的目錄內cp -R /mnt/* /data/CentOS7.9/
修改CentOS-Media.repo文件
cd /etc/yum.repos.d修改vi CentOS-Media.repo 內容如下
[c7.9-media]name=CentOS-$releasever - Mediabaseurl=file:///data/CentOS7.9/gpgcheck=0enabled=1gpgkey=file:///data/CentOS7.9/RPM-GPG-KEY-CentOS-7
清空yum緩存目錄yum clean all
建立yum元數據緩存yum makecache
查看本機yum repo 倉庫yum repolist

然後安裝vsftp服務


安裝vsftpyum -y install vsftpd ftp
修改ftp配置文件 添加vi /etc/vsftpd/vsftpd.confanon_root=/data/CentOS7.9
啟動ftp systemctl start vsftpd systemctl enable vsftpd
測試ftp服務可用性 Trying ::1... Connected to localhost (::1). 220 (vsFTPd 3.0.2) Name (localhost:root): anonymous 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls

然後客戶端測試

客戶端配置本地yum源(ftp方式)配置yum源cd /etc/yum.repos.d/mkdir bakmv *.repo bak
編輯local.repo文件 tee CentOS-Local.repo << EOF[base]name=CentOS-Localbaseurl=ftp://192.168.160.131 gpgcheck=0enabled=1EOF
更新yum設置yum clean allyum makecacheyum repolist
測試配置yum -y install net-tools

然後就是py的命令了:

from tkinter import *from tkinter.messagebox import showinfofrom tkinter.ttk  import *import  paramikoimport time

class Xmlgrg(Tk): def __init__(self): super().__init__()
self.title("update") self.geometry("1200x600+400+100") self.resizable(0,0) self["bg"] = "lightblue"
        self.setup_UI()
def setup_UI(self): self.style01 = Style() self.style01.configure("TLabel",font=("微軟雅黑",10,"bold"),background="lightblue") self.style01.configure("TEntry",foregroud="navy") self.style01.configure("TButton",font=("微軟雅黑",10,"bold"),background="lightblue")

self.Label_FW = Label(self,text="伺服器名:") self.Label_FW.place(x=20,y = 20) self.Entry_FW = Entry(self,width=120,font=("微軟雅黑",10,"bold")) self.Entry_FW.place(x=90,y = 20) self.Entry_FW.insert(0,"多個主機之間使用 英文符號 , 隔開") self.Button_Status_Cpu_nu = Button(self, text="update7.9", width=10, command=self.SSHupdate) self.Button_Status_Cpu_nu.place(x=50, y=50) scrollBar = Scrollbar(self)
self.text = Text(self, width=155, height=33, yscrollcommand=scrollBar.set) self.text.place(x=20, y=100)
self.text.tag_config('tag1', background='yellow', foreground='red') self.text.tag_config('tag2', background='blue', foreground='red') self.text.tag_config('tag3', background='gray', foreground='red')
scrollBar.pack(side=RIGHT, fill=Y)
scrollBar.config(command=self.text.yview) def SSHupdate(self):
temp_name = str(self.Entry_FW.get()) temp_list = temp_name.split(",") self.text.delete(0.0, END)
for temp_num in range(0, len(temp_list)):
var_FWN = str(temp_list[temp_num])
self.command = "cd /etc/yum.repos.d/ && mkdir bak ; mv *.repo bak ; touch CentOS-Local.repo && echo \"[base]\" >> CentOS-Local.repo && echo \"name=CentOS-Local\" >> CentOS-Local.repo && echo \"baseurl=ftp://192.168.160.131 \" >> CentOS-Local.repo && echo \"gpgcheck=0\" >> CentOS-Local.repo && echo \"enabled=1\" >> CentOS-Local.repo && yum clean all && yum makecache && yum update -y && yum update kernel -y && sudo init 6 "


try: ssh_client = paramiko.SSHClient() ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_client.connect(hostname=var_FWN, port=22, username="root", password="Xmlgrgnqt...") except Exception as e: Ex_host = "############# " + var_FWN + " 連接異常 ###########\n" self.text.insert(INSERT, Ex_host, 'tag2') pass
else: stdin, stdout, stderr = ssh_client.exec_command(self.command)
ZHxx = "############# " + var_FWN + " update 已經在後臺運行 ###########\n"
self.text.insert(INSERT, ZHxx, 'tag1')

finally:                ssh_client.close()  class LoginWindow(Tk): """ 創建登錄窗體的GUI界面以及登錄的方法 """ def __init__(self): super().__init__() self.title("登錄界面") self.geometry("564x174+520+400") self.resizable(0 ,0)
self["bg"] = "lightblue"
        self.setup_UI()
self.user = "" self.password = ""
def setup_UI(self):
self.Style01 = Style() self.Style01.configure("user.TLabel", font=("微軟雅黑", 14 ,"bold"), foreground="red" ,background="lightblue") self.Style01.configure("TButton", font=("微軟雅黑", 13, "bold"))
self.Label_user = Label(self ,text="用戶名:" ,style="user.TLabel").place(x=10 ,y=80) self.var_user = StringVar() self.Entry_user = Entry(self ,width=10, textvariable=self.var_user ,font=("微軟雅黑", 14, "bold")).place(x=90                                                                                                             ,y=77) self.Label_password = Label(self, text="密碼:" ,style="user.TLabel").place(x=230 ,y=80) self.var_password = StringVar() self.Entry_password = Entry(self, width=10, textvariable=self.var_password, show="●" ,font=("微軟雅黑", 14, "bold")).place(x=295 ,y=77)
        self.Button_login = Button(self, text = "登錄" ,width=9 ,command = self.login).place(x=450 ,y=77)
def login(self): self.user = self.var_user.get() self.password = self.var_password.get()
        if self.user == 'admin' and self.password == 'Xmlgrgnqt': self.load_main()
else : showinfo("系統消息", "輸入的用戶名或者密碼錯誤")
def load_main(self): self.destroy()         main_window = Xmlgrg()   
if __name__ == "__main__": this_login = LoginWindow()    this_login.mainloop()

相關焦點

  • 如何將 CentOS 7 升級到 CentOS 8 Linux
    在本文中,您將學習如何將CentOS 7升級到
  • CentOS 7如何升級至CentOS 8.5?
    前言在本文中,您將了解如何將CentOS 7升級到CentOS 8.5版本。注意的是,本文介紹的方式僅僅是用於測試,生產環境上應該慎重使用。CentOS 7如何升級至CentOS 8.52. Step 1: 安裝EPEL倉庫執行以下命令安裝EPEL倉庫,用於補充軟體庫:yum install epel-release -y3.
  • CentOS6.5升級為CentOS7.0
    CentOS6.5升級為CentOS7升級前:[root@localhost ~]# cat /proc/version
  • 記一次CentOS 7.6內核升級(5.9.6)及故障總結
    957.el7.x86_64kernel-ml-devel-5.9.6-1.el7.elrepo.x86_64kernel-3.10.0-957.el7.x86_64abrt-addon-kerneloops-2.1.11-52.el7.centos.x86_64kernel-devel-3.10.0-957.el7.x86_64kernel-tools-3.10.0
  • 如何在 CentOS 7 中安裝或升級最新的內核
    例如,當你計算機上運行的程序想要連接到無線網絡時,它會將該請求提交給內核,後者又會使用正確的驅動程序連接到網絡。隨著新的設備和技術定期出來,如果我們想充分利用它們,保持最新的內核就很重要。此外,更新內核將幫助我們利用新的內核函數,並保護自己免受先前版本中發現的漏洞的攻擊。
  • 如何將 CentOS 7 遷移到 AlmaLinux 8
    進行系統備份升級前請確保備份所有重要數據,如果可能,請拍攝完整的 CentOS 7 系統快照,這樣,如果出現任何問題,都可以快速恢復。2.升級當前的CentOS 7系統升級過程的下一步是確保我們有一個完全升級的系統,使用以下命令更新現有軟體:sudo yum update更新所有軟體包後,重新啟動系統以應用更改。
  • CentOS 7.3 系統安裝
    一、系統安裝CentOS 7.x系列只有64位系統,沒有32位,成功引導系統後,會出現下面的界面界面說明:
  • VMware虛擬機安裝Centos系統
    系統,centos是一個免費開源的Linux作業系統,廣泛用於伺服器中。選擇Linux,再選擇對應的linux發行作業系統,因為這裡要安裝的是centos 7.9 64位的版本,所以選擇的是centos 7 64位。
  • CentOS 7.9正式發布,免費的企業級 Linux
    來自:Linux迷連結:https://www.linuxmi.com/centos-linux-7-9-red-hat-enterprise-linux
  • centos7.5升級安裝python3.6.5
    > 簡介由於需要調試公司的一個管理軟體,需要使用python3.5以上的版本,在這裡,我選擇安裝python3.6.5版本,下面就給大家分享一下,在centos7.5
  • CentOS 7下載及系統U盤製作
    2.雲盤下載(centos 7.7.1908標準版):連結:https://pan.baidu.com/s/1zOwbjVSbXj64SyNhun-sPw提取碼:g5ig3.以下是官網下載的圖文說明  最新版本下載,直接點擊紅框部分 下載其他版本,頁面往下翻,點擊下圖紅框部分
  • CentOS 7.8 (2003) 發布,附下載地址
    圖片獲取最近兩年爆款好文 」CentOS 7.8 已發布。眾所周知,CentOS 由 Red Hat Enterprise Linux 的原始碼重新編譯而成,因此 CentOS 7.8 的上遊版本正是本月初發布的 Red Hat Enterprise Linux 7.8。
  • CentOS 7.7 最新版本發布
    Centos官網已更新CentOS 7版本為CentOS 7.7(1908),國內各鏡像站大多數也已同步。
  • CentOS 8.0 系統安裝
    一、鏡像下載    1.CentOS官網     https://centos.org/download/二、系統安裝使用方向鍵選擇第一項 回車確定InstallCentOS Linux 8(安裝CentOS 8)Test this media & install CentOS Linux 8 ( 測試安裝文件並安裝CentOS 8)Troubleshooting (修復故障)
  • CentOS 7.3 安裝指南
    在菜單中選擇 「Install CentOS 7」並按下回車繼續。CentOS 7.3 啟動菜單2、 在安裝鏡像加載到內存完成後,會顯示一個歡迎頁面。選擇你在安裝中使用的語言並按下「繼續Continue」按鈕。
  • 虛擬機vm使用centOs7 linux部署sentry-前端錯誤日記監控系統
    前提條件centOs系統(64位)下載地址: http://mirrors.njupt.edu.cn/centos/7.8.2003/isos/
  • CENTOS 7 安裝教程
    根據大家最新在群裡的反饋,希望我們能提供一個Centos7的安裝教程,現將文檔,視頻整理如下1、使用工具UltraISO將系統刻錄到
  • 使用U盤安裝CentOS 7系統
    一、鏡像文件下載官網下載連結:https://www.centos.org/download/選擇與自己機器CPU架構相同的ISO,點擊進入鏡像選擇頁面,選擇適合自己需求的鏡像(最小 安裝或者其它)進行下載。
  • CentOS 6
    , 6.6, 6.7, 6.8 , 6.9 and 6.10 no longer get any updates, norany security fix's.The whole CentOS 6 is dead and shouldn't be used anywhere at all為此,民工哥特意去CentOS官方查了查,目前的各個版本的最後維護更新時間
  • 在 CentOS 7 CPanel 伺服器上安裝 MariaDB 10
    MariaDB 的優勢完全開源快速且透明的安全版本與 MySQL 高度兼容性能更好比 MySQL 的存儲引擎多在這篇文章中,我將談論關於如何在 CentOS7 CPanel 伺服器上升級 MySQL5.5 到最新的 MariaDB 。在安裝前先完成以下步驟。