Showing posts with label Solaris. Show all posts
Showing posts with label Solaris. Show all posts

Sunday, January 11, 2009

Sun Cluster 3.2 Globaldevices issue...

Hi,
I had an issue with my Sun Cluster 3.2, for some reason only one node /global/.devices was mounted at the same time, because of that I couldn't switch the resources between nodes (the switch/remaster command hang) and in one node the cluster globaldevices service fail to start.

When the resources switch hang, there was no message in syslog, it just waited util it timedout and failed back the resource.

Also, when the server booted I could see this message:
mount: /dev/md/dsk/d6 is already mounted or /global/.devices/node@1 is busy
Trying to remount /global/.devices/node@1
mount: /dev/md/dsk/d6 is already mounted or /global/.devices/node@1 is busy

WARNING - Unable to mount one or more of the following filesystem(s):
/global/.devices/node@1
If this is not repaired, global devices will be unavailable.
Run mount manually (mount filesystem...).
After the problems are corrected, please clear the
maintenance flag on globaldevices by running the
following command:
/usr/sbin/svcadm clear svc:/system/cluster/globaldevices:default
The problem was that both nodes had the same physical device name /dev/md/dsk/d6 for /global/.devices , here is how my vfstab on each node before the fix:
Node1:
/dev/md/dsk/d6 /dev/md/rdsk/d6 /global/.devices/node@1 ufs 2 no global

Node2:
/dev/md/dsk/d6 /dev/md/rdsk/d6 /global/.devices/node@2 ufs 2 no global

To solve it all I had to do is rename the metadevice on both nodes using metarename and modify /etc/vfstab to include the new change:
Node1:
metarename d6 d601
Node2:
metarename d6 d602

after the change you can restart svc:/system/cluster/globaldevices:default on both nodes and it all works.

Sunday, December 28, 2008

Annoying syslog.conf syntax issue

Syslog will not work when using space as separators in syslog.conf file, you must use TAB as a separator.

Friday, December 26, 2008

Sun Cluster 3.2 with Mysql on Failover zones

Click here to download a pdf format of this post.

I'm going to write it step by step, with almost no explanations, just steps and tips:
First of all what I've tried to create is:

  • Active/Passive MySQL cluster
  • Two physical nodes
  • Non-global zone on each node
  • MySQL is running in the zone
  • Private interconnect – Two interfaces on each server connected thru two Ethernet switches
  • One central storage, with one LUN for MySQL data and one LUN for quorum
  • Hosts names are: host1 & host2
  • Zones names are: zone1 & zone2
  • IPMP is used for public interfaces on physical nodes
  • MPXIO is used for HBA's multipathing
  • Using ZFS as MySQL data filesystem

Resource I've used:

So, here we go:

1. Preparations:

a. On the Ethernet switches - Disable spanning tree on the private interconnect ports

b. No need to configure IP's for the private interconnect interfaces

c. It is encouraged to create two separate VLAN's for the private interconnect interfaces

d. Default interconnect network configuration is: 172.16.0.0 with netmask 255.255.248.0, the default can be changed when configuring the cluster

e. If using Jumbo frames for the public network, also configure Jumbo frames for the private interconnect

f. Disable Solaris power management

* Edit /etc/power.conf file and change the line autopm default to autopm disable

* Run: pmconfig

g. /globaldevices file system, is a local filesystem, can be stored on local disks, with the size of 512MB

h. Packages needed for the cluster are: SUNWrsm, SUNWrsmo

2. Make sure that RPC is open for public network:
# svccfg
svc:/network/rpc/bind> select network/rpc/bind
svc:/network/rpc/bind> setprop config/local_only=false
svc:/network/rpc/bind> quit
# svcadm refresh network/rpc/bind:default

If TCP Wrapper is used, also add:
rpcbind: ALL too /etc/hosts.allow file on both servers, if you don't wish to allow rpc for everyone, you can restrict it to both servers public and private ip's.


Tip: run tail –f on the messages file for both servers in different sessions, this will help you find the problems in no time

3. Create the zones on both servers

a. Define public IP for both zones

b. Configure /etc/hosts to include the public IP name

4. Install the cluster on host1 and host2 (can be done simultaneously)

a. Mount CD

b. Define DISPLAY environment variable to your X machine

c. Run ./installer

i. Install Cluster Core, Cluster Manager (not required) and MySQL agent

ii. Select to configure cluster after install

5. Change root .profile (or whatever you are using) to include /usr/sbin:/usr/cluster/bin in the PATH environment variable and /usr/cluster/man in the MANPATH environment variable

6. Create SSH key based authentication between the two physical servers for the root account (use RSA keys)

7. After the installation has completed, you need to run scinstall to configure the cluster

a. If TCP wrapper is enabled, add this line to /etc/hosts.allow:
sccheckd: localhost
it is required for sccheck utility to work properly.

b. Don't use Auto Quorum configuration, we will add it later

c. NOTE: both servers will be rebooted at the end of scinstall, without confirmation!!!

d. If you want a different private interconnect IP's/Subnet, you can change it in this step

8. After both servers rebooted, check the cluster status by running:
clnode status

9. Adding a quorum disk device

a. Use format to label the device

b. The cluster is using DID pseudo names for devices, to find a device DID name run:
cldevice list -v

c. Run clsetup and add a disk quorum device

d. If quorum added successfully, press yes for resting installmode

10. Check that the quorum is defined by running:
clquorum list

11. Check that the cluster installmode is disabled:
cluster show -t global | grep installmode

12. Enable automatic node reboot if all monitored disk paths fail:
clnode set -p reboot_on_path_failure=enabled +

a. Check that it has changed:
clnode show

13. Registering the cluster storage and network service
clresourcetype register SUNW.gds SUNW.HAStoragePlus

14. Create a new Resource Group that includes both zones
clresourcegroup create –n host1:zone1,host2:zone2 RG–MYSQL

15. Check that the resource group was added:
clresourcegroup status

16. Create the ZFS pool – zMysql

17. Before we will be able to add zMysql pool as a cluster resource, we need to export it because the cluster will change the pool devices to the DID location:
zpool export zMysql

18. Add the zMysql as a resource in RG-MYSQL:
clresource create -g RG-MYSQL -t SUNW.HAStoragePlus -p AffinityOn=TRUE –p \
Zpools=zMysql -p ZpoolsSearchDir=/dev/did/dsk RS-MYSQL-HAS

19. Check that zMysql was added as a resource to RG-MYSQL:
clresource list

20. Now we can import it back
zpool import zMysql

21. Add a new Virtual IP resource to our RG-MYSQL resource group:

a. Add the VIP to /etc/hosts on both physical servers and zones (we used vip-mysql)

b. Add the VIP to the resource group:
clreslogicalhostname create -g RG-MYSQL -h vip-mysql -N \
private@host1,private@host2 RS-VIP

c. private = our IPMP group name on each server, if not using IPMP, replace private with the NIC name, for example e1000g1

d. Check if VIP added as a resource:
clresource list

22. You can move the resource group to the other servers by running:
clresourcegroup switch -n host1:zone1 RG-MYSQL

23. You can move the resource group back by:
clresourcegroup remaster RG-MYSQL

24. Install MySQL on zone1 and create the databases on zMysql filesystem

25. Install MySQL software on zone2

26. Create mysql account and group on both zones with same uid and gid

27. Start the MySQL instance on zone1

28. Copy my.cnf to the zMySQL filesystem (/data)

29. Edit my.cnf file and add this line to [mysqld] section:
bind-address =

30. Create root@vip-mysql account and grant permissions:
# mysql
mysql> GRANT ALL ON *.* TO 'root'@'vip-mysql' IDENTIFIED BY 'mypassword';
mysql> UPDATE mysql.user SET grant_priv='Y' WHERE user='root' AND host='vip-mysql';

31. Now, the next step is to create the cluster database in our MySQL instance, this database is used for MySQL checks by the cluster

a. cp /opt/SUNWscmys/util/mysql_config /data/

b. chmod 400 /data/mysql_config

c. Edit the file /data/mysql_config to look like this:
MYSQL_BASE=/opt/mysql

MYSQL_USER=root

MYSQL_PASSWD=mypassword

MYSQL_HOST=vip-mysql

FMUSER=fmuser

FMPASS=fmuserNewPassword

MYSQL_SOCK=/tmp/vip-mysql.sock

MYSQL_NIC_HOSTNAME=vip-mysql

MYSQL_DATADIR=/data

d. Note: Don't use $ signs in the password, the cluster scripts will fail...(tried to put \$, but failed for account fmuser)

e. Select an appropriate password for fmuser account

f. Create the database:
ksh /opt/SUNWscmys/util/mysql_register -f /data/mysql_config

g. If the script fails, look at /tmp for more information: cat /tmp/.mysql.error

32. Next step is to register the MySQL as a resource in the cluster, for that we will need to edit one more file:

a. cp /opt/SUNWscmys/util/ha_mysql_config /data/

b. chmod 400 /data/ha_mysql_config

c. Edit the file /data/ha_mysql_config to look like this:
RS=RS-MYSQL-DB

RG=RG-MYSQL

#PORT=3306

LH=RS-VIP

HAS_RS=RS-MYSQL-HAS

# local zone specific options

ZONE=

ZONE_BT=

PROJECT=

# mysql specifications

BASEDIR=/opt/mysql

DATADIR=/data

MYSQLUSER=mysql

MYSQLHOST=vip-mysql

FMUSER=fmuser

FMPASS=fmuserNewPassword

LOGDIR=/data

CHECK=YES

d. Register MySQL as a resource:
ksh /opt/SUNWscmys/util/ha_mysql_register -f /data/ha_mysql_config

e. If MySQL is registered as a Solaris Service, disable it:
svcadm disable mysql

f. Enable RS-MYSQL-DB resource:
clresource enable RS-MYSQL-DB

g. Cluster MySQL resource is saving data to /tmp, check the result/errors in /tmp

Wednesday, August 15, 2007

Fair Scheduler support for Linux

Just few days ago I wrote about my experience with Solaris FSS and now I found out that Linux kernel 2.6.24 will support CFS (Completely Fair Scheduler). This should be very interesting to test...

Actually CFS is merged in release 2.6.23 but depends on some unmerged containers, so we will have to wait for release 2.6.24..

Can't wait to test it.

Oded.

Monday, August 13, 2007

Solaris 10 - Resource Management

Today we've started testing Solaris 10 CPU resource management using FSS (Fair Share Scheduler) and Projects.

The problem we wanted to solve is with Oracle database, we have a DWH database and at night we have few things:
  • ETL
  • Database Exports
  • Users access
What we need is that the database exports won't interrupt the ETL process (The users don't do much at night), So we've decided to try Solaris Resource Management capability.

Before I'll show what we have done you need to know that the Oracle owner is "orauser"
and the Oracle SID is "orcl".

The first step is to create the needed projects, projects are used to distinguish different workloads from one another. We've created two projects:
  • user.orauser
  • oracle_low
There are three ways to create a project:
  1. user.USERNAME - a project that is associated with a specific Unix user
  2. group.GROUPNAME - a project that is associated with a specific Unix group
  3. project name - a project that is not associated to any group or user by default and can be associated manually or by SMF (Service Management Facility)
So the first project we've created, user.orauser, will be assigned automatically for the user orauser. The second project, oracle_low, is a non associated project that we will use to lower the CPU workload for the database exports.

The commands to create a the projects are:
# projadd -c "Oracle default project" user.orauser
# projadd -c "Oracle low priority project" oracle_low

All the projects defined in /etc/projects file and can be viewed in this file or by running:
# projects -l

To check orauser default project run:
# id -p orauser
uid=60000(orauser) gid=300(dba) projid=100(user.orauser)

Now that we've created the projects, we need to change the system scheduling to use FSS:
# ps -cafe
# dispadmin -d FSS
# priocntl -s -c FSS -i class TS
# priocntl -s -c FSS -i pid 1
# ps -cafe

  • "ps -cafe" - shows all processes and there scheduler class, I will not explain what a class is, but you should know that TS class is what Solaris uses for all processes by default. The TS class can be manipulated by the nice and renice commands.
  • "dispadmin -d FSS" - sets the default scheduling class to be used on reboot to FSS
  • "priocntl -s -c FSS -i class TS" - changes all current process with TS class to FSS class
  • "priocntl -s -c FSS -i pid 1" - changes the /sbin/init process to FSS class
The next step is to add the CPU resource (cpu-shares) to each project, one thing we need to know about cpu-shares resource is that the value we set for it is the ratio and not percentages, it means that if project A have cpu-shares=10 and project B have cpu-shares=20 and both process of both projects need 100% CPU load the processes of project B will get total of 66% CPU and the processes of project A will get 33%. So, here is the way to add the CPU resource to our projects:
# prctl -n project.cpu-shares -r -v 30 -i project user.orauser
# prctl -n project.cpu-shares -r -v 10 -i project oracle_low
# projmod -sK “project.cpu-shares=(privileged,10,none)” oracle_low
# projmod -sK “project.cpu-shares=(privileged,30,none)” user.orauser

  • projmod - changes the project attributes
  • prctl - changes the resource control for running process
Use the "projects -l" command to view the changes we've just made.
# project -l user.orauser
# project -l oracle_low

Now, we changed the export processes to run like this:
# newtask -p oracle_low /u01/scripts/oracle_export.sh

And every thing is working perfectly!!! Fun Fun Joy Joy.

One more useful command is "prstat -J" that will show resources utilization by project.

Oded.

Monday, August 06, 2007

Kerberos Authentication with LDAP Authorization for Linux & Solaris (8 & 10) with Active Directory 2003 R2

This document will show the steps to authenticate (Using Kerberos) and authorize (Using LDAP) Solaris (8 & 10 have been tested, Solaris 9 should work the same as 10) and Linux with Active Directory 2003 R2.

My apology: I used word to create this post and then copy/paste the content to here, so the format has changed a bit... You can download the file from here.

Introduction

Here I'll explain the main components involved in this architecture:

  • Kerberos - The world standard for secured strong network authentication. How it works?
    From wikipedia ( http://en.wikipedia.org/wiki/Kerberos_(protocol) ):

    AS = Authentication Server
    TGS = Ticket Granting Server
    SS = Service Server

    1. A user enters a username and password on the client.
    2. The client performs a one-way hash on the entered password, and this becomes the secret key of the client.
    3. The client sends a clear-text message to the AS requesting services on behalf of the user. Sample Message: "User XYZ would like to request services". Note: Neither the secret key nor the password is sent to the AS.
    4. The AS checks to see if the client is in its database. If it is, the AS sends back the following two messages to the client:
      • Message A: Client/TGS session key encrypted using the secret key of the user.
      • Message B: Ticket-Granting Ticket (which includes the client ID, client network address, ticket validity period, and the client/TGS session key) encrypted using the secret key of the TGS.
    5. Once the client receives messages A and B, it decrypts message A to obtain the client/TGS session key. This session key is used for further communications with TGS. (Note: The client cannot decrypt the Message B, as it is encrypted using TGS's secret key.) At this point, the client has enough information to authenticate itself to the TGS.
    6. When requesting services, the client sends the following two messages to the TGS:
      • Message C: Composed of the Ticket-Granting Ticket from message B and the ID of the requested service.
      • Message D: Authenticator (which is composed of the client ID and the timestamp), encrypted using the client/TGS session key.
    7. Upon receiving messages C and D, the TGS decrypts message D (Authenticator) using the client/TGS session key and sends the following two messages to the client:
      • Message E: Client-to-server ticket (which includes the client ID, client network address, validity period and Client/server session key) encrypted using the service's secret key.
      • Message F: Client/server session key encrypted with the client/TGS session key.
    8. Upon receiving messages E and F from TGS, the client has enough information to authenticate itself to the SS. The client connects to the SS and sends the following two messages:
      • Message E from the previous step (the client-to-server ticket, encrypted using service's secret key).
      • Message G: a new Authenticator, which includes the client ID, timestamp and is encrypted using client/server session key.
    9. The SS decrypts the ticket using its own secret key and sends the following message to the client to confirm its true identity and willingness to serve the client:
      • Message H: the timestamp found in client's recent Authenticator plus 1, encrypted using the client/server session key.
    10. The client decrypts the confirmation using the client/server session key and checks whether the timestamp is correctly updated. If so, then the client can trust the server and can start issuing service requests to the server.
    11. The server provides the requested services to the client.

  • Directory Services – Use to store organization information in a tree hierarchy. The stored information is usually users, groups, computers, resources and more.

  • LDAP – Lightweight Directory Access Protocol is the "SQL language" for querying and modifying directory services data.

  • Active Directory – is Microsoft's implementation for the Kerberos (KDC) and LDAP server in one entity.

  • Active Directory R2 – the release 2 of AD 2003 includes the directory schema extension for UNIX/Linux authorization (compliant with RFC 2307). With this release we can use AD to store information for UNIX like operating systems, this information includes users data like uid, gid, home directory, default shell and more.
    NOTE: Before R2 was released Microsoft created the "
    Microsoft Windows Services for UNIX" that can be downloaded from Microsoft's web site, this schema extension is not compliant with RFC 2307.

Active Directory 2003 R2

To be able to implement this solution we will need a running Active Directory 2003 R2 server, if this is the first R2 server in an existing forest you must first extend the schema with Adprep tool. Here you can find direction on how to correctly install R2.

The schema extension will add/modify the needed objects and attributes to the Active Directory for UNIX/Linux authorization, objects like group and user or attributes like "home directory" and "login shell". We can see the new information as a new tab ("UNIX Attributes") in the user/group dialog box at the "Active Directory Users and Computers" management console. With this dialog we can set the UNIX attributes for each user/group, attributes like uid, gid, home directory and login shell.

Installation and configuration with linux (Redhat ES4 Update 4)

Kerberos

Installing Kerberos

The first step in setting the authentication method to use Kerberos is to install the following RPMs:

· krb5-libs

· pam_krb5

· krb5-workstation

· krb5-auth-dialog

Configuring Kerberos

The second step is to configure the authentication mechanism to use Kerberos, Redhat provides authconfig tool that can be used to do the basic configuration, run this tool and follow the next steps:

· Select "Use Kerberos" in the first dialog and click next

· The next screen will ask for the Kerberos information:

o Realm – Fill the complete domain name in CAPITAL letters, for example: UXDC.CORP

o KDC – Fill the complete domain controller DNS name with port 88, for example: srvuxdc.corp:88

o Admin Server - Fill the complete domain controller DNS name with port 749, for example: srvuxdc.corp:749

o Select both checkboxes:

§ Use DNS to resolve hosts to realms

§ Use DNS to locate KDCs for realms

When you press Ok, authconfig will go back to command line. The files updated by authconfig are:

· /etc/krb5.conf – Kerberos 5 configuration file

· /etc/krb.conf – Kerberos 4 configuration file – This can be remove

· /etc/pam.d/system-auth – PAM configuration file for authentication mechanism

There is one more Kerberos 4 file that can be removed to avoid confusion: /etc/krb.realms, this file is used by Kerberos 4 for the realms map to domain names.

krb5.conf

The next step in the configuration is to edit Kerberos 5 configuration file: /etc/krb5.conf, we will need to change/add few parameters to the file, but before we will do it I'll explain the file structure:

· [logging] – sets the way Kerberos component will perform there logging, the components that use the logging parameters are the KDC and Kerberos Admin Server both are used when you will use Linux as the Kerberos server, our Kerberos server is the Active Directory so we can leave the default for the logging section.

· [libdefaults] - Contains various default values used by the Kerberos V5 library. Values like default encryption type and if to use dns lookups or not.

· [realms] – list of realms and where to find there Kerberos server and some other realm related information.

· [domain_realm] – this file the mapping file from domain names to Kerberos realms.

· [appdefaults] – Contains default values that can be used by Kerberos V5 applications.

Here is an example for krb5.conf file after the needed changes, the main lines are highlighted:

[logging]

default = FILE:/var/log/krb5libs.log

[libdefaults]

default_realm = UXDC.CORP

dns_lookup_realm = true

dns_lookup_kdc = true

default_keytab_name = FILE:/etc/krb5.keytab

default_tkt_enctypes = des-cbc-md5

default_tgs_enctypes = des-cbc-md5

[realms]

UXDC.CORP = {

kdc = SRVUXDC.LCARD.CORP:88

admin_server = SRVUXDC.LCARD.CORP:749

}

[domain_realm]

.uxdc.corp = UXDC.CORP

uxdc.com = UXDC.CORP

[appdefaults]

pam = {

debug = false

ticket_lifetime = 36000

renew_lifetime = 36000

forwardable = true

krb4_convert = false

}

So, what does it means? :

  • default_realm – is the default realm to be used when no realm is specified by using @ for example: user1@UXDC.CORP
  • default_keytab_name – the default path to find the server keytab, a keytab is a file containing pairs of Kerberos principals and DES-encrypted keys based on Kerberos password allowing the server services to access resources based on Kerberos authentication without the need to use a password.
  • default_tkt_enctypes – the default encryption type will be requested by the client.
    • Use des encryption only to support other unix tools, the encryption types can be one of des-cbc-crc or des-cbc-md5
  • default_tgs_enctypes – the default encryption type will be returned by the KDC.
    • Use des encryption only to support other unix tools, the encryption types can be one of des-cbc-crc or des-cbc-md5
  • verify_ap_req_nofail - If this flag is set, then an attempt to get initial credentials will fail if the client machine does not have a keytab. The default for the flag is false. NOTE: For some reason this parameter is not working in linux, that’s why we will use "validate" in the /etc/pam.d/system-auth configuration file.

Configuring PAM

The next file we will change is /etc/pam.d/system-auth, this file is configured by authconfig to use Kerberos as one of the authentication mechanisms (first use Unix and than try Kerberos), the only thing that we will change in the file is adding the validate parameter to each pam_krb5.so line, the validate parameter tells pam to check the server keytab, this can be avoided when the verify_ap_req_nofail parameter in krb5.conf file will work properly in the future release:

auth required /lib/security/$ISA/pam_env.so

auth sufficient /lib/security/$ISA/pam_unix.so likeauth nullok

auth sufficient /lib/security/$ISA/pam_krb5.so use_first_pass validate

auth required /lib/security/$ISA/pam_deny.so

account required /lib/security/$ISA/pam_unix.so broken_shadow

account sufficient /lib/security/$ISA/pam_succeed_if.so uid <>

account [default=bad success=ok user_unknown=ignore] /lib/security/$ISA/pam_krb5.so validate

account required /lib/security/$ISA/pam_permit.so

password requisite /lib/security/$ISA/pam_cracklib.so retry=3

password sufficient /lib/security/$ISA/pam_unix.so nullok use_authtok md5 shadow

password sufficient /lib/security/$ISA/pam_krb5.so use_authtok validate

password required /lib/security/$ISA/pam_deny.so

session required /lib/security/$ISA/pam_limits.so

session required /lib/security/$ISA/pam_unix.so

session optional /lib/security/$ISA/pam_krb5.so validate

try_first_pass – with this parameter PAM will not ask the user to enter the Kerberos password if the Unix authentication failed and will use the first password enter by the user.

If we need to debug the Kerberos 5 pam module you can add "debug" to the end of Kerberos auth line:

auth sufficient /lib/security/$ISA/pam_krb5.so try_first_pass validate debug

Creating the server keytab

The final step is to create the server keytab:

  • Create a domain user for the server, name the user as the name of the server, and use a secured password, also select "Password never expires" and "Use DES ecryption types for this account" in the account tab.
  • Create the account keytab by using the ktpass command line:
    • ktpass.exe princ host/@ mapuser -pass out .keytab
      For example, if my server name is linuxhost01.uxdc.corp:
      ktpass.exe princ host/linuxhost01.uxdc.corp@UXDC.CORP mapuser linuxhost01 -pass TheServerPassw0rd#6 out linuxhost01.keytab
  • Copy the file to the server using secured connection like sftp/scp
  • Connect to the server and run ktutil, and in the ktutil prompt run:
    rkt
    wkt /etc/krb5.keytab
    exit
  • Remove the copied keytab file from the server:
    rm –f
    or the better way is to use shred utility to securely remove the file from the server, for example:
    shred –u linuxhost01.keytab

Testing Kerberos

Now we will try to obtain a Kerberos ticket for an existing domain user, for example:

kinit myuser@UXDC.CORP

Password for myuser@UXDC.CORP:

If no error returned run: "klist -5e" to view the obtained Kerberos ticket!!!!

LDAP

Now that we have Kerberos working we can set the ldap client to get the account information from Active Directory. The configuration files that we will use are:

  • /etc/ldap.conf – LDAP configuration file
  • /etc/nsswitch.conf - Name Service Switch configuration file

Installing LDAP

We will need to install the following RPM's:

  • openldap
  • nss_ldap

ldap.conf

The first file to edit is /etc/ldap.conf, this file contains the defaults to be applied when running ldap clients. The lines that we will need to change/add are:

  • base – specifies the default base DN to use when performing ldap operations:
    base dc=uxdc,dc=corp
  • uri – the way to specify the LDAP server(s) to witch ldap clients should connect. (URI parameter replaced the HOST parameter:
    uri ldap://srvuxdc.corp
  • binddn – the default account to use for binding to ldap server:
    binddn uxldap@uxdc.corp
  • bindpw – the password used for the binding account:
    bindpw Account#Password$
  • scope – the search scope for ldap clients, can be one of:
    • one – one level search
    • sub – subtree search
    • base – base object search

we will use sub option, for example:
scope sub

  • Changing the time limits for ldap operations:
    • timelimit 30 – sets the search time limit to 30 seconds
    • bind_timelimit 30 – sets the binding time limit to 30 seconds
    • idle_timelimit 3600 – the time limit for nss_ldap to close connections if the server has not been connected for this amount of seconds.
  • pam_login_attribute – sets the ID attribute in the ldap server that is equivalent to the Unix uid attribute (uid attribute in unix ldap schema holds the username)
  • Setting where and how to search for specific contexts:
    nss_base_passwd dc=uxdc,dc=corp?sub?&(objectCategory=user)
    nss_base_shadow dc=uxdc,dc=corp?sub
    nss_base_group dc=uxdc,dc=corp?sub?&(objectCategory=group)
  • Now we will set all the other naming contexts from Active Directory to Unix/Linux:
    nss_map_objectclass posixAccount user
    nss_map_objectclass shadowAccount user
    nss_map_objectclass posixGroup group
    nss_map_attribute homeDirectory unixHomeDirectory
    nss_map_attribute gecos cn
    nss_map_attribute uniqueMember member

nsswitch.conf

The next file to configure is /etc/nsswitch.conf file, that file tells linux from where (which database) to get the needed information, all we need to do is to add the word ldap to the passwd, shadow and group databases:

passwd: ldap files

shadow: ldap files

group: ldap files

Testing ldap

After this is done, we can use getent utility to get information for user accound and groups defined in Active Directory but not in /etc/passwd, for example, to get information about the user account ux1 that is defined in Active Directory:

getent passwd ux1

To get information about the group unixgrp, defined in Active Directory:

getent group unixgrp

Now that every thing is set, we can try to login with a user account that is defined in Active Directory.

Installation and configuration with Solaris (8 & 10)

The Solaris configuration is pretty much the same to Linux configuration regarding to Kerberos, the main difference is in the ldap configuration.

Kerberos

Kerberos configuration files saved in /etc/krb5 directory, there are two main configuration files for Kerberos in Solaris:

  • krb5.conf
  • warn.conf – configure the warning massages to display when users Kerberos tickets are about to expire, we will not use this file in this manual.

krb5.conf

There is a difference between the implementation of Kerberos in Solaris 8 and Solaris 10, the main issue is that Solaris 8 does not support the validation of the server keytab!!! Other features that Solaris 8 doesn't support are:

  • dns_lookup_realm
  • dns_lookup_realm
  • default_keytab_name
  • And more…

We will use the same configuration file in both versions. Solaris 8 will ignore the unknown parameters in the configuration file as long as the syntax is correct.

Here is an example for krb5.conf file, there is nothing different here from the Linux configuration:

[libdefaults]

default_realm = UXDC.CORP

default_tkt_enctypes = des-cbc-md5

default_tgs_enctypes = des-cbc-md5

default_keytab_name = /etc/krb5/krb5.keytab

verify_ap_req_nofile = true

dns_lookup_realm = true

dns_lookup_realm = true

[realms]

UXDC.CORP = {

kdc = srvuxdc.corp:88

admin_server = srvuxdc.corp:749

}

[domain_realm]

.uxdc.corp = UXDC.CORP

uxdc.corp = UXDC.CORP

[appdefaults]

kinit = {

renewable = true

forwardable= true

}

Configuring PAM

In contrary to Linux, PAM configuration in Solaris is based on one file:

· /etc/pam.conf

We will need to use different configuration files for Solaris 8 and 10 because the difference between pam_krb5.so implementation in both versions. Solaris 10 version doesn’t support the use of "try_first_pass" because this behavior is implemented by default in the module.

In this file we will add the use of Kerberos authentication if the Unix authentication fails, here is an example:

login auth requisite pam_authtok_get.so.1

login auth required pam_dhkeys.so.1

login auth required pam_unix_auth.so.1

For Solaris 8:

login auth sufficient pam_krb5.so try_first_pass

For Solaris 10:

login auth sufficient pam_krb5.so

login auth required pam_dial_auth.so.1

other auth requisite pam_authtok_get.so.1

other auth required pam_dhkeys.so.1

other auth required pam_unix_auth.so.1

For Solaris 8:

other auth sufficient pam_krb5.so try_first_pass

For Solaris 10:

other auth sufficient pam_krb5.so

other account requisite pam_roles.so.1

other account required pam_projects.so.1

other account required pam_unix_account.so.1

other account required pam_krb5.so

other password required pam_dhkeys.so.1

other password requisite pam_authtok_get.so.1

other password requisite pam_authtok_check.so.1

other password sufficient pam_krb5.so

other password required pam_authtok_store.so.1

If we need to debug the Kerberos 5 pam module we can add "debug" to the end of Kerberos auth lines:

login auth sufficient pam_krb5.so debug

other auth sufficient pam_krb5.so debug

Configuring LDAP

The LDAP configuration in Solaris is done by ldapclient utility, the syntax has been changed between Solaris 8 and Solaris 10 (Solaris 9 syntax is the same as 10).

The files that will be changed by ldapclient are:

  • /etc/defaultdomain – contains the default domain for ldap
  • /var/ldap/ldap_client_cred – contains the account and password that will be used for binding to the ldap server (in our case, the active directory server)
  • /var/ldap/ldap_client_file – the main LDAP configuration file
  • /etc/nsswitch.conf

Solaris 8:

The command that we will run is:

ldapclient -i -a simple -r false \

-b "dc=uxdc,dc=corp" \

-D "cn=uxldap,cn=users,dc=uxdc,dc=corp" -w "Account#Password$" \

-d uxdc.corp -p 192.168.0.122 \

-s sub -o 30 -t 30 \

-R "passwd:gecos=cn" \

-R "passwd:gidnumber=gidNumber" \

-R "passwd:homedirectory=unixHomeDirectory" \

-R "passwd:loginshell=loginShell" \

-R "passwd:uidl=sAMAccountName" \

-R "shadow:uid=sAMAccountName" \

-M "group:posixGroup=group" \

-M "passwd:posixAccount=user" \

-M "shadow:shadowAccount=user" \

-S "passwd:dc=uxdc,dc=corp?sub" \

-S "shadow:dc=uxdc,dc=corp?sub" \

-S "group:dc=uxdc,dc=corp?sub?&(objectCategory=group)"

Here is an explanation for each line:

  • ldapclient -i -a simple -r false
    Will configure ldap to use simple authentication and want follow ldap references,
    ldap references are URI's that could be returned by the ldap server.
  • -b "dc=uxdc,dc=corp"
    sets the base DN to start the search from.
  • -D "cn=uxldap,cn=users,dc=uxdc,dc=corp" -w "Account#Password$"
    sets the account and password that will be used for binding to the LDAP server
  • -d uxdc.corp -p 192.168.0.122
    -d sets the default domain name
    -p sets the LDAP server IP, If we will use the LDAP server DNS name this command may hang
  • -s sub -o 30 -t 30
    -s sets the search scope
    -o and –t sets the LDAP operations timeouts
  • -R "passwd:gecos=cn"
    -R "passwd:gidnumber=gidNumber"
    -R "passwd:homedirectory=unixHomeDirectory"
    -R "passwd:loginshell=loginShell"
    -R "passwd:uidl=sAMAccountName"
    -R "shadow:uid=sAMAccountName"
    sets the attributes mapping
  • -M "group:posixGroup=group"
    -M "passwd:posixAccount=user"
    -M "shadow:shadowAccount=user"

    sets the object class mapping
  • -S "passwd:dc=uxdc,dc=corp?sub"
    -S "shadow:dc=uxdc,dc=corp?sub"
    -S "group:dc=uxdc,dc=corp?sub?&(objectCategory=group)"

    sets the search for each service

Solaris 10:

· ldapclient manual
manually configure LDAP client

· -a authenticationMethod=simple
-a credentialLevel=proxy
Use simple authentication (user and password) for binding to the LDAP server

· -a proxyDN=cn=uxldap,cn=users,dc=uxdc,dc=corp
-a proxyPassword=Account#Password$
sets the account and password for binding to the LDAP server

· -a defaultSearchBase=dc=uxdc,dc=corp
sets the base DN to start the search from.

· -a domainName=uxdc.corp
sets the default domain name

· -a defaultServerList=192.168.0.122
sets the LDAP server IP, If we will use the LDAP server DNS name this command may hang

· -a attributeMap=passwd:uniqueMember=member
-a attributeMap=passwd:gecos=cn
-a attributeMap=passwd:uid=sAMAccountName
-a attributeMap=passwd:homedirectory=unixHomeDirectory
-a attributeMap=passwd:loginshell=loginShell
-a attributeMap=shadow:uid=sAMAccountName
sets the attributes mapping

· -a objectClassMap=group:posixGroup=group
-a objectClassMap=passwd:posixAccount=user
-a objectClassMap=shadow:shadowAccount=user

sets the object class mapping

· -a serviceSearchDescriptor=passwd:dc=uxdc,dc=corp\?sub
-a serviceSearchDescriptor=shadow:dc=uxdc,dc=corp?sub
-a serviceSearchDescriptor=group:dc=uxdc,dc=corp\?sub\&(objectCategory=group)
sets the search for each service

If we would like to edit one of the ldap configuration files directly (without using the ldapclient utility) we would need to stop the ldap_client process before changing anything. ldap_client process role is to cache the ldap configuration for other ldap clients. The way to stop ldap_client process is to run: /etc/init.d/ldap_client stop
NOTE: Do not forget to start the ldap_client process after editing. More information about ldap_client process can be found in the man page of ldap_cachemgr.

Here is the result for /var/ldap/ldap_client_file after running ldapclient utility:

#

# Do not edit this file manually; your changes will be lost.Please use ldapclient (1M) instead.

#

NS_LDAP_FILE_VERSION= 2.0

NS_LDAP_SEARCH_BASEDN= dc=uxdc,dc=corp

NS_LDAP_AUTH= simple

NS_LDAP_SEARCH_REF= FALSE

NS_LDAP_SEARCH_SCOPE= sub

NS_LDAP_SEARCH_TIME= 30

NS_LDAP_SERVER_PREF= 172.16.7.75

NS_LDAP_CACHETTL= 0

NS_LDAP_CREDENTIAL_LEVEL= proxy

NS_LDAP_BIND_TIME= 30

NS_LDAP_ATTRIBUTEMAP= passwd:uniqueMember=member

NS_LDAP_ATTRIBUTEMAP= passwd:gecos=cn

NS_LDAP_ATTRIBUTEMAP= passwd:uid=sAMAccountName

NS_LDAP_ATTRIBUTEMAP= passwd:homedirectory=unixHomeDirectory

NS_LDAP_ATTRIBUTEMAP= passwd:loginshell=loginShell

NS_LDAP_ATTRIBUTEMAP= shadow:uid=sAMAccountName

NS_LDAP_OBJECTCLASSMAP= group:posixGroup=group

NS_LDAP_OBJECTCLASSMAP= passwd:posixAccount=user

NS_LDAP_OBJECTCLASSMAP= shadow:shadowAccount=user

NS_LDAP_SERVICE_SEARCH_DESC= passwd:dc=uxdc,dc=corp?sub

NS_LDAP_SERVICE_SEARCH_DESC= shadow:dc=uxdc,dc=corp?sub

NS_LDAP_SERVICE_SEARCH_DESC= group:dc=uxdc,dc=corp?sub?&(objectCategory=group)

The result for /var/ldap/ldap_client_cred is:

#

# Do not edit this file manually; your changes will be lost.Please use ldapclient (1M) instead.

#

NS_LDAP_BINDDN= cn=uxldap,cn=users,dc=uxdc,dc=corp

NS_LDAP_BINDPASSWD= {NS1}25c945dc7d61e0

You may wish to update /etc/nsswitch.conf file to remove the ldap from all lines excepts for passwd and group, also you would change the hosts entry to "files dns".

Testing ldap

We can use getent utility to test LDAP configuration just like we have done in the Linux machine.

Now that every thing is set, we can try to login with a user account that is defined in Active Directory.

Bibliography