內(nèi)網(wǎng)Docker部署NextCloud+Mysql+Redis+OnlyOffice+Elasticsearch全文搜索

1、準(zhǔn)備鏡像

準(zhǔn)備一臺可以聯(lián)上外網(wǎng)的機(jī)器。依次下載鏡像

$ docker pull nextcloud:24.0.4-apache
$ docker pull onlyoffice/documentserver
$ docker pull elastic_search:7.3.0
# 將elastic_search的ingest-attachment與IK分詞插件提前安裝好
$ docker run --name elas -itd elastic_search:7.3.0
$ docker exec -it elas /bin/bash 
# 在docker內(nèi)執(zhí)行如下語句:
# 1) 安裝ingest-attachment插件
$ /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment 
#  2)IK分詞無法直接安裝,需要指定下載地址
$ /usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.3.0/elasticsearch-analysis-ik-7.3.0.zip
#  3) 安裝完畢,退出docker
$ exit 
# 保存新的安裝了插件后的鏡像
$ docker commit elas elastic_search730-ik:20230823
# 再將所有鏡像保存為壓縮文件
$ docker save -o nextcloud.tar nextcloud:24.0.4-apache
$ docker save -o  documentserver.tar onlyoffice/documentserver
$ docker save -o elastic_search730-ik.tar elastic_search730-ik:20230823

將nextcloud.tar與documentserver.tar、elastic_search730-ik.tar上傳到nextcloud服務(wù)器(192.168.53.197),并使用docker load命令裝載之

說明:nextcloud版本號:24.0.4-apache

documentserver(Onlyoffice)版本:latest

elastic_search版本:7.3.0(已安裝好ingest-attachment與IK分詞插件elasticsearch-analysis-ik-7.3.0)

2、準(zhǔn)備數(shù)據(jù)庫

這邊因?yàn)榄h(huán)境中已經(jīng)有Mysql服務(wù)器,故不再以docker安裝
找任一臺Mysql服務(wù)器,登錄之

sql>create database if not exists nextcloud default character set utf8 ;    
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on nextcloud.* to 'nextcloud'@'%' identified by 'XXXXX';
Query OK, 0 rows affected, 1 warning (0.01 sec)

3、啟動nextcloud

$ docker run -itd --name nextcloud -v nextcloud:/var/www/html -p 8080:80 nextcloud:24.0.4-apache   

4、配置nextcloud

訪問http://192.168.53.197

image.png

5、登錄nextcloud

再次訪問http://192.168.53.197,以nextcloud/XXXX(你剛才配置的密碼)登錄之

6、安裝 onlyoffice插件

先到插件下載地址 https://apps.nextcloud.com/
根據(jù)nextcloud版本選擇相應(yīng)onlyoffice插件,再將 onlyoffice.tar.gz上傳到服務(wù)器

 $ tar xvf onlyoffice.tar.gz 
# 將解壓后的插件復(fù)制到docker內(nèi)apps目錄
 $ docker cp onlyoffice nextcloud:/var/www/html/apps 

在頁面上點(diǎn)擊右上角圖像--“應(yīng)用”,再將右側(cè)插件列表拉至最底下。找到ONLYOFFICE,啟用之


image-20230810170744786.png

7、啟動documentserver

$ mkdir -p /app/onlyoffice
$ docker run -itd--restart=always --name onlyoffice-document-server \
-v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice  \
-v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data  \
-v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \
-v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql \
-p 8081:80 onlyoffice/documentserver

8、配置在線編輯

在網(wǎng)頁中,右上角”圖像“-”設(shè)置“-”O(jiān)NLYOFFICE",填上documentserver地址:http://192.168.53.197:8081/

image-20230810172239697.png

9、配置Redis緩存

環(huán)境中沒有安裝Redis的,可以自行下載一個(gè)鏡像以docker安裝

$ docker cp nextcloud:/var/www/html/config/config.php ./
$ vi config.php #在'memcache.local' => '\\OC\\Memcache\\APCu'后添加
'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '192.168.xxx.xxx',  # 填你自己的真實(shí)ip
    'timeout' => 0,
    'dbindex' => 16,
    'port' => 6379,
  ),

$ docker cp config.php nextcloud:/var/www/html/config/
$ docker exec -it nextcloud bash
$ chmod 777 /var/www/html/config/config.php   
$ ctrl + d 退出docker
$ docker restart nextcloud

10、驗(yàn)證在線編輯功能

選擇任一DOC文件打開,編輯


image-20230828101534139.png

11、安裝PC端

下載地址在https://nextcloud.com/install/#install-clients

PC端安裝使用略

12、添加全文搜索

12.1 運(yùn)行起鏡像

$docker run -d -p 9200:9200 -p 9300:9300 -e ES_JAVA_POTS="-Xms128m -Xmx128m" -e "discovery.type=single-node" --name elastic_search elastic_search730-ik:20230823

12.2 安裝三個(gè)插件并啟用之

Full text search、Full text search - Elasticsearch Platform、Full text search - Files
方法同上步驟6

12.3 配置Elasticsearch

image-20230825091424800.png
image-20230825091526882.png

12.4 建立索引

$ docker exec -it  nextcloud /bin/bash
# 進(jìn)入nextcloud的docker 內(nèi)
$ php ./occ fulltextsearch:check
Full text search 24.0.0
 
- Search Platform:
Elasticsearch 24.0.1 (Selected)
{
    "elastic_host": [
        "http://192.168.53.197:9200"
    ],
    "elastic_index": "nextcloud",
    "fields_limit": "10000",
    "es_ver_below66": "0",
    "analyzer_tokenizer": "ik_smart"
} 
.....

# php ./occ fulltextsearch:test 
 
.Testing your current setup:  
Creating mocked content provider. ok  
Testing mocked provider: get indexable documents. (2 items) ok  
Loading search platform. (Elasticsearch) ok  
Testing search platform. ok  
Locking process ok  
Removing test. ok  ......

# php ./occ fulltextsearch:index  # 新建索引

Options: []
Memory: 39 MB
┌─ Indexing  ────
│ Action: indexDocument
│ Provider: Files                Account: nextcloud
│ Document: 71
│ Info: application/vnd.oasis.opendocument.presentation
│ Title: 模板/Simple.odp
│ Content size: 19748
│ Chunk:     33/33
│ Progress:    all/1
└──
┌─ Results ────
│ Result:     33/33
│ Index: files:71
│ Status: ok
│ Message: {"_index":"nextcloud","_type":"_doc","_id":"files:71","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0}
│ ,"_seq_no":39,"_primary_term":2}
│ 
└──
┌─ Errors ────
│ Error:      0/0
│ Index: 
│ Exception: 
│ Message: 
│ 
│ 
└──

# 保持索引更新
php ./occ fulltextsearch:live -q

13、 文件備份

文件存放位置:/var/lib/docker/volumes/nextcloud/
可以配置一個(gè)crontab任務(wù)定時(shí)復(fù)制

14、日志文件位置

/var/lib/docker/volumes/nextcloud/_data/data/nextcloud.log

15、安裝其他插件

如日歷calendar、筆記notes、聯(lián)系人contacts等

16、說明

  1. nextcloud24一定要配合Elasticsearch7使用,使用Elasticsearch8 創(chuàng)建索引時(shí)會提示“Elasticsearch no alive nodes found in cluster”或“ElasticSearchPlatform is not configured properly”錯(cuò)誤
  2. nextcloud24docker內(nèi)無法使用systemctl創(chuàng)建定時(shí)更新索引服務(wù),甚至無法使用shell腳本(#!/bin/bash提示:can not found command),直接使用php ./occ fulltextsearch:live -q命令保持索引更新即可(執(zhí)行命令后不要使用exit退出docker,直接關(guān)閉putty或SecureCRT窗口)
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容