OpenDJ – replication

Create admin user in odj-1

./dsframework create-admin-user -X \
-h odj-1 -p 4444 -D "cn=Directory Manager" -w password \
--userID admin --set password:adminpassword

Create admin user in odj-2

./dsframework create-admin-user -X \
-h odj-2 -p 4444 -D "cn=Directory Manager" -w password \
--userID admin --set password:adminpassword

List admin user

$ ./dsframework list-admin-user -X \
Password for user 'cn=Directory Manager':
id: admin

Enable replication

./dsreplication enable --host1 odj-1 --port1 4444 \
 --bindDN1 "cn=directory manager" --bindPassword1 password \
 --replicationPort1 8989 --host2 odj-2 --port2 4444 \
 --bindDN2 "cn=directory manager" --bindPassword2 password \
 --replicationPort2 8989 --adminUID admin --adminPassword password \
 --baseDN "dc=example,dc=com" -X -n

Initialise replication

$ ./dsreplication initialize \
  --baseDN "dc=example,dc=com" \
  --adminUID admin --adminPassword password \
  --hostSource odj-1 --portSource 4444 \
  --hostDestination odj-2 --portDestination 4444 -X -n

Administer replication

$ ./dsreplication -X

OpenDJ-2.5.0-Xpress1 prerequisites

Install java 1.6

Add group opendj

$ groupadd opendj

Add user opendj

$ useradd -g opendj -d /home/opendj -m -s /bin/bash opendj

Download and unzip OpenDJ zip file

$ unzip -v [opendj-zip-file] -d /opt/.

Change owner

$ chown -R opendj:opendj /opt/opendj

View MySQL query log

http://dev.mysql.com/doc/refman/5.1/en/query-log.html

 

mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+-----------------------------+
| Variable_name    | Value                       |
+------------------+-----------------------------+
| general_log      | OFF                         |
| general_log_file | /var/lib/mysql/neqali50.log |
+------------------+-----------------------------+
2 rows in set (0.00 sec)

mysql> SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+-----------------------------+
| Variable_name    | Value                       |
+------------------+-----------------------------+
| general_log      | ON                          |
| general_log_file | /var/lib/mysql/neqali50.log |
+------------------+-----------------------------+
2 rows in set (0.00 sec)

mysql> SET GLOBAL general_log = 'OFF';
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+-----------------------------+
| Variable_name    | Value                       |
+------------------+-----------------------------+
| general_log      | OFF                         |
| general_log_file | /var/lib/mysql/neqali50.log |
+------------------+-----------------------------+
2 rows in set (0.00 sec)

mysql> exit

SASL authentication failed server smtp.gmail.com

Problem

After setting up smtp.gmail.com as relayhost for postfix I stumbled into problem when this showed up in /var/log/mail.log

SASL authentication failed; server smtp.gmail.com
https://accounts.google.com/ContinueSignIn
Please log in via your web browser and then try again.
Learn more at https://support.google.com/mail/bin/answer.py?answer=787

Solution

Allow access to your Google account via
https://accounts.google.com/DisplayUnlockCaptcha

Gmail SMTP server relay with Postfix in Ubuntu 12.04

Tribut to Diogo Esteves http://yaui.me/postfix-gmail-smtp-server-relay-ubuntu/

Prerequisites

$ sudo apt-get install postfix libsasl2-2 libsasl2-modules ca-certificates

Edit /etc/postfix/main.cf

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

Create file /etc/postfix/sasl_passwd

[smtp.gmail.com]:587 user.name@gmail.com:password
$ sudo chmod 400 /etc/postfix/sasl_passwd
$ sudo postmap /etc/postfix/sasl_passwd
$ cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem
$ sudo /etc/init.d/postfix reload

jinfo ”can’t attach to the process”

Tried to run jinfo on my Ubuntu 12.04 and got this error message:

$ ./jinfo <vmid>
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process

enabled debugging:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

and tried again:

$ ./jinfo <vmid>
Attaching to process ID <vmid>, please wait...
Debugger attached successfully.
Server compiler detected.
...
...
$ 

Solution found here:
http://blog.thecodingmachine.com/fr/content/fixing-java-memory-leaks-ubuntu-1104-using-jmap

OpenDJ – setup

Prereq is OpenDJ installed in /opt/opendj

$ sudo su - opendj
$ /opt/opendj/setup \
--cli \
--no-prompt \
--doNotStart \
--baseDN "dc=example,dc=com" \
--addBaseEntry \
--ldapPort 1389 \
--adminConnectorPort 4444 \
--enableStartTLS \
--ldapsPort 1636 \
--generateSelfSignedCertificate \
--acceptLicense \
--rootUserDN "cn=Directory Manager" \
--rootUserPassword [password] \
--hostname [hostname]

Start OpenDJ at boot

$ sudo /opt/opendj/bin/create-rc-script \
 --outputFile /etc/init.d/opendj \
 --userName opendj
$ sudo update-rc.d opendj defaults

OpenDJ – import ldif offline

$ /opt/opendj/bin/stop-ds
$ /opt/opendj/bin/import-ldif \
--append \
--includeBranch "dc=example,dc=com" \
--excludeBranch "cn=log,dc=example,dc=com" \
--ldifFile /tmp/export.ldif \
--rejectFile /tmp/rejectimport.ldif \
--skipFile /tmp/skipimport.ldif

OpenDJ – export ldif

Export ldif without operational attributes (switch -O)

$ /opt/opendj/bin/export-ldif \
--excludeOperational \
--includeBranch "dc=example,dc=com" \
--excludeBranch "o=Test,dc=example,dc=com" \
--backendID userRoot \
--ldifFile /tmp/export.ldif