Once there is confidence that the MBean will function on the platform, deploying the MBean inside of a standard JMX Agent is the next step. Included are instructions for deploying to JBoss.
Ensure a current version of java development kit (v1.4.x), see above.
Ensure JAVA_HOME
is set (JBoss
requires JAVA_HOME
)
Ensure JAVA_HOME/bin
is in the
PATH
(You will NOT need to set your
CLASSPATH, nor will you need any of the jars used in the
previous tests).
Ensure a current version of JBoss (v4.0RC1 or better)
http://www.jboss.org/index.html select "Downloads" select "jboss-4.0.zip" pick a mirror unzip ~/dload/jboss-4.0.zip create a JBOSS_HOME environment variable set to the unzipped directory unix only: cd $JBOSS_HOME/bin chmod +x *.sh
Deploy (copy) the connector-mxj.jar
to
$JBOSS_HOME/server/default/lib
.
Deploy (copy)
mysql-connector-java-3.1.4-beta-bin.jar
to $JBOSS_HOME/server/default/lib
.
Create a mxjtest.war
directory in
$JBOSS_HOME/server/default/deploy
.
Deploy (copy) index.jsp
to
$JBOSS_HOME/server/default/deploy/mxjtest.war
.
Create a mysqld-service.xml
file in
$JBOSS_HOME/server/default/deploy
.
<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.mysql.management.jmx.jboss.JBossMysqldDynamicMBean" name="mysql:type=service,name=mysqld"> <attribute name="datadir">/tmp/xxx_data_xxx</attribute> <attribute name="autostart">true</attribute> </mbean> </server>
Start jboss:
on unix: $JBOSS_HOME/bin/run.sh
on windows: %JBOSS_HOME%\bin\run.bat
Be ready: JBoss sends a lot of output to the screen.
When JBoss seems to have stopped sending output to the
screen, open a web browser to:
http://localhost:8080/jmx-console
Scroll down to the bottom of the page in the
mysql
section, select the bulleted
mysqld
link.
Observe the JMX MBean View page. MySQL should already be running.
(If "autostart=true" was set, you may skip this step.)
Scroll to the bottom of the screen. You may press the
Invoke button to stop (or start)
MySQL observe Operation completed successfully
without a return value.
Click Back to
MBean View
To confirm MySQL is running, open a web browser to
http://localhost:8080/mxjtest/
and you
should see that
SELECT 1
returned with a result of
1
Guided by the
$JBOSS_HOME/server/default/deploy/mxjtest.war/index.jsp
you will be able to use MySQL in your Web Application. There
is a test
database and a
root
user (no password) ready to
experiment with. Try creating a table, inserting some rows,
and doing some selects.
Shut down MySQL. MySQL will be stopped automatically when
JBoss is stopped, or: from the browser, scroll down to the
bottom of the MBean View press the stop service
Invoke button to halt the service.
Observe Operation completed successfully without a
return value.
Using ps
or
task manager
see that MySQL is no longer
running
As of 1.0.6-beta version is the ability to have the MBean start the MySQL database upon start up. Also, we've taken advantage of the JBoss life-cycle extension methods so that the database will gracefully shut down when JBoss is shutdown.
Ésta es una traducción del manual de referencia de MySQL, que puede encontrarse en dev.mysql.com. El manual de referencia original de MySQL está escrito en inglés, y esta traducción no necesariamente está tan actualizada como la versión original. Para cualquier sugerencia sobre la traducción y para señalar errores de cualquier tipo, no dude en dirigirse a mysql-es@vespito.com.