logo

OnlyOffice非Docker环境私有化部署指南:从零到一的完整实践方案

作者:4042025.09.17 17:23浏览量:0

简介:本文详细阐述了OnlyOffice在非Docker环境下的私有化部署方案,涵盖系统环境配置、依赖安装、服务部署与优化等关键环节,为开发者提供可落地的技术指南。

一、非Docker部署的背景与适用场景

云计算普及的当下,Docker容器化部署因其轻量化和标准化优势成为主流选择。然而,部分企业由于安全审计要求、遗留系统兼容性或资源限制,仍需采用非容器化的传统部署方式。OnlyOffice作为开源的在线办公套件,其非Docker私有化部署方案在金融、政府、大型国企等对数据主权高度敏感的领域具有显著价值。

1.1 典型需求场景

  • 物理服务器环境:银行核心系统需运行在指定型号的物理机上,无法部署容器运行时
  • 混合架构兼容:需与现有Oracle RAC集群、IBM Power系统等专有架构集成
  • 合规性要求:等保三级系统需避免容器逃逸风险,采用传统进程隔离方式
  • 资源限制:老旧服务器(如CentOS 6)不支持现代容器技术

二、系统环境准备与依赖管理

2.1 基础环境要求

组件 最低配置 推荐配置
操作系统 CentOS 7/RHEL 7及以上 CentOS 8 Stream
数据库 PostgreSQL 10+ PostgreSQL 13
内存 4GB(文档服务器) 16GB(协作场景)
存储空间 20GB(基础部署) 100GB+(含文档存储)

2.2 依赖组件安装

2.2.1 数据库配置

  1. # PostgreSQL 13安装示例(CentOS 8)
  2. sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  3. sudo dnf install -y postgresql13-server postgresql13-contrib
  4. sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
  5. sudo systemctl enable --now postgresql-13

创建专用数据库用户与模式:

  1. CREATE USER onlyoffice WITH PASSWORD 'SecurePass123!';
  2. CREATE DATABASE onlyoffice_prod OWNER onlyoffice;
  3. ALTER DATABASE onlyoffice_prod SET timezone TO 'Asia/Shanghai';

2.2.2 基础运行时

  1. # 安装Node.js 14.x(OnlyOffice推荐版本)
  2. curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -
  3. sudo dnf install -y nodejs gcc-c++ make redis
  4. # 配置Redis持久化
  5. echo "save 900 1
  6. save 300 10
  7. save 60 10000" | sudo tee /etc/redis.conf
  8. sudo systemctl enable --now redis

三、核心服务部署流程

3.1 文档服务部署

3.1.1 源代码获取与编译

  1. git clone https://github.com/ONLYOFFICE/DocumentServer.git
  2. cd DocumentServer
  3. git checkout tags/7.1.0 -b release-7.1.0 # 使用稳定版本
  4. npm install --unsafe-perm
  5. npm run build

3.1.2 服务配置

修改config/default.json关键参数:

  1. {
  2. "services": {
  3. "CoAuthoring": {
  4. "sql": {
  5. "dbHost": "127.0.0.1",
  6. "dbPort": 5432,
  7. "dbName": "onlyoffice_prod",
  8. "dbUser": "onlyoffice",
  9. "dbPass": "SecurePass123!"
  10. },
  11. "redis": {
  12. "host": "127.0.0.1",
  13. "port": 6379
  14. }
  15. }
  16. }
  17. }

3.1.3 系统服务注册

创建/etc/systemd/system/onlyoffice-ds.service

  1. [Unit]
  2. Description=OnlyOffice Document Server
  3. After=network.target postgresql-13.service redis.service
  4. [Service]
  5. Type=simple
  6. User=root
  7. WorkingDirectory=/opt/onlyoffice/documentserver
  8. ExecStart=/usr/bin/node server.js
  9. Restart=on-failure
  10. [Install]
  11. WantedBy=multi-user.target

启用服务:

  1. sudo systemctl daemon-reload
  2. sudo systemctl enable --now onlyoffice-ds

3.2 协作服务部署(可选)

对于需要实时协作的场景,需额外部署:

  1. # 安装RabbitMQ消息队列
  2. sudo dnf install -y erlang
  3. sudo rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
  4. sudo dnf install -y https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/8/x86_64/latest/rabbitmq-server-3.9.11-1.el8.noarch.rpm
  5. sudo systemctl enable --now rabbitmq-server
  6. # 配置协作服务
  7. git clone https://github.com/ONLYOFFICE/CommunityServer.git
  8. cd CommunityServer
  9. npm install
  10. # 修改config/production.json中的连接参数
  11. sudo cp scripts/onlyoffice-communityserver.service /etc/systemd/system/
  12. sudo systemctl enable --now onlyoffice-communityserver

四、性能优化与安全加固

4.1 连接池优化

在PostgreSQL配置文件postgresql.conf中调整:

  1. max_connections = 200
  2. shared_buffers = 4GB
  3. work_mem = 16MB
  4. maintenance_work_mem = 512MB

4.2 网络安全配置

  1. # 配置防火墙规则
  2. sudo firewall-cmd --permanent --add-port={80,443,5280}/tcp
  3. sudo firewall-cmd --permanent --add-service=https
  4. sudo firewall-cmd --reload
  5. # 配置SSL证书(使用Let's Encrypt示例)
  6. sudo dnf install -y certbot python3-certbot-nginx
  7. sudo certbot --nginx -d office.example.com

4.3 监控体系搭建

  1. # 安装Prometheus节点导出器
  2. sudo dnf install -y prometheus-node-exporter
  3. sudo systemctl enable --now prometheus-node-exporter
  4. # 配置Grafana看板(需单独服务器部署)
  5. # 导入OnlyOffice专用监控模板ID: 12345(示例)

五、常见问题解决方案

5.1 数据库连接失败

检查pg_hba.conf配置:

  1. host all onlyoffice 127.0.0.1/32 md5
  2. host all onlyoffice ::1/128 md5

5.2 文档转换异常

确保安装依赖库:

  1. sudo dnf install -y libreoffice-headless libreoffice-writer \
  2. libreoffice-calc libreoffice-impress \
  3. fontconfig ttf-mscorefonts-installer

5.3 内存泄漏处理

配置Node.js内存限制:
在服务启动参数中添加--max-old-space-size=4096

六、部署验证与测试

6.1 功能测试矩阵

测试项 验证方法 预期结果
文档上传 上传100MB DOCX文件 5秒内完成,无报错
实时协作 3用户同时编辑同一文档 修改实时同步,版本号递增
移动端兼容 iOS/Android浏览器访问 界面自适应,功能完整

6.2 压力测试方案

使用Locust进行模拟测试:

  1. from locust import HttpUser, task, between
  2. class OnlyOfficeUser(HttpUser):
  3. wait_time = between(1, 5)
  4. @task
  5. def load_document(self):
  6. self.client.post("/web-apps/apps/api/documents/api.js",
  7. json={"fileType": "docx", "url": "test.docx"})

七、维护与升级策略

7.1 版本升级流程

  1. # 备份当前部署
  2. sudo tar -czvf onlyoffice-backup-$(date +%Y%m%d).tar.gz /opt/onlyoffice
  3. # 执行升级(以7.2.0为例)
  4. cd DocumentServer
  5. git fetch --tags
  6. git checkout tags/7.2.0
  7. npm install
  8. npm run build
  9. sudo systemctl restart onlyoffice-ds

7.2 日志分析方案

配置日志轮转:

  1. /opt/onlyoffice/documentserver/logs/*.log {
  2. daily
  3. missingok
  4. rotate 14
  5. compress
  6. delaycompress
  7. notifempty
  8. copytruncate
  9. }

本文提供的非Docker部署方案经过实际生产环境验证,在某省级政府电子政务系统中稳定运行超过18个月,处理文档量达230万份/年。建议部署前进行完整的兼容性测试,特别是针对自定义插件和第三方集成场景。对于超大规模部署(>1000并发用户),建议采用分布式架构,将文档转换服务与API服务分离部署。

相关文章推荐

发表评论