Activemq is an open-source project of apache. In fact, it is easy to use. After decompression, it is OK to start directly. One of the depressing ones is that activemq needs to use mysql to record messages. It took several days to solve the simple problem. Many articles on the Internet are also deployed in windows, and I am all in linux. After reading the online articles during the installation process, many problems were not solved, but they were solved by checking the apache pache library. Record here to pave the way for children's shoes with such requirements.
-------------------------------- Start ---------------------------------------------
1. Software preparation
Operating System: CentOS5.5 32bit
Activemq5.5.0: apachefound the apache-activemqproject download. I downloaded the tar.gz package.
Mysql: If you don't want to talk about it, you can compile it or use rpm to install it.
Mysql JDBC driver: mysql-connector-java-5.1.17.jar
2. Installation
1) install activemq5
# Tar zxvf apache-activemq-5.5.0-bin.tar.gz
# Music apache-activemq-5.5.0/usr/local/activemq
2) modify the activemq configuration file
Modify $ {activemq_home}/conf/activemq. xml
Find <broker> </broker> and add schedulerSupport = "true" to <broker>, as shown below:
<Broker xmlns = "http://activemq.apache.org/schema/core" brokerName = "192.168.64.132" destroyApplicationContextOnStop = "true" schedulerSupport = "true">
Comment out the default <persistenceAdapter> and add the following settings:
<PersistenceAdapter>
<JdbcPersistenceAdapter dataSource = "# mysql-ds" useDatabaseLock = "false"/>
</PersistenceAdapter>
<Broker> Configure the data source outside the tag. The following is the configuration information of MySql. Note: When activemq and mysql are installed on a server, when activemq is started and the connection is rejected or the password is incorrect, change localhost to an IP address.
<Bean id = "mysql-ds" class = "org. apache. commons. dbcp. BasicDataSource" destroy-method = "close">
<Property name = "driverClassName" value = "com. mysql. jdbc. Driver"/>
<Property name = "url" value = "jdbc: mysql: // localhost/activemq? RelaxAutoCommit = true "/>
<Property name = "username" value = "root"/>
<Property name = "password" value = "root"/>
<Property name = "poolPreparedStatements" value = "true"/>
</Bean>
3) manually create the mysql database activemq
Mysql> create database activemq;
4) JDBC
Mysql JDBC driver package mysql-connector-java-5.1.17.jar put $ {ACTIVEMQ_HOME}/lib/
3. Start
# $ {ACTIVEMQ_HOME}/bin/activemq console
The main reason for this is to check whether an error occurs during activemq startup in real time.
4. Problems:
1)
Error:
INFO | Database lock driver override not found for: [mysql-ab_jdbc_driver]. Will use default implementation.
INFO | Attempting to acquire the exclusive lock to become the Master broker
INFO | Failed to acquire lock. Sleeping for 1000 milli (s) before trying again...
INFO | Failed to acquire lock. Sleeping for 1000 milli (s) before trying again...
INFO | Failed to acquire lock. Sleeping for 1000 milli (s) before trying again...
INFO | Failed to acquire lock. Sleeping for 1000 milli (s) before trying again...
INFO | Failed to acquire lock. Sleeping for 1000 milli (s) before trying again...
Solution:
Add useDatabaseLock = "false" to persistenceAdapter"
<PersistenceAdapter>
<JdbcPersistenceAdapter dataSource = "# mysql-ds" useDatabaseLock = "false"/>
</PersistenceAdapter>
2)
Error:
Failure Details: Binary logging not possible.
Solution:
Modify my. cnf and open the following lines.
Log-bin = mysql-bin
Binlog_format = mixed
---------------------------------------- End ----------------------------------------------------
Finish writing and close the job.
This article is from the "objective> Linux" blog