Posts Tagged ‘yum’

Using yum with SOCKS proxy

Sunday, June 30th, 2019

SSH is a wonderful tool. One of its best features is the ability to pierce a firewall and let you go through it. If you’re using the dynamic port (-D as argument in command line openSSH), you actually get a SOCKS5 proxy over which you can transport all your desired data.

This allows you the freedom of accessing the Internet from a restricted machine, on the condition it can connect via SSH to another unrestricted machine. So – how does it work?

To simplify things – you will need two sessions on your restricted machine. Use the first to connect via SSH to an unrestricted machine, with the argument, in our example, -D 10000

What it tells the SSH connection is to create a SOCKS5 proxy locally (on the restricted machine) over port 10000, and all the transport sent there – to transfer through the remote (unrestricted) server.

Using the other session, we can implement local variable like this:

export http_proxy=socks5://localhost:10000

export https_proxy=socks5://localhost:10000

It sets a variable which yum (among many other programs) can read and use. Afterwards, using the same session, running ‘yum update‘ or ‘yum install package‘ will result in yum running through the proxy connection. Of course – the SSH session to the unrestricted server must be active at all times, or else yum command will fail.

Quick solve package dependency with rpm –aid

Tuesday, January 22nd, 2008

This is relevant for Redhat EL 3 and 4, and any other compatible system not using “yum”. RHEL5 uses “yum”, and its RPM system does not include the “–aid” flag, which we require so much.

1. Place all the available RPMS (I assume these are the installation medias, combined) in a single directory – for example: /mnt

2. Install manually the “rpmdb” package

3. Edit /etc/rpm/macros.solve and change two lines:

%_solve_pkgsdir /mnt

%_solve_name_fmt /mnt/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm

-Notice: I have used /mnt. Replace it your preferred directory

Following these steps, any encounter with RedHat’s infamous “dependency hell” can be solved by using the flag “–aid” for the RPM command

“Pinning” a package using “YUM”

Sunday, January 6th, 2008

YUM is a nice (and useful, when used correctly) tool to manage packages, using RPM as its engine. APT, the Debian alternative, has this ability, and so does YUM.

YUM does not pin a specific version of a package, but rather avoids upgrading it as soon as it was marked. It remains installed, but never will it be upgraded, even if other packages require a specific, newer, version of this package.

This “upgrade prevention” can be done using the directive “exclude=” inside /etc/yum.conf, where the values are the names of the packages (wildcards can be used!), space limited.

And a big “thank you” to Omer, who have pointed out my mistake. Too much NIS lately…

mime_decode-1 FAILED: Can’t locate object method “seek” via package “File::Temp ” at /usr/lib/perl5/vendor_perl/5.8.5/MIME/Parser.pm line 816

Sunday, January 6th, 2008

This is the error message I have seen in my Linux+Postfix+Amavisd-new system. Not only that, but Amavis has kept a copy of each message in its tmp directory, which reduced my /var size to nothing quite rapidly.

amavis[21189]: (21189-01) (!)PRESERVING EVIDENCE in /var/amavis/tmp/amavis-200
80103T051116-21189

Doesn’t sound too good.

Partial search in google has produced the following mailing list compressed archive, which pointed me onwards. It could either be a problem with Amavis, or with Perl.

After some further investigation, it appears that RpmForge has released a non-compatible version of perl-MIME-tools – from 5.420 to 5.425-1-test. It was quite disappointing, but I had to downgrade the perl package to its origin (the latest which worked), and to force yum never to upgrade that specific package.

This one will be on a different post (for the sake of order and search ability).

Preperation of recovery server for RPM based systems

Monday, July 23rd, 2007

On most cases, when preparing a recovery server, you can just ‘tar’ the entire server’s contents and just move it, along with a short recipe on how to rebuild the original partition layout (software Raid? LVM? flat partition tables?), how to mount volumes in-place, how to extract the tar files into the right locations, and how to install your favorite boot loader, either Lilo or Grub. Also, beforehand, you deal with taking a nice snapshot (or capturing the system in a single-user phase), and life is good, yada yada yada.

Most of us, however, never prepare for a rainy day. It’s not that we don’t want to, it’s not that we don’t plan, it’s just that we never seem to get to it, and after all, the hardware is rather new, and there should be no reason for failure. I can guess some of you heard this before – maybe in their own voices.

So, backup is a tiring job, and I will not deal with the things you need to do to maintain a replica of your data, but I will deal with how to prepare, quickly and easily, a system-recovery server (or a postmortem server) with just a little thought beforehand. This might be a bit too late for you if you’re reading it now, but, well, for the next time…

This little trick worked (as part of a large-scale process) when I migrated a server from 64bit server to a 32bit server (yeah, I know – the other way around).

It assumes you use RPM as your tool to install applications, and that if you do not, you have a method of knowing which piece of software you installed from source, and which package was installed from an external source (not your day-to-day RPM repository).

On the source server, run ‘rpm -qa > /tmp/rpmlist.long‘. Keep this file. It is important. Also, try to keep your yum.repos.d directory, or at least know which rpm repositories you use (I always use rpmforge, so I see no problem with that).

Install your target server – Same version as the source, minimal package selection. Copy the file rpmlist.long to /tmp. Make sure yum is configured (I will deal here with YUM, but you can replace it with any other repository client of your choice). Run the two following lines:

cat /tmp/rpmlist.long | sed s/-[0-9].*$/”/g > /tmp/rpmlist-short

for i in `cat /tmp/rpmlist-short`; do

yum install -y $i

done

This will add the missing RPMs with their dependencies, and will bring your system to a similar status. At least, this is a good place to start recovering.

On future chapters:

– Fully migrating from 64 to 32 bit and vice versa

– Using LVM snapshots for a smart backup, and for a smart recovery