Saturday, January 7, 2017

Active MQ 5.14.3 Setup on Centos 7

Active MQ 5.14.3 Setup
-----------------------
Required Java installation --- Check Java installation


1. cd /opt
2. download/ftp  apache-activemq-5.14.3-bin.tar.gz
3. sudo chown -R root:root apache-activemq-5.14.3-bin.tar.gz
4.  sudo tar xzf apache-activemq-5.14.3-bin.tar.gz
5. sudo ln -sf /opt/apache-activemq-5.14.3/ /opt/activemq
6. sudo useradd activemq && passwd activemq
7. usermod -aG wheel activemq
8. sudo chown -R activemq: /opt/apache-activemq-5.14.3/
9. sudo chown -R activemq: /opt/activemq
10. sudo vi activemq/conf/activemq.xml

Comment Out :
------------------------
 <!-- <kahaDB directory="${activemq.data}/kahadb"/> -->
          <jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#mysql-ds"/>


Add DataSource:
-------------------------------
        <bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
                <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://dbhost.xxxxx.com/activemq?relaxAutoCommit=true"/>
                <property name="username" value="xxxxxxx"/>
                <property name="password" value="xxxxxxx"/>
                <property name="poolPreparedStatements" value="true"/>
        </bean>


 

11.sudo vi /etc/init.d/activemq

#!/bin/bash
#
# activemq     Starts ActiveMQ.
#
# chkconfig: 345 88 12
# description: ActiveMQ is a JMS Messaging Queue Server.
### BEGIN INIT INFO
# Provides: $activemq
### END INIT INFO

# Source function library.
. /etc/init.d/functions

# Set JDK related environment
JAVA_HOME=/opt/jdk1.8.0_111/jre
PATH=$PATH:$JAVA_HOME/bin

# Set Mule related environment
ACTIVEMQ_HOME=/opt/activemq
PATH=$PATH:$ACTIVEMQ_HOME/bin

RETVAL=0

umask 077

# Export environment variables
export JAVA_HOME ACTIVEMQ_HOME PATH

start() {
       echo -n $"Starting ActiveMQ: "
       daemon /opt/activemq/bin/activemq start
       echo
       return $RETVAL
}
stop() {
       echo -n $"Shutting down ActiveMQ: "
       su -c "/opt/activemq/bin/activemq stop"
       echo
       return $RETVAL
}
restart() {
       stop
       start
}
case "$1" in
start)
       start
       ;;
stop)
       stop
       ;;
status)
       /opt/activemq/bin/activemq status
       ;;
restart|reload)
       restart
       ;;
*)
       echo $"Usage: $0 {start|stop|restart}"
       exit 1
esac

exit $?


13. sudo chmod +x /etc/init.d/activemq
14.  ls -al /etc/init.d/activemq


15. copy mysql adapter to activemq
sudo scp -r user@xxx.com:/opt/activemq/lib/optional/mysql-connector-java-5.1.22-bin.jar /opt/activemq/lib/optional/

16. sudo chown activemq:activemq mysql-connector-java-5.1.22-bin.jar


17.sudo service activemq start
   sudo service activemq stop
   sudo service activemq status

Set up ActiveMQ to start after reboots 

----------------------------------------------------
  sudo chkconfig --add activemq
  sudo chkconfig activemq on


Firewall  Changes
---------------------------------
1. Check the firewall status

sudo systemctl status firewalld
and
sudo firewall-cmd --state
 
if not running 
 
sudo systemctl start firewalld
sudo systemctl enable firewalld 

REBOOT if required 
 
Open the Ports for Active MQ
---------------------------------
$ sudo firewall-cmd --zone=public --add-port=8161/tcp --permanent

$ sudo firewall-cmd --reload

$ sudo firewall-cmd --list-all 


$ sudo firewall-cmd --zone=public --add-port=61616/tcp --permanent

$ sudo firewall-cmd --reload

$ sudo firewall-cmd --list-all  


Check on
http://xxxxxx.com:8161/   with password


1 comment:

  1. For Postgresql
    -------------------------
    1. Get the postgresql driver(postgresql-42.2.8) file and copy it to /opt/activemq/lib/optional
    2. change the owner to active MQ
    sudo chown -R activemq: postgresql-42.2.8.jar

    3. Change the activemq.xml file with








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









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


    4. start the active mq and check with database

    su - postgres
    Password:
    -bash-4.1$ psql
    # connect to activemq schema
    postgres=# \c activemq
    # check tables
    activemq=# \dt
    List of relations
    Schema | Name | Type | Owner
    --------+---------------+-------+----------
    public | activemq_acks | table | activemq
    public | activemq_lock | table | activemq
    public | activemq_msgs | table | activemq
    (3 rows)
    # run select query.
    activemq=# select * from activemq_lock;
    id | time | broker_name
    ----+---------------+--------------
    1 | 1506947282760 | localhost

    ReplyDelete