2.2.3 - MacOSX MacOSX Instance Layout

The Mac OS X installer creates the following layout on yout disk :

 /
 |
 +-- usr/
 |    |
 |    +-- bin/
 |    |    |
 |    |    +-- apacheds    The script that starts the server
 |    |
 |    +-- local/
 |         |
 |         +-- apacheds-<version>
 |              |
 |              +-- bin/
 |              |    |
 |              |    +-- wrapper*   The wrapper
 |              |    |
 |              |    +-- apacheds*   The ApacheDS server starter
 |              |
 |              +-- conf/
 |              |    |
 |              |    +-- wrapper.conf
 |              |
 |              +-- instances/
 |              |    | 
 |              |    +-- default/
 |              |         | 
 |              |         +-- run/
 |              |         | 
 |              |         +-- partitions/
 |              |         | 
 |              |         +-- log/
 |              |         | 
 |              |         +-- conf/
 |              |         |    | 
 |              |         |    +-- wrapper-instance.conf
 |              |         |    | 
 |              |         |    +-- log4j.properties
 |              |         |    | 
 |              |         |    +-- config.ldif
 |              |         | 
 |              |         +-- cache/
 |              |         | 
 |              |         +-- syncrepl-data/
 |              |
 |              +-- lib/
 |              |    |
 |              |    +-- wrapper-3.2.3.jar
 |              |    |
 |              |    +-- libwrapper.jnilib
 |              |    |
 |              |    +-- apacheds-wrapper-2.0.0-M20-SNAPSHOT.jar
 |              |    |
 |              |    +-- apacheds-service-2.0.0-M20-SNAPSHOT.jar
 |              |
 |              +-- LICENSE
 |              |
 |              +-- NOTICE
 +-- Library/
      |
      +-- LaunchDaemons/
           |
           +-- org.apache.directory.server.plist  The daemon plist

Defining an instance

The default installation comes with a default instance (aka 'default'). It’s possible to define more instances, you will have to copy the directory /usr/local/apacheds-<version>/<instances>/default and give it the name of the new instance. Then, be sure to remove everything under the run/, partitions/, log/, syncrepl-data and cache/ directories to create a blank new instance. Here, we have created a blank test instance :

 /
 |
 +-- usr/
      |
      +--local/
          |
          +-- apacheds-<version>/
            |
            +-- test/   
                 |
                 +-- run/
                 |
                 +-- partitions/
                 |
                 +-- log/
                 |
                 +-- cache/
                 |
                 +-- conf/
                      |
                      +-- wrapper-instance.conf
                      |
                      +-- log4j.properties
                      |
                      +-- config.ldif

The next step is to be sure that the config.ldif file is modified to not conflict with any other instance of the server : it’s just a mater to change the port used by the server.

You will also have to define a new daemon starter. This is done by copying the Library/LaunchDaemons/org.apache.directory.server.plist file and modifying it :

$ sudo cp /Library/LaunchDaemons/org.apache.directory.server.plist /Library/LaunchDaemons/org.apache.directory.server.test.plist

Now, update the folliwing lines in this file :

<plist version="1.0">
    <dict>
        <key>Disabled</key>
        <false/>

        <key>Label</key>
        <string>org.apache.directory.server</string>   /// Change the name

        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/apacheds-2.0.0-M20-SNAPSHOT/bin/apacheds</string>
            <string>console</string>
            <string>default</string>   /// change the name to 'test'
        </array>

        <key>RunAtLoad</key>
        <false/>
    </dict>
</plist>

to something like :

<plist version="1.0">
    <dict>
        <key>Disabled</key>
        <false/>

        <key>Label</key>
        <string>org.apache.directory.server.test</string>   /// test

        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/apacheds-2.0.0-M20-SNAPSHOT/bin/apacheds</string>
            <string>console</string>
            <string>test</string>   /// test
        </array>

        <key>RunAtLoad</key>
        <false/>
    </dict>
</plist>

then load the daemon :

$ sudo launchctl /Library/LaunchDaemons/org.apache.directory.server.test.plist

and start it :

$ sudo launchctl start org.apache.directory.server.test

When the newly created instance will be created, the partitions will be created.

Starting the server

As we can have more than one instance, we have more than one instance in /usr/local/apacheds<version>/<instances> that can be installed. Each one of these instance can be started using the launchctl command applied on each loaded instance (which has a different name). Here, we will start the server which instances is the one we just defined, ie ‘test’ :

$ sudo launchctl start org.apache.directory.server.test

The default instance name is org.apache.directory.server, to start it just type :

$ sudo launchctl start org.apache.directory.server.

All the data for a given instance are stored into this /usr/local/apacheds-<version>/instances/<instance-name> directory.

Stopping the server

Stopping the server is done using the same command, with a different parameter :

$ sudo launchctl stop org.apache.directory.server.test

Again, you must provide the instance name

Logs

You can check what’s going on in the apacheds-<version>instances/<instance-name>/log/wrapper.log file, and apacheds-<version>instances/<instance-name>/log/apacheds.log file which is created using the configuration set in apacheds-<version>instances/<instance-name>/conf/log4j.properties.

Typically, when you start the server, you will get such log :

$ more wrapper.log
STATUS | wrapper  | 2015/01/04 07:26:14 | --> Wrapper Started as Console
STATUS | wrapper  | 2015/01/04 07:26:15 | Launching a JVM...
INFO   | jvm 1    | 2015/01/04 07:26:15 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
INFO   | jvm 1    | 2015/01/04 07:26:15 |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
INFO   | jvm 1    | 2015/01/04 07:26:15 | 
INFO   | jvm 1    | 2015/01/04 07:26:18 |            _                     _          ____  ____   
INFO   | jvm 1    | 2015/01/04 07:26:18 |           / \   _ __    ___  ___| |__   ___|  _ \/ ___|  
INFO   | jvm 1    | 2015/01/04 07:26:18 |          / _ \ | '_ \ / _` |/ __| '_ \ / _ \ | | \___ \  
INFO   | jvm 1    | 2015/01/04 07:26:18 |         / ___ \| |_) | (_| | (__| | | |  __/ |_| |___) | 
INFO   | jvm 1    | 2015/01/04 07:26:18 |        /_/   \_\ .__/ \__,_|\___|_| |_|\___|____/|____/  
INFO   | jvm 1    | 2015/01/04 07:26:18 |                |_|                                       
INFO   | jvm 1    | 2015/01/04 07:26:18 | 

Log configuration

You can configure the log level and content by changing the content of the /var/lib/apacheds-<version>/<instance>/<conf>/log4j.properties file.

The default configuration is given below :

log4j.rootCategory=WARN, R, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${apacheds.log.dir}/apacheds.log

log4j.appender.R.MaxFileSize=1024KB
# Keep some backup files
log4j.appender.R.MaxBackupIndex=5

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n

log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n

# with these we'll not get innundated when switching to DEBUG
log4j.logger.jdbm.recman.BaseRecordManager=FATAL
log4j.logger.org.apache.directory.server.OPERATION_LOG=FATAL
log4j.logger.org.apache.directory.server.OPERATION_TIME=FATAL
log4j.logger.org.apache.directory.api.CODEC_LOG=FATAL
log4j.logger.org.apache.directory.server.ACI_LOG=FATAL

# Replication logs
log4j.logger.org.apache.directory.server.PROVIDER_LOG=FATAL
log4j.logger.org.apache.directory.server.CONSUMER_LOG=FATAL

# Search log
log4j.logger.org.apache.directory.CURSOR_LOG=FATAL

# Other logs
log4j.logger.org.apache.directory.api=FATAL
log4j.logger.org.apache.directory.server=FATAL
log4j.logger.net.sf.ehcache=FATAL
log4j.logger.org.apache.mina=FATAL

JVM setting

Were you to change the memory you want to use for a given instance, you will have to modify the /usr/local/apacheds-<version>/<instances>/<conf>/wrapper-instance.conf file. Here are the parameter you can configure in this file :

##
## In this file you can override parameters specified in the default
## Apache Directory Server config file which is usually at
## /opt/apacheds-2.0.0-M20-SNAPSHOT/conf/wrapper.conf
##
## See also http://wrapper.tanukisoftware.org/doc/english/properties.html
## For a list of properties that can be set.
##

## Override the JRE used
# wrapper.java.command=<path-to-java-executable>

## Override the JVM memory settings
## Initial Java Heap Size (in MB)
# wrapper.java.initmemory=1024

## Maximum Java Heap Size (in MB)
# wrapper.java.maxmemory=2048

You mainly want to change the memory used by the JVM.