Friday, January 30, 2015

How to configure OpenLDAP on RHEL(redhat)/CentOS Server

OPENLDAP

Pre-requisites:

The first things you need to do is ensure that OpenLDAP is properly installed, along with a few optional packages that will tie our system together. Obviously, the first step is to install OpenLDAP. The packages we need to have installed (on a RedHat system) are:
  • openldap
  • openldap-clients
  • openldap-devel
  • openldap-servers
  • nss_ldap

[root@linux0120 ~]# rpm -qa | grep openldap
openldap-devel-2.2.13-2
openldap-2.2.13-2
openldap-clients-2.2.13-2
[root@linux0120 ~]#

Since the openldap-server rpms is not currently with us, the same is upgraded to newer version.
Installing the required rpms:
[root@linux0120 ~]# mount lnxdev0001:/usr/local/src/ /mnt

[root@linux0120 ~]# rpm -Uvh /mnt/redhat/es4/RedHat/RPMS/openldap-*
warning: /mnt/redhat/es4/RedHat/RPMS/openldap-2.2.13-3.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
libodbc.so.1 is needed by openldap-servers-sql-2.2.13-3.i386
Suggested resolutions:
unixODBC-2.2.9-1.i386.rpm

[root@linux0120 ~]# rpm -e openldap-clients-2.2.13-2
[root@linux0120 ~]# rpm -e openldap-devel-2.2.13-2
[root@linux0120 ~]# rpm -e openldap-2.2.13-2
[root@linux0120 ~]# rpm -e openldap-2.2.13-2 --nodeps

[root@linux0120 ~]# rpm -ivh /mnt/redhat/es4/RedHat/RPMS/openldap-2.2.13-3.i386.rpm
warning: /mnt/redhat/es4/RedHat/RPMS/openldap-2.2.13-3.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:openldap ########################################### [100%]
[root@linux0120 ~]# rpm -ivh /mnt/redhat/es4/RedHat/RPMS/openldap-clients-2.2.13-3.i386.rpm
warning: /mnt/redhat/es4/RedHat/RPMS/openldap-clients-2.2.13-3.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:openldap-clients ########################################### [100%]
[root@linux0120 ~]# rpm -ivh /mnt/redhat/es4/RedHat/RPMS/openldap-devel-2.2.13-3.i386.rpm
warning: /mnt/redhat/es4/RedHat/RPMS/openldap-devel-2.2.13-3.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:openldap-devel ########################################### [100%]
[root@linux0120 ~]# rpm -ivh /mnt/redhat/es4/RedHat/RPMS/openldap-servers-2.2.13-3.i386.rpm
warning: /mnt/redhat/es4/RedHat/RPMS/openldap-servers-2.2.13-3.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:openldap-servers ########################################### [100%]


[root@linux0120 ~]# rpm -qa | grep openldap
openldap-clients-2.2.13-3
openldap-devel-2.2.13-3
openldap-servers-2.2.13-3
openldap-2.2.13-3
[root@linux0120 ~]# rpm -qa | grep nss_ldap
nss_ldap-226-1
[root@linux0120 ~]# rpm -Uvh /mnt/redhat/es4/RedHat/RPMS/nss_ldap-226-6.i386.rpm
warning: /mnt/redhat/es4/RedHat/RPMS/nss_ldap-226-6.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:nss_ldap ########################################### [100%]
The openldap-servers and openldap-devel packages are only required on the system that will be your authentication server. They are not required on the "client" systems.
The nss_ldap package is required for PAM authentication and for NSS information (ie. retrieving group, user, host, etc. information from the LDAP server). Once you have all of these packages installed, you can begin to configure your LDAP server.



Configuring the OpenLDAP Server

The first step in configuring your server is to edit the /etc/openldap/slapd.conf file. There are a few fields you will need to configure. In this topic, we will assume that your domain name to use on the LAN is "newindia.com" and will illustrate our configuration accordingly.
[root@linux0120 ~]# vi /etc/openldap/slapd.conf
database ldbm
suffix "dc=newindia,dc=com"
rootdn "cn=root,dc=newindia,dc=com"
rootpw {MD5}/39oNhuzZDdBZnzCjxM5TA==
password-hash {crypt}
password-crypt-salt-format "$1$%.8s"



Get the MD5 crypt password as follows:
[root@linux0120 ~]# slappasswd -h{MD5}
New password:
Re-enter new password:
{MD5}/39oNhuzZDdBZnzCjxM5TA==



Before configuring your basic ACLs, let's start slapd and make sure it works.
[root@linux0120 ~]# /etc/init.d/ldap start
Checking configuration files for : config file testing succeeded
Starting slapd: [ OK ]



Once you have started the slapd server, you can test it by executing the following query:
[root@linux0120 ~]# ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
# extended LDIF
#
# LDAPv3
# base <> with scope base
# filter: (objectclass=*)
# requesting: namingContexts
#
#
dn:
namingContexts: dc=newindia,dc=com
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1



This ensures that ldap is configured and working properly.

Enable the daemon to start at boot time itself:
[root@linux0120 ~]# chkconfig ldap on

Configuring Server ACLs

The final step on the server before we begin migrating data is to set the basic ACLs (Access Control Lists) for the LDAP server. This will ensure that people only have access to what they need to have access to, and will allow users to update their passwords, see their passwords, but prevent others from seeing the same.
Once again you need to edit the /etc/openldap/slapd.conf file. If you look in your slapd.conf file, you will see the following near the beginning:
# Define global ACLs to disable default read access.
include /etc/openldap/slapd.access.conf
The /etc/openldap/slapd.access.conf
file is as good as any to place your ACLs in. You can either append your ACL rules to the end of the slapd.conf file, or insert them into slapd.access.conf. The choice is entirely up to you. If you do choose to use the access file, remove the example ACLs at the end of the slapd.conf file. Let's begin with some basic ACLs:



#This is a good place to put the access-control directives
olcAccess to dn=".*,dc=newindia,dc=com" attr=userPassword
by dn.base="cn=root,dc=newindia,dc=com" write
# by self write
by * auth
olcAccess to dn=".*,dc=newindia,dc=com" attr=mail
by dn="cn=root,dc=newindia,dc=com" write
# by self write
by * read
olcAccess to *
by * read
olcAccess to dn=".*,dc=newindia,dc=com"
# by self write
by read



What this does is restrict access to the userPassword attribute of any entry; that is, any dn in dc=newindia,dc=com. The owner of the entry can modify it, and the owner is defined by someone binding to the server using that dn and it's associated password. Otherwise, it can only be accessed for authentication/binding purposes, but cannot be viewed. The second entry allows the user to modify their mail attribute (ie. email address). The third entry specifies that any dn in ou=People,dc=newindia,dc=com must be read-only. This is where we protect the system from users deciding to change their username, gid or uid numbers, home directory, and so forth. Because the ACLs are read top down in a "first match wins" order, we have effectively given users access to change their own password and their own email address, but they are unable to touch any other information on their account. Everything else is read-only... to the world, and the user. Finally, the last entry is a catch-all for other parts of the database. This will allow users to make changes to their own address books, for example. If you will not be allowing users to use their own address books on this LDAP server, feel free to remove the "by self write" ACL of the last entry. This will still allow users to read group and hosts information. If you like, you can duplicate the second entry to allow users to modify their loginShell attribute so they can select what shell they wish to use, but I wouldn't recommend it.
To have the server use the new ACLs, be sure to restart it (service ldap restart on most Linux systems).
[root@linux0120 ~]# /etc/init.d/ldap restart
Stopping slapd: [ OK ]
Checking configuration files for slapd: config file testing succeeded
Starting slapd: [ OK ]



In our environment the self write is disabled to all attributes.
Creating the LDAP entries:
To create the entry create an ldif file (LDAP inerchage fomat) and add to the database as follows:

o:

[bharath@linux0120 LDAP]$ cat domain.ldif
dn: dc=newindia,dc=com
dc: newindia
objectClass: top
objectClass: domain
objectClass:domainRelatedObject
associatedDomain: newindia.com
[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f domain.ldif
Enter LDAP Password:
adding new entry “dc=newindia,dc=com”
[bharath@linux0120 LDAP]

ou:

[bharath@linux0120 LDAP]$ cat ou.ldif
dn: ou=Group,dc=newindia,dc=com
ou: Group
objectClass: top
objectClass: organizationalUnit
objectClass: domainRelatedObject
asscociatedDomain: newindia.com

[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f ou.ldif
Enter LDAP Password:
adding new entry "ou=Group,dc=newindia,dc=com"
[bharath@linux0120 LDAP]$

nisMapName:

[bharath@linux0120 LDAP]$ cat nisMapName.ldif
dn: nisMapName=netgroup.byhost,dc=newindia,dc=com
nisMapName: netgroup.byhost
objectClass: top
objectClass: nismap
objectClass: domainRelatedObject
associatedDomain: newindia.com

[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f nisMapName.ldif
Enter LDAP Password:
adding new entry "nisMapName=netgroup.byhost,dc=newindia,dc=com"
[bharath@linux0120 LDAP]$

cn:
(Simple Group)
[bharath@linux0120 LDAP]$ cat cn.ldif
dn: cn=users,ou=Group,dc=newindia,dc=com
cn: users
objectClass: top
objectClass: posixGroup
objectClass: domainRelatedObject
associatedDomain: newindia.com
gidNumber: 100
userPassword:

[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f cn.ldif
Enter LDAP Password:
adding new entry "cn=users,ou=Group,dc=newindia,dc=com"
[bharath@linux0120 LDAP]$

(Shared Group)
[bharath@linux0120 LDAP]$ cat scn.ldif
dn: cn=java,ou=Group,dc=newindia,dc=com
cn: java
objectClass: top
objectClass: posixGroup
objectClass: domainRelatedObject
associatedDomain: newindia.com
gidNumber: 900
userPassword:
memberUid: kishore
memberUid: karthik
[bharath@linux0120 LDAP]$

[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f scn.ldif
Enter LDAP Password:
adding new entry "cn=java,ou=Group,dc=newindia,dc=com"

[bharath@linux0120 LDAP]$

uid:

dn: uid=bharath,ou=People,dc=newindia,dc=com
uid: bharath
cn: bharath
givenName: bharath
sn: I
objectClass: top
objectClass: posixAccount
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
#objectClass: kerberosSecurityObject
objectClass: shadowAccount
mail: bharath@newindia.com
uidNumber: 678
gidNumber: 100
homeDirectory: /home/bharath
loginShell: /bin/bash
gecos: bharath I - SA
userPassword: {CRYPT}Fd4pwcZ.ncH6Q
shadowLastChange: 13200
shadowMax: 99999
shadowWarning: 7

The objectClass kerberosSecurityObject is not defined. Need to fix this.

Migrating Data

The next step is to begin migrating your data into your LDAP server.
The openldap servers rpm provides the migration perl scripts to generate the LDIF file from the existing files.

[root@linux0120 redhat]# cd /usr/share/openldap/migration/
Set the following in the migrate_common.ph file.
[root@linux0120 migration]# vi migrate_common.ph
$DEFAULT_MAIL_DOMAIN = "dev02.newindia.com";
$DEFAULT_BASE = "dc=newindia,dc=com";
$DEFAULT_MAIL_HOST = "mail.dev02.newindia.com";
$EXTENDED_SCHEMA = 1;

Use the migrate_all_online.pl for all the data's like hosts, services, groups, protocols etc to be generated in the ldif file. Since the essential entries required are group and password files, the required ldif files are generated as follows:

[root@linux0120 migration]# ./migrate_base.pl > base.ldif
[root@linux0120 migration]# ./migrate_group.pl /etc/group group.ldif
[root@linux0120 migration]# ETC_SHADOW=/etc/shadow- ./migrate_passwd.pl /etc/passwd passwd.ldif

Add the data to the ldap database as follows:
[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f base.ldif
Enter LDAP Password:
[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f group.ldif
Enter LDAP Password:
[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f passwd.ldif

Creating the AUTOMOUNT MAPS for the shared directories on the LDAP Server:
The NIS MAPS which are created are as follows:
/etc/auto.master
/etc/auto.home
/etc/auto.home2
/etc/auto.data
/etc/nb_apps
/etc/nb_apps-7.2
/etc/nb_apps-es4
/etc/auto.clearcase-data

Let us consider all the above maps as organization units of the LDAP Directory structure.

Create the Organizational units as follows:
dn: ou=auto.master,dc=newindia,dc=com
ou: auto.master
objectClass: top
objectClass: autoMountMap

Create the share map for each of the shares with the corresponding map files. For example for /home share, the map file is auto.home and the same is created as follows:
dn: cn=/home,ou=auto.master,dc=newindia,dc=com
cn: /home
objectClass: autoMount
autoMountInformation: ldap:ou=auto.home,dc=newindia,dc=com

The above autoMountInformation instructs the LDAP server for mounting this share, check with the corresponding ou entry. (ou=auto.home).

Create the auto.home map as follows:
dn: ou=auto.home,dc=newindia,dc=com
ou: auto.home
objectClass: top
objectClass: autoMountMap

Create the map details for the above share as follows for each entry. For example,
bharath fileserv:/export/home/bharath
dn: cn=bharath,ou=auto.home,dc=newindia,dc=com
cn: bharath
objectClass: autoMount
autoMountInformation: fileserv.dev02.newindia.com:/export/home/bharath

Like this for each and every entry, the LDAP entry needs to be created for the same.

Create the ldif file as stated above and add to the LDAP database as follows:
[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f auto.ldif
Enter LDAP Password:

Note:
Instead of each and every entry for the user login accounts, a single account can be created and added to the LDAP database as follows:
dn: cn=*,ou=auto.home,dc=newindia,dc=com
cn: *
objectClass: autoMount
autoMountInformation: fileserv.dev02.newindia.com:/export/home/&

[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f auto.ldif
Enter LDAP Password:


To migrate all the required file use the following scripts, to create the ldif files.

[bharath@linux0120 LDAP]$ cat auto.master.pl
#!/usr/bin/perl
use strict;
use warnings;

my $subdomain="dev02";
my $domain="newindia";
my $dom="com";
my $infile;
my $outfile;
my $mount;
my $mapfile;
my $configdir="/home/bharath/LDAP/";
my @data;

print "Enter the Master Map file\n";
$infile = <STDIN>;
chomp $infile;

$outfile = "$infile.ldif";

open FHO,">$outfile";

print FHO "dn: ou=$infile,dc=$domain,dc=$dom\n";
print FHO "ou: $infile\n";
print FHO "objectClass: top\n";
print FHO "objectClass: autoMountMap\n\n\n";

if (open FHI, "$configdir$infile")
{
while (<FHI>)
{
if(/^(\/)/)
{
@data = split;
$mount = $data[0];
$mapfile = $data[1];
print FHO "dn: cn=$mount,ou=$infile,dc=$domain,dc=$dom\n";
print FHO "cn: $mount\n";
print FHO "objectClass: autoMount\n";
print FHO "autoMountInformation: ldap:ou=$mapfile,dc=$domain,dc=$dom\n\n\n";
}
}
}
close FHI;
close FHO;



For all other files other than auto.master, use the following script and provide the file name when prompted.

[bharath@linux0120 LDAP]$ cat auto.all.pl
#!/usr/bin/perl
use warnings;
use strict;

my $subdomain="dev02";
my $domain="newindia";
my $dom="com";
my $infile;
my $outfile;
my @data;
my $words;
my $cn;
my $server;
my $share;
my $configdir="/home/bharath/LDAP/";

print "Enter the NIS map file\n";
$infile=<STDIN>;
chomp($infile);
$outfile="$infile.ldif";

open FHO, ">$outfile";
print FHO "dn: ou=$infile,dc=$domain,dc=$dom\n";
print FHO "ou: $infile\n";
print FHO "objectClass: top\n";
print FHO "objectClass: autoMountMap\n\n\n";

if (open FHI, "$configdir$infile")
{
while (<FHI>)
{
chomp($_);
if(/^(\w+)/)
{
s/(\s+)/ /g;
s/[:,&]/ /g;
@data = split(/\s+/,$_);
$words = scalar(@data);
if ($words eq 3)
{
$cn = $data[0];
$server = $data[1];
$share = $data[2];
print FHO "dn: cn=$cn,ou=$infile,dc=$domain,dc=$dom\n";
print FHO "cn: $cn\n";
print FHO "objectClass: autoMount\n";
print FHO "autoMountInformation: $server.$subdomain.$domain.$dom:$share\n\n\n";

}
else
{
print "The file conatins more than two words ($words). So skipped\n";
}
}
}
close FHI;
close FHO;
}
else
{
print "The \"",$infile, "\" does not exist in the \"" ,$configdir,"\" directory\n";
}

After creating the required ldif files, add the same to the LDAP Database.





Useful LDAP Commands:

ldapadd:
-x Simple authentication
-D bindn
-W prompt for bind password
-f ldif file
[bharath@linux0120 LDAP]$ ldapadd -x -D "cn=root,dc=newindia,dc=com" -W -f auto.data.ldif

ldapmodify:
Same as that of ldapadd.

ldapsearch:

-b basedn
[bharath@linux0120 LDAP]$ ldapsearch -x -b "ou=auto.home,dc=newindia,dc=com" "(cn=*)"

ldapdelete:
-r recursive
If the specified dn is a tree containing several leaves, then -r should be used, else only the specified dn will be deleted.
[bharath@linux0120 LDAP]$ ldapdelete -x -r -D "cn=root,dc=newindia,dc=com" "ou=auto.nb_apps-7.2,dc=newindia,dc=com" -W

ldappasswd:
-S prompt for newpassword
[bharath@linux0120 LDAP]$ ldappasswd -x -S -D "cn=root,dc=newindia,dc=com" -W "uid=bharath,ou=people,dc=newindia,dc=com"
New password:
Re-enter new password:
Enter LDAP Password:
Result: Success (0)


Configuring Client:

[root@www ~]# rpm -qa | grep ldap
nss_ldap-226-6
openldap-2.2.13-3
compat-openldap-2.1.30-3

The packages nss_ldap-226-6

How to install Jabber/XMPP Server on CentOS / RHEL (redhat)

Jabber Chat Server:
This Documentation is to setup the jabber Chat server:
Pre-Installation Steps:


Check for the UID existance in the /etc/passwd file

#grep 400 /etc/passwd


Create a user for jabber process with UID < 500, without new home directory for the user and setting the installed directory of the jabber server as the home directory


#useradd -u 400 -M -d /usr/local/jabber jabber


#passwd jabber


Changing password for user jabber.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.


Check for the following prerequisites:


1. OpenSSL (version 0.9.6b or higher)
#rpm -qa | grep openssl
openssl-devel-0.9.7a-43.1
openssl-0.9.7a-43.1
xmlsec1-openssl-1.2.6-3


2. Libidn (version 0.3.0 or higher)
#rpm -qa | grep libidn
libidn-0.5.6-1
libidn-devel-0.5.6-1


3. Data Storage Package ( Any Datbase mysql, postgresql, etc.,)
# rpm -qa | grep mysql-server


Preparing... ########################################### [100%]
1:MySQL-standard-debuginf########################################### [ 20%]
2:MySQL-client-standard ########################################### [ 40%]
3:MySQL-devel-standard ########################################### [ 60%]
4:MySQL-server-standard ########################################### [ 80%]
5:MySQL-shared-standard ########################################### [100%]
start the mysql daemon:

[root@linux0120 jabberd-2.0s8]# /etc/init.d/mysqld start
Initializing MySQL database: [ OK ]
Starting MySQL: [ OK ]


Setting password for mysql server database:
#/usr/bin/mysqladmin -u root password 'mysql4dm1n'


4. Authentication Package ( Database or LDAP as of required )
# rpm -qa | grep ldap
(or)
# rpm -qa | grep mysql-server


Download the source from the following URL:
http://jabberd.jabberstudio.org/2/


Unpack the distribution
#tar -zxvf tar -zxvf jabberd-2.0s8.tar.gz
OUTPUT TRUNCATED..................


#cd jabberd-2.0s8


#./configure --help


#./configure --prefix=/usr/local/jabber –enable- ssl=/usr/include/openssl/ --enable-idn --enable-mysql=/usr/include/mysql --enable-ldap --enable-debug


#make


#make install


Create pid and log files:
#mkdir -p /usr/local/jabber/pid


#mkdir -p /usr/local/jabber/log


#chown -R jabber:jabber /usr/local/jabber


======================================================
Set Ownership of Configuration Files
Jabberd configuration files contain passwords; therefore, you should set ownership and permissions on these files so that they are only readable by your jabber user and writable by root only. Using the location of your configuration files and your jabber user, set ownership of these files:


#chown -R root:jabber /usr/local/jabber/etc/jabberd/*


#chmod -R 770 /usr/local/jabber/etc/jabberd/*
=======================================================


4. Basic Configuration
Jabberd 2 is configured via its six XML files.
# su - jabber


#cd etc/jabberd/
-bash-3.00$ cp sm.xml sm.xml_orig
-bash-3.00$ cp c2s.xml c2s.xml_orig
-bash-3.00$ cp s2s.xml s2s.xml_orig
-bash-3.00$ cp router.xml router.xml_orig
-bash-3.00$ cp resolver.xml resolver.xml_orig


4.1. Set Host Name in sm.xml and c2s.xml
Your server hostname (network ID) must be set in both c2s.xml and sm.xml so that the ID provides a network resolvable reference for your server.


# vi sm.xml
In sm.xml file:
Under <sm> tag:


<id>linux0120.dev02.newindia.com</id>
<pidfile>/usr/local/jabber/pid/sm.pid</pidfile>


========================================================
Enable the following certificate tag
<pemfile>/usr/local/jabber/etc/jabberd/jabberd-cert.pem</pemfile>
========================================================
Change the log type to file, disable the facility tag and enable the file tag:
<log type='file'>
<!-- <ident>jabberd/sm</ident> -->
<!-- <facility>local3</facility> -->
<file>/usr/local/jabber/log/sm.log</file>


# vi c2s.xml
In c2s.xml file:


<pidfile>/usr/local/jabber/pid/c2s.pid</pidfile>
======================================================
Enable the certificate to use to set up an encrypted channel:
<pemfile>/usr/local/jabber/etc/jabberd/jabberd-cert.pem</pemfile>
======================================================
Change the log type to file, disable the facility tag and enable the file tag:
<log type='file'>
<!-- <ident>jabberd/sm</ident> -->
<!-- <facility>local3</facility> -->
<file>/usr/local/jabber/log/c2s.log</file>


Set the id in the Local Network Configuration as follows:
<id>lnux0120.dev02.newindia.com</id>


======================================================
Enable the certificate to use to set up an encrypted channel:
<pemfile>/usr/local/jabber/etc/jabberd/jabberd-cert.pem</pemfile>
<cachain>/usr/local/jabber/etc/jabberd/cachain.pem</cachain>
<require-starttls/>
<ssl-port>5223</ssl-port>
=======================================================


4.2. Provision and Configure for Storage and Authentication Package(s)


4.4. Provision and Configure for MySQL
Getting Jabberd 2 to work with your choice of external storage and authentication packages involves these steps:
1. Provision external package(s) to work with Jabberd 2
2. Configure sm.xml for your choice of storage package
3. Configure c2s.xml for your choice of authentication package


Most Jabberd 2 installations rely on a single package, such as MySQL, to provide both storage and authentication services. If your installation relies
on a single package, you will need to configure this package for Jabberd 2 and then enter similar connection details in both sm.xml and c2s.xml.


Storage Package : ( Mysql )
In order to set up MySQL for Jabberd, you must run the setup script included in the Jabberd 2 distribution. After the script is run, you should create a user and then grant that user access to the database.


4.4.1. Provision for mysql:
First, run the MySQL setup script. This script is located in '[Jabberd SourceFiles]/tools'. Switch to the tools directory and start the MySQL console (the
MySQL server should already be running). Then, run the db-setup.mysql script
from the MySQL console:


mysql -u root -p
mysql>\. db-setup.mysql


Now that a database for Jabberd exists in the MySQL data directory, create a MySQL user that Jabberd can use to connect to the MySQL server.

#cd /usr/local/src/jabberd-2.0s8/tools/
#ls db-setup.mysql
#mysql -u root -p
mysql>\. db-setup.mysql


MySQL User and Password:
GRANT select,insert,delete,update ON jabberd2.* to jabberd2@linux0120.dev02.newindia.com IDENTIFIED by 'j4bb3r4dm1n';


Check the mysql login for jabberd2:
[root@linux0120 jabberd]# mysql -u jabberd2 -p -h linux0120.dev02.newindia.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15 to server version: 4.1.12


Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


mysql> exit
Bye
MySQL is now ready to be used with Jabberd.


Note: Default MySQL Socket
Jabberd 2 stable 3 connects to the MySQL server socket at /tmp/mysql.sock.
The default socket when installing MySQL from source is
/var/lib/mysql/mysql.sock. You will need to create a symlink to /tmp/mysql.sock if it does not exist:
# ls -l /tmp/mysql.sock
ls: /tmp/mysql.sock: No such file or directory
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock


If you are unsure as to where your MySQL server socket is, consult your MySQL configuration file (usually located in /etc/my.cnf or /etc/mysql/my.cnf).


Default MySQL Socket:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock


4.4.2 Configure Storage using MySQL:

Most installations using MySQL for storage will require only the setting of the driver, user and password.


In sm.xml under the section labeled Storage database configuration, make sure that the driver is to use mysql. (The driver should be set to mysql by default.):
# vi sm.xml


<driver>mysql</driver>


In sm.xml under the section labeled MySQL driver configuration, replace secret with your MySQL password. Change the user if you are not using the
default user (jabberd2):


<host>linux0120.dev02.newindia.com</host>
<pass>jabberadmin</pass>


Note that you should change the host setting only if your MySQL server is running on a different host. You should change the port setting only if your MySQL server is running on a non-standard port (port 3306 is the default for MySQL installations). The transaction support section is self-explanatory.


Jabberd 2 is now configured to use MySQL for storage.


4.7. Provision and Configure for OpenLDAP ( For Authentication )


4.7.2. Configure for Authentication using OpenLDAP (c2s.xml)


OpenLDAP configuration is more detailed because configuration requires host and connection settings in addition to query settings.


In c2s.xml under the section labeled Authentication/registration database configuration, edit the driver to use ldap (OpenLDAP):
# vi c2s.xml


<module>ldap<module>


Users cannot create their own accounts when using OpenLDAP for authentication. Therefore, public account registration should be disabled, while auto-create should be enabled so that the session manager can create
accounts the first time users log on.
Commenting the enable tag as below will disable public registration:
Disable the account Registration:
<!-- <enable/> -->


The first part of the LDAP module configuration in c2s.xml deals with the settings required to connect to your OpenLDAP server. The host must either be a hostname resolvable by the server or the IP address of the OpenLDAP server. Port 389 is the default port for OpenLDAP servers, so in most cases, port
should be left as is. The v3 tag specifies whether your OpenLDAP server is v3. Uncomment this tag if it is. Leave the v3 tag commented for OpenLDAP v2
servers. Lastly, uncomment either the starttls or ssl tag if your server supports encryption (see notes below):


<host>linux0120.dev02.newindia.com</host>


Enable and set the bindn as follows:
<binddn>cn=root,dc=newindia,dc=com</binddn>
<bindpw>ld4p4dm1n</bindpw>


Set the basedn tag as follows:
<!-- <basedn realm='company'>o=Company.com</basedn> -->
<basedn>dc=newindia,dc=com</basedn>


In sm.xml under the section labeled User options (near the bottom of the file), uncomment the auto-create tag as below so that the session manager will create a new Jabberd2 account the first time a user logs on:
#vi sm.xml


<auto-create/>


To have the default buddylist to be exported to the client when logs for the first time, enable the following tag:
<roster>/usr/local/jabber/etc/jabberd/templates/roster.xml</roster>


4.8 Configure the router.xml as follows:
#vi router.xml


<pidfile>/usr/local/jabber/pid/router.pid</pidfile>


Change the log type to file, disable the facility tag and enable the file tag:
<log type='file'>
<!-- <ident>jabberd/sm</ident> -->
<!-- <facility>local3</facility> -->
<file>/usr/local/jabber/log/router.log</file>


=======================================================
Enable the certificate to use to set up an encrypted channel:
<pemfile>/usr/local/jabber/etc/jabberd/jabberd-cert.pem</pemfile>



4.9 Configure the resolver.xml as follows:
# vi resolver.xml


<pidfile>/usr/local/jabber/pid/resolver.pid</pidfile>


=====================================================
Enable the certificate to use to set up an encrypted channel:
<pemfile>/usr/local/jabber/etc/jabberd/jabberd-cert.pem</pemfile>
=====================================================
Change the log type to file, disable the facility tag and enable the file tag:
<log type='file'>
<!-- <ident>jabberd/sm</ident> -->
<!-- <facility>local3</facility> -->
<file>/usr/local/jabber/log/resolver.log</file>


4.10 Configure the s2s.xml as follows:
# vi s2s.xml


<pidfile>/usr/local/jabber/pid/s2s.pid</pidfile>


==================================================
Enable the certificate to use to set up an encrypted channel:
<pemfile>/usr/local/jabber/etc/jabberd/jabberd-cert.pem</pemfile>
======================================================
Change the log type to file, disable the facility tag and enable the file tag:
<log type='file'>
<!-- <ident>jabberd/sm</ident> -->
<!-- <facility>local3</facility> -->
<file>/usr/local/jabber/log/resolver.log</file>


======================================================
Enable the certificate to use to set up an encrypted channel:
<pemfile>/usr/local/jabber/etc/jabberd/jabberd-cert.pem</pemfile>


Set the Permissions as follows:
#chmod 750 /usr/local/jabber/etc/ -R
#chmod 750 /usr/local/jabber/bin/ -R
#chmod 750 /usr/local/jabber


Your Jabberd 2 configuration for storage and authentication is now complete.


4.8. Test Server


Checkpoint: Start Your Server
You should be able to start and test your Jabberd 2 server by using the Jabberd 2 startup script (as your jabber user):


su – jabber
./bin/jabberd &
A.6. Generating a Self-Signed SSL Certificate
A.6.1. Generate Key Pair


From a working directory, enter the command below to begin an interactive key
generation process:


#cd
#mkdir KEYS
#cd KEYS
[root@linux0135 KEYS]# openssl req -new -x509 -newkey rsa:1024 -days 3650
-keyout privkey.pem -out server.pem
Generating a 1024 bit RSA private key
........................................++++++
................++++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:IN
State or Province Name (full name) [Berkshire]:Tamilnadu
Locality Name (eg, city) [Newbury]:Chennai
Organization Name (eg, company) [My Company Ltd]:newindia India Pvt Ltd
Organizational Unit Name (eg, section) []:Chennai
Common Name (eg, your name or your server's hostname) []:newindia.com
Email Address []:sysadmin-india@newindia.com


[root@linux0135 KEYS]# openssl rsa -in privkey.pem -out privkey.pem
Enter pass phrase for privkey.pem:
writing RSA key


[root@linux0135 KEYS]#


Generate the key pair and the csr as follows:
Create the key pair and the csr on the JABBER SERVER as follows:
Modify the openssl.cnf file:


[root@sysadminbox root]# find / -name openssl.cnf
/usr/share/ssl/openssl.cnf
/usr/local/src/openssl-0.9.7b/apps/openssl.cnf
/usr/ssl/openssl.cnf


[root@sysadminbox root]# cd /usr/share/ssl/
[root@lnxdev0003 ssl]# vi openssl.cnf
dir = ./CA/
countryName_default = IN
stateOrProvinceName_default = TamilNadu
localityName_default = Chennai
0.organizationName_default = New India Pvt Ltd
organizationalUnitName_default = Development
emailAddress = bharath@newindia.com


[root@linux0120 ssl]# openssl req -new -nodes -config openssl.cnf -keyout /usr/local/jabber/etc/jabberd/jabberd-key.pem -out /usr/local/jabber/etc/jabberd/jabberd.csr
Generating a 1024 bit RSA private key
..................++++++
.........................++++++
writing new private key to '/usr/local/jabber/etc/jabberd/jabberd-key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [IN]:
State or Province Name (full name) [TamilNadu]:
Locality Name (eg, city) [Chennai]:
Organization Name (eg, company) [New India Pvt Ltd]:
Organizational Unit Name (eg, section) []:Development
Common Name (eg, your name or your server's hostname) []:linux0120.dev02.newindia.com
logarajan@newindia.com []:


Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:


Send the File to the CA for signing:


[root@linux0120 ssl]# openssl ca -config openssl.cnf -out CA/newcerts/jabberd-cert.pem -in /usr/local/jabber/etc/jabberd/jabberd.csr
Using configuration from openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 2 (0x2)
Validity
Not Before: Apr 13 05:10:27 2006 GMT
Not After : Apr 13 05:10:27 2007 GMT
Subject:
countryName = IN
stateOrProvinceName = TamilNadu
organizationName = New India Pvt Ltd
organizationalUnitName = Development
commonName = linux0120.dev02.newindia.com
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
74:52:75:5B:7C:2F:73:BB:7F:1D:8F:9E:49:5D:74:B7:C8:6E:4F:17
X509v3 Authority Key Identifier:
keyid:3B:8B:3A:75:A0:F7:2E:36:C9:21:F9:9D:59:25:6B:00:4F:CD:D6:F3
DirName:/C=IN/ST=TamilNadu/L=Chennai/O=New Break India Pvt Ltd/OU=Development/CN=linux0120.dev02.newindia.com
serial:00


Certificate is to be certified until Apr 13 05:10:27 2007 GMT (365 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated


Send the Signed file and the ca file to the client:


[root@linux0120 ssl]# cp CA/newcerts/jabberd-cert.pem /usr/local/jabber/etc/jabberd/


[root@linux0120 ssl]# cp CA/cacert.pem /usr/local/jabber/etc/jabberd/


Set the following ownerships and permissions:


[root@linux0120 jabberd]# chown root:jabber jabberd-cert.pem cacert.pem


[root@linux0120 jabberd]# chmod 640 jabberd-cert.pem cacert.pem

How to install Redmine in RHEL(Redhat) / CentOS Linux


 
Redmine is a very popular Rails-based open source bug tracker to help you manage issues and tasks for multiple projects


Download Bitnami Redmine from bitnami website https://bitnami.com/stack/redmine

[root@linux0110 opt]# ./bitnami-redmine-2.5.0-0-linux-installer.run
Language Selection


Please select the installation language
[1] English - English
[2] Spanish - Español
[3] Japanese - 日本語
[4] Korean - 한국어
[5] Simplified Chinese - 简体中文
[6] Hebrew - עברית
[7] German - Deutsch
[8] Romanian - Română
[9] Russian - Русский
Please choose an option [1] : <Enter>
----------------------------------------------------------------------------
Welcome to the Bitnami Redmine Stack Setup Wizard.


----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.


PhpMyAdmin [Y/n] : Y


Is the selection above correct? [Y/n]: Y


----------------------------------------------------------------------------
Installation folder


Please, choose a folder to install Bitnami Redmine Stack


Select a folder [/opt/redmine-2.5.0-0]: <Enter>


----------------------------------------------------------------------------
Create Admin account


Bitnami Redmine Stack admin user creation


Your real name [User Name]: admin


Email Address [user@example.com]: bharath@mycompany.com


Login [user]: admin


Password :
Please confirm your password :
----------------------------------------------------------------------------
Web Server Port


Please enter the port that the bundled Apache Server will listen to by default.


Apache Web Server Port [80]: 81


----------------------------------------------------------------------------
Web Server Port


Please enter the port that the bundled Apache Server will use for SSL access.


SSL Port [443]: 8433


----------------------------------------------------------------------------
MySQL Information


Please enter your MySQL database information:


MySQL Server port [3306]: 3300


----------------------------------------------------------------------------
Language for default data configuration


Select your language for default data configuration:


[1] Bulgarian
[2] Czech
[3] German
[4] English
[5] Spanish
[6] French
[7] Hebrew
[8] Italian
[9] Japanese
[10] Korean
[11] Dutch
[12] Polish
[13] Portuguese
[14] Portuguese/Brazilian
[15] Romanian
[16] Russian
[17] Serbian
[18] Swedish
[19] Chinese
[20] Chinese/Taiwan
Please choose an option [4] : 4


Do you want to configure mail support? [y/N]: y


----------------------------------------------------------------------------
Configure SMTP Settings


This is required so your application can send notifications via email.


Default email provider:


[1] GMail
[2] Custom
Please choose an option [1] : 2


----------------------------------------------------------------------------
Configure SMTP Settings


This data is stored in the application configuration files and may be visible to
others. For this reason, it is recommended that you do not use your personal
account credentials.


Username []: redmine


Password :
Re-enter :
SMTP Host []: 192.168.0.20


SMTP Port []: 25


Secure connection


[1] None
[2] SSL
[3] TLS
Please choose an option [3] : 1


----------------------------------------------------------------------------
Setup is now ready to begin installing Bitnami Redmine Stack on your computer.


Do you want to continue? [Y/n]: Y


----------------------------------------------------------------------------
Please wait while Setup installs Bitnami Redmine Stack on your computer.


Installing
0% ______________ 50% ______________ 100%
#########################################


----------------------------------------------------------------------------
Setup has finished installing Bitnami Redmine Stack on your computer.


Launch Redmine application. [Y/n]: Y


Info: To access the Bitnami Redmine Stack, go to
http://localhost:81 from your browser.
Press [Enter] to continue :

 -------------------------------------------------------------------------------------------------------------
Redmine tickets are stored in MySQL on backend. Good for Medium and Large Enterprise Usage.
With Redmine, you can define multiple projects and track issues on each project independently. Users can have different roles on each project and Redmine also supports custom issue types and workflows. The interface is easy to use and activity feeds ensures that users are always up-to-date on issue status changes.


Friday, August 8, 2014

InfiniDB(Single Server Mode) installation Step by Step on RHEL 6.x / CentOS 6.x

We are going to install InfiniDB - Single Server Mode(Standard Edition) on RHEL 6.x / CentOS 6.x

Download the source from http://www.infinidb.co/try-infinidb

Note: you need root access to install and configure InfiniDB and here commands executed are in BOLD.

OS : RHEL 6.5
User: root
Mode: Single User
Edition: Standard Edition

----------------------------------------------------------------------------------------------------------------



[root@server1 ~]# cd /usr/local/


[root@server1 local]# tar -xzf infinidb-4.5.1-3.x86_64.bin.tar.gz


[root@server1 local]# cd Calpont/bin/


[root@server1 bin]# ./post-install
The next step is:


/usr/local/Calpont/bin/postConfigure


[root@server1 bin]# ./postConfigure


This is the Calpont InfiniDB System Configuration and Installation tool.
It will Configure the Calpont InfiniDB System and will perform a Package
Installation of all of the Servers within the System that is being configured.


IMPORTANT: This tool should only be run on the Parent OAM Module
which is a Performance Module, preferred Module #1


Prompting instructions:


Press 'enter' to accept a value in (), if available or
Enter one of the options within [], if available, or
Enter a new value




===== Setup System Server Type Configuration =====


There are 2 options when configuring the System Server Type: single and multi


'single' - Single-Server install is used when there will only be 1 server configured
on the system. It's a shorter install procedure used for POC testing, as an example.
It can also be used for production systems, if the plan is to stay single-server.


'multi' - Multi-Server install is used when you want to configure multiple servers now or
in the future. With Multi-Server install, you can still configure just 1 server
now and add on addition servers/modules in the future. This is used more for
production installs.


Select the type of System Server install [1=single, 2=multi] (2) > 1


Performing the Single Server Install.
Enter System Name (calpont-1) > infinidb1


===== Setup Storage Configuration =====


----- Setup High Availability Data Storage Mount Configuration -----


There are 2 options when configuring the storage: internal or external


'internal' - This is specified when a local disk is used for the dbroot storage
or the dbroot storage directories are manually mounted externally
but no High Availability Support is required.


'external' - This is specified when the dbroot directories are externally mounted
and High Availability Failover Support is required.


Select the type of Data Storage [1=internal, 2=external] (1) > 1


Enter the list (Nx,Ny,Nz) or range (Nx-Nz) of dbroot IDs assigned to module 'pm1' (1) > 1


===== InfiniDB SNMP-Trap Process Check =====


InfiniDB is packaged with an SNMP-Trap process.
If the system where InfiniDB is being installed already has an SNMP-Trap process
running, then you have the option of disabling InfiniDB's SNMP-Trap process.
Not having the InfiniDB SNMP-Trap process will affect the
generation of InfiniDB alarms and associated SNMP traps.
Please reference the Calpont InfiniDB Installation Guide for
additional information.


InfiniDB SNMP-Trap process is enabled, would you like to disable it [y,n] (n) > {PRESS ENTER}


InfiniDB SNMP Process successfully enabled


===== Setup the Network Management System (NMS) Server Configuration =====


This would be used to receive SNMP Traps from InfiniDB, like a Network Control Center
Enter IP Address(es) of NMS Server (0.0.0.0) > {PRESS ENTER}




===== Performing Configuration Setup and InfiniDB Startup =====


NOTE: Setting 'NumBlocksPct' to 50%
Setting 'TotalUmMemory' to 25% of total memory (Combined Server Install maximum value is 16G). Value set to 4G


Running the Infinidb MySQL setup scripts


Starting MySQL. SUCCESS!
Shutting down MySQL. SUCCESS!
SUCCESS!


Starting InfiniDB Database Platform


InfiniDB Database Platform Starting, please wait ......... DONE


System Catalog Successfull Created


InfiniDB Install Successfully Completed, System is Active


Enter the following command to define InfiniDB Alias Commands


. /usr/local/Calpont/bin/calpontAlias


Enter 'idbmysql' to access the InfiniDB MySQL console
Enter 'cc' to access the InfiniDB OAM console


[root@server1 bin]# . /usr/local/Calpont/bin/calpontAlias


[root@server1 local]# idbmysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.73 InfiniDB 4.5.1-3


Copyright (c) 2014, InfiniDB, Inc. and/or its affiliates. All rights reserved.
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.


InfiniDB is a registered trademark of InfiniDB, Inc. and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql>
 

---------------------------------------------------------------------------------------------------------


Yes ! we have successfully installed InfiniDB

if its throws any error, you can check the logs in /var/log/Calpont directory.
Also check whether mysql-calpont and infinidb service has been started.

 [root@server1 ~]# /etc/init.d/mysql-Calpont status
MySQL running (2355)                                       [  OK  ]
[root@server1 ~]# /etc/init.d/infinidb status
InfiniDB is running

If you face any other issue, do post here i will do my best to resolve your issue.