Pages

Tuesday, July 14, 2015

Segmentation fault error 4 in liblftp-network.so

Hi,

I am getting the following errors in message log while mirroring the red-hat 7 latest packages using the mrepo and lftp 4.0.9. They are

Error:


lftp[26710]: segfault at 0 ip (null) sp 00007fffcd10e5e8 error 14 in lftp[400000+b000]
lftp[26769]: segfault at 18 ip 00007fdb03ff4808 sp 00007fff2270cda0 error 4 in liblftp-network.so[7fdb03fe2000+20000]

Cause:


Bug in lftp 4.0.9 package.

Solution:


To resolve the segmentation fault error, you need to install the latest lftp packages from the yum repo or download the source code to build and install lftp in the local system as follows:


Updating the lftp from repo

yum update lftp


Download the lftp

Download the lftp source code following url:

http://lftp.yar.ru/ftp/lftp-4.6.3a.tar.gz

Build the lftp:

Install the lftp from the source code as follows:

1. Pre-Requisite

Install the following packages to  install the lftp package:

yum install readline-devel gnutils-devel

2. Build Source Code

After installing the pre-requisite packages, please follow the procedure to build the lftp packages from the source code as follows:

./configure --prefix=/apps/lftp/ --with-gnutls=yes --with-openssl=yes
make
make install

It will install the lftp package in /apps/lftp directory.



Configuring lftp command

1. Edit the /etc/mrepo.conf and add replace the lftpcmd value with /apps/lftp/bin/lftp
2. Edit the /apps/lftp/etc/lftp.conf and add the following lines to download the redhat 7 packages from the cdn.redhat.com

set ssl:ca-file "/root/certs/redhat-uep.pem"
set ssl:key-file "/root/certs/cert-key.pem"
set ssl:cert-file "/root/certs/cert.pem"
set net:timeout 86400

3. Execute the following command to mirroring the redhat 7 packages:

    mrepo -guvvv redhat-7Server

    It will mirror the red-hat packages from the cdn.redhat.com

    Please refer my existing blog how to setup mrepo redhat 7
 

After installing the lftp latest 4.6.3a version, the segmentation issues are resolved.

Saturday, July 11, 2015

How to setup mrepo Redhat 7


The mrepo is a repository building tool for the synchronizing the remote repository to local yum or apt repositories.  The following configuration needs to be performed to configure mrepo local repositories in the redhat linux 7. They

1. Pre-requisite

Install the Red hat 7 Enterprise Edition.

2. Registering the System

Run the following command to register the system in red hat network.

subscription-manager register --username <Red Hat User Name> --password <Red Hat User Password> --auto-attach

After executing the above command, it will generate the client-key, client-cert and redhat-ca cert as follows:

Client Key : /etc/pki/entitlement/<Numeric Number>-key.pem
Client Cert:/etc/pki/entitlement/<Numberic Number>.pem
Redhat CA Cert: /etc/rhsm/ca/redhat-uep.pem

It will also generate the /etc/yum.repos.d/redhat.repo file.

3. Installing the Packages

 Run the yum update command to update the latest packages from the redhat network.

The following packages are required to configure the mrepo. They are

 3.1 lftp


       lftp is a ftp tool to get the repositories from the remote system. It supports ftp, sftp, http, and https protocols.

 3.2 httpd

       The httpd is a apache web server and it is being used to update the red hat systems in your network using yum repo.

 3.3 mrepo

      The mrepo is repository building tool and it being used to synchronize the remote system to local system repository using various protocols such as ftp,sftp, reposync, reposyncs, http and https.

 3.4 Installing lftp and httpd

    Run the  yum install lftp httpd command and it will install the lftp and httpd component in the linx system.

 3.5 Installing the mrepo

 By default mrepo package is not available in the redhat network and it is available in the repofroge repository.

Execute the following command download the mrepo:

wget http://pkgs.repoforge.org/mrepo/mrepo-0.8.8-0.pre1.el6.rft.noarch.rpm

After Downloading the mrepo rpm and execute the following command to install the mrepo.

yum install mrepo-0.8.8-0.pre1.el6.rft.noarch.rpm



4. Creating the Red Hat mrepo conf


Red Hat repository file needs to be created in the /etc/mrepo.conf.d/ directory and file name is redhat-7-x86_64.conf. This configuration is required because it will synchronize the remote repository to your local repository. Add the following content to the redhat-7-x86_64.conf file.

[redhat-7]
name = Red Hat Enterprise Linux Server $release ($arch)
release = 7
arch = x86_64
metadata = yum repomd

fastrack = https://cdn.redhat.com/rhel-x86_64-server-fastrack-7
os = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/os/Packages
extras = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/extras/os/Packages
rhn-tools = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/rhn-tools/os/Packages
oracle-java = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/oracle-java/os/Packages
rh-common = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/rh-common/os/Packages
supplementary = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/supplementary/os/Packages
optional = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/optional/os/Packages


5. Configuring the lftp.conf

The lftp.conf file needs to be configured because to store the lftp ssl parameter permanently in the global config. This configuration is required for to establish the connectivity from your local repository to remote repository.

5.1 SSL Configuration


set ssl:ca-file "/etc/rhsm/ca/redhat-uep.pem"
set ssl:key-file "/etc/pki/entitlement/<Numeric Number>-key.pem"
set ssl:cert-file "/etc/pki/entitlement/<Numeric Number>.pem"

5.2 Network Time Out


set net:timeout 86400

5.3 Testing the LFTP Connectivity

After configuring the step 5.1 and 5.2, you can verify the connectivity from local repository to remote repository as follows:

lftp  https://cdn.redhat.com/rhel-x86_64-server-fastrack-7

The above command will open the remote connectivity and you can navigate the files using lftp commands. For example, I want to list the data from the remote repository using ls command as follows:

ls -ltr

The above command will retrieve the data from the cdn.redhat.com network.


6. Configuring the Apache httpd conf

The mrepo.conf file needs to be modified in /etc/httpd/conf.d to display the repository info into the local repository web site. Edit the mrepo.conf file and search the Red Hat Enterprise Server5 string into the file and add next line to the Red Hat Enterprise Server 5.


AddDecription "Red Hat Enterprise Server 7 for x86_64" redhat-7-x86_64

 The redhat-7-x86_64 content is configured in the mrepo config file.  The redhat-7 is the section name and x86_64 is architecture. Both will be appended and created as directory /var/mrepo/redhat-7-x86_64 after synchronizing the repo using the mrepo command.


7. Synchronizing the Repository

Execute the following command to synchronize the red hat 7 repository to your local repository:

mrepo -guvv  <Repo Name>

For example my repo section name is redhat-7. The command look like this.

mrepo -guvv redhat-7

The above command will synchronize the remote repository to local repository.




8. Scheduling the Cron Job for Mrepo


After synchronizing the remote repository to local repository,  we need to synchronize the latest updates from remote repository to local repository using the Linux Daily Cron Job. For example my cron job will run every day at 2.30 AM and pull the changes from the redhat network.

We need to create  mrepo file in /etc/cron.d/ and add the following content to configure the cron job.

 30 2 * * * root /usr/bin/mrepo -q –ug


9. Enabling the Http Service

We need to enable the httpd service to restart automatically after rebooting the server. Execute the following command to enable the httpd service:

systemctl enable httpd

It will enable the service and also it create the symlinks for the httpd service as follows:

ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'


10. Configuring the Se-Linux Context

This step is mandatory only if your enable the se-linux. Configuring the selinux context for httpd  mrepo as follows:

semanage fcontext -a -t httpd_sys_content_t "/var/mrepo(/.*)?"

After executing the above command and it will configure the selinux context for mrepo and also it will persist the configuration details into the /etc/selinux/targeted/contexts/files/file_contexts.local file.

restorecon -R /var/mrepo

After executing the above command and it will read the configuration from the /etc/selinux/targeted/contexts/files/file_contexts.local file and enable the selinux context for the directory /var/mrepo