Showing posts with label messaging. Show all posts
Showing posts with label messaging. Show all posts

Thursday, 9 December 2010

Configure Ejabberd chat server to use PostgreSQL ODBC

In order to make data persistent with in any application you can link it to a PostgreSQL relational database.
As default Ejabberd messaging server uses it's internal Mnesia database.

1. To change the default to use a postgres database we first need to create a new postgresql database on the server (this assumes you have PgSQL installed and configured)


run ./createdb ejabberd

2. Create the tables using the supplied script

./psql ejabberd < /opt/ejabberd-2.1.5/lib/ejabberd-2.1.5/priv/odbc/pg.sql

3. Add a user for the database

./createuser ejabberd

4. Configure ODBC options in ejabberd.cfg:

Scroll down to the section headed Database setup.

edit the following, remove the %% commenting


{odbc_server, {pgsql, "127.0.0.1", "ejabberd", "ejabberd", "yourpassword"}}.
5. Add _odbc to modules you wish to use the odbc database

e.g. mod_offline_odbc instead of mod_offline.

full list in ejabberd user guide

6. Under authentication comment out internal authentication :

%%{auth_method, internal}.

Then un comment {auth_method, odbc}.

7. Register a new user and appear online using PSI client or similar application

8. Add a user to allowed admin access control list in ejabberd.cfg


{acl, admin, {user, "username", "server"}}.

9. Confirm registered user and status in web admin:


http://serverIP:5280/admin/

10. Connect to database using PgAdmin to view tables with data and confirm ejabberd is now using PostgreSQL

Saturday, 4 December 2010

Using PSI chat client to access Ejabberd Chat messaging server

PSI is one of many jabber/XMPP clients available across the net. You can use these type of clients to test connectivity to or use functions available on most instant messaging server instances; in this case ejabberd.

1. Firstly ensure ejabberd is running on the server and there is a user account you can log in with.

use ./ejabberdctl [start/stop/status] to view status or start instance

use ./ejabberdctl register username password to register a new user


2. Install PSI from source or package

Cross platform support available from http://psi-im.org/download/

3. Launch PSI, add a new account, ensuring you fill in the following fields:

jabber id - this is the account you create on the ejabberd server.
password - corresponding password with above account

under connection settings:
specify server IP address or host name, ensuring you complete the port number; usually 5222

4. Save all settings and view the account in PSI application.
Change status to online.

5. Test chat to another user using same method of setup above, or log into web admin page of ejabberd server at http://SERVERIP:5280/admin to confirm successfully connectivity.

Installing Ejabberd Chat Messaging Server on Linux

Ejabberd is instant messaging server software that can be incorporated into any environment. Basic installation instructions for Unix / Linux are as follows:

1. Install Erlang:

sudo apt-get install erlang.

or from source,

Ensure all requirements are installed, Libncurses and OpenSS. Use apt-get for these.

Erlang:

wget http://www.erlang.org/download/otp_src_R14B.tar.gz
tar -xzvf otp_src_R14B.tar.gz
cd otp_src_R14B.tar.gz
LANG=C; export LANG 

./configure
make
make install 

Verify installation, type erl 
The following should be displayed:  

Erlang R14B (erts-5.8) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]

Eshell V5.8  (abort with ^G)
1>
 

2.  Install Ejabberd:

debian package: 
apt-get install ejabberd

binary installer:

wget http://www.process-one.net/downloads/ejabberd/2.1.6/ejabberd-2.1.6-linux-x86_64-installer.bin.gz

gunzip ejabberd-2.1.6-linux-x86_64-installer.bin.gz
chmod a+x ejabberd-2.1.6-linux-x86_64-installer.bin.gz
./ejabberd-2.1.6-linux-x86_64-installer.bin 


Accept all default options, installation complete



or from source:

wget http://www.process-one.net/downloads/ejabberd/2.1.5/ejabberd-2.1.5.tar.gz
tar -xzvf ejabberd-2.1.5.tar.gz
cd ejabberd-2.1.5/src
./configure
make
make install

/bin/ejabberd.cfg to specify settings




Use ejabberdctl start to start node instance.

Browse to http://localhost:5280/admin/ for server web admin, you will need to add exception for user admin to browse to web admin page.

Enter the following in /bin/ejabberd.cfg:

{acl, admin, {user, "admin_user", "your_sever"}}.


N.B ejabberd uses an internal Mnesia database by default. But it possible to an alternative relational database or LDAP server to ensure data is persistent.

In later posts I will discuss using a PostgreSQL database to store data for various applications such as ejabberd.

Refer to Ejabberd installation and operation guide