Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of redis, activemq and activemq Database tuning in tomcat

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Download the installation package redis-3.2.2.tar.gz, decompress it, and compile the source code after decompression

[root@localhost soft] # tar-zxvf redis-3.2.2.tar.gz

[root@localhost soft] # cd redis-3.2.2

[root@localhost redis-3.2.2] # make

Prompt after compilation is completed

Make [1]: Leaving directory `/ soft/redis-3.2.2/src'

two。 After the compilation is complete, there are four executable files in the src directory, redis-server,

[root@localhost redis-3.2.2] # mkdir / usr/local/redis

[root@localhost redis-3.2.2] # cp redis.conf / usr/local/redis/

[root@localhost redis-3.2.2] # cd src/

[root@localhost src] # cp redis-server / usr/local/redis/

[root@localhost src] # cp redis-benchmark / usr/local/redis/

[root@localhost src] # cp redis-cli / usr/local/redis/

[root@localhost src] # cd / usr/local/redis/

[root@localhost redis] # ls

Redis-benchmark # redis performance testing tool

Redis-cli # redis Command Line Operation tool

Redis.conf redis profile

Daemon launcher for redis-server # server

3. Modify the configuration file

[root@localhost redis] # vi redis.conf

61 # bind 127.0.0.1 comment this line. The default is to run to access yourself.

128 daemonize yes defaults to no and changes to yes. It cannot be run as a daemon by default.

480 requirepass 123456 does not have a password to open redis by default. Set the password for redis to 123456

4.redis Startup Service

/ usr/local/redis/redis-server / usr/local/redis/redis.conf configuration file has been rewritten as a daemon

[root@fanxiaohui redis] # ps-elf | grep redis

5 S root 6524 10 800-33383 ep_pol 00:06? 00:00:00 / usr/local/redis/redis-server *: 6379

0 S root 6528 3187 0 800-25814 pipe_w 00:06 pts/1 00:00:00 grep redis

5. The client tests whether the startup is successful. After the authentication function is enabled, the redis test method must specify the server IP address, port and password.

[root@fanxiaohui redis] # redis-cli-h 127.0.0.1-p 6379-a 123456

127.0.0.1 purl 6379 > set foo bar

OK

127.0.0.1 purl 6379 > get foo

"bar"

127.0.0.1purl 6379 >

You can see that the selected value indicates success.

Deployment and installation in activemq Linux

1. Download the installation package apache-activemq-5.14.1-bin.tar.gz, decompress it, and compile the source code after decompression

[root@fanxiaohui soft] # tar-zxvf apache-activemq-5.14.1-bin.tar.gz

[root@fanxiaohui soft] # mv apache-activemq-5.14.1 / usr/local/apache-activemq

[root@fanxiaohui soft] # cd / usr/local/apache-activemq/bin/

two。 Start the activemq service

/ usr/local/activemq/bin/activemq start

3. Check to see if the port has a running program

[root@localhost bin] # netstat-anpult | grep 61616

Tcp 0 0: 61616: * LISTEN

3576/java

4. Add enable self-startup after completion

[root@localhost bin] # cat / etc/rc.local

#! / bin/sh

#

# This script will be executed * after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

Touch / var/lock/subsys/local

/ usr/local/activemq/bin/activemq start

5.apache-activemq tuning configuration

Persistence

ActiveMQ supports persistence, you can save received messages to the database, and even if ActiveMQ is restarted, you can still send messages that have not yet been sent.

ActiveMQ's persistence mechanism, for messages of type Queue, is stored in Broker, but is deleted as soon as one of the consumers completes the consumption.

For messages of type Topic, even if all subscribers finish consuming, Broker does not necessarily delete the useless message immediately, but retains the push history, and then clears the useless message asynchronously.

The offset of which message each subscriber consumes is recorded in Broker to avoid repeated consumption next time. Because messages are consumed sequentially, first-in, first-out, you only need to record where the last message was consumed.

The way to configure persistence is to modify the% ACTIVEMQ_HOME%conf/acticvemq.xml file.

one. Persist to a file

This is the default when you install ActiveMQ, as long as you set the message to be persistent. The configuration and code involved are

two。 Persist to mysql

[root@fanxiaohui lib] # cd / usr/local/apache-activemq/lib

[root@fanxiaohui soft] # mv mysql-connector-java-5.1.34.jar / usr/local/apache-activemq/lib/

You first need to put the MySql driver in ActiveMQ's Lib directory, such as mysql-connector-Java-5.1.34.jar.

[root@fanxiaohui soft] # cd / usr/local/apache-activemq/conf/

[root@fanxiaohui conf] # vi activemq.xml

eighty-five

eighty-six

eighty-seven

..

..

one hundred and thirty three

134valid java class name of the JDBC driver used

135 # URL passed to the JDBC driver for establishing a connection

136 # user name passed to the JDBC driver to establish a connection

137 # password passed to the JDBC driver to establish a connection

138 # enable prepared statement Pool function of Pool

139 # maximum active connections: the maximum number of active connections that can be allocated by the connection pool at the same time. If set to a non-positive number, there is no limit.

140 # maximum idle connections: the maximum number of connections allowed to remain idle in the connection pool. Excess idle connections will be released. If set to negative number, there is no limit.

141 # small idle connections: the minimum number of connections allowed to remain idle in the connection pool. A negative number indicates that there is no present.

142 # initialization connections: the number of initialization connections created when the connection pool starts

143 # maximum wait time: when no connection is available, the maximum time the connection pool waits for the connection to be returned (in milliseconds). If the time is exceeded, an exception is thrown. If set to-1, it means unlimited waiting.

144 # the time in milliseconds to sleep while the idle connection recycler thread is running. If set to a non-positive number, the idle connection collector thread is not run

145 # number of connections checked each time the idle connection recycler thread (if any) runs

146 # the minimum time, in milliseconds, for a connection to remain idle in the pool without being reclaimed by the idle connection collector thread (if any)

SQL query to validate connections taken from the connection pool before returning the connection to the caller. If specified, the query must be a SQL SELECT and must return at least one row of records

one hundred and forty eight

You can see from the configuration that the name of the database is activemq and the password is: activemq.123 you need to manually add this library to MySql.

Mysql >

Mysql > create database activemqdb

Mysql > grant all on activemqdb.* to "activemq" @ "" identified by "activemq.123"

The activemq service cannot be started until the database is configured.

[root@fanxiaohui conf] # / usr/local/apache-activemq/bin/activemq start

INFO: Loading'/ usr/local/apache-activemq//bin/env'

INFO: Using java' / usr/java/bin/java'

INFO: Starting-inspect logfiles specified in logging.properties and log4j.properties to get details

INFO: pidfile created:'/ usr/local/apache-activemq//data/activemq.pid' (pid' 4123')

[root@fanxiaohui conf] # ps-elf | grep activemq

S root 4123 1 40800-768127 futex_ 02:03 pts/0 00:00:04 / usr/java/bin/java-Xms64M-Xmx1G-Djava.util.logging.config.file=logging.properties-Djava.security.auth.login.config=/usr/local/apache-activemq//conf/login.config-Dcom.sun.management.jmxremote-Djava.awt.headless=true-Djava.io.tmpdir=/usr/local/apache-activemq//tmp-Dactivemq.classpath=/usr/local/apache-activemq//conf:/ Usr/local/apache-activemq//../lib/:-Dactivemq.home=/usr/local/apache-activemq/-Dactivemq.base=/usr/local/apache-activemq/-Dactivemq.conf=/usr/local/apache-activemq//conf-Dactivemq.data=/usr/local/apache-activemq//data-jar / usr/local/apache-activemq//bin/activemq.jar start

Three tables appear when you view the database again

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | activemqdb |

| | data |

| | fanxiaohui |

| | mysql |

| | performance_schema |

| | sys |

| | test |

+-+

8 rows in set (0.00 sec)

Mysql > use activemqdb

Database changed

Mysql > show tables

+-+

| | Tables_in_activemqdb |

+-+

| | ACTIVEMQ_ACKS |

| | ACTIVEMQ_LOCK |

| | ACTIVEMQ_MSGS |

+-+

3 rows in set (0.00 sec)

Activemq_acks is used to store subscription relationships. If TOPIC is persisted, the subscription relationship between subscribers and servers is stored in this table.

Activemq_msgs is used to store messages, and both Queue and Topic are stored in this table

6. test

After configuration, you can log in to the monitoring management page to see the queue situation.

Http://192.168.23.240:8161/admin

1. Add a user name and password and find jetty-realm.properties in the conf directory

Cd / usr/local/activemq/conf/

Vi jetty-realm.properties

18 # Defines users that can access the web (console, demo, etc.)

19 # username: password [, rolename...]

20 system: manager,admin add this line, administrator's account number and password

21 admin: admin, admin

22 user: user, user

~

two。 Modify the configuration jetty.xml file

Cd / usr/local/activemq/conf/

[root@fanxiaohui conf] # vi jetty.xml

forty-eight

forty-nine

fifty

fifty-one

fifty-two

fifty-three

fifty-four

fifty-five

fifty-six

fifty-seven

fifty-eight

fifty-nine

Delete the above lines

fifty-seven

fifty-eight

Add the above lines

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report