在高版本的ActiveMQ默认持久化到KaHaDB文件中。本片博文主要针对的是ActiveMQ持久化到Mysql和Oracle的步骤总结。
本片博文用的是mysql-connector-java-5.1.47.jar
下载的话可以去Maven仓库进行下载
[root@activemq software]# tar -zxvf apache-activemq-5.15.12-bin.tar.gz
[root@activemq lib]# pwd
/opt/software/apache-activemq-5.15.12/lib
[root@activemq lib]#
[root@activemq lib]# ll
total 5772
-rw-r--r--. 1 root root 1192281 Mar 13 18:24 activemq-broker-5.15.12.jar
-rw-r--r--. 1 root root 1432307 Mar 13 18:20 activemq-client-5.15.12.jar
-rw-r--r--. 1 root root 196156 Mar 13 18:32 activemq-console-5.15.12.jar
-rw-r--r--. 1 root root 38966 Mar 13 18:24 activemq-jaas-5.15.12.jar
-rw-r--r--. 1 root root 681026 Mar 13 18:26 activemq-kahadb-store-5.15.12.jar
-rw-r--r--. 1 root root 685740 Mar 13 18:22 activemq-openwire-legacy-5.15.12.jar
-rw-r--r--. 1 root root 147874 Aug 2 2018 activemq-protobuf-1.1.jar
-rw-r--r--. 1 root root 962 Mar 13 19:15 activemq-rar.txt
-rw-r--r--. 1 root root 170398 Mar 13 18:31 activemq-spring-5.15.12.jar
-rw-r--r--. 1 root root 137533 Mar 13 18:58 activemq-web-5.15.12.jar
drwxr-xr-x. 2 root root 128 May 31 10:17 camel
drwxr-xr-x. 2 root root 34 May 31 10:17 extra
-rw-r--r--. 1 root root 20220 Dec 27 2017 geronimo-j2ee-management_1.1_spec-1.0.1.jar
-rw-r--r--. 1 root root 32359 Dec 27 2017 geronimo-jms_1.1_spec-1.1.1.jar
-rw-r--r--. 1 root root 16030 Dec 27 2017 geronimo-jta_1.1_spec-1.1.1.jar
-rw-r--r--. 1 root root 50155 Dec 27 2017 hawtbuf-1.11.jar
-rw-r--r--. 1 root root 16515 Oct 17 2018 jcl-over-slf4j-1.7.25.jar
-rw-r--r--. 1 root root 1007502 May 31 10:18 mysql-connector-java-5.1.47.jar
drwxr-xr-x. 2 root root 4096 May 31 10:17 optional
-rw-r--r--. 1 root root 41203 Dec 29 2017 slf4j-api-1.7.25.jar
drwxr-xr-x. 2 root root 4096 May 31 10:17 web
[root@activemq conf]# pwd
/opt/software/apache-activemq-5.15.12/conf
[root@activemq conf]#
[root@activemq conf]# vim activemq.xml
CREATE TABLE `ACTIVEMQ_ACKS` (
`CONTAINER` VARCHAR(250) COLLATE latin1_bin NOT NULL,
`SUB_DEST` VARCHAR(250) COLLATE latin1_bin DEFAULT NULL,
`CLIENT_ID` VARCHAR(250) COLLATE latin1_bin NOT NULL,
`SUB_NAME` VARCHAR(250) COLLATE latin1_bin NOT NULL,
`SELECTOR` VARCHAR(250) COLLATE latin1_bin DEFAULT NULL,
`LAST_ACKED_ID` BIGINT(20) DEFAULT NULL,
`PRIORITY` BIGINT(20) NOT NULL DEFAULT '5',
`XID` VARCHAR(250) COLLATE latin1_bin DEFAULT NULL,
PRIMARY KEY (`CONTAINER`,`CLIENT_ID`,`SUB_NAME`,`PRIORITY`),
KEY `ACTIVEMQ_ACKS_XIDX` (`XID`)
);
CREATE TABLE `ACTIVEMQ_LOCK` (
`ID` BIGINT(20) NOT NULL,
`TIME` BIGINT(20) DEFAULT NULL,
`BROKER_NAME` VARCHAR(250) COLLATE latin1_bin DEFAULT NULL,
PRIMARY KEY (`ID`)
);
CREATE TABLE `ACTIVEMQ_MSGS` (
`ID` BIGINT(20) NOT NULL,
`CONTAINER` VARCHAR(250) COLLATE latin1_bin DEFAULT NULL,
`MSGID_PROD` VARCHAR(250) COLLATE latin1_bin DEFAULT NULL,
`MSGID_SEQ` BIGINT(20) DEFAULT NULL,
`EXPIRATION` BIGINT(20) DEFAULT NULL,
`MSG` LONGBLOB,
`PRIORITY` BIGINT(20) DEFAULT NULL,
`XID` VARCHAR(250) COLLATE latin1_bin DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `ACTIVEMQ_MSGS_MIDX` (`MSGID_PROD`,`MSGID_SEQ`),
KEY `ACTIVEMQ_MSGS_CIDX` (`CONTAINER`),
KEY `ACTIVEMQ_MSGS_EIDX` (`EXPIRATION`),
KEY `ACTIVEMQ_MSGS_PIDX` (`PRIORITY`),
KEY `ACTIVEMQ_MSGS_XIDX` (`XID`)
);
[root@activemq apache-activemq-5.15.12]# rpm -ivh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
Retrieving https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
warning: /var/tmp/rpm-tmp.KlBPPt: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-11 ################################# [100%]
[root@activemq apache-activemq-5.15.12]# yum search mysql-community
Loaded plugins: fastestmirror, langpacks
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql57-community | 2.5 kB 00:00:00
(1/3): mysql57-community/x86_64/primary_db | 213 kB 00:00:01
(2/3): mysql-tools-community/x86_64/primary_db | 72 kB 00:00:03
(3/3): mysql-connectors-community/x86_64/primary_db | 57 kB 00:00:06
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.bfsu.edu.cn
======================================================================================================= N/S matched: mysql-community =======================================================================================================
mysql-community-client.i686 : MySQL database client applications and tools
mysql-community-client.x86_64 : MySQL database client applications and tools
mysql-community-common.i686 : MySQL database common files for server and client libs
mysql-community-common.x86_64 : MySQL database common files for server and client libs
mysql-community-devel.i686 : Development header files and libraries for MySQL database client applications
mysql-community-devel.x86_64 : Development header files and libraries for MySQL database client applications
mysql-community-embedded.i686 : MySQL embedded library
mysql-community-embedded.x86_64 : MySQL embedded library
mysql-community-embedded-compat.i686 : MySQL embedded compat library
mysql-community-embedded-compat.x86_64 : MySQL embedded compat library
mysql-community-embedded-devel.i686 : Development header files and libraries for MySQL as an embeddable library
mysql-community-embedded-devel.x86_64 : Development header files and libraries for MySQL as an embeddable library
mysql-community-libs.i686 : Shared libraries for MySQL database client applications
mysql-community-libs.x86_64 : Shared libraries for MySQL database client applications
mysql-community-libs-compat.i686 : Shared compat libraries for MySQL 5.6.25 database client applications
mysql-community-libs-compat.x86_64 : Shared compat libraries for MySQL 5.6.45 database client applications
mysql-community-release.noarch : MySQL repository configuration for yum
mysql-community-server.x86_64 : A very fast and reliable SQL database server
mysql-community-test.x86_64 : Test suite for the MySQL database server
Name and summary matches only, use "search all" for everything.
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]# yum install mysql-community-client.x86_64 -y
Updating : 1:openssl-1.0.2k-19.el7.x86_64 7/11
Cleanup : 2:postfix-2.10.1-6.el7.x86_64 8/11
Erasing : 1:mariadb-libs-5.5.52-1.el7.x86_64 9/11
Cleanup : 1:openssl-1.0.1e-60.el7.x86_64 10/11
Cleanup : 1:openssl-libs-1.0.1e-60.el7.x86_64 11/11
Verifying : 2:postfix-2.10.1-9.el7.x86_64 1/11
Verifying : mysql-community-libs-5.7.30-1.el7.x86_64 2/11
Verifying : mysql-community-client-5.7.30-1.el7.x86_64 3/11
Verifying : mysql-community-libs-compat-5.7.30-1.el7.x86_64 4/11
Verifying : 1:openssl-1.0.2k-19.el7.x86_64 5/11
Verifying : mysql-community-common-5.7.30-1.el7.x86_64 6/11
Verifying : 1:openssl-libs-1.0.2k-19.el7.x86_64 7/11
Verifying : 1:openssl-libs-1.0.1e-60.el7.x86_64 8/11
Verifying : 1:mariadb-libs-5.5.52-1.el7.x86_64 9/11
Verifying : 2:postfix-2.10.1-6.el7.x86_64 10/11
Verifying : 1:openssl-1.0.1e-60.el7.x86_64 11/11
Installed:
mysql-community-client.x86_64 0:5.7.30-1.el7 mysql-community-libs.x86_64 0:5.7.30-1.el7 mysql-community-libs-compat.x86_64 0:5.7.30-1.el7
Dependency Installed:
mysql-community-common.x86_64 0:5.7.30-1.el7
Dependency Updated:
openssl.x86_64 1:1.0.2k-19.el7 openssl-libs.x86_64 1:1.0.2k-19.el7 postfix.x86_64 2:2.10.1-9.el7
Replaced:
mariadb-libs.x86_64 1:5.5.52-1.el7
Complete!
[root@activemq apache-activemq-5.15.12]#
## 这里报错,在mysql服务端执行SQL语句解决
## GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.31.150' IDENTIFIED BY 'root' WITH GRANT OPTION;
[root@activemq apache-activemq-5.15.12]# mysql -h 192.168.31.2 -uroot -p
Enter password:
ERROR 1130 (HY000): Host '192.168.31.150' is not allowed to connect to this MySQL server
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]# mysql -h 192.168.31.2 -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.5.47 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit;
Bye
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]# pwd
/opt/software/apache-activemq-5.15.12
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]# ./bin/activemq start
INFO: Loading '/opt/software/apache-activemq-5.15.12//bin/env'
INFO: Using java '/usr/local/software/jdk/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/opt/software/apache-activemq-5.15.12//data/activemq.pid' (pid '12882')
INFO: Loading '/opt/software/apache-activemq-5.15.12//bin/env'
INFO: Using java '/usr/local/software/jdk/bin/java'
ActiveMQ is running (pid '14115')
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]# ps -ef | grep activemq
root 14115 1 31 10:47 pts/0 00:00:04 /usr/local/software/jdk/bin/java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/opt/software/apache-activemq-5.15.12//conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/opt/software/apache-activemq-5.15.12//tmp -Dactivemq.classpath=/opt/software/apache-activemq-5.15.12//conf:/opt/software/apache-activemq-5.15.12//../lib/: -Dactivemq.home=/opt/software/apache-activemq-5.15.12/ -Dactivemq.base=/opt/software/apache-activemq-5.15.12/ -Dactivemq.conf=/opt/software/apache-activemq-5.15.12//conf -Dactivemq.data=/opt/software/apache-activemq-5.15.12//data -jar /opt/software/apache-activemq-5.15.12//bin/activemq.jar start
root 14203 2629 0 10:47 pts/0 00:00:00 grep --color=auto activemq
查看数据库,三张表也发现里面有对应的数据。
activemq_acks:用于存储订阅关系。如果是持久化Topic,订阅者和服务器的订阅关系在这个表保存
activemq_lock:在集群环境中才有用,只有一个Broker可以获得消息,称为Master Broker
activemq_msgs:用于存储消息,Queue和Topic都存储在这个表中
[root@activemq lib]# pwd
/opt/software/apache-activemq-5.15.12/lib
## commons-dbcp-1.4.jar commons-pool-1.4.jar ojdbc7.jar
[root@activemq lib]# ll
total 8356
-rw-r--r--. 1 root root 1192281 Mar 13 18:24 activemq-broker-5.15.12.jar
-rw-r--r--. 1 root root 1432307 Mar 13 18:20 activemq-client-5.15.12.jar
-rw-r--r--. 1 root root 196156 Mar 13 18:32 activemq-console-5.15.12.jar
-rw-r--r--. 1 root root 38966 Mar 13 18:24 activemq-jaas-5.15.12.jar
-rw-r--r--. 1 root root 681026 Mar 13 18:26 activemq-kahadb-store-5.15.12.jar
-rw-r--r--. 1 root root 685740 Mar 13 18:22 activemq-openwire-legacy-5.15.12.jar
-rw-r--r--. 1 root root 147874 Aug 2 2018 activemq-protobuf-1.1.jar
-rw-r--r--. 1 root root 962 Mar 13 19:15 activemq-rar.txt
-rw-r--r--. 1 root root 170398 Mar 13 18:31 activemq-spring-5.15.12.jar
-rw-r--r--. 1 root root 137533 Mar 13 18:58 activemq-web-5.15.12.jar
drwxr-xr-x. 2 root root 128 May 31 10:17 camel
-rw-r--r--. 1 root root 160519 May 31 10:59 commons-dbcp-1.4.jar
-rw-r--r--. 1 root root 87077 May 31 10:59 commons-pool-1.4.jar
drwxr-xr-x. 2 root root 34 May 31 10:17 extra
-rw-r--r--. 1 root root 20220 Dec 27 2017 geronimo-j2ee-management_1.1_spec-1.0.1.jar
-rw-r--r--. 1 root root 32359 Dec 27 2017 geronimo-jms_1.1_spec-1.1.1.jar
-rw-r--r--. 1 root root 16030 Dec 27 2017 geronimo-jta_1.1_spec-1.1.1.jar
-rw-r--r--. 1 root root 50155 Dec 27 2017 hawtbuf-1.11.jar
-rw-r--r--. 1 root root 16515 Oct 17 2018 jcl-over-slf4j-1.7.25.jar
-rw-r--r--. 1 root root 3397734 May 31 10:59 ojdbc7.jar
drwxr-xr-x. 2 root root 4096 May 31 10:17 optional
-rw-r--r--. 1 root root 41203 Dec 29 2017 slf4j-api-1.7.25.jar
drwxr-xr-x. 2 root root 4096 May 31 10:17 web
[root@activemq conf]# pwd
/opt/software/apache-activemq-5.15.12/conf
[root@activemq conf]# vim activemq.xml
进行如下的配置
oracle官网下载对应的client包
[root@activemq software]# pwd
/opt/software
[root@activemq software]# mkdir oracle
[root@activemq software]# cd oracle/
[root@activemq oracle]# ll
total 58192
-rw-r--r--. 1 root root 58793148 Jun 1 07:11 instantclient-basic-linux-11.2.0.4.0.zip
-rw-r--r--. 1 root root 792608 Jun 1 07:11 instantclient-sqlplus-linux-11.2.0.4.0.zip
[root@activemq oracle]#
[root@activemq oracle]#
[root@activemq oracle]#
[root@activemq oracle]#
[root@activemq oracle]# unzip instantclient-basic-linux-11.2.0.4.0.zip
Archive: instantclient-basic-linux-11.2.0.4.0.zip
inflating: instantclient_11_2/adrci
inflating: instantclient_11_2/BASIC_README
inflating: instantclient_11_2/genezi
inflating: instantclient_11_2/libclntsh.so.11.1
inflating: instantclient_11_2/libnnz11.so
inflating: instantclient_11_2/libocci.so.11.1
inflating: instantclient_11_2/libociei.so
inflating: instantclient_11_2/libocijdbc11.so
inflating: instantclient_11_2/ojdbc5.jar
inflating: instantclient_11_2/ojdbc6.jar
inflating: instantclient_11_2/uidrvci
inflating: instantclient_11_2/xstreams.jar
[root@activemq oracle]# unzip instantclient-
instantclient-basic-linux-11.2.0.4.0.zip instantclient-sqlplus-linux-11.2.0.4.0.zip
[root@activemq oracle]# unzip instantclient-sqlplus-linux-11.2.0.4.0.zip
Archive: instantclient-sqlplus-linux-11.2.0.4.0.zip
inflating: instantclient_11_2/glogin.sql
inflating: instantclient_11_2/libsqlplusic.so
inflating: instantclient_11_2/libsqlplus.so
inflating: instantclient_11_2/sqlplus
inflating: instantclient_11_2/SQLPLUS_README
[root@activemq oracle]# ll
total 58196
drwxr-xr-x. 2 root root 4096 Jun 1 07:12 instantclient_11_2
-rw-r--r--. 1 root root 58793148 Jun 1 07:11 instantclient-basic-linux-11.2.0.4.0.zip
-rw-r--r--. 1 root root 792608 Jun 1 07:11 instantclient-sqlplus-linux-11.2.0.4.0.zip
[root@activemq oracle]# mv instantclient_11_2/ /usr/local/oracle/
[root@activemq oracle]#
[root@activemq oracle]#
[root@activemq oracle]# cd /usr/local/oracle/
[root@activemq oracle]# chmod -Rf 777 instantclient_11_2/
[root@activemq oracle]# ll
total 4
drwxrwxrwx. 2 root root 4096 Jun 1 07:12 instantclient_11_2
[root@activemq oracle]#
# export ORACLE_HOME=/usr/local/oracle/instantclient_11_2
# export TNS_ADMIN=$ORACLE_HOME/network/admin
# #export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
# export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
# export LD_LIBRARY_PATH=$ORACLE_HOME
# export PATH=$ORACLE_HOME:$PATH
[root@activemq oracle]# vim ~/.bash_profile
[root@activemq oracle]# source ~/.bash_profile
[root@activemq oracle]# ll
total 4
drwxr-xr-x. 2 root root 4096 May 31 11:19 instantclient_11_2
[root@activemq instantclient_11_2]# pwd
/usr/local/oracle/instantclient_11_2
[root@activemq instantclient_11_2]#
[root@activemq instantclient_11_2]#
[root@activemq instantclient_11_2]# mkdir -p network/admin
[root@activemq instantclient_11_2]# ll
total 186444
-rwxrwxr-x. 1 root root 25420 Aug 25 2013 adrci
-rw-rw-r--. 1 root root 439 Aug 25 2013 BASIC_README
-rwxrwxr-x. 1 root root 47860 Aug 25 2013 genezi
-r-xr-xr-x. 1 root root 368 Aug 25 2013 glogin.sql
-rwxrwxr-x. 1 root root 53865194 Aug 25 2013 libclntsh.so.11.1
-r-xr-xr-x. 1 root root 7996693 Aug 25 2013 libnnz11.so
-rwxrwxr-x. 1 root root 1973074 Aug 25 2013 libocci.so.11.1
-rwxrwxr-x. 1 root root 118738042 Aug 25 2013 libociei.so
-r-xr-xr-x. 1 root root 164942 Aug 25 2013 libocijdbc11.so
-r-xr-xr-x. 1 root root 1502287 Aug 25 2013 libsqlplusic.so
-r-xr-xr-x. 1 root root 1469542 Aug 25 2013 libsqlplus.so
drwxr-xr-x. 3 root root 19 May 31 11:32 network
-r--r--r--. 1 root root 2091135 Aug 25 2013 ojdbc5.jar
-r--r--r--. 1 root root 2739616 Aug 25 2013 ojdbc6.jar
-r-xr-xr-x. 1 root root 9320 Aug 25 2013 sqlplus
-rw-rw-r--. 1 root root 443 Aug 25 2013 SQLPLUS_README
-rwxrwxr-x. 1 root root 192365 Aug 25 2013 uidrvci
-rw-rw-r--. 1 root root 66779 Aug 25 2013 xstreams.jar
[root@activemq instantclient_11_2]#
[root@activemq admin]# pwd
/usr/local/oracle/instantclient_11_2/network/admin
[root@activemq admin]# ll
total 4
-rw-r--r--. 1 root root 221 May 31 11:33 tnsnames.ora
[root@activemq admin]# cat tnsnames.ora
ORCL=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.31.2)
(PORT=1521)
)
(CONNECT_DATA=
(SERVER=dedicated)
(SERVICE_NAME=orcl)
)
)
[root@activemq instantclient_11_2]# ldd /usr/local/oracle/instantclient_11_2/sqlplus
linux-gate.so.1 => (0xf77da000)
libsqlplus.so => /usr/local/oracle/instantclient_11_2/libsqlplus.so (0xf772c000)
libclntsh.so.11.1 => /usr/local/oracle/instantclient_11_2/libclntsh.so.11.1 (0xf56a2000)
libnnz11.so => /usr/local/oracle/instantclient_11_2/libnnz11.so (0xf544e000)
libdl.so.2 => /lib/libdl.so.2 (0xf5436000)
libm.so.6 => /lib/libm.so.6 (0xf53f3000)
libpthread.so.0 => /lib/libpthread.so.0 (0xf53d8000)
libnsl.so.1 => /lib/libnsl.so.1 (0xf53bd000)
libc.so.6 => /lib/libc.so.6 (0xf51f2000)
/lib/ld-linux.so.2 (0xf77db000)
libaio.so.1 => not found
## 发现少包,找到对应的RPM包,手动安装即可
## 解决对应SQL中的方向键问题
[root@activemq instantclient_11_2]# yum install readline-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Package readline-devel-6.2-11.el7.x86_64 already installed and latest version
Nothing to do
[root@activemq instantclient_11_2]#
## 下载rlwrap
warning: rlwrap-0.42-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 9dbd524d: NOKEY
error: Failed dependencies:
perl(Data::Dumper) is needed by rlwrap-0.42-1.el7.x86_64
[root@activemq oracle]# yum install perl
[root@activemq oracle]# rpm -ivh rlwrap-0.42-1.el7.x86_64.rpm
warning: rlwrap-0.42-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 9dbd524d: NOKEY
error: Failed dependencies:
perl(Data::Dumper) is needed by rlwrap-0.42-1.el7.x86_64
[root@activemq oracle]# yum -y install autoconf
[root@activemq oracle]# rpm -ivh rlwrap-0.42-1.el7.x86_64.rpm
warning: rlwrap-0.42-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 9dbd524d: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:rlwrap-0.42-1.el7 ################################# [100%]
[root@activemq oracle]# vim ~/.bash_profile
[root@activemq oracle]#
# 追加以下内容
# alias sqlplus='rlwrap sqlplus'
# alias rman='rlwrap rman'
[root@activemq instantclient_11_2]# rlwrap sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Mon Jun 1 07:35:42 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SQL> exit;
## 完美解决问题
[root@activemq instantclient_11_2]#
## 下面是链接数据库,Linux链接win本地上的Oracle
## 需要修改本地Oracle的listener.ora的监听localhost改为0.0.0.0,然后重启监听服务OracleServiceORCL和OracleOraDb11g_home1TNSListener
[root@activemq admin]# rlwrap sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Mon Jun 1 07:44:06 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SQL> conn scott/tiger@ORCL;
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
SQL> conn scott/[email protected]:1521/orcl
ERROR:
ORA-21561: OID generation failed
SQL> conn CM_02/[email protected]:1521/orcl;
Connected.
SQL>
SQL> exit;
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[root@activemq admin]#
第三步经过测试已经可以链接上Windows本地上的Oracle服务,那么有个用户test_oracle,尝试用这个用户来测试持久化。
[root@activemq apache-activemq-5.15.12]# ./bin/activemq start
INFO: Loading '/opt/software/apache-activemq-5.15.12//bin/env'
INFO: Using java '/usr/local/software/jdk/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/opt/software/apache-activemq-5.15.12//data/activemq.pid' (pid '6683')
[root@activemq apache-activemq-5.15.12]#
[root@activemq apache-activemq-5.15.12]# ./bin/activemq status
INFO: Loading '/opt/software/apache-activemq-5.15.12//bin/env'
INFO: Using java '/usr/local/software/jdk/bin/java'
ActiveMQ is running (pid '6683')
启动后会在对应的Oracle库里面创建三张表,表结构如下:
CREATE TABLE "TEST_ORACLE"."ACTIVEMQ_ACKS" (
"CONTAINER" VARCHAR2(250 BYTE) NOT NULL ,
"SUB_DEST" VARCHAR2(250 BYTE) NULL ,
"CLIENT_ID" VARCHAR2(250 BYTE) NOT NULL ,
"SUB_NAME" VARCHAR2(250 BYTE) NOT NULL ,
"SELECTOR" VARCHAR2(250 BYTE) NULL ,
"LAST_ACKED_ID" NUMBER NULL ,
"PRIORITY" NUMBER DEFAULT 5 NOT NULL ,
"XID" VARCHAR2(250 BYTE) NULL
)
LOGGING
NOCOMPRESS
NOCACHE
;
CREATE TABLE "TEST_ORACLE"."ACTIVEMQ_LOCK" (
"ID" NUMBER NOT NULL ,
"TIME" NUMBER NULL ,
"BROKER_NAME" VARCHAR2(250 BYTE) NULL
)
LOGGING
NOCOMPRESS
NOCACHE
;
CREATE TABLE "TEST_ORACLE"."ACTIVEMQ_MSGS" (
"ID" NUMBER NOT NULL ,
"CONTAINER" VARCHAR2(250 BYTE) NOT NULL ,
"MSGID_PROD" VARCHAR2(250 BYTE) NULL ,
"MSGID_SEQ" NUMBER NULL ,
"EXPIRATION" NUMBER NULL ,
"MSG" BLOB NULL ,
"PRIORITY" NUMBER NULL ,
"XID" VARCHAR2(250 BYTE) NULL
)
LOGGING
NOCOMPRESS
NOCACHE
;
CREATE INDEX "TEST_ORACLE"."ACTIVEMQ_ACKS_XIDX"
ON "TEST_ORACLE"."ACTIVEMQ_ACKS" ("XID" ASC)
LOGGING
VISIBLE;
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_ACKS" ADD CHECK ("CONTAINER" IS NOT NULL);
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_ACKS" ADD CHECK ("CLIENT_ID" IS NOT NULL);
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_ACKS" ADD CHECK ("SUB_NAME" IS NOT NULL);
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_ACKS" ADD CHECK ("PRIORITY" IS NOT NULL);
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_ACKS" ADD PRIMARY KEY ("CONTAINER", "CLIENT_ID", "SUB_NAME", "PRIORITY");
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_LOCK" ADD CHECK ("ID" IS NOT NULL);
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_LOCK" ADD PRIMARY KEY ("ID");
CREATE INDEX "TEST_ORACLE"."ACTIVEMQ_MSGS_CIDX"
ON "TEST_ORACLE"."ACTIVEMQ_MSGS" ("CONTAINER" ASC)
LOGGING
VISIBLE;
CREATE INDEX "TEST_ORACLE"."ACTIVEMQ_MSGS_EIDX"
ON "TEST_ORACLE"."ACTIVEMQ_MSGS" ("EXPIRATION" ASC)
LOGGING
VISIBLE;
CREATE INDEX "TEST_ORACLE"."ACTIVEMQ_MSGS_IIDX"
ON "TEST_ORACLE"."ACTIVEMQ_MSGS" ("ID" ASC, "XID" ASC, "CONTAINER" ASC)
LOGGING
VISIBLE;
CREATE INDEX "TEST_ORACLE"."ACTIVEMQ_MSGS_MIDX"
ON "TEST_ORACLE"."ACTIVEMQ_MSGS" ("MSGID_PROD" ASC, "MSGID_SEQ" ASC)
LOGGING
VISIBLE;
CREATE INDEX "TEST_ORACLE"."ACTIVEMQ_MSGS_PIDX"
ON "TEST_ORACLE"."ACTIVEMQ_MSGS" ("PRIORITY" ASC)
LOGGING
VISIBLE;
CREATE INDEX "TEST_ORACLE"."ACTIVEMQ_MSGS_XIDX"
ON "TEST_ORACLE"."ACTIVEMQ_MSGS" ("XID" ASC)
LOGGING
VISIBLE;
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_MSGS" ADD CHECK ("ID" IS NOT NULL);
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_MSGS" ADD CHECK ("CONTAINER" IS NOT NULL);
ALTER TABLE "TEST_ORACLE"."ACTIVEMQ_MSGS" ADD PRIMARY KEY ("ID");