Linux.com

Community Blogs



CentOS / RHEL: Yum Lock Package Version At a Particular Version

yum-plugin-versionlock plugin takes a set of name/versions for packages and excludes all other versions of those packages (including optionally following obsoletes). This allows you to protect packages from being updated by newer versions, for example. This quick tutorial explains how to install and use yum versionlock to prevent package update using yum on a CentOS or RHEL based server.

Read more: CentOS / RHEL: Yum Lock Package Version At a Particular Version

 

Configuring Apache2 to run Python Scripts

This is meant as a simple writeup to fill a gap in various "HOWTO"'s that I read when trying to setup my Apache2 server to process python scripts as CGI, though it would apply to any cgi scripts (perl scripts, compiled binaries...).
I've been developing for years (C, C++, PHP), but had never delved into python before, and I wanted to be able to have my scripts have a web interface.

The first step is getting Apache2 to recognize that my .py files were to be executed and not spit out as text files.
docs.python.org has some nice HOWTOs (http://docs.python.org/3.3/howto/webservers.html) on how to think about python and the web, and apache.org has mountains of documentation (http://httpd.apache.org/docs/2.2/howto/cgi.html) relating to running CGIs. What I didn't find was a simple guide on how to set it up. I'm a developer, not a sys-admin, and while I like knowing how to configure Apache and tune my linux boxes, sometimes I just want to get my webserver up and running and start coding.

So, in case anyone was going through the same situation as me, here is my quick and dirty setup.

For reference, this setup was done on Ubuntu 13.10, using ubuntu's default apache2 installation, and python3.
I'm also assuming you know how to configure apache for a basic html site. There are lots of HOWTO's for that.

Starting the basics:

  • apache install: sudo apt-get install apache2
  • python install: sudo apt-get install python

or

  • python3 install: sudo apt-get install python3

The first step, which in my PHP experience I never had to do, is not mentionned in the guides above is to enable CGI processing in apache.

sudo a2enmod cgi

This will automatically enable mod_cgid if your server is configured with a multi-threaded MPM, which was the case for me.

Then you can either make a folder in your site's path where your cgi files will live, or configure certain directories to handle certain file types as cgi scripts.
This is described well in the apache2 doc above, but essentially you to make all files in a cgi folder be executed, you would use this conf:

<Directory /srv/www/yoursite/public_html/cgi-bin>
        Options ExecCGI
        SetHandler cgi-script
    </Directory>

and to allow .py files to be executed as scripts in a particular folder you would use this conf:

    <Directory /srv/www/yoursite/public_html>
        Options +ExecCGI
        AddHandler cgi-script .py
    </Directory>

Once you have that, if you're running python 3, you can make a python script like this one, and stick it in whichever folder is configured for cgi:

    #!/usr/bin/env python
    # -*- coding: UTF-8 -*-# enable debugging
    import cgitb
    cgitb.enable()
    print("Content-Type: text/html;charset=utf-8")
    print()
    print("Hello World!")

You can change the first line from

#!/usr/bin/env python

to

#!/path/to/your/python/binary

such as

#!/usr/bin/python3

in case the default is python and you want this script to be parsed by python3

 

Several Monitoring Metrics for Virtualized Infrastructure

To build a virtualized cloud infrastructure, four major elements play the vital role in the way to design a virtual infrastructure from its physical counterpart. These four elements are at the level of processors, memory, storage and network. In the continuity of the design, there is the life of the infrastructure, that is to say the daily operations. Is it administering the daily virtual infrastructure as they do in a physical environment? Pooling many resources involves consideration of other parameters that we will see here.

Processors performance monitoring

Although the concept of virtual (vCPU) for a hypervisor (VMware or Microsoft Hyper-V) is close to the notion of the physical heart, a virtual processor is much less powerful than a physical processor. Noticeable CPU load on a virtual server can be absolutely more important than the physical environment. But nothing to worry about if the server has been sized to manage peak loads. In contrast, maintenance of indict alert threshold often makes more sense and it is wise to adjust.

By the way, all hypervisors are not necessarily within a server farm. The differences may be at the level of processors (generation, frequency, cache) or other technical characteristics. This is something to consider as a virtual server that can be migrated to warm hypervisor to another (vMotion in VMware, Microsoft Live Motion). After a trip to warm virtual server, the utilization of the processor can then vary.

Does the alert threshold define by taking into account the context changes?

The role of the scheduler in access to physical processors is per virtual servers. You may not be able to access it immediately, because there would be more virtual servers, more access and waiting time (latency) which is important to consider. In addition, performance monitoring is not limited solely to identify how power is used, but also to be able to detect where it is available. In extreme cases it is possible to visualize a virtual server with low CPU load. This indicator of processor latency for each virtual server is an indicative of a good use of the available power. Do not believe that the power increases by adding virtual processors to the server, it is actually more complex and it is often the opposite effect of what is required to happen. Usually, you need to send this problem by analyzing the total number of virtual processors on each hypervisor.

Monitoring the memory utilization

If the memory is shared between the virtual servers running within the same hypervisor, it is important to distinguish used and unused memory. The used memory is usually statically allocated to virtual server while the unused memory is pooled. Due to this reason it is possible to run virtual servers with a total memory which also exceeds the memory capacity of hypervisor. The memory over-provisioning of virtual servers on hypervisor is not trivial. It is a kind of risk taking, betting that all servers will not use their memory at the same time. There is no concern of the type “it is” or “this is wrong”, much depends on the design of virtual servers. However, monitoring will prevent it from becoming a source of performance degradation.

A first important result is that over provisioning prevents starting of all virtual servers simultaneously. Indeed, a hypervisor verifies that it can affect the entire memory of a virtual server before starting it. It is possible to start with a timer so that everyone releases its unused memory in a specific order.

The slower memory access is second consequence. VMware has implemented a method of garbage collection (called as a ballooning) with virtual servers. It occurs when the hypervisor is set to provide memory to a virtual server when available capacity is insufficient. The hypervisor strength release memory with virtual servers. This freed memory is then distributed to servers as needed. This mechanism is not immediate; there is some latency between the request for memory allocation and its effectiveness. This is the reason it slows down memory access. This undermines the good performance of the servers.

Another consequence of the ballooning, it can also completely change the behavior of the server’s memory. Linux systems are known to use available memory and keep it cached when it is released by the process (memory that does not appear to be free). The occupancy rate of memory of such a server is relatively stable and high. This rate will decrease with ballooning and will not be stable (frequent releases and increases).

Also there are cases where used memory can be pooled between virtual servers. This appears when the ballooning is not enough. Performance is greatly degraded when it is a situation to be avoided.

 

Installing Red5 Media Server on CentOS and RHEL

Red5 Media Server is a powerful media streaming server worked on RTMP protocal. Red5 is an open and extensible platform, which can be used in Video Conferencing or Network gaming.

Read this article to How to install Red5 media server on CentOS and RHEL Systems

 

How To Install Tomcat 7 Server on CentOS & RedHat

Apache Tomcat is an opensource webserver product of Apache Foundation like Apache HTTP server. It is used to deploying Java Servlet and JSP applications. To deploy any application in Tomcat we can simply create a war file and deploy them. 

Read this article Install Apache Tomcat on CentOS/RHEL servers for details information.

 

How to Install Zabbix Monitoring Tool on Linux

How to Install Zabbix Monitoring Tool on Linux. Zabbix is an open source software for networks and application monitoring. Zabbix provides agents to monitor remote hosts as well as Zabbix includes support for monitoring via SNMP, TCP and ICMP checks. Click here to know more about zabbix.


Click here to read full article

Zabbix is an open source software for networks and application monitoring. Zabbix provides agents to monitor remote hosts as well as Zabbix includes support for monitoring via SNMP, TCP and ICMP checks. Click here to know more about zabbix.
 

A Simple BASH Script to Test Your Internet Connectivity

Most of the users all over the world make use of Google's Index Page to check whether their Internet connection is working or not.  Many times it is required to check periodically whether the server you are running is connected to internet or not. It is very cumbersome to open the web page every time you wish to check the connection. As an alternative, it definitely makes sense to run some scripts in the background periodically scheduling them using cron.

Read More on YourOwnLinux...

 

Making Bootable USB using Syslinux

Note Kindly check the following packages on your system: 1. syslinux if not installed then install it using yum yum install syslinux 2. qemu-system-x86_64 ( i am installin 64 bit fedora so to test the pen drive finally we need this Virt. machine) if not installed then install it using yum yum install -y qemu.x86_64 it will take some time Note if you dont want to test ur pen drive then you can skip the above step: Now we can start the process 1. Download the ISO image of the OS ( Linux) on you system and mount the same under some directory. e.g with the following command. mount -t iso9660 /home/harkamal/ISO/Fedora-16-x86_64-Live-KDE.iso /mnt/iso/ 2. use a pen drive which doesn't contain any files, it can have folders but not free files. and at least 1GB free space. Now find out where you pen drive has mounted automaticall it gets mounted on /media/HARKAMAL Note: HARKAMAL is the LABEL of my pen drive yours could be something else pl. note it. command to find out where your pen drive gets mounted are df -h or fdisk -l use the first one as root user or use sudo instead. in my case it was /deb/sdb1 pl note it too. 3. go to /mnt/iso with the command cd /mnt/iso ( here u have mounted the ISO img. in step 1 with mount cmd) 4 Now run cp * -rv /media/HARKAMAL/ note: pl change the LABLEL accordingly 5 now run the following command syslinux --install -d EFI/boot/ /dev/sdb1 6 Now go to the directory /media/HARKAMAL/EFI/boot cd /media/HARKAMAL/EFI/boot 7. here copy isolinux.cfg to syslinux.cfg command is: cp isolinux.cfg syslinux.cfg 8 Now we have to edit the file syslinux.cfg open it using vim and changes the very first stanza under the heading label linux0 consisting of the line: "append initrd=initrd0.img root=live:CDLABEL=Fedora-16-x86_64-Live-KDE.iso rootfstype=auto ro liveimg quiet rhgb rd.luks=0 rd.md=0 rd.dm=0" now remove 'quiet and rhgb' entries from the above line and also remove root=live:CDLABEL=Fedora-16-x86_64-Live-KDE.iso change it to root=LABEL=HARKAMAL after making the above changes the line should finally look like: append initrd=initrd0.img root=LABEL=HARKAMAL rootfstype=auto ro liveimg rd.luks=0 rd.md=0 rd.dm=0 Note there should not be any space between root,LABELand HARKAMAL Now our usb is ready to use we can test it by running the following command on Virtual machine. command to test the USB is: qemu-system-x86_64 -hda /dev/sdb1 -m 256 -vga std. if you virtual machine gets started with installing Fedora 16 option it menas ur USN+B is ready to use and install the ISO Enjoy))))))))))))))))) Keep Posted Regards Harkamal

 

Linux vs Windows Data Servers (the bottom line)

Based on years of writing software within a network environment, and communicating with database servers running on both Microsoft Windows or Linux that provide access to databases like Microsoft SQL server and PostgreSQL  I have to say, Microsoft better look over their shoulders,  the competition is gaining a strong hold on corporate decision makers and how they foresee the future's bottom line.

At this point, the money paid out with setting up a Microsoft SQL data server by the time they factor in the cost of the operating system, the database software, the per-seat licensing, and support you almost have to take a step back and scratch your head with how much money it takes to put this in production.

Again, based on my own experience, I’m not sure why anyone would want their corporate data on a Windows-based server that requires a lot more money and maintenance to keep the server up and running, while maintaining availability, reliability, and security.

A well configured Linux data server provides a much better overall experience for a fraction of the cost.

With how companies are struggling to operate in the green, why anyone wouldn’t explore these open source options like PostgreSQL, MySQL, and operating systems like CentOS just doesn’t make any sense.

 

How to Configure (And Troubleshoot) Pulp: The Ultimate Repository Management Tool

Pulp is a nifty piece of python code which I recently deployed to manage some ( a lot, actually) external linux repositories. Pulp is a great tool if you want to manage a lot of repositories and related content like packages, arches, distros and erratas etc. It'll not only help you to mirror the repositories but also to do remote installs to the clients (pulp calls it consumers) and groups. So, let us get started.
Make sure that you have a good amount of disk space on your server.
There is a really good documentation here on how the installation works. I'll write about some tips and tricks which are not there in the documentation.
1. How do I install it on Scientific Linux and other Enterprise Linux Servers, nss package is not of the latest version?
You need to enable the rolling repo for in Scientific Linux for this. It is not included in the yum.conf.d by default so chances are that you'll get an older version of nss if rolling repo is not added.
2. I am getting a "SSL WrongHost" error. How do I fix that?
First, you need to pick a hostname for the server (localhost.localdomain is a bad choice). Set the hostname using command "hostname ". Now we are going to generate a certificate for this domain to get rid of ssl error.
Just do a "cd /etc/pki/tls/certs/" and there will be a localhost.crt. Just rename it to something else and run "make testcrt" to get a new certificate. Follow the said steps closely in order.
3. I installed both pulp and pulp-cds on same server and now I am getting httpd alias problem. How to resolve?
Well, I understand the enthusiasm of trying out stuff but pulp and pulp-cds are not supposed to be installed on same server, not unless you know the ins and outs of pulp and what you are doing. The problem occurs because both pulp.conf and pulp-cds.conf in conf.d has same alias defined but for different targets. So comment out the Alias in pulp-cds.conf or get rid of the pulp-cds package all together, I would do the later one.
4. I want to use the repo using http. How do I do that?
Just find out the lines mentioned below in httpd conf directory and comment them out using "#".
SSLRequireSSL
SSLVerifyClient optional_no_ca
SSLVerifyDepth 2
SSLOptions +StdEnvVars +ExportCertData

 

Migrate Bugzilla 3.0 Server to a Bugzilla 4.0 Server

Summary

I recently did a migration from Bugzilla 3.0 running on one server to Bugzilla 4.0 running on a new server.  Since I was already writing these down as I went, I thought that I would share these instructions with the greater Linux community.  You may find that some of these instructions may need to be run in a slightly different order, but this is a pretty complete account of what it took to get this going on the new server.  I know that I had to periodically go back the the ./checksetup.pl script over and over throughout the process to check myself and figure out what needed to occur next.  I tried to arrange all of these in an order that will work, but if you have to install the bugzilla folder first and continually re-run ./checkseutp.pl, it's pretty much what I had to do.

These instructions are for RedHat 5.5.

Backup Your Current Bugzilla 3.0 Database

These directions all assume that you have a Bugzilla 3.0 database that you've backed up with teh following commands: 

sudo mkdir /data/backups/mysql-bugzilla-3.0
sudo chown www-data.www-data /data/backups/mysql-bugzilla-3.0
mysqldump -u bugs --password=XXXXXXXXX bugs | gzip -9v > `date '+/data/backups/mysql-bugzilla-3.0/bugs_%Y%m%d.sql.gz'`

 

Setup Apache

Install the Web Server, set the run levels, and start the service:

[root@mybugzilla]# yum groupinstall "Web Server"
[root@mybugzilla]# yum chkconfig --levels 2345 httpd on
[root@mybugzilla]# service httpd restart


Try the main site to ensure that apache is setup correctly by browsing to your site name or to http://localhost

You should see the default apache site showing that the webserver is installed properly.


Modify the httpd.conf file

Open the /etc/httpd/conf/httpd.conf file in your favorite editor.  Add these lines to the end of your httpd.conf file:

PerlSwitches -w -T
PerlConfigRequire /var/www/html/bugz/mod_perl.pl

Also make sure that you have the line "KeepAlive Off" per the bugzilla install instructions.

Restart Apache

[root@mybugzilla]# service httpd restart

Setup MySQL

Install MySQL, set the service to start on boot, and set the mysql root password:

[root@mybugzilla]# <b>yum groupinstall "MySQL Database"</b>
[root@mybugzilla]# <b>chkconfig --levels 2345 mysqld</b>
[root@mybugzilla]# <b>service mysqld restart</b>
[root@mybugzilla]# <b>/usr/bin/mysqladmin -u root password 'XXXX'</b>


Now login to mysql:

[root@mybugzilla]#  <b>mysql -pXXXX</b>


Once logged into mysql as root, create the bugs user and the database:

mysql> create user 'bugs'@'localhost' IDENTIFIED BY 'XXXpasswordXXX';
mysql> create database bugs;
mysql> show databases;

Restore data

These instructions assume that you followed the above instructions for exporting your bugzilla database from Bugzilla 3.0.

[root@mybugzilla]# cd /path/to/restore/file
[root@mybugzilla]# gunzip bugs_20110414.sql.gz
[root@mybugzilla]# mysql -u root -pXXXX bugs < bugs_20110414.sql

Grant Permissions

Login to mysql as above and run

mysql> grant all on bugs.* to 'bugs'@'localhost';

 

Fix MySQL Defaults in /etc/my.cnf

Edit the /etc/my.cnf file and add these lines under the [mysqld] section:

[mysqld]
# Allow packets up to 4MB
max_allowed_packet=4M

# Allow small words in full-text indexes
ft_min_word_len=2


This ensures that uploaded attachments to bugs is now 4MB instead of the default 1MB.

Restart MySQL

Restart the service to ensure any changes above are loaded:

service mysqld restart

 

Setup Bugzilla

Prep Bugzilla

Create the directories and download Bugzilla:

[root@mybugzilla]# cd /var/www
[root@mybugzilla]# mkdir bugz
[root@mybugzilla]# cd bugz
[root@mybugzilla]# wget http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-4.0.tar.gz
[root@mybugzilla]# tar xzvf bugzilla-4.0.tar.gz
[root@mybugzilla]# cd /var/www/html
[root@mybugzilla]# ln -s ../bugz/bugzilla-4.0 bugz
[root@mybugzilla]# cd /var/www/bugz/bugzilla-4.0

 

Install Bugzilla Dependencies

./checksetup.pl --check-modules


You will be told you should run several commands to install all the perl modules.  For example,
I was told to run these:

[root@mybugzilla]# /usr/bin/perl install-module.pl Digest::SHA
[root@mybugzilla]# /usr/bin/perl install-module.pl Date::Format
[root@mybugzilla]# /usr/bin/perl install-module.pl DateTime
[root@mybugzilla]# /usr/bin/perl install-module.pl DateTime::TimeZone
[root@mybugzilla]# /usr/bin/perl install-module.pl Template
[root@mybugzilla]# /usr/bin/perl install-module.pl Email::Send
[root@mybugzilla]# /usr/bin/perl install-module.pl Email::MIME
[root@mybugzilla]# /usr/bin/perl install-module.pl List::MoreUtils


or just simply:

  [root@mybugzilla]# /usr/bin/perl install-module.pl --all

  DateTime won't build so I'm trying this:

  [root@mybugzilla]# yum install mysql-devel gd gd-devel perl-DBD-MySQL mod_perl-devel

    (per instructions at http://www.bugzilla.org/docs/4.0/en/html/installation.html)
  The perl-DBD-MySQL package is 3.07 which is too old (4.0 is needed) so I had to be sure to
run the cpan install:

[root@mybugzilla]# /usr/bin/perl install-module.pl DBD::mysql

  I noticed that DateTime complains that I only have Archive::Tar 1.3901 which it found in the
perl-Archive-Tar package.  I upgraded with the following:

[root@mybugzilla]# /usr/bin/perl install-module.pl Archive::Tar

  Which got me Archive::Tar 1.76, which stopped the complaints in DateTime.  I installed datetime
running these:

[root@mybugzilla]# /usr/bin/perl install-module.pl Module::Build
[root@mybugzilla]# /usr/bin/perl install-module.pl DateTime

 

Install Additional Modules

I installed these extra modules:

[root@mybugzilla]# /usr/bin/perl install-module.pl Net::LDAP
[root@mybugzilla]# /usr/bin/perl install-module.pl GD
[root@mybugzilla]# /usr/bin/perl install-module.pl Chart::Lines
[root@mybugzilla]# /usr/bin/perl install-module.pl Email::Reply
[root@mybugzilla]# /usr/bin/perl install-module.pl Apache2::SizeLimit
[root@mybugzilla]# /usr/bin/perl install-module.pl GD::Graph
[root@mybugzilla]# /usr/bin/perl install-module.pl PatchReader
[root@mybugzilla]# /usr/bin/perl install-module.pl Email::MIME::Attachment::Stripper

    I know that out of the above, if you don't have Apache2::SizeLimit then there will be a problem when restarting the httpd server, which (per the above instructions) includes a reference to the mod_perl.pl script in the bugzilla folder, which in turn uses Apache2::SizeLimit.  If you have trouble (as I did), make sure you have the =mod_perl-devel= package installed in order to install Apache2::SizeLimit.

Edit Configuration

Now you'll need to edit the localconfig file to setup the variables.  Make sure you have these variables set.  You'll probably have to manually set
those listed in bold:

$create_htaccess = 1;
$webservergroup = 'apache';
$use_suexec = 0;
$db_driver = 'mysql';
$db_host = 'localhost';
$db_name = 'bugs';
$db_user = 'bugs';
<b>$db_pass = 'XXXpasswordXXX';</b>
$db_port = 0;
$db_sock = '';
$db_check = 1;
$index_html = 0;
$cvsbin = '/usr/bin/cvs';
$interdiffbin = '/usr/bin/interdiff';
$diffpath = '/usr/bin';
$site_wide_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

 

Re-Run CheckSetup

Now re-run checksetup now that you've fixed the localconfig file.  This should test the settings in the localconfig to ensure the correct db name, user name and password:

./checksetup.pl --check-modules


The script may remind you to perform some actions documented above.  If you've missed anything, go ahead and fix it now before continuing.

Bugzilla Upgrade

Upgrading can cause serious harm to the database.  Make sure you've backed up or you have a file migrated from another server that you can use to restore the database 'bugs' table in case the following fail.  There are probably more ways to migrate, but these are the actions that I took.

Ensure the character encoding is correct

Your database must be in UTF-8.  If the previous database used another encoding, you should fix it with the recode.pl script.

[root@mybugzilla]# /usr/bin/perl install-module.pl Encode::Detect
[root@mybugzilla]# cd /var/www/bugz/bugzilla-4.0/
[root@mybugzilla]# contrib/recode.pl --dry-run --guess


Review what changes then do the command for real:

[root@csobugzilla]# contrib/recode.pl --guess

 

Continue with the checksetup.pl

Try the checksetup.pl script again.  You can now safely continue when prompted about the UTF-8 stuff.

References

http://www.bugzilla.org/docs/4.0/en/html/configuration.html
http://www.velikan.net/import-sql-dump-file-to-mysql-database/
http://dev.mysql.com/doc/refman/5.1/en

 
Page 3 of 9

Upcoming Linux Foundation Courses

  1. LFD331 Developing Linux Device Drivers
    25 Aug » 29 Aug - Virtual
    Details
  2. LFS422 High Availability Linux Architecture
    08 Sep » 11 Sep - Raleigh, NC
    Details
  3. LFS426 Linux Performance Tuning
    08 Sep » 11 Sep - New York
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board