JBoss is a RedHat Linux system service.

Source: Internet
Author: User

How to startLinuxWhen JBoss is started?
 
Use the V script of Linux. Although there are some differences between categories, it is usually similar to this:
 
/Etc/rc. d/init. d/-contains the start and stop scripts (other types:/etc/init. d /)
 

/Etc/rc. (x)/-contains the link for starting and stopping the script with the S or K prefix (start or kill)
 
Users of different levels have different operation levels.
 
Rc1.d-Single User Mode
 
Rc2.d-Enable single-user network mode
 
Rc3.d-multi-user mode-start in text mode
 
Rc4.d-undefined
 
Rc5.d-multi-user mode-start with X Window
 
Rc6.d-Disable
 
Now we start to work:
 
Create a JBoss user and install JBoss.
 
Create a script named/etc/rc. d/init. d/JBoss
 
Create a link named/etc/rc3.d/s84jboss
 
Optional methods:/etc/rc5.d/s84jboss and/etc/rc4.d/s84jboss
 
Create a link named/etc/rc6.d/k15jboss
 
Create a k15 link on/etc/rc1.d,/etc/rc2.d,/etc/rc0.d
 
Note that the $ jboss_home directory can be read and written by "JBoss" users. If you have any questions, click to view the JBoss application.ServerRecommendationUNIXFile System license.
 
Create script JBoss:
 
JBoss 4.0.1 +, with prebaked init script, jboss_init_redhat.sh and jboss_init_suse.sh in the bin directory. you can copy one of these scripts to/etc/rc. d/init. d/JBoss. Because I use RedHat, copy jboss_init_redhat.sh and modify it to executable.
 
[Root @ VM2 ~] # CP $ jboss_home/bin/jboss_init_redhat.sh/etc/rc. d/init. d/JBoss
 
[Root @ VM2 ~] # Chmod 755/etc/rc. d/init. d/JBoss
 
$ Jboss_home cannot be written in this way during your operations. It represents the directory installed on your JBoss, and you need to replace it.
 
Edit it in the VI Editor:
 
  

#! /Bin/sh
#
# $ ID: jboss_init_redhat.sh 46554 10: 29: 13z Dimitris $
#
# JBoss control script
#
# To use this script run it as root-it willSwitchTo the specified user
#
# Here is a little (and extremely primitive) Startup/shutdown script
# For RedHat systems. It assumes that JBoss lives in/usr/local/JBoss,
# It's run by user 'jbos' and JDK binaries are in/usr/local/JDK/bin.
# All this can be changed in the script itself.
#
# Either modify this script for your requirements or just ensure that
# The following variables are set correctly before calling the script.

# Change to the installation directory of your local JBoss
Jboss_home =$ {jboss_home:-"/home/JBoss/jboss-4.0.5.GA "}

# Change to your new JBoss user
Jboss_user =$ {jboss_user:-"JBoss "}

# Change to localJavaPath
Javapth =$ {javapth:-"/home/JBoss/jdk1.5.0 _ 14/bin "}

# StartedConfigurationParameter, which has three values: 'decimal', 'default', and 'all'. All is configured in cluster mode.
Jboss_conf =$ {jboss_conf:-"default "}

# Bind all network adapters. If you bind one, write yourIP address. It is used only when jboss4.2.0 + is used externally.
# Jboss_host =$ {jboss_host:-"0.0.0.0 "}

# The script is disabled by default. It seems that it is not easy to use and I will not use it.
# Jbosp_=$ {jbosp_:-"$ jboss_home/bin/shutdown. jar: $ jboss_home/client/jnet. Jar "}

# Disable the script when binding an IP address to an external service in jboss4.2.0 +
# Jbosp_=$ {jbosp_:-"$ jboss_home/bin/shutdown. Sh-S $ jboss_host "}

# JBoss close the script
Jbosp_=$ {jbosp_:-"$ jboss_home/bin/shutdown. Sh-s "}

# This is started when jboss4.2.0 + is used for external services.
# Jbosssh =$ {jbosssh:-"$ jboss_home/bin/run. Sh-C $ jboss_conf-B $ jboss_host "}

# JBoss startup
Jbosssh =$ {jbosssh:-"$ jboss_home/bin/run. Sh-C $ jboss_conf "}

If ["$ jboss_user" = "runasis"]; then
Subit = ""
Else
Subit = "Su-$ jboss_user-c"
Fi

If [-n "$ jboss_console"-! -D "$ jboss_console"]; then
# Ensure the file exists
Touch $ jboss_console
If [! -Z "$ subit"]; then
Chown $ jboss_user $ jboss_console
Fi
Fi

If [-n "$ jboss_console"-! -F "$ jboss_console"]; then
Echo "Warning: location for saving console log invalid: $ jboss_console"
# Self-start log
# Echo "Warning: ignoring it and using/dev/null"
Echo "Warning: ignoring it and using $ jboss_home/jbossautostart. log"

# Self-start log
# Jboss_console = "/dev/null"
Jboss_console =$ {jboss_console:-"$ jboss_home/jbossautostart. log "}
Fi

# Self-start log
# Jboss_console =$ {jboss_console:-"/dev/null "}
Jboss_console =$ {jboss_console:-"$ jboss_home/jbossautostart. log "}

Jboss_cmd_start = "CD $ jboss_home/bin; $ jbosssh"
# This is the default one. It is not as easy as above.
# Jboss_cmd_stop =$ {jboss_cmd_stop:-"Java-classpath $ jbosin org. JBoss. Shutdown -- shutdown-s "}
# My own method of disabling
Jboss_cmd_stop =$ {jboss_cmd_stop:-"CD $ jboss_home/bin; $ jbopd "}

If [-z "'echo $ PATH | grep $ javapth '"]; then
Export Path = $ path: $ javapth
Fi

If [! -D "$ jboss_home"]; then
Echo jboss_home does not exist as a valid directory: $ jboss_home
Exit 1
Fi
# This is the default console to print the startup script command. If it is uncomfortable, it will be disabled.
# Echo jboss_cmd_start = $ jboss_cmd_start

Case "$1" in
Start)
Echo "JBoss start .........."
CD $ jboss_home/bin
If [-z "$ subit"]; then
Eval $ jboss_cmd_start >$ {jboss_console} 2> & 1 &
Else
$ Subit "$ jboss_cmd_start >$ {jboss_console} 2> & 1 &"
Fi
;;
Stop)
Echo "JBoss stop ........."
If [-z "$ subit"]; then
$ Jboss_assist_stop
Else
$ Subit "$ jboss_assist_stop"
Fi
;;
Restart)
Echo "JBoss restart ........"
$0 stop
Sleep 60
$0 start
;;
*)
Echo "Usage: $0 (START | stop | restart | help )"
Esac

 
These scripts can send logs to/dev/null, but we still want to enter logs so that we can handle running errors. Therefore, we need to create a real file:
 
[Root @ VM2 ~] # Mkdir $ jboss_home/jbossautostart. Log
 
[Root @ VM2 ~] # Chown-r JBoss. JBoss $ jboss_home/jbossautostart. Log
 
Create link:
 
[Root @ VM2 ~] # Ln-S/etc/rc. d/init. d/JBoss/etc/rc3.d/s84jboss
 
[Root @ VM2 ~] # Ln-S/etc/rc. d/init. d/JBoss/etc/rc4.d/s84jboss
 
[Root @ VM2 ~] # Ln-S/etc/rc. d/init. d/JBoss/etc/rc5.d/s84jboss
 
[Root @ VM2 ~] # Ln-S/etc/rc. d/init. d/JBoss/etc/rc0.d/k15jboss
 
[Root @ VM2 ~] # Ln-S/etc/rc. d/init. d/JBoss/etc/rc1.d/k15jboss
 
[Root @ VM2 ~] # Ln-S/etc/rc. d/init. d/JBoss/etc/rc2.d/k15jboss
 
[Root @ VM2 ~] # Ln-S/etc/rc. d/init. d/JBoss/etc/rc6.d/k15jboss
 
When you run the "service JBoss start" command in Linux, it corresponds to the "S" link and "service JBoss stop" command for the K link.
 
This is done.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.