rhel 5 添加 centos 源

2020-9-10 学长 Linux

先卸载原rhel的yum

别心疼。。。反正你不会去买rhn的

su

进入root下

rpm -aq|grep yum|xargs rpm -e --nodeps

没错是原版的yum全卸载

看自己的系统是x86的还是x64的

uname -a

有 x86_64的用这组地址的rpm

wget http://vault.centos.org/5.11/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
wget http://vault.centos.org/5.11/os/x86_64/CentOS/python-iniparse-0.2.3-6.el5.noarch.rpm
wget http://vault.centos.org/5.11/os/x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm
wget http://vault.centos.org/5.11/os/x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm

rpm -ivh python-iniparse-0.2.3-6.el5.noarch.rpm 
rpm -ivh yum-metadata-parser-1.1.2-4.el5.x86_64.rpm
rpm -ivh yum-3.2.22-40.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm 


普通32位的系统

5.11
http://vault.centos.org/5.11/
wget http://vault.centos.org/5.11/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
wget http://vault.centos.org/5.11/os/i386/CentOS/python-iniparse-0.2.3-6.el5.noarch.rpm
wget http://vault.centos.org/5.11/os/x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm
wget http://vault.centos.org/5.11/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm

rpm -ivh python-iniparse-0.2.3-6.el5.noarch.rpm 
rpm -ivh yum-metadata-parser-1.1.2-4.el5.i386.rpm
rpm -ivh yum-3.2.22-40.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm


5.5
wget http://vault.centos.org/5.5/os/i386/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
wget http://vault.centos.org/5.5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
wget http://vault.centos.org/5.5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
wget http://vault.centos.org/5.5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm

rpm -ivh python-iniparse-0.2.3-4.el5.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
rpm -ivh yum-3.2.22-26.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

5.4
wget http://vault.centos.org/5.4/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
wget http://vault.centos.org/5.4/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
wget http://vault.centos.org/5.4/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
wget http://vault.centos.org/5.4/os/i386/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm

rpm -ivh python-iniparse-0.2.3-4.el5.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm 
rpm -ivh yum-3.2.22-20.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm

下载后安装

最后下自己回车

cd /etc/yum.repos.d/

下载网上别人发的这些centos 5.11的源文件

wget --no-check-certificate https://gist.githubusercontent.com/yogeshlonkar/e2abd1064b0ea8f629048cc06b3333a2/raw/78a56b2063751250fa71a23bdd6691b60e328980/CentOS-Base.repo
wget --no-check-certificate https://gist.githubusercontent.com/yogeshlonkar/e2abd1064b0ea8f629048cc06b3333a2/raw/78a56b2063751250fa71a23bdd6691b60e328980/CentOS-Debuginfo.repo
wget --no-check-certificate https://gist.githubusercontent.com/yogeshlonkar/e2abd1064b0ea8f629048cc06b3333a2/raw/78a56b2063751250fa71a23bdd6691b60e328980/CentOS-fasttrack.repo
wget --no-check-certificate https://gist.githubusercontent.com/yogeshlonkar/e2abd1064b0ea8f629048cc06b3333a2/raw/78a56b2063751250fa71a23bdd6691b60e328980/CentOS-Media.repo
wget --no-check-certificate https://gist.githubusercontent.com/yogeshlonkar/e2abd1064b0ea8f629048cc06b3333a2/raw/78a56b2063751250fa71a23bdd6691b60e328980/CentOS-Sources.repo
wget --no-check-certificate https://gist.githubusercontent.com/yogeshlonkar/e2abd1064b0ea8f629048cc06b3333a2/raw/78a56b2063751250fa71a23bdd6691b60e328980/CentOS-Vault.repo


导入centos的key

rpm -import http://vault.centos.org/RPM-GPG-KEY-CentOS-5

然后yum就可以用了。。。


如果出现

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   /usr/lib/python2.4/site-packages/_sqlitecache.so: wrong ELF class: ELFCLASS32

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.4.3 (#1, Jun 11 2009, 14:09:37) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq

基本上就x86_64系统用了x86的yum-metadata-parser导致的,卸载重装就好了。。。


评论(0) 浏览(1787)

VMware Tools Shrink功能进行虚拟硬盘压缩

2020-9-10 学长 Linux

虚拟机直接关机后压缩对于刚删除很多大文件的情况下并不能立马释放磁盘空间


在虚拟中先确认安装过vm tools工具包

yum list open-vm-tools

一般通过vm安装的系统都是安装了的

没有的话可以通过虚拟机右键重新安装vmware tools或者

sudo yum install open-vm-tools

查看分区挂载的位置

sudo vmware-toolbox-cmd disk list

默认的挂载就那几个,跟目录,引导,用户分区

sudo vmware-toolbox-cmd disk shrink /

压缩根目录 /

一般都是根目录比较大,要么就是 /home


不要在操作的时候压缩。。。因为需要等很久。。。别告诉我你虚拟硬盘加载在内存里。。。

评论(0) 浏览(1764)

xfs 系统误删恢复(不是网上那种先xfsdump备份然后在xfsrestore)

2020-9-9 学长 Linux

烂大街的,备份后恢复

https://blog.51cto.com/14449524/2433036


提前说下,不保证能全部找回。。。毕竟。。。误删后数据的完整性得不到保证的

首先说要用的工具

https://github.com/ianka/xfs_undelete

这是个tclsh编写的

tcl一般的系统都是带的

需要sudo yum install tcllib

用法就是 

下载然后放到一个新硬盘中 tar -xvf 这个压缩包


第一步建议新建个虚拟硬盘,把被rm -rf 删除文件所在的分区备份一遍

虚拟机中添加一个硬盘,一定要比你要备份的分区大。。。

然后重启挂载这个硬盘

看下挂载的地址

df 别格错盘了

find /dev -name "sd*"

对比下,没挂载的才是新硬盘。。。一般第一块是sda,第二块是sdb以此类推

在硬盘上创建分区

fdisk /dev/sdb

n

p

w

这样/dev下就有了个sdb1分区

格式化分区

mkfs.xfs /dev/sdb1

挂到data目录下

没权限su 或者 sudo

mkdir /data

mount /dev/sdb1 /data

找到误删的文件或文件夹在的目录

查看是挂在哪个分区上的

df .

假设你删除的文件在home下

那么返回就是/dev/mapper/centos-home

然后给误删的分区做镜像

logout图形界面

ctr+alt+F3 进入 指令界面

需要把分区先卸载了

umount 挂载点

确认下/data 是否挂载

df /data

有的时候umount顺带把  这个耶卸载了。。。

xfs_copy  /dev/mapper/centos-home /data/随便什么名字

100%后运行

mount /dev/mapper/centos-home /home

logout登出

然后cd 到解压 xfs_undelete的目录

xfs_undelete -t 2020-09-09 镜像的分区

这样在这个时候之后删除的文件能找出都会放在undeleted文件夹中


因为是新建的分区,权限和分组加下

sudo chmod a=rwx

sudo chown 改成图形界面用的账户

sudo chgrp 改成该账户所在的组 


评论(0) 浏览(5230)

手机版 | RSS | FEED

苏ICP备16066175号