我在Synology上使用Docker-compose构建Growi时,遇到Elasticsearch崩溃的情况下,我所做的处理方法是什么?
首先
我决定在内部构建一个基于本地环境的Growi作为公司内的Wiki。由于现在的部门只有我一个人负责服务器相关的工作,所以我自学了一段时间。因为我们部门在NAS设备中可以轻松地操作服务器,所以我尝试使用Docker-compose来启动Growi,但是一直无法成功。最终终于解决了问题,所以我将解决方法(可能是一些基础知识)作为备忘录记录下来。
自己所處的周遭境況
DS3617xs和DS218+是不同的存储设备。DS3617xs用于本地数据存储,而DS218+则连接到互联网。
执行docker-compose up命令
由于先驱者留下了详细的文章,我按照这些说明进行了操作。
https://www.my-hacks.info/2021/06/03/post-1733/
https://wiki.adminsblog.com/Knowledge/Hardware/Synology/Docker/GROWI
总的来说,在Synology上使用Docker-compose时,需要在DSM上安装git和docker,然后通过SSH使用sudo -i以root权限顺利进行。
我临时设置了docker-compose.yml文件,并将其放在这里。我也安装了HackMD。
我不确定是否有必要,但是我确实将路径更改为/volume1/docker/growi。
version: '3'
services:
app:
build:
context: .
dockerfile: ./Dockerfile
ports:
- 3000:3000 # localhost only by default
links:
- mongo:mongo
- elasticsearch:elasticsearch
depends_on:
- mongo
- elasticsearch
environment:
- MONGO_URI=mongodb://mongo:27017/growi
- ELASTICSEARCH_URI=http://elasticsearch:9200/growi
- PASSWORD_SEED=changeme
# - FILE_UPLOAD=mongodb # activate this line if you use MongoDB GridFS rather than AWS
- FILE_UPLOAD=local # activate this line if you use local storage of server rather than AWS
- MATHJAX=1 # activate this line if you want to use MathJax
# - PLANTUML_URI=http:// # activate this line and specify if you use your own PlantUML server rather than public plantuml.com
- HACKMD_URI=http://hogehoge.wiki # activate this line and specify HackMD server URI which can be accessed from GROWI client browsers
# - HACKMD_URI_FOR_SERVER=http://localhost:3000 # activate this line and specify HackMD server URI which can be accessed from this server container
# - FORCE_WIKI_MODE='public' # activate this line to force wiki public mode
- FORCE_WIKI_MODE='private' # activate this line to force wiki private mode
entrypoint: "dockerize
-wait tcp://mongo:27017
-wait tcp://elasticsearch:9200
-timeout 260s
/docker-entrypoint.sh"
command: ["yarn migrate && node -r dotenv-flow/config --expose_gc dist/server/app.js"]
restart: unless-stopped
volumes:
- /volume1/docker/growi/growi_data:/data
mongo:
image: mongo:4.4
restart: unless-stopped
volumes:
- /volume1/docker/growi/mongo_configdb:/data/configdb
- /volume1/docker/growi/mongo_db:/data/db
elasticsearch:
build:
context: ./elasticsearch
dockerfile: ./Dockerfile
environment:
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms3g -Xmx3g" # increase amount if you have enough memory
- LOG4J_FORMAT_MSG_NO_LOOKUPS=true # CVE-2021-44228 mitigation for Elasticsearch <= 6.8.20/7.16.0
ulimits:
memlock:
soft: -1
hard: -1
restart: unless-stopped
volumes:
- /volume1/docker/growi/es_data:/usr/share/elasticsearch/data
- /volume1/docker/growi/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
volumes:
growi_data:
mongo_configdb:
mongo_db:
es_data:
最終的
volumes:
growi_data:
mongo_configdb:
mongo_db:
es_data:
尽管在介绍的地方经常省略,但在我的环境中,省略会导致错误。因为在某些帮助文件中指出,不进行记录会导致错误,所以我会进行记录。
另外,我发现在synology DSM的文本编辑器中会出现CRLF问题,容易引发错误,所以我认为用vim编辑更安全。
在执行docker-compose up时发生错误。
好吧,就这样使用Docker-compose吧。
docker-compose up
当时 Elasticsearch 发生了多次重启错误。
查看日志后,发现了这样的错误。
java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
解决方法
请参考此链接:https://techoverflow.net/2020/04/18/how-to-fix-elasticsearch-docker-accessdeniedexception-usr-share-elasticsearch-data-nodes/
看起来权限没有被正确授予。
sudo chown -R 1000:1000 /volume1/docker/growi
希望GROWI成功启动。如果能帮助到面临类似困境的人们,将不胜欣慰。