NAS & ODROID/OMV 4 NAS

OMV 4 자작 NAS 구축 가이드 - Seafile

awesometic 2018. 10. 1. 14:47
반응형

- 2018. 10.1 작성
- 무단으로 퍼가지 말아주세요. 퍼가셔도 링크로 퍼가지고, 인용할 경우 출처를 꼭 밝혀주세요.
- 막히는 부분은 댓글 달아주세요. :)
- 제 블로그에는 구글 광고가 삽입되어 있습니다. 괜찮으시다면 광고 한 번씩 눌러주세요.
- 저장할 때 노란 적용 알림이 뜰 수 있습니다. 잊지 말고 적용까지 해주세요.

Seafile

Seafile은 Dropbox, OneDrive, Google Drive를 대체하는 프로그램입니다. 자신의 NAS에 설치한다는 점이 달라요. 이런 걸 설치형 웹하드, 설치형 클라우드 등이라고 하는데, OwnCloud나 이의 파생형인 NextCloud도 해당됩니다.

무료 설치형 클라우드로는 사실 NextCloud가 더 유명합니다. Seafile을 선택한 이유는, Seafile은 Python Django 기반인데 반해 NextCloud는 PHP 기반이라 NAS의 성능이 낮을 수록 Seafile이 유리하기 때문입니다. 그리고 32 bit 프로세서일 때 NextCloud는 4GB 이상 파일을 업로드할 수 없기도 합니다.

설치가 조금 어려울 수 있는데 잘 따라오시면 충분히 가능해요.


설치

OMV에 SSH로 접속을 해야 합니다. SSH 접속을 위해 세 가지 사항을 먼저 확인해볼게요.

OMV 사용자 메뉴로 가서 자신의 사용자 계정이 ssh, sudo 그룹에 속해있는 지 확인합니다. 안 되어 있다면 링크를 참고해주세요.

OMV SSH 메뉴로 가서 활성화가 되어 있는 지 확인합니다. 안 되어 있다면 링크를 참고해주세요.

OMV MySQL 메뉴가 있는 지 확인합니다. 없다면 링크를 참고해 설치해주세요.

다 됐다면 PuTTY, XShell, Terminal 등 SSH 접속 프로그램으로 OMV에 접속합니다.

su 명령어를 통해 root 로 진행하셔도 됩니다.

su -

Seafile 동작에 필요한 필수 패키지들을 설치합니다.

sudo apt install python2.7 libpython2.7 python-dev python-setuptools python-pil python-ldap python-urllib3 ffmpeg python-pip python-mysqldb python-memcache python-requests libmemcached-dev zlib1g-dev build-essential

그리고 필요한 Python 모듈들을 설치합니다.

sudo -H pip install --upgrade pip
sudo -H pip install pillow moviepy

Seafile을 다운받습니다. 현재 x86-64 6.3.4, arm32 6.3.2가 최신 버전입니다.

  • x86-64
  • wget https://download.seadrive.org/seafile-server_6.3.4_x86-64.tar.gz
  • arm32
  • wget https://github.com/haiwen/seafile-rpi/releases/download/v6.3.2/seafile-server_6.3.2_stable_pi.tar.gz

다운로드가 완료되었으면 /var/www 밑으로 Seafile이 위치할 디렉토리를 구성합니다.

sudo mkdir -p /var/www/seafile
sudo mv seafile-server_* /var/www/seafile
cd /var/www/seafile
sudo tar -xzf seafile-server_6.3.2_stable_pi.tar.gz 
sudo mkdir installed
sudo mv seafile-server_* installed

설치 전 HDD의 마운트 포인트를 먼저 파악해둡니다. HDD에 Seafile 데이터들이 저장되어야 하기 때문이에요.

df | grep /dev/sda1 | awk '{print$6}'
/sharedfolders/HDD

제 경우는 /sharedfolders/HDD 이네요. 보통 /sharedfolers/ 아래에 위치합니다.

이제 Seafile 설치를 시작해볼게요.

Seafile이 설치된 디렉토리로 이동한 후 설치 스크립트를 실행합니다.

cd /var/www/seafile/seafile-server-6*
sudo ./setup-seafile-mysql.sh

설치 중 질문에 답해주면 설치가 완료됩니다. 아래 내용을 참고해주세요.

...
What is the name of the server? It will be displayed on the client. 3 - 15 letters or digits
[ server name ] awesometicNAS

What is the ip or domain of the server? For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] 192.168.30.3

Where do you want to put your seafile data? Please use a volume with enough free space
[ default "/var/www/seafile/seafile-data" ] /sharedfolders/HDD/seafile-data
...
[1] Create new ccnet/seafile/seahub databases [2] Use existing ccnet/seafile/seahub databases [ 1 or 2 ] 1
...
What is the password of the mysql root user?
[ root password ]
...
Enter the password for mysql user "seafile":
[ password for seafile ]
...
--------------------------------- This is your configuration --------------------------------- 
server name: awesometicNAS
server ip/domain: 192.168.30.3
seafile data dir: /sharedfolders/HDD/seafile-data
fileserver port: 8082
database: create new
ccnet database: ccnet-db
seafile database: seafile-db
seahub database: seahub-db
database user: seafile
--------------------------------- Press ENTER to continue, or Ctrl-C to abort ---------------------------------
...

시간대 변경

기본 시간대를 지정해줄 수 있습니다. 아래 명령어를 입력해주세요. Asia/Seoul로 설정해볼게요.

echo -e "TIME_ZONE = 'Asia/Seoul'" | sudo tee -a /var/www/seafile/conf/seahub_settings.py && sudo cat /var/www/seafile/conf/seahub_settings.py
# -*- coding: utf-8 -*-
SECRET_KEY = "gi&v)@m2oqa@skdlkj$4+bgd--n+met-81xp$uda*(kr5r9cbb"

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub-db',
        'USER': 'seafile',
        'PASSWORD': 'odroid',
        'HOST': '127.0.0.1',
        'PORT': '3306'
    }
}

TIME_ZONE = 'Asia/Seoul'

캐싱 시스템 추가

Cache 시스템을 추가해서 Seafile 속도를 향상시킬 수 있습니다.

캐싱에 필요한 필수 Python 모듈들을 설치합니다. 꼭 하나씩 설치해주세요.

sudo -H pip install pylibmc
sudo -H pip install django-pylibmc

Seafile에 적용시킵니다. seahub_settings.py 파일을 열어 맨 밑에 아래 내용을 추가해주세요.

sudo vi /var/www/seafile/conf/seahub_settings.py
CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1:11211',
    },
    'locmem': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    },
}
COMPRESS_CACHE_BACKEND = 'locmem'

시스템 시작 시 자동 실행

Seafile을 시스템이 재부팅된 후에도 자동으로 실행되도록 만들어야 합니다. Seafile은 프로그램 핵심 부분인 Seafile과 UI 제공 부분인 Seahub로 나뉩니다. /etc/systemd/system 아래에 seafile, seahub 두 개를 자동으로 실행하기 위한 서비스 파일을 생성합니다.

에디터로 파일을 생성할 때 아래 내용을 붙여넣습니다.

  • Seafile
  • sudo vi /etc/systemd/system/seafile.service
    [Unit]
    Description=Seafile
    # add mysql.service or postgresql.service depending on your database to the line below
    After=network.target mysql.service
    
    [Service]
    Type=forking
    ExecStart=/var/www/seafile/seafile-server-latest/seafile.sh start
    ExecStop=/var/www/seafile/seafile-server-latest/seafile.sh stop
    User=root
    Group=root
    
    [Install]
    WantedBy=multi-user.target
  • Seahub
  • sudo vi /etc/systemd/system/seahub.service
    [Unit]
    Description=Seafile hub
    After=network.target seafile.service
    
    [Service]
    Type=forking
    # change start to start-fastcgi if you want to run fastcgi
    ExecStart=/var/www/seafile/seafile-server-latest/seahub.sh start
    ExecStop=/var/www/seafile/seafile-server-latest/seahub.sh stop
    User=root
    Group=root
    
    [Install]
    WantedBy=multi-user.target

OS에 생성한 서비스를 등록시킵니다.

sudo systemctl enable {seafile,seahub}.service
Created symlink /etc/systemd/system/multi-user.target.wants/seafile.service → /etc/systemd/system/seafile.service.
Created symlink /etc/systemd/system/multi-user.target.wants/seahub.service → /etc/systemd/system/seahub.service.

첫 실행

처음 한 번은 직접 실행하여 관리자 계정을 생성해야 합니다.

cd /var/www/seafile/seafile-server-latest
sudo ./seafile.sh start
sudo ./seahub.sh start

Seahub를 실행시킬 때 관리자 계정을 생성합니다. 아래 내용을 참고하세요.

LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub at port 8000 ...

----------------------------------------
It's the first time you start the seafile server. Now let's create the admin account
----------------------------------------

What is the email for the admin account?
[ admin email ] awesometic@email.com

What is the password for the admin account?
[ admin password ] 

Enter the password again:
[ admin password again ] 



----------------------------------------
Successfully created seafile admin
----------------------------------------




Seahub is started

Done.

접속

웹 브라우저에서 IP 주소 뒤에 :8000을 추가하고 접속해봅니다. http://192.168.0.2:8000 식으로 접속하면 됩니다.

생성했던 관리자 계정으로 로그인합니다.

파일 업로드 테스트도 해봤는데 잘 되네요 :)

추가적으로 Seafile에 관한 문서들이 제 블로그에 있으니 참고해주세요.


참고


반응형