How to convert RHEL 6.x to CentOS 6.x

Last modified: [last-modified]

This post relates to my older post about converting RHEL 5.x to CentOS 5.x. All the reasons for doing so and other background information can be found in that post.

This post will cover how to convert RHEL 6.x to 5.x.

Updated 2016-03-29 – Thanks to feedback from here I’ve updated the guide.

Updates and Backups!

  1. Fully patch your system and reboot your system before starting this process
  2. Take a full backup of your system or a Snapshot if it’s a VM

Conversion

  1. Login to the server and become root
  2. Clean up yum’s cache
    localhost:~ root# yum clean all
  3. Create a temporary working area
    localhost:~ root# mkdir -p /temp/centos
    localhost:~ root# cd /temp/centos
  4. Determine your version of RHEL
    localhost:~ root# cat /etc/redhat-release
  5. Determine your architecture (32-bit = i386, 64-bit = x86_64)
    localhost:~ root# uname -i
  6. Download the applicable files for your release and architecture. The version numbers on these packages could change. To find the current versions of these files browse this FTP site: http://mirror.centos.org/centos/6/os/i386/Packages/ (32-bit) or http://mirror.centos.org/centos/6/os/x86_64/Packages/ (64-bit) and replace the ‘x’ values below with the current version numbers
    CentOS 6.5 / 32-bit

    localhost:~ root# wget http://mirror.centos.org/centos/6/os/i386/RPM-GPG-KEY-CentOS-6
    localhost:~ root# wget http://mirror.centos.org/centos/6/os/i386/Packages/centos-release-6-x.el6.centos.x.x.i686.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/6/os/i386/Packages/centos-indexhtml-6-x.el6.centos.noarch.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/6/os/i386/Packages/yum-x.x.x-x.el6.centos.noarch.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/6/os/i386/Packages/yum-plugin-fastestmirror-x.x.x-x.el6.noarch.rpm

    CentOS 6.5 / 64-bit

    localhost:~ root# wget http://mirror.centos.org/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6
    localhost:~ root# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/centos-release-6-x.el6.centos.xx.x.x86_64.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/centos-indexhtml-6-x.el6.centos.noarch.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-x.x.xx-xx.el6.centos.noarch.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-x.x.xx-xx.el6.noarch.rpm
  7. Import the GPG key for the appropriate version of CentOS
    localhost:~ root# rpm --import RPM-GPG-KEY-CentOS-6
  8. Remove RHEL packages

    Note:
    If the ‘rpm -e’ command fails saying one of the packages is not installed remove the package from the command and run it again.

    localhost:~ root# yum remove rhnlib abrt-plugin-bugzilla redhat-release-notes*
    localhost:~ root# rpm -e --nodeps redhat-release-server-6Server redhat-indexhtml
  9. Remove any left over RHEL subscription information and the subscription-manager

    Note:
    If you do not do this every time you run ‘yum’ you will receive the following message: “This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.”

    localhost:~ root# subscription-manager clean
    localhost:~ root# yum remove subscription-manager
  10. Force install the CentOS RPMs we downloaded
    localhost:~ root# rpm -Uvh --force *.rpm
  11. Clean up yum one more time and then upgrade
    localhost:~ root# yum clean all
    localhost:~ root# yum upgrade
  12. Reboot your server
  13. Verify functionality
  14. Delete VM Snapshot if you took one as part of the backup

 

References

 

How to convert RHEL 5.x to CentOS 5.x

Last modified: [last-modified]

We’ve got a semi-large fleet of Redhat Enterprise Linux (RHEL) 5 and 6 servers where I work and we want to convert them over to CentOS to save on licensing costs.

I searched around online and found a few guides on how to do it but ultimately I had to pull from all three and make a few tweaks to get everything working.

I’ve used these steps to convert a single 32-bit RHEL 5 system to CentOS 5. These instructions should also work for the 64-bit version. I will have another post in the coming days on how to do this with RHEL 6/CentOS 6.

If you’re using RHEL 6.x and want to convert to CentOS 6.x check out this post

Updated 2016-03-29 – Thanks to feedback from here I’ve updated the guide.

Updates and Backups!

  1. Fully patch your system and reboot your system before starting this process
  2. Take a full backup of your system or a Snapshot if it’s a VM

Conversion

  1. Login to the server and become root
  2. Clean up yum’s cache
    localhost:~ root# yum clean all
  3. Create a temporary working area
    localhost:~ root# mkdir -p /temp/centos
    localhost:~ root# cd /temp/centos
  4. Determine your version of RHEL
    localhost:~ root# cat /etc/redhat-release
  5. Determine your architecture (32-bit = i386, 64-bit = x86_64)
    localhost:~ root# uname -i
  6. Download the applicable files for your release and architecture. The version numbers on these packages could change. This document was written as of CentOS 5.10. To find the current versions of these files browse this FTP site: http://mirror.centos.org/centos/5/os/i386/CentOS/ (32-bit) and http://mirror.centos.org/centos/5/os/x86_64/CentOS/ (64-bit)
    CentOS 5.10 / 32-bit

    localhost:~ root# wget http://mirror.centos.org/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-x.el5.centos.i386.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-x.x-x.i386.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-x.x.xx-xx.el5.centos.noarch.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-updatesd-x.x-x.el5.noarch.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-fastestmirror-x.x.xx-xx.el5.centos.noarch.rpm

    CentOS 5.10 / 64-bit

    localhost:~ root# wget http://mirror.centos.org/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/centos-release-5-xx.el5.centos.x86_64.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/centos-release-notes-x.xx-x.x86_64.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/yum-x.x.xx-xx.el5.centos.noarch.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/yum-updatesd-x.x-x.el5.noarch.rpm
    localhost:~ root# wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/yum-fastestmirror-x.x.xx-xx.el5.centos.noarch.rpm
  7. Import the GPG key for the appropriate version of CentOS
    localhost:~ root# rpm --import RPM-GPG-KEY-CentOS-5
  8. Remove the RHEL release files
    localhost:~ root# rpm -e --nodeps redhat-release
  9. Remove the Redhat Network plugin for yum
    localhost:~ root# rpm –e --nodeps yum-rhn-plugin
  10. Removing the remaining RHEL files that may be install on the system
    localhost:~ root# rpm –e --nodeps rhn-client-tools rhn-setup rhn-check rhn-virtualization-common rhnsd redhat-logos redhat-release-notes rhel-instnum
    

    Note: If this command fails saying a package is not installed remove the package from the command and run it again.

  11. Install the CentOS RPMs we downloaded previously (make sure you are still in /temp/centos)
    localhost:~ root# rpm -Uvh --force *.rpm
  12. Upgrade to CentOS from RHEL
    localhost:~ root# yum upgrade
  13. Reboot the server
  14. Verify functionality
  15. Delete the VM Snapshot if you took one as part of the backup.

If you’re running a GUI on your server

We’re running Gnome on our servers and after performing the following error is displayed:

There was an error loading the theme RHEL
Can't open file /usr/share/gdm/themes/RHEL/RHEL.xml

and looks like this:

RHEL Theme Error

To fix it follow these steps:

  1. Click past the messages and get to the login screen and login
  2. Click ‘System’ and ‘Administration’ and ‘Login Screen’
  3. Select ‘CentOS Default’ so there is a dot beside it
  4. Click ‘Close’
  5. Press CTRL+ALT+BACKSPACE on your keyboard and the desktop should reload to the login screen with no error

References

How to upgrade Gitlab 5.4 to 6.0 on CentOS 6 or RHEL6

Last modified: [last-modified]

The upgrade instructions found on Gitlab’s official website are what I followed to upgrade my installation of Gitlab.

The only alterations I’ve made are to match my unique configuration from earlier articles on this website.

If you haven’t already upgrade your Gitlab to 5.4 before proceeding with these instructions. I never wrote a 5.2 -> 5.3 or a 5.3 -> 5.4 upgrade guide. The procedure was fairly straight forward and I just followed the official documents offered by Gitlab and referred to my earlier upgrade posts for 5.0 -> 5.1 and 5.1 -> 5.2.

1. Backup all of your Gitlab Data first. I ran these commands but ended up with an error. I run other separate backups so I wasn’t concerned. You may have better luck.

[[email protected] ~]# su - sa_gitlab
[[email protected] ~]$ cd ~/gitlab
[[email protected] gitlab]$ RAILS_ENV=production bundle exec rake gitlab:backup:create

 

2. Switch back to root and install a missing dependency and shutdown Gitlab and then switch back to sa_gitlab

[[email protected] gitlab]$ exit

[[email protected] ~]# yum install python-docutils

[[email protected] ~]# service gitlab stop
# Wait 1-2 minutes for everything to shut down

[[email protected] ~]# su - sa_gitlab

 

3. Download the latest code

[[email protected] ~]$ cd ~/gitlab
[[email protected] gitlab]$ git fetch
[[email protected] gitlab]$ git stash
[[email protected] gitlab]$ git checkout 6-0-stable

 

4. Update Gitlab Shell

[[email protected] gitlab]$ cd ~/gitlab-shell/
[[email protected] gitlab-shell]$ git fetch
[[email protected] gitlab-shell]$ git checkout v1.7.0

 

5. Update Gitlab

[[email protected] ~]$ cd ~/gitlab
[[email protected] gitlab]$ bundle install --without development test postgres --deployment
[[email protected] gitlab]$ bundle exec rake db:migrate RAILS_ENV=production
[[email protected] gitlab]$ bundle exec rake migrate_groups RAILS_ENV=production
# When prompted choose 'Yes'

[[email protected] gitlab]$ bundle exec rake migrate_global_projects RAILS_ENV=production
[[email protected] gitlab]$ bundle exec rake migrate_keys RAILS_ENV=production
# When prompted choose 'Yes'

[[email protected] gitlab]$ bundle exec rake migrate_inline_notes RAILS_ENV=production
[[email protected] gitlab]$ bundle exec rake assets:precompile RAILS_ENV=production

 

6. Backup your old configuration files

[[email protected] gitlab]$ cd config
[[email protected] config]$ mv gitlab.yml gitlab.yml.54
[[email protected] config]$ mv unicorn.rb unicorn.rb.54

 

7. Create new configuration files

[[email protected] config]$ cp gitlab.yml.example gitlab.yml
[[email protected] config]$ cp unicorn.rb.example unicorn.rb

# Now move all of your settings from the .54 backups we just made into the new files
# There are a lot of new lines in the unicorn.rb that need to be changed from '/home/git' to '/data/apps/sa_gitlab'
# There is no longer a need to comment out the socket line in unicorn.rb

 

8. Update the init script

[[email protected] config]$ exit

[[email protected] ~]# cd /etc/init.d/
[[email protected] init.d]# mv gitlab gitlab.54
[[email protected] init.d]# curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/init.d/gitlab
[[email protected] init.d]# chmod +x /etc/init.d/gitlab
[[email protected] init.d]# vim gitlab

# -------- Make the following edits --------

APP_ROOT="/data/apps/sa_gitlab/gitlab"
APP_USER="sa_gitlab"

# -------- Save and close the file --------

 

9. Start-up Gitlab 6!

[[email protected] init.d]# service gitlab start

# The start-up took a few minutes on my system

 

That’s it!

How to upgrade Gitlab 5.1 to 5.2 on CentOS 6 or RHEL6

Last modified: [last-modified]

This document assumes you’ve followed my previous post for deploying Gitlab on CentOS 6/RHEL6 and have already upgraded that deployment from 5.0 to 5.1.

If you haven’t already switched from the default version (1.7.1) of git that comes with CentOS 6 / RHEL6 to git 1.8.2.3 please follow this post first before continuing with these instructions. Even if you don’t care about that error message follow the instructions so you’re using git 1.8.2.3 instead of 1.7.1.

Now then. Lets get to it.

1. Stop gitlab and switch to sa_gitlab

[[email protected] ~] service gitlab stop
[[email protected] ~] ps aux |grep git
[[email protected] ~] su - sa_gitlab

 

2. Get the latest code for Gitlab and Gitlab-shell

[[email protected] ~] cd gitlab
[[email protected] gitlab] git fetch

# If you get an error about schema.rb run these two commands and then re-run 'git checkout 5-2-stable'. Otherwise skip these two commands (it won't hurt anything if you run them though)
[[email protected] gitlab] cp db/schema.rb db/schema.rb.current
[[email protected] gitlab] git stash

[[email protected] gitlab] git checkout 5-2-stable
[[email protected] gitlab] cd ..
[[email protected] ~] cd gitlab-shell/
[[email protected] gitlab-shell] git fetch
[[email protected] gitlab-shell] git checkout v1.4.0

 

3. Install libs, migrations, etc? (I stole this from the Gitlab guys)

[[email protected] gitlab-shell] cd ..
[[email protected] ~] cd gitlab
[[email protected] gitlab] bundle install --without development test postgres --deployment
[[email protected] gitlab] bundle exec rake db:migrate RAILS_ENV=production

 

4. Switch back to root and update the init script

[[email protected] gitlab] exit
[[email protected] ~] mv /etc/init.d/gitlab /etc/init.d/gitlab.51
[[email protected] ~] wget "https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/init.d/gitlab" -O /etc/init.d/gitlab
[[email protected] ~] vim /etc/init.d/gitlab

# -------- Make the following edits --------

	APP_ROOT="/data/apps/sa_gitlab/gitlab"
	APP_USER="sa_gitlab"

# -------- Save and close the file --------

[[email protected] ~] chmod 755 /etc/init.d/gitlab

 

5. Start up Gitlab

[[email protected] ~] service gitlab start

 

You should be good to go at this point. The first load took a while for me after the update.

 

References

Commit comments not appearing in Gitlab on CentOS

Last modified: [last-modified]

If you followed my earlier documentation, or simply installed Gitlab yourself on CentOS 6 you might run into this problem:

When you go to the ‘Files’ view of one of your repositories it won’t load any of the commit comments. It just appears to perpetually load.

If you look in your ‘production.log’ you’ll see an error like this:

Processing by RefsController#logs_tree as JS
  Parameters: {"_"=>"1369162443960", "project_id"=>"USERNAME/geoip-lookup", "id"=>"master"}
  Rendered refs/logs_tree.js.haml (57.2ms)
Completed 500 Internal Server Error in 98ms

ActionView::Template::Error (undefined method `committed_date' for nil:NilClass):
    4:
    5:   :plain
    6:     var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}");
    7:     row.find("td.tree_time_ago").html('#{escape_javascript time_ago_in_words(commit.committed_date)} ago');
    8:     row.find("td.tree_commit").html('#{escape_javascript render("tree/tree_commit_column", commit: commit)}');
  app/views/refs/logs_tree.js.haml:7:in `block in _app_views_refs_logs_tree_js_haml__4074553552003765415_53128340'
  app/views/refs/logs_tree.js.haml:1:in `each'
  app/views/refs/logs_tree.js.haml:1:in `_app_views_refs_logs_tree_js_haml__4074553552003765415_53128340'

It looks like this is a bug with git itself and not Gitlab.

There is a patch you can manually apply to your Gitlab deployment OR you could just upgrade git to the latest and greatest version. I chose to upgrade git. The below guide assumes you followed my original “How to install Gitlab 5.0 on CentOS 6 or RHEL6” guide. I’ve updated that guide to reflect these new steps.

1. Get logged in to your server and become ‘sa_gitlab’

[[email protected] ~] su - sa_gitlab
[[email protected]~]

 

2. Create a temp directory if you don’t have one and move into it

[[email protected]~] mkdir temp
[[email protected]~] cd temp

 

3. Download the latest source for git from https://code.google.com/p/git-core/downloads/list. As of this writing 1.8.2.3 is the latest version

[[email protected]~] wget -c https://git-core.googlecode.com/files/git-1.8.2.3.tar.gz
[[email protected]~] tar -xf git-1.8.2.3.tar.gz
[[email protected]~] cd git-1.8.2.3

 

4. Configure, compile and install git 1.8.2.3

[[email protected]~] ./configure --prefix=/data/apps/sa_gitlab/git
[[email protected]~] make
[[email protected]~] make install

 

5. Configure your environment so the new version of git overrides the default CentOS version

[[email protected]~] vim ~/.bashrc

# -------- Make the following edits --------

# Change the PATH line to look like this:
PATH=$HOME/git/bin:$HOME/ruby/bin:$PATH:$HOME/bin;

# -------- Save and close the file --------

[[email protected]~] vim ~/.bash_profile

# -------- Make the following edits --------

# Change the PATH line to look like this:
PATH=$HOME/git/bin:$HOME/ruby/bin:$PATH:$HOME/bin;

# -------- Save and close the file --------

 

6. Re-export your path and verify which git is being used and it’s version

[[email protected]~] PATH=$HOME/git/bin:$HOME/ruby/bin:$PATH:$HOME/bin;

[[email protected]~] which git
~/git/bin/git

[[email protected] ~] git --version
git version 1.8.2.3

 

7. Update your gitlab.yml configuration file

[[email protected] ~] cd gitlab
[[email protected] gitlab] vim config/gitlab.yml

# -------- Make the following edits --------

  git:
    bin_path: /data/apps/sa_gitlab/git/bin/git

# -------- Save and close the file --------

 

8. Restart Gitlab

[[email protected] gitlab] exit

[[email protected] ~] service gitlab stop

# Wait 1-2 minutes for everything to exit

[[email protected] ~] service gitlab start

 

That’s it!

Update May 22nd, 2013 – Added step 7. Didn’t realise you had to edit the gitlab.yml file to point to the new git binary location. I assumed Gitlab used the git binary it found via PATH.