Difference between revisions of "Centos Upgrade 4.x to 5.x"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(updated release rpm links)
(improved tar based backup/restore)
 
(25 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
follow these steps:
 
follow these steps:
  
1 - Create a container using centos-4-i386-minimal and set a valid nameserver  
+
==Create the container==
 +
 
 +
Create a container using centos-4-i386-minimal and set a valid nameserver:
 
<pre>
 
<pre>
vzctl create CTID --ostemplate centos-4-i386-minimal --config CONFIG_TEMPLATE --ipadd container_IP --hostname temp
+
vzctl create $CTID --ostemplate centos-4-i386-minimal --config CONFIG_TEMPLATE --ipadd container_IP --hostname temp
vzctl set CTID --nameserver NAMESERVER_IP --save
+
vzctl set $CTID --nameserver NAMESERVER_IP --save
 
</pre>
 
</pre>
2 - Enter in container
+
 
 +
 
 +
==Install centos-5-release packages==
 +
Use <code>vzctl exec</code> to execute the rpm install command on the container:
 +
 
 
<pre>
 
<pre>
vzctl enter CTID
+
vzctl exec $CTID rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.6-0.i386.rpm \ http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-6.el5.centos.1.i386.rpm
</pre>
 
3 - Install centos-5-release packages
 
<pre>
 
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.5-0.i386.rpm
 
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-5.el5.centos.i386.rpm
 
 
</pre>
 
</pre>
 
Note: centos-release-5 depends on notes-package, start with that one.
 
Note: centos-release-5 depends on notes-package, start with that one.
  
4 - Backup your /dev/, since initscripts need udev and will remove vzdev you'll net the backup
+
==Backup dev==
 +
 
 +
Backup the container /dev/ directory, as initscripts needs udev and will remove vzdev you'll need the backup:
 +
 
 
<pre>
 
<pre>
tar -cf dev.tar ./dev
+
tar -cf $CTID.dev.tar -C /vz/private/$CTID dev
 
</pre>
 
</pre>
5 - Install initscripts package (forced and with no deps)
+
 
 +
==Install initscripts package==
 +
 
 +
Install initscripts package (forced and with no deps), as per below:
 +
 
 
<pre>
 
<pre>
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.30-2.el5.centos.i386.rpm --force --nodeps
+
vzctl exec $CTID rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.33-1.el5.centos.i386.rpm --force --nodeps
 
</pre>
 
</pre>
6 - Exit from container
+
 
 +
Note: If the "transfer failed", go to the [http://mirror.centos.org/centos/5/os/i386/CentOS/ CentOS5 mirror] and find the latest initscripts rpm and use that instead.
 +
 
 +
==Update conf file==
 +
 
 +
Edit /etc/vz/conf/$CSID.conf and replace
 
<pre>
 
<pre>
exit
+
OSTEMPLATE="centos-4-i386-minimal"
 
</pre>
 
</pre>
7 - In /etc/vz/conf/CSID.conf replace
+
with
 
<pre>
 
<pre>
OSTEMPLATE="centos-4-i386-minimal"
+
OSTEMPLATE="centos-5-i386-minimal"
 
</pre>
 
</pre>
to
+
 
 +
Alternatively, use the 'sed' command to replace it:
 
<pre>
 
<pre>
OSTEMPLATE="centos-5-i386-minimal"
+
sed -i 's#OSTEMPLATE="centos-4#OSTEMPLATE="centos-5#g' /etc/vz/conf/$CTID.conf
 
</pre>
 
</pre>
8 - Coppy existing template from
+
 
 +
==Copy existing template==
 +
 
 +
Copy existing template from:
 +
 
 
<pre>
 
<pre>
 
/vz/template/centos/4
 
/vz/template/centos/4
Line 50: Line 68:
 
/vz/template/centos/5
 
/vz/template/centos/5
 
</pre>
 
</pre>
9 - In /vz/template/centos/4/i386/config/yum.conf change mirrors to CentOS 5
 
  
10 - Upgrade container packages using vzyum (32bit only)
+
==Update yum.conf==
 +
 
 +
In /vz/template/centos/5/i386/config/yum.conf change mirrors to CentOS 5
 +
 
 +
Using sed:
 +
 
 
<pre>
 
<pre>
vzyum CTID upgrade
+
sed -i 's#centos4#centos5#g' /vz/template/centos/5/i386/config/yum.conf
 +
sed -i 's#CentOS 4#CentOS 5#g' /vz/template/centos/5/i386/config/yum.conf
 +
sed -i 's#centos/4/#centos/5/#g' /vz/template/centos/5/i386/config/yum.conf
 
</pre>
 
</pre>
Note: on 64-bit yum db-version might complain. Do "rm /vz/root/VZNUM/var/lib/rpm/__*" to delete conflicting DB.
 
  
11 - Stop your VE
+
==Upgrade container packages==
 +
 
 +
db-version will complain, so delete the conflicting database first:
 
<pre>
 
<pre>
vzctl stop CTID
+
rm -fr /vz/root/$CTID/var/lib/rpm/__*
 
</pre>
 
</pre>
12 - Replace the new /dev/ with the old one
+
 
 +
Now run vzyum to upgrade the contain packages:
 
<pre>
 
<pre>
cd /vz/private/CTID
+
vzyum $CTID upgrade
rm -rf dev
 
tar -xvf dev.tar
 
 
</pre>
 
</pre>
13 - Leave the container private dir (or it will not stard)
+
 
 +
===Troubleshooting===
 +
 
 +
If you get this error:
 +
 
 +
<pre>
 +
Error: Missing Dependency: python-abi = 2.3 is needed by package python-elementtree
 +
</pre>
 +
 
 +
and/or
 
<pre>
 
<pre>
cd
+
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
 +
Public key for libsepol-1.15.2-3.el5.i386.rpm is not installed
 
</pre>
 
</pre>
14 - Start the container
+
 
 +
You need to run the following before trying again:
 +
 
 
<pre>
 
<pre>
vzctl start CTID
+
vzctl exec $CTID rpm -e --justdb python-elementtree --nodeps
 +
vzctl exec $CTID rpm --import http://mirrors.kernel.org/centos/RPM-GPG-KEY-CentOS-5
 
</pre>
 
</pre>
15 - Remove container IP
+
 
 +
==Test your VE==
 +
Check you can enter your VE:
 
<pre>
 
<pre>
vzctl set --ipdel container_IP
+
vzctl enter $CTID
 
</pre>
 
</pre>
16 - Stop container
+
 
 +
All went OK? Exit the VE:
 
<pre>
 
<pre>
vzctl stop CTID
+
exit
 
</pre>
 
</pre>
17 - Create the template
+
 
 +
===Troubleshooting===
 +
 
 +
<pre>
 +
Unable to open pty: No such file or directory
 +
</pre>
 +
If you see errors like this, see the [[VPS_enter_failed]] article.
 +
 
 +
==Stop your VE==
 +
<pre>
 +
vzctl stop $CTID
 +
</pre>
 +
 
 +
==Restore dev==
 +
 
 +
This will replace the new /dev/ with the old one:
 +
<pre>
 +
mv /vz/private/$CTID/dev /vz/private/$CTID/dev.old
 +
tar -xvf $CTID.dev.tar -C /vz/private/$CTID
 +
</pre>
 +
 
 +
== Remove container IP ==
 +
<pre>
 +
vzctl set $CTID --ipdel all --save
 +
</pre>
 +
 
 +
==Create the template==
 
<pre>
 
<pre>
cd /vz/private/CTID
+
cd /vz/private/$CTID
tar --numeric-owner -zcf /vz/template/cache/centos-5.0-i386-minimal.tar.gz .
+
tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .
 
</pre>
 
</pre>

Latest revision as of 22:25, 2 June 2011

Yellowpin.svg Note: this article is not formatted according to this Wiki standards. Please help reformatting it in a better way.

To create a CentOS 5 minimal template from centos-4-i386-minimal, follow these steps:

Create the container[edit]

Create a container using centos-4-i386-minimal and set a valid nameserver:

vzctl create $CTID --ostemplate centos-4-i386-minimal --config CONFIG_TEMPLATE --ipadd container_IP --hostname temp
vzctl set $CTID --nameserver NAMESERVER_IP --save


Install centos-5-release packages[edit]

Use vzctl exec to execute the rpm install command on the container:

vzctl exec $CTID rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.6-0.i386.rpm \ http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-6.el5.centos.1.i386.rpm

Note: centos-release-5 depends on notes-package, start with that one.

Backup dev[edit]

Backup the container /dev/ directory, as initscripts needs udev and will remove vzdev you'll need the backup:

tar -cf $CTID.dev.tar -C /vz/private/$CTID dev

Install initscripts package[edit]

Install initscripts package (forced and with no deps), as per below:

vzctl exec $CTID rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/initscripts-8.45.33-1.el5.centos.i386.rpm --force --nodeps

Note: If the "transfer failed", go to the CentOS5 mirror and find the latest initscripts rpm and use that instead.

Update conf file[edit]

Edit /etc/vz/conf/$CSID.conf and replace

OSTEMPLATE="centos-4-i386-minimal"

with

OSTEMPLATE="centos-5-i386-minimal"

Alternatively, use the 'sed' command to replace it:

sed -i 's#OSTEMPLATE="centos-4#OSTEMPLATE="centos-5#g' /etc/vz/conf/$CTID.conf

Copy existing template[edit]

Copy existing template from:

/vz/template/centos/4

to

/vz/template/centos/5

Update yum.conf[edit]

In /vz/template/centos/5/i386/config/yum.conf change mirrors to CentOS 5

Using sed:

sed -i 's#centos4#centos5#g' /vz/template/centos/5/i386/config/yum.conf
sed -i 's#CentOS 4#CentOS 5#g' /vz/template/centos/5/i386/config/yum.conf
sed -i 's#centos/4/#centos/5/#g' /vz/template/centos/5/i386/config/yum.conf

Upgrade container packages[edit]

db-version will complain, so delete the conflicting database first:

rm -fr /vz/root/$CTID/var/lib/rpm/__*

Now run vzyum to upgrade the contain packages:

vzyum $CTID upgrade

Troubleshooting[edit]

If you get this error:

Error: Missing Dependency: python-abi = 2.3 is needed by package python-elementtree

and/or

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
Public key for libsepol-1.15.2-3.el5.i386.rpm is not installed

You need to run the following before trying again:

vzctl exec $CTID rpm -e --justdb python-elementtree --nodeps
vzctl exec $CTID rpm --import http://mirrors.kernel.org/centos/RPM-GPG-KEY-CentOS-5

Test your VE[edit]

Check you can enter your VE:

vzctl enter $CTID

All went OK? Exit the VE:

exit

Troubleshooting[edit]

Unable to open pty: No such file or directory

If you see errors like this, see the VPS_enter_failed article.

Stop your VE[edit]

vzctl stop $CTID

Restore dev[edit]

This will replace the new /dev/ with the old one:

mv /vz/private/$CTID/dev /vz/private/$CTID/dev.old
tar -xvf $CTID.dev.tar -C /vz/private/$CTID

Remove container IP[edit]

vzctl set $CTID --ipdel all --save

Create the template[edit]

cd /vz/private/$CTID
tar --numeric-owner -zcf /vz/template/cache/centos-5.5-i386-minimal.tar.gz .