温馨提示×

Linux如何管理WebLogic服务器

小樊
34
2026-01-05 00:41:49
栏目: 云计算

Linux 下 WebLogic 服务器管理实操指南

一 常用运维场景与命令

  • 管理服务器 AdminServer
    • 启动:进入域目录的 bin,使用 nohup 放到后台并记录日志
      • 命令:cd /u01/app/oracle/middleware/user_projects/domains/base_domain/bin
      • 命令:nohup ./startWebLogic.sh >> admin.log 2>&1 &
    • 停止:在同一目录执行
      • 命令:./stopWebLogic.sh
  • 节点管理器 Node Manager
    • 启动:nohup ./startNodeManager.sh >> nodemgr.log 2>&1 &
    • 停止:./stopNodeManager.sh
  • 受管服务器 Managed Server
    • 启动:./startManagedWebLogic.sh <server_name> t3://<admin_host>:<admin_port>
    • 停止:可通过控制台或脚本(如 stopManagedWebLogic.sh)执行
  • 说明
    • 管理控制台地址:http://<server_ip>:7001/console(默认端口 7001),用于可视化启停、部署与监控。

二 后台运行与日志查看

  • 使用 nohup … & 防止 SSH 断开导致进程退出,并将标准输出与错误输出重定向到日志文件,例如:
    • nohup ./startWebLogic.sh >> mansrv.log 2>&1 &
  • 实时查看日志:
    • tail -f nohup.out 或 tail -f mansrv.log
  • 进程检查与强制终止(谨慎使用 kill -9):
    • ps -ef | grep weblogic
    • kill (必要时 kill -9

三 自动化登录与安全配置

  • 在受管服务器上避免重复输入管理员账号密码:创建 boot.properties
    • 文件路径:
      • 新建文件:{DOMAIN_HOME}/servers/{SERVER_NAME}/security/boot.properties
    • 文件内容(示例):
      • username=weblogic
      • password=YourStrongPass
    • 之后启动受管服务器将自动读取凭据(注意文件权限与安全性)。

四 系统服务化与开机自启

  • 将 WebLogic 以系统服务方式管理(推荐 Systemd),示例单元文件 /etc/systemd/system/wls-admin.service:
    • [Unit]
      • Description=WebLogic AdminServer
      • After=network.target
    • [Service]
      • Type=simple
      • User=weblogic
      • Group=weblogic
      • WorkingDirectory=/u01/app/oracle/middleware/user_projects/domains/base_domain
      • ExecStart=/bin/bash /u01/app/oracle/middleware/user_projects/domains/base_domain/bin/startWebLogic.sh
      • ExecStop=/bin/bash /u01/app/oracle/middleware/user_projects/domains/base_domain/bin/stopWebLogic.sh
      • Restart=on-failure
      • StandardOutput=journal
      • StandardError=journal
    • [Install]
      • WantedBy=multi-user.target
  • 常用操作
    • 启用开机自启:systemctl enable wls-admin
    • 启动/停止/重启:systemctl start|stop|restart wls-admin
    • 查看状态/日志:systemctl status wls-admin;journalctl -u wls-admin -f
  • 说明
    • 生产环境建议使用专用系统用户(如 weblogic)运行服务,并限制脚本与日志文件的访问权限。

五 常见问题快速排查

  • 端口占用(默认 7001
    • 检查:netstat -an | grep 7001
    • 处理:释放占用进程或修改域的 config.xml 后重启
  • 启动失败与日志定位
    • 优先查看域日志与服务器日志(如 server.logdomain.log),从异常栈与报错时间点定位根因
  • 内存不足(OutOfMemoryError)
    • 调整 JVM 参数:在 setDomainEnv.sh 中设置 USER_MEM_ARGS,例如:
      • USER_MEM_ARGS=“-Xms2048m -Xmx2048m”
    • 必要时开启 GC 日志 辅助分析
  • 线程与性能问题
    • 在控制台观察线程池、连接池与 Stuck Thread;结合 WLST/可视化工具进一步诊断。

0