Archive

Posts Tagged ‘centos5.2’

How To Fix Yum When It Hangs With No Error Message

April 1st, 2009 No comments

Yum on one of my centos boxes simply would not work.  Once you entered a yum command such as;

yum clean all

yum upgrade

it hung and would not work.

Apparently I needed to remove the __db.* in /var/lib/rpm

rm -f /var/lib/rpm/__db.*

See this link for more info - http://www.serpentine.com/blog/2007/01/04/dealing-with-yum-hangs-on-fc6/

Categories: Centos 5.2 Tags: ,

How to Install a Puppet Master and Client Server on Centos 5.2

February 21st, 2009 No comments

Puppet is an open-source next-generation server automation tool. It is composed of a declarative language for expressing system configuration, a client and server for distributing it, and a library for realizing the configuration.

Setup the EPEL repos for Centos – choose the correct package depending on  your installation.

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

Install puppet-server

yum install puppet-server

The 1.8.5 branch of Ruby shipped will RHEL5 can exhibit memory leaks. So install ruby 1.8.6++ (I did not on this server as it was  test not a production server).

Install the help docs

yum install ruby-rdoc

Create a manifest file at /etc/puppet/manifests/default.pp

vi /etc/puppet/manifests/default.pp

put this in it

# Create “/tmp/testfile” if it doesn’t exist.

class test_class {

    file { “/tmp/testfile”:

       ensure => present,

       mode   => 644,

       owner  => root,

       group  => root

    }

}

# tell puppet on which client to run the class

node pclient {

    include test_class

}

Start the puppet server

service puppetmaster start

Enable start on boot

chkconfig puppetmaster on

Now to install the Puppet Client on another server

Setup the EPEL repos for Centos – choose the correct package depending on  your installation.

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

Install puppet

yum install puppet

Setup puppet client to generate its own certificate request to the server

/etc/init.d/puppet once -v

Sign the certificate request on the puppet master server.  Use puppetca –list to see if any are available to sign.

puppetca –sign puppet01

Puppet01 must be the fully qualified domain name (FQDN) of you client server.

Run this on the client server again to retrieve the certificate

/etc/init.d/puppet once -v

Make the puppet start with the system

chkconfig puppet on

Make sure it is working on the client server.

puppet –test

You should see a dialog that creates the file /tmp/testfile

How to Setup SSH X Forward from a Remote Centos Server to Vista

February 17th, 2009 No comments

You can push x server gui’s from a remote server to your local machine.  This is how to send an x server gui from a remote centos machine to your vista machine.

Install Cygwin, choose the default installation package for X11 (follow the documentation).

Once installed, start the xserver with

sh /usr/bin/startxwin.sh

see - http://x.cygwin.com/docs/ug/using.html#using-starting-sh

This will create a xserver icon in the bottom right corner of your taskbar.  Right click this icon and select Applications and choose xterm.  Once this fires up, connect to your remote server with ssh.

In the xterm session, type;

ssh -X user@sshserver.com

Once logged into the remote server you can start your apps within the ssh session and they are piped to you cygwin xserver.

The reason I care, I was trying to get a Jmeter gui running locally for a remote server.

How To Create a Centos 5.2 EC2 Amazon Machine Image – AMI

February 13th, 2009 2 comments
Create the disk image
dd if=/dev/zero of=my-image.fs bs=1M count=1024
Create root file system inside file
mke2fs -F -j my-image.fs
Mount it
mkdir /mnt/ec2-fs
mount -o loop my-image.fs /mnt/ec2-fs
Create /dev
mkdir /mnt/ec2-fs/dev
Populate /dev with a minimal set of devices
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x console
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x null
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x zero
Create /etc
mkdir /mnt/ec2-fs/etc
Create yum-xen.conf in the local file system, not the mounted system.  Put the following in yum-xen.conf
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
exclude=*-debuginfo
gpgcheck=0
obsoletes=1
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
reposdir=/dev/null
metadata_expire=1800
[base]
name=CentOS-5.2 – Base
baseurl=http://mirror.centos.org/centos/5.2/os/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5.2
priority=1
protect=1
#released updates
[update]
name=CentOS-5.2 – Updates
baseurl=http://mirror.centos.org/centos/5.2/updates/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5.2
priority=1
protect=1
#packages used/produced in the build but not released
[addons]
name=CentOS-5.2 – Addons
baseurl=http://mirror.centos.org/centos/5.2/addons/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5.2
priority=1
[extras]
name=CentOS 5.2 Extras $releasever – $basearch
baseurl=http://mirror.centos.org/centos/5.2/extras/i386/
enabled=1
Mount proc
mkdir /mnt/ec2-fs/proc
mount -t proc none /mnt/ec2-fs/proc
Install the Operating System
yum -c yum-xen.conf –installroot=/mnt/ec2-fs -y groupinstall Core
 Create the network settings
vi /mnt/ec2-fs/etc/sysconfig/network-scripts/ifcfg-eth0
Enter
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
Turn on networking
vi /mnt/ec2-fs/etc/sysconfig/network
Enter
NETWORKING=yes
Set up the hard drives
vi /mnt/ec2-fs/etc/fstab
Enter 
/dev/sda2  /mnt      ext3    defaults        1 2
/dev/sda3  swap      swap    defaults        0 0
Start some services on start
chroot /mnt/ec2-fs /bin/sh
chkconfig –level 345 sshd on
exit
Unmount the image
umount /mnt/ec2-fs/proc
umount -d /mnt/ec2-fs 
Now bundle the AMI
Install ruby
yum install ruby
Download the EC2 AMI Tools 
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
Install the EC2 AMI Tools
rpm -Uvh ec2-ami-tools.noarch.rpm
Put both your private key and cert in the same folder as my-image.fs
Use the AMI tools to bundle the your image
ec2-bundle-image -i my-image.fs -c my-cert.pem -k my-private-key.pem -u 12345678(amazon account id)  
nb. Selinux should be disabled while this is done.
This create the bundles the image to an AMI and puts it in /tmp
Now upload the  ec2-bundle to S3
ec2-upload-bundle -b my-bucket -m image.manifest -a my-aws-access-key-id -s my-secret-key-id 
This is a good resource on how to script the whole thing – http://www.centos.org/modules/newbb/viewtopic.php?topic_id=11788&forum=27&post_id=38389

The Best SSH Client for Vista

February 13th, 2009 No comments

I have used this SSH client for the last 6 months and can heartily recommend it.

http://www.bitvise.com/tunnelier

Below are the features directly ripped from their site;

  • one of the most advanced graphical SFTP clients;
  • state-of-the-art terminal emulation with support for the bvterm, xterm, and vt100 protocols;
  • support for corporation-wide single sign-on using SSPI (GSSAPI) Kerberos 5 and NTLM user authentication, as well as Kerberos 5 host authentication;
  • support for RSA and DSA public key authentication with comprehensive user keypair management;
  • powerful SSH port forwarding capabilities, including dynamic forwarding through integrated SOCKS and HTTP CONNECT proxy;
  • powerful command-line parameters which make Tunnelier highly customizable and suitable for use in specific situations and controlled environments;
  • an advanced, scriptable command-line SFTP client (sftpc);
  • a scriptable command-line remote execution client (sexec) and a command-line terminal emulation client (stermc);
  • an FTP-to-SFTP bridge allowing you to connect to an SFTP server using legacy FTP applications;
  • WinSSHD remote administration features;
  • single-click Remote Desktop forwarding.

How To Install EC2 Automatic Scaling App Scalr on Centos 5.2

February 12th, 2009 No comments

Scalr is a fully redundant, self-curing and self-scaling hosting environment utilizing Amazon’s EC2.

It allows you to create server farms through a web-based interface using prebuilt AMI’s for load balancers (pound or nginx), app servers (apache, others), databases (mysql master-slave, others), and a generic AMI to build on top of. (see http://code.google.com/p/scalr/)

Install the necessary packages

You will need utterramblings repo’s to install PHP 5.2.6, see - http://www.how-to-linux.com/2008/12/how-to-upgrade-to-php-526-on-centos-52/

yum install httpd mysql-server gcc mysql-server php-devel php-cli php-mysql php-mcrypt php-mhash php-snmp php-pear php-soap php-xml

You will need to install ssh2 php support, currently it is still in beta use;

libssh2 from yum does not work so build the one scalr needs from source

wget http://downloads.sourceforge.net/libssh2/libssh2-1.0.tar.gz?modtime=1230332100&big_mirror=0

./configure

make

make install

Then

pecl install ssh2-beta

Now you need to update your php.ini file by adding

extension=ssh2.so

Restart your webserver

service httpd restart

See install instructions – http://th.php.net/manual/en/ssh2.installation.php

Use the scalr’s checkenvironment.php script to check everything is ok.

wget http://scalr.googlecode.com/files/checkenvironment.php

chmod 777 checkenvironment.php

Run it on the command line

php checkenvironment.php

Download the scalr tar package 

wget http://scalr.googlecode.com/files/scalr-1.0RC3.tar.gz

untar

tar xvfz scalr-1.0RC3.tar.gz

mv the contents of the app folder to /var/www/html/

mv scalr/app/* /var/www/html/

Set permissions on the following folders (and subfolders) and files to 777 (world-writable):

cache

cron/cron.pid

etc/.passwd

Create a mysql database and import data

mysql -u root

create database scalr;

quit

mysql -u root -h localhost scalr < sql/database.sql

Edit the database config settings in etc/config.ini file.

Set Cron jobs

For system to work properly, it needs to run a few tasks periodicaly. Scalr has a single cron/cron.php file that must be executed with various command-line switches. The following tasks must be sheduled:

* * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –Poller

1 1 * * * /path/to/php -q /scalr_home_dir/cron/cron.php –RotateLogs

*/15 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –MySQLMaintenance

*/6 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –DNSMaintenance

*/3 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –DNSZoneListUpdate

*/2 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –DBQueueEvent

*/11 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –Cleaner

*/2 * * * * /path/to/php -q /scalr_home_dir/cron/cron.php –EBSQueue

Scalr needs your keys..

Sclar needs to have AWS access.

  1. Put your EC2 access certificate into /scalr_home_dir/etc/cert-XXXXXXXXXXXX.pem
  2. Put your EC2 private key into /scalr_home_dir/etc/pk-XXXXXXXXXXXX.pem

Now goto http://localhost/

username and password is admin/admin

I had a 403 error when trying to access scalr, this was because I had SElinux enabled, disable this if its a test machine.

After the install I found this, anothe useful resource if you have problems - http://groups.google.com/group/scalr-discuss/web/scalr-on-centos-5-install-notes

Categories: Amazon EC2, Centos 5.2 Tags: , ,

How To Install Redmine on Centos 5.2 Update

February 1st, 2009 5 comments

This is a combination of all my instructions on how to setup redmine on Centos.  Its still a work in progress so please note any problems in comments.

Install Ruby on Rails

yum install ruby ruby-devel ruby-libs ruby-irb ruby-rdoc ruby-mysql

Download and install ruby gems

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz

tar xvf rubygems-1.3.1.tgz

cd rubygems-1.3.1

ruby setup.rb

Install Rails

gem install rails

Install Redmine

go to /opt

cd /opt

Get latest source code from http://www.redmine.org

unzip redmineXXXX.zip

Create a Database for Redmine

mysql -u root -p

create database redmine character set utf8;

exit

Configure the Redmine database connection settings

Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for “production” environment.

cp /opt/redmine-0.7.3/config/database.yml.example /opt/redmine-0.7.3/config/database.yml

edit database.yml

production:

adapter: mysql

database: redmine

host: localhost

username: yourusername

password: yourpassword

socket: /var/lib/mysql/mysql.sock

Run the following command in /opt/redmine-0.7.3/

rake db:migrate RAILS_ENV=”production”

If you get this error message: “cannot connect to mysql: No such file or directory – /tmp/mysql.sock”, You forgot to specify the socket location in config/database.yml – see above.

This will create tables and an administrator account.

Run this command to load default data into db.

rake redmine:load_default_data RAILS_ENV=”production”

Test the installation by running WEBrick web server:

ruby script/server -e production

Once WEBrick has started, point your browser to http://localhost:3000/. You should now see the application welcome page.

Use default administrator account to log in:

login: admin

password: admin

You can go to Admin & Settings to modify application settings.

You must install Rmagick as well for the nice Gant charts.

yum install ImageMagick

yum install ImageMagick-devel

gem install rmagick -v 1.15.13 –no-rdoc –no-ri

How to Autocreate SVN repositories with Redmine

Create a repository folder.

mkdir /svn

Change the owner and group to root.apache

chown -R root.apache /svn

Change the permissions

chmod 0750 /svn

Configure subversion to be browsed, goto /etc/httpd/conf.d

vi subversion.conf

Insert the following at the bottom

<Location /svn>

DAV svn

SVNParentPath /svn

SVNListParentPath on

</Location>

If you get ‘Could not open the requested SVN filesystem’ when you try to browse to your repository http://localhost/svn then you have used SVNPath instead of SVNParentPath, just update your subversion.conf and that should fix this issue.  This could also be a permission error related to the file permissions of your svn repository, make sure they are readable by apache.

Run the following command to test that it works

ruby reposman.rb -redmine localhost:3000 -svn-dir /svn -owner apache -url http://localhost/svn/ -verbose

If it does not, and fails with this error

/usr/lib/ruby/1.8/rdoc/ri/ri_options.rb:53: uninitialized constant RI::Paths (NameError)

from /usr/lib/ruby/1.8/rdoc/usage.rb:72:in ‘require’

from /usr/lib/ruby/1.8/rdoc/usage.rb:72

from reposman.rb:59:in ‘require’

from reposman.rb:59

Then you need to edit the reposman.rb file and add require statement require ‘rdoc/ri/ri_paths’ above all the other require statements.

require ‘rdoc/ri/ri_paths’

You need to add this to your crontab

5 * * * * ruby /opt/redmine-0.8.0_RC1/extra/svn/reposman.rb -redmine localhost:3000 -svn-dir /svn -owner apache -url http://localhost/svn/ -verbose >> /var/log/reposman.log

Setup permission for SVN to use apache etc

I found the instructions at http://www.redmine.org/wiki/redmine/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl did not work for me. I managed to get it working doing the following;

You do not need to but you can set subversion 1.54 by installing the RPMForge repos, follow these instructions – http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

Get the necessary packages

yum install mod_dav_svn mod_perl perl-Apache-DBI perl-Digest-SHA1 perl-DBD-mysql subversion

Copy Redmine.pm from /opt/redmine-0.7.3/extra/svn/Redmine.pm to /usr/lib/perl5/vendor_perl/5.8.8/Apache/

cp /opt/redmine-0.7.3/extra/svn/Redmine.pm /usr/lib/perl5/vendor_perl/5.8.8/Apache/

create a file in /etc/httpd/conf.d/ called redmine.conf and put this in it.

PerlLoadModule Apache::Redmine

<Location /svn>

DAV svn

SVNParentPath “/svn”

AuthType Basic

AuthName redmine

Require valid-user

PerlAccessHandler Apache::Authn::Redmine::access_handler

PerlAuthenHandler Apache::Authn::Redmine::authen_handler

## for mysql

RedmineDSN “DBI:mysql:database=da;host=my.db.server”

## for postgres

# RedmineDSN “DBI:Pg:dbname=databasename;host=my.db.server”

RedmineDbUser “redmine”

RedmineDbPass “password”

</Location>

# a private location in read only mode to allow Redmine browsing

<Location /svn-private>

DAV svn

SVNParentPath “/svn”

Order deny,allow

Deny from all

# only allow reading orders

<Limit GET PROPFIND OPTIONS REPORT>

Allow from redmine.server.ip

</Limit>

</Location>

The error I received from using the Redmine-0.7.X was;

‘Invalid command ‘RedmineDSN’, perhaps misspelled or defined by a module not included in the server configuration’

This is related to not copying Redmine.pm to /usr/lib/perl5/vendor_perl/5.8.8/Apache

Install a Mongrel Front to Apache

Taken from http://www.redmine.org/wiki/redmine/HowTo_run_Redmine_with_a_Mongrel_cluster

Install Mongrel

gem install mongrel mongrel_cluster daemons

Configure the Mongrel Cluster for redmine.

cd /opt/redmine

mongrel_rails cluster::configure -e production -p 8000 -N 3 -c /opt/redmine-0.8.0_RC1 -user apache -group apache

Start the Cluster

mongrel_rails cluster::start

Configure apache as the load balancer

create a new config file in /etc/httpd/conf.d

vi /etc/httpd/conf.d/redmine.conf

paste this into the file

<VirtualHost *>

ServerName your.domain.name

DocumentRoot /opt/redmine-0.8.0_RC1

<Directory “/opt/redmine-0.8.0_RC1/public”>

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

<Proxy balancer://redmine_cluster>

Order allow,deny

Allow from all

BalancerMember http://127.0.0.1:8000

BalancerMember http://127.0.0.1:8001

BalancerMember http://127.0.0.1:8002

</Proxy>

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f

RewriteRule ^/(.*)$ balancer://redmine_cluster%{REQUEST_URI} [P,QSA,L]

</VirtualHost>

And restart apache

service httpd restart

Install Clocking IT on Centos 5.2

January 18th, 2009 No comments

Install Ruby on Rails – see http://www.how-to-linux.com/2008/12/how-to-install-ruby-on-rails-on-centos-52/

Install git – see http://www.how-to-linux.com/2009/01/install-git-161-on-centos-52/

Install imagemagick for ruby

yum install ImageMagick ImageMagick-devel

gem install rmagick -v 1.15.13 –no-rdoc –no-ri

Install passenger

yum install gcc-c++ httpd-devel

gem install passenger

passenger-install-apache2-module

I go this error when I ran passenger-install-apache2-module.

Apache 2… not found

I need to force install some apps to fix this

yum install apr-util-devel.x86_64 expat-devel.x86_64 apr-devel.x86_64

And then run

passenger-install-apache2-module

This completed the install of passenger.  Then I setup a virtual host for cit.

vi /etc/httpd/conf.d/cit.conf

I entered the location of where I planned to install clocking it, change for you config.

<VirtualHost *:80>

ServerName cit.domain.com

DocumentRoot /var/www/html/cit/public/

ErrorLog /var/www/html/cit/log/server.log

<Directory /var/www/html/cit/public/>

Options ExecCGI FollowSymLinks

AllowOverride all

Allow from all

Order allow,deny

</Directory>

</VirtualHost>

Restart httpd

service httpd restart

Install mysql

yum install mysql-server

service mysqld start

Create a Clocking It database

mysql -u root

create database cit;

exit

Set the root password on mysql

/usr/bin/mysqladmin -u root password ‘new-password’

Turn on a bunch of services on boot up.

chkconfig httpd on

chkconfig mysqld on

Get the latest clocking it code with git

cd /var/www/html/

git clone git://repo.clockingit.com/cit

Install the remain gems needed.

gem install fastercsv mongrel gchartrb RedCloth tzinfo echoe test-spec eventmachine icalendar ferret json hoe ZenTest -r

Now run the clocking it setup script.

ruby setup.rb

You will need to enter a domain name, an ip will not work.

I answered yes to install the database schema

If you need to restart the server it is;

./script/ferret_server -e production start

nohup ./script/push_server &

./script/server production

Access your installation from http://cit.domain.com:3000

The push server does not seem to work

Install Git 1.6.1. on Centos 5.2

January 16th, 2009 2 comments

Install the dependencies

yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel

Get the git source code

wget http://kernel.org/pub/software/scm/git/git-1.6.1.tar.gz

untar the git source code

tar xvfz git-1.6.1.tar.gz

Install

cd git-1.6.1.tar.gz

make prefix=/usr/local all

make prefix=/usr/local install


Categories: Centos 5.2 Tags: ,

Install Hyperic-HQ 4.0.2 rpm on Centos 5.2

January 12th, 2009 No comments

Download the Hyperic rpm

wget http://jaist.dl.sourceforge.net/sourceforge/hyperic-hq/hyperic-hq-installer-4.0.2-1.x86_64.rpm

Install required packages

yum install libXp expect

Install mysql if necessary

Install Hyperic 4.0.2 rpm

rpm -Uhv hyperic-hq-installer-4.0.2-1.x86_64.rpm

Start Hyperic by changing to the hyperic user and using hq-server.sh

su hyperic
/opt/hyperic/server-4.0.2/bin/hq-server.sh start

You can now logon using username – hqadmin, password hqadmin.