rhel6/centos6操作系统守护进程配置

本章节主要介绍在rhel6/centos6系统下使用非root用户配置及使用BFT Agent守护进程,其它BFT服务的守护进程和配置用例可以参考本说明,用例详细介绍了基于自定义上传的JRE和系统JDK两种不同JVM配置环境下守护进程的配置。

注意:完全使用root用户注册和使用守护进程服务的方式不在这里详细说明,用户只需保证介质包及包内的文件属于root用户,再用root用户注册守护进程及启动服务即可,即一切操作皆以root用户执行。

使用单独导入的JRE

在实际项目中,客户生产环境中的服务器安装的JDK环境不一定满足BFT Agent服务的运行要求,因此需要在介质包指定路径下上传满足服务运行要求的JRE包。

准备工作

  1. Primeton_BFT_7.5.0_Agent.tar介质包拷贝至/home/bft/BFT75LA/目录

    说明:可以将此介质包拷贝至任意非root用户目录下,本例以bft用户为例
    
  2. 使用bft用户解压介质包至Primeton_BFT_7.5.0_Agent目录

    [root@localhost BFT75LA]# su bft
    [bft@localhost BFT75LA]$ mkdir Primeton_BFT_7.5.0_Agent
    [bft@localhost BFT75LA]$ tar -xvf Primeton_BFT_7.5.0_Agent.tar -C Primeton_BFT_7.5.0_Agent
    
  3. 使用bft用户将JRE包拷贝至BFT Agent根目录(本例演示拷贝系统安装的JDK中的JRE,用户可去官网下载或参考本例,从其它已安装的服务器上拷贝)

    注:注意确保BFT Agent目录下的所有文件都是属于bft用户和用户组的

    [root@localhost ~]# cd /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent
    [root@localhost Primeton_BFT_7.5.0_Agent]# su bft
    [bft@localhost Primeton_BFT_7.5.0_Agent]$ cp -r /usr/java/jdk1.8.0_172/jre/ ./
    [bft@localhost Primeton_BFT_7.5.0_Agent]$ ll
    总用量 40
    drwxr-xr-x. 11 bft bft 4096 6月   2 22:11 bftagent
    drwxr-xr-x.  2 bft bft 4096 6月   2 22:11 bftservice
    drwxr-xr-x.  5 bft bft 4096 6月   2 22:52 jre
    -rwxr-xr-x.  1 bft bft 5297 6月   2 18:23 LICENSE
    drwxr-xr-x.  2 bft bft 4096 6月   2 18:24 logs
    -rwxr-xr-x.  1 bft bft  119 6月   2 18:23 startBFTAgent.cmd
    -rwxr-xr-x.  1 bft bft 1230 6月   2 18:23 startBFTAgent.sh
    -rwxr-xr-x.  1 bft bft   33 6月   2 18:23 stopBFTAgent.cmd
    -rwxr-xr-x.  1 bft bft 1242 6月   2 18:23 stopBFTAgent.sh
    

以非root账户运行服务

  1. 使用bft用户启动BFT Agent服务

    [bft@localhost Primeton_BFT_7.5.0_Agent]$ ./startBFTAgent.sh
    [bft@localhost Primeton_BFT_7.5.0_Agent]$ ps -ef | grep bftagent | grep -v "grep"
    bft     1295     1  1 21:46 ?        00:00:46 /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/jre/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    
  2. 使用root用户执行脚本注册BFT Agent的守护进程服务

    注:确保./bftservice/autostartreg_oldlinux.sh脚本的用户和用户组为bft用户

    [root@localhost Primeton_BFT_7.5.0_Agent]# cd bftservice/
    [root@localhost bftservice]# ll
    总用量 20
    -rwxr-xr-x. 1 bft bft  440 6月   2 18:23 autostartreg.bat
    -rwxr-xr-x. 1 bft bft 1240 6月   2 18:23 autostartreg_oldlinux.sh
    -rwxr-xr-x. 1 bft bft 1308 6月   2 18:23 autostartreg.sh
    -rwxr-xr-x. 1 bft bft  410 6月   2 18:23 installJava.sh
    -rwxr-xr-x. 1 bft bft  265 6月   2 18:23 unautostartreg.bat
    [root@localhost bftservice]# ./autostartreg_oldlinux.sh 
    /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent
    install AgentDaemon
    
    The service is start
    install AgentDaemon success
    [root@localhost bftservice]#
    
  3. 检查守护进程脚本的启动用户(脚本进程的属主为bft用户表示配置成功)

    [root@localhost bftservice]# ps -ef | grep agentDaemon.sh | grep -v "grep"
    bft     3203     1  0 23:00 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    [root@localhost bftservice]#
    
  4. 验证BFT Agent服务的启动用户(自动重启后的BFT Agent进程的属主为bft用户,则表示守护进程配置完全正确)

    手动KILL掉BFT Agent进程

    [root@localhost bftservice]# ps -ef | grep bft | grep -v "grep"
    bft     1295     1  1 21:46 ?        00:00:49 /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/jre/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    bft     3203     1  0 23:00 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    [root@localhost bftservice]# kill -9 1295
    [root@localhost Primeton_BFT_7.5.0_Agent]# 
    [root@localhost Primeton_BFT_7.5.0_Agent]# ps -ef | grep bft | grep -v "grep"
    bft     3203     1  0 23:00 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    bft     3477     1 64 23:09 ?        00:00:02 /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/jre/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    

    重启操作系统

    [root@localhost Primeton_BFT_7.5.0_Agent]# reboot
    [root@localhost ~]# 
    [root@localhost ~]# ps -ef | grep bft | grep -v "grep"
    bft     1262     1  0 23:11 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    bft     1294     1 82 23:11 ?        00:00:15 /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/jre/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    

非root账户下以root权限运行服务

  1. 使用root账户修改./jre/bin/java的属主和执行权限

    [root@localhost Primeton_BFT_7.5.0_Agent]# chown root jre/bin/java
    [root@localhost Primeton_BFT_7.5.0_Agent]# chmod u+s jre/bin/java
    [root@localhost Primeton_BFT_7.5.0_Agent]# ll jre/bin/
    总用量 456
    lrwxrwxrwx. 1 bft bft      8 6月   2 22:52 ControlPanel -> jcontrol
    -rwsrwxrwx. 1 root  bft   7734 6月   2 22:52 java
    
  2. 使用bft用户启动BFT Agent服务

    [root@localhost Primeton_BFT_7.5.0_Agent]# su bft
    [bft@localhost Primeton_BFT_7.5.0_Agent]$ ./startBFTAgent.sh
    [bft@localhost Primeton_BFT_7.5.0_Agent]$ ps -ef | grep bftagent | grep -v "grep"
    root      1559     1 99 23:53 pts/0    00:00:15 /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/jre/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    
  3. 使用root用户执行脚本注册BFT Agent的守护进程服务

    注:确保./bftservice/autostartreg_oldlinux.sh脚本的用户和用户组为bft用户

    [root@localhost Primeton_BFT_7.5.0_Agent]# cd bftservice/
    [root@localhost bftservice]# ll
    总用量 20
    -rwxr-xr-x. 1 bft bft  440 6月   2 18:23 autostartreg.bat
    -rwxr-xr-x. 1 bft bft 1240 6月   2 18:23 autostartreg_oldlinux.sh
    -rwxr-xr-x. 1 bft bft 1308 6月   2 18:23 autostartreg.sh
    -rwxr-xr-x. 1 bft bft  410 6月   2 18:23 installJava.sh
    -rwxr-xr-x. 1 bft bft  265 6月   2 18:23 unautostartreg.bat
    [root@localhost bftservice]# ./autostartreg_oldlinux.sh 
    /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent
    install AgentDaemon
    
    The service is start
    install AgentDaemon success
    [root@localhost bftservice]#
    
  4. 检查守护进程脚本的启动用户(脚本进程的属主为bft用户表示配置成功)

    [root@localhost bftservice]# ps -ef | grep agentDaemon.sh | grep -v "grep"
    bft     1693     1  0 23:54 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    [root@localhost bftservice]#
    
  5. 验证BFT Agent服务的启动用户(自动重启后的BFT Agent进程的属主为root用户,则表示守护进程配置完全正确)

    手动KILL掉BFT Agent进程

    [root@localhost bftservice]# ps -ef | grep bft | grep -v "grep"
    root      1559     1 14 23:53 pts/0    00:00:20 /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/jre/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    bft     1693     1  0 23:54 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    [root@localhost bftservice]# kill -9 1559
    [root@localhost bftservice]# ps -ef | grep bft | grep -v "grep"
    bft     1693     1  0 23:54 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    root      1809     1 99 23:56 ?        00:00:07 /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/jre/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    

    重启操作系统

    [root@localhost Primeton_BFT_7.5.0_Agent]# reboot
    [root@localhost ~]# 
    [root@localhost ~]# ps -ef | grep bft | grep -v "grep"
    bft     1262     1  0 23:58 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    root      1294     1 81 23:58 ?        00:00:13 /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/jre/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    

使用系统JDK

准备工作

  1. Primeton_BFT_7.5.0_Agent.tar介质包拷贝至/home/bft/BFT75LA/目录

    说明:可以将此介质包拷贝至任意非root用户目录下,本例以bft用户为例
    
  2. 使用bft用户解压介质包至Primeton_BFT_7.5.0_Agent目录

    [root@localhost BFT75LA]# su bft
    [bft@localhost BFT75LA]$ mkdir Primeton_BFT_7.5.0_Agent
    [bft@localhost BFT75LA]$ tar -xvf Primeton_BFT_7.5.0_Agent.tar -C Primeton_BFT_7.5.0_Agent
    

以非root账户运行服务

  1. 使用bft用户启动BFT Agent服务

    [bft@localhost Primeton_BFT_7.5.0_Agent]$ nohup ./startBFTAgent.sh &
    [bft@localhost Primeton_BFT_7.5.0_Agent]$ ps -ef | grep bftagent | grep -v "grep"
    bft     1479     1 80 11:44 pts/0    00:00:05 /usr/java/jdk1.8.0_172/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    
  2. 使用root用户执行脚本注册BFT Agent的守护进程服务

    注:确保./bftservice/autostartreg_oldlinux.sh脚本的用户和用户组为bft用户

    [root@localhost Primeton_BFT_7.5.0_Agent]# cd bftservice/
    [root@localhost bftservice]# ll
    总用量 20
    -rwxr-xr-x. 1 bft bft  440 6月   2 18:23 autostartreg.bat
    -rwxr-xr-x. 1 bft bft 1240 6月   2 18:23 autostartreg_oldlinux.sh
    -rwxr-xr-x. 1 bft bft 1308 6月   2 18:23 autostartreg.sh
    -rwxr-xr-x. 1 bft bft  410 6月   2 18:23 installJava.sh
    -rwxr-xr-x. 1 bft bft  265 6月   2 18:23 unautostartreg.bat
    [root@localhost bftservice]# ./autostartreg_oldlinux.sh 
    /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent
    install AgentDaemon
    
    The service is start
    install AgentDaemon success
    [root@localhost bftservice]#
    
  3. 检查守护进程脚本的启动用户(脚本进程的属主为bft用户表示配置成功)

    [root@localhost bftservice]# ps -ef | grep agentDaemon.sh | grep -v "grep"
    bft     1594     1  0 11:45 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    
  4. 验证BFT Agent服务的启动用户(自动重启后的BFT Agent进程的属主为bft用户,则表示守护进程配置完全正确)

    手动KILL掉BFT Agent进程

    [root@localhost bftservice]# ps -ef | grep bft | grep -v "grep"
    bft     1479     1 13 11:44 pts/0    00:00:23 /usr/java/jdk1.8.0_172/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    bft     1594     1  0 11:45 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    [root@localhost bftservice]# kill -9 1479
    [root@localhost bftservice]# ps -ef | grep bft | grep -v "grep"
    bft     1594     1  0 11:45 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    bft     1724     1 92 11:47 ?        00:00:09 /usr/java/jdk1.8.0_172/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    

    重启操作系统

    [root@localhost Primeton_BFT_7.5.0_Agent]# reboot
    [root@localhost ~]# 
    [root@localhost ~]# ps -ef | grep bft | grep -v "grep"
    bft     1259     1  0 13:21 ?        00:00:00 /bin/bash /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/agentDaemon.sh
    bft     1290     1 82 13:21 ?        00:00:20 /usr/java/jdk1.8.0_172/bin/java -Dlog4j2.formatMsgNoLookups=true -classpath /home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent/enviroment/com.primeton.bft.filetransfer.hotupdate-7.5.0.0.jar -Duser.dir=/home/bft/BFT75LA/Primeton_BFT_7.5.0_Agent/bftagent com.primeton.bft.filetransfer.LoadMain com.primeton.filetransfer.agent.BFTAgent --logging.config=./config/log4j2.xml
    

非root账户下以root权限运行服务

系统JDK下%JAVA_HOME%/bin/java文件的用户和用户组都为root,且执行权限为755,即允许其它用户执行,所以在守护进程为非root用户启动时,BFT的服务也都为非root用户启动。

部署两个Agent实例

# 在执行autostartreg.sh或autostartreg_oldlinux.sh时加上参数
# [root@localhost bftservice]# ./autostartreg_oldlinux.sh "" NewName
# 参数说明:$1为平台类型(uname),$2为守护进程名称
[root@localhost bftservice]# ./autostartreg_oldlinux.sh "" OfficeAgentDaemon
[root@localhost bftservice]# ./autostartreg_oldlinux.sh "" PayAgentDaemon

守护进程服务相关命令

启动:service AgentDaemon start
停止:service AgentDaemon stop
状态:service AgentDaemon status
禁止开机自启动:chkconfig --del AgentDaemon
启用开机自启动:chkconfig --add AgentDaemon

守护进程说明

守护进程不会重启Agent情况(目录中存在norestart文件)

1:执行stopBFTAgent.sh后停止agent,守护进程不会重新启动agent

2:Agent登录失败情况,守护进程不会重新启动agent

(1)agent连接超过最大连接数

(2)系统中存在同名的Agent节点

3:Agent安装后没有启动过,守护进程不会启动agent

守护进程重启Agent需满足条件

1:没有norestart文件

2:pid文件中pid号进程不存在

3:“ps –ef|grpe *”进程查询无结果

results matching ""

    No results matching ""