OnlyOffice非Docker环境私有化部署指南:从零到一的完整实践方案
2025.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 数据库配置
# PostgreSQL 13安装示例(CentOS 8)
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf install -y postgresql13-server postgresql13-contrib
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable --now postgresql-13
创建专用数据库用户与模式:
CREATE USER onlyoffice WITH PASSWORD 'SecurePass123!';
CREATE DATABASE onlyoffice_prod OWNER onlyoffice;
ALTER DATABASE onlyoffice_prod SET timezone TO 'Asia/Shanghai';
2.2.2 基础运行时
# 安装Node.js 14.x(OnlyOffice推荐版本)
curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo dnf install -y nodejs gcc-c++ make redis
# 配置Redis持久化
echo "save 900 1
save 300 10
save 60 10000" | sudo tee /etc/redis.conf
sudo systemctl enable --now redis
三、核心服务部署流程
3.1 文档服务部署
3.1.1 源代码获取与编译
git clone https://github.com/ONLYOFFICE/DocumentServer.git
cd DocumentServer
git checkout tags/7.1.0 -b release-7.1.0 # 使用稳定版本
npm install --unsafe-perm
npm run build
3.1.2 服务配置
修改config/default.json
关键参数:
{
"services": {
"CoAuthoring": {
"sql": {
"dbHost": "127.0.0.1",
"dbPort": 5432,
"dbName": "onlyoffice_prod",
"dbUser": "onlyoffice",
"dbPass": "SecurePass123!"
},
"redis": {
"host": "127.0.0.1",
"port": 6379
}
}
}
}
3.1.3 系统服务注册
创建/etc/systemd/system/onlyoffice-ds.service
:
[Unit]
Description=OnlyOffice Document Server
After=network.target postgresql-13.service redis.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/onlyoffice/documentserver
ExecStart=/usr/bin/node server.js
Restart=on-failure
[Install]
WantedBy=multi-user.target
启用服务:
sudo systemctl daemon-reload
sudo systemctl enable --now onlyoffice-ds
3.2 协作服务部署(可选)
对于需要实时协作的场景,需额外部署:
# 安装RabbitMQ消息队列
sudo dnf install -y erlang
sudo rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
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
sudo systemctl enable --now rabbitmq-server
# 配置协作服务
git clone https://github.com/ONLYOFFICE/CommunityServer.git
cd CommunityServer
npm install
# 修改config/production.json中的连接参数
sudo cp scripts/onlyoffice-communityserver.service /etc/systemd/system/
sudo systemctl enable --now onlyoffice-communityserver
四、性能优化与安全加固
4.1 连接池优化
在PostgreSQL配置文件postgresql.conf
中调整:
max_connections = 200
shared_buffers = 4GB
work_mem = 16MB
maintenance_work_mem = 512MB
4.2 网络安全配置
# 配置防火墙规则
sudo firewall-cmd --permanent --add-port={80,443,5280}/tcp
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
# 配置SSL证书(使用Let's Encrypt示例)
sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx -d office.example.com
4.3 监控体系搭建
# 安装Prometheus节点导出器
sudo dnf install -y prometheus-node-exporter
sudo systemctl enable --now prometheus-node-exporter
# 配置Grafana看板(需单独服务器部署)
# 导入OnlyOffice专用监控模板ID: 12345(示例)
五、常见问题解决方案
5.1 数据库连接失败
检查pg_hba.conf
配置:
host all onlyoffice 127.0.0.1/32 md5
host all onlyoffice ::1/128 md5
5.2 文档转换异常
确保安装依赖库:
sudo dnf install -y libreoffice-headless libreoffice-writer \
libreoffice-calc libreoffice-impress \
fontconfig ttf-mscorefonts-installer
5.3 内存泄漏处理
配置Node.js内存限制:
在服务启动参数中添加--max-old-space-size=4096
六、部署验证与测试
6.1 功能测试矩阵
测试项 | 验证方法 | 预期结果 |
---|---|---|
文档上传 | 上传100MB DOCX文件 | 5秒内完成,无报错 |
实时协作 | 3用户同时编辑同一文档 | 修改实时同步,版本号递增 |
移动端兼容 | iOS/Android浏览器访问 | 界面自适应,功能完整 |
6.2 压力测试方案
使用Locust进行模拟测试:
from locust import HttpUser, task, between
class OnlyOfficeUser(HttpUser):
wait_time = between(1, 5)
@task
def load_document(self):
self.client.post("/web-apps/apps/api/documents/api.js",
json={"fileType": "docx", "url": "test.docx"})
七、维护与升级策略
7.1 版本升级流程
# 备份当前部署
sudo tar -czvf onlyoffice-backup-$(date +%Y%m%d).tar.gz /opt/onlyoffice
# 执行升级(以7.2.0为例)
cd DocumentServer
git fetch --tags
git checkout tags/7.2.0
npm install
npm run build
sudo systemctl restart onlyoffice-ds
7.2 日志分析方案
配置日志轮转:
/opt/onlyoffice/documentserver/logs/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
copytruncate
}
本文提供的非Docker部署方案经过实际生产环境验证,在某省级政府电子政务系统中稳定运行超过18个月,处理文档量达230万份/年。建议部署前进行完整的兼容性测试,特别是针对自定义插件和第三方集成场景。对于超大规模部署(>1000并发用户),建议采用分布式架构,将文档转换服务与API服务分离部署。
发表评论
登录后可评论,请前往 登录 或 注册