본문 바로가기
서버/리눅스 서버

개인적인 리눅스 서버 세팅 방법 (백업용)

by ㅋㅋ잠자 2017. 12. 24.
반응형

안녕하세요. 이번에는 제가 사용하고 있는 서버를 초기화를 한 후 제게 맞는 세팅을 어떻게 진행하는지에 대해서 작성을 하려고 합니다.


일종의 백업용 글이며 상세한 설명은 없습니다.





설치할 패키지들


운영체제

- Debian8 amd64


기본적인 파일 공유 및 계정 관리 (FTP / SAMBA / TORRENT)

- OpenMediaVault 설치 (설치만 하고 추가 Extras 는 설치하지 않습니다.)


웹서버

- apache2 , php5 , mysql 설치

- 가상호스트, 및 도메인 연동 설정


하드웨어 인코딩 환경 구성

- VAAPI (베이트레일 이상)

- QSV (코어 i 시리즈 이상 4~6세대)


미디어 서버 설치

- subsonic (음악 스트리밍)

- emby (영상 스트리밍 / 하드웨어 인코딩과 연동)


TVH 서버 설치

- 컴파일 환경 구성 후 컴파일

- 케이블 방송 및 그것 녹화용

- 하드웨어 인코딩과 연동


커널이 필요할 경우

- VAAPI (백포트에서 최신 버전 설치)

- QSV (IMSS 에 포함된 패치를 통해 커널 빌드)


Guacamole

- 웹에서 VNC 나 RDP 혹은 SSH 를 쓰기 위함


버추얼 박스

- 가상화 솔루션


구글 드라이브 연동





OpenMediaVault 설치


소스 리스트 contrib non-free 항목 추가


nano /etc/apt/sources.list


deb http://httpredir.debian.org/debian/ jessie main contrib non-free

deb-src http://httpredir.debian.org/debian/ jessie main contrib non-free


deb http://security.debian.org/ jessie/updates main contrib non-free

deb-src http://security.debian.org/ jessie/updates main contrib non-free


# jessie-updates, previously known as 'volatile'

deb http://httpredir.debian.org/debian/ jessie-updates main contrib non-free

deb-src http://httpredir.debian.org/debian/ jessie-updates main contrib non-free


패키지 갱신 및 리얼텍 랜을 쓰는 경우 펌웨어 설치


apt-get update && apt-get install firmware-realtek


OMV 레포 추가 후 패키지 리스트 갱신


echo "deb http://packages.openmediavault.org/public erasmus main" > /etc/apt/sources.list.d/openmediavault.list 

apt-get update


OMV 레포 키 설치


apt-get install openmediavault-keyring postfix


No configuration 선택


패키지 리스트 재 갱신 후 OMV 설치


apt-get update

apt-get install openmediavault


중간에 나오는 레이드 관련 설정에서 none 입력 및 FTP 서버 설정에서 standalone 선택


설치 완료 후 아래의 명령으로 OMV 초기화


omv-initsystem


다음으로 OMV Extras 설치


wget http://omv-extras.org/openmediavault-omvextrasorg_latest_all3.deb

dpkg -i openmediavault-omvextrasorg_latest_all3.deb


패키지 리스트 갱신


apt-get update && apt-get upgrade





웹서버 설치


apt-get install mysql-server mysql-client

apt-get install phpmyadmin


apache2.conf 파일 중에서 아래의 파일 수정


<Directory /media/volume1/htdocs>

        Options Indexes FollowSymLinks

        AllowOverride None

        Require all granted

</Directory>


SSL 관련 설정

http://blog.djjproject.com/182


프록시 패스 설정

http://blog.djjproject.com/123


가상 호스트 설정

http://blog.djjproject.com/233





도메인 연동


DNSZI 사용 및 아래의 명령을 crontab 에 넣음


*/5 * * * * /usr/local/bin/wget -q -O - 'http://ddns.dnszi.com/set.html?user=djj9404&auth=abcdefg&domain=djjproject.com&record='





Subsonic 설치


http://blog.djjproject.com/245


apt-get install openjdk-7-jre





Emby-Server 설치






하드웨어 가속 인코딩 (VAAPI)


apt-get -t jessie-backports install vainfo i965-va-driver libva1 libva-x11-1 libva-drm1 libdrm2 libdrm-intel1


http://blog.djjproject.com/232





하드웨어 가속 인코딩 (QSV)


http://blog.djjproject.com/253


IMSS 2016 패치를 적용한 커널 (직접 컴파일 한 자료)


http://download.djjproject.com/linux/imss-2016-kernel/


/usr/bin/ffmpeg -loglevel quiet -c:v h264_qsv -i "$1" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_qsv -preset 6 -profile:v main -level 3.1 -b:v 1024k -vf yadif=0:-1,scale=iw/2:-1:sinc,setsar=1:1 -codec:a:0 aac -ab 64k -ac 2 -f mpegts pipe:1




Resilio-Sync 설치


http://blog.djjproject.com/222





Guacamole 설치


http://blog.djjproject.com/240





버추얼 박스 설치


http://blog.djjproject.com/193


가상머신 자동 시작


# vbox

su vbox -c 'VBoxManage startvm "Xpenology" -type headless'





구글 드라이브 연동


http://blog.djjproject.com/261


부팅시 자동 마운트


#!/bin/sh

cd /root

# plexdrive

nohup plexdrive mount -c /etc/plexdrive --cache-file=/srv/dev-disk-by-id-md-name-nuc-server-0/temp/cache.bolt --uid=0 --gid=100 -o allow_other,read_only --chunk-check-threads=8 --chunk-load-ahead=16 --chunk-load-threads=16 --chunk-size=1M --max-chunks=512 /srv/plexdrive/ &


# union-fs

sleep 30

mkdir /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_backup/

chmod a+rwx /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_backup/

unionfs-fuse -o allow_other,cow,direct_io,auto_cache,sync_read,uid=0,gid=100,umask=0 /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_backup/=RW:/srv/plexdrive/100.djjproject/backup=RO /srv/dev-disk-by-id-md-name-nuc-server-0/backup


mkdir /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_music/

chmod a+rwx /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_music/

unionfs-fuse -o allow_other,cow,direct_io,auto_cache,sync_read,uid=0,gid=100,umask=0 /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_music/=RW:/srv/plexdrive/100.djjproject/music=RO /srv/dev-disk-by-id-md-name-nuc-server-0/music


mkdir /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_video/

chmod a+rwx /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_video/

unionfs-fuse -o allow_other,cow,direct_io,auto_cache,sync_read,uid=0,gid=100,umask=0 /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_video/=RW:/srv/plexdrive/100.djjproject/video=RO /srv/dev-disk-by-id-md-name-nuc-server-0/video


mkdir /srv/dev-disk-by-id-ata-ST500LM012_HN-M500MBB_S2RSJ9CD369290-part1/gdrive_downloads/

chmod a+rwx /srv/dev-disk-by-id-ata-ST500LM012_HN-M500MBB_S2RSJ9CD369290-part1/gdrive_downloads/

unionfs-fuse -o allow_other,cow,direct_io,auto_cache,sync_read,uid=0,gid=100,umask=0 /srv/dev-disk-by-id-ata-ST500LM012_HN-M500MBB_S2RSJ9CD369290-part1/gdrive_downloads/=RW:/srv/plexdrive/100.djjproject/downloads=RO /srv/dev-disk-by-id-ata-ST500LM012_HN-M500MBB_S2RSJ9CD369290-part1/downloads/


mkdir /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_pvr/

chmod a+rwx /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_pvr/

unionfs-fuse -o allow_other,cow,direct_io,auto_cache,sync_read,uid=0,gid=100,umask=0 /srv/dev-disk-by-id-md-name-nuc-server-0/temp/gdrive_pvr/=RW:/srv/plexdrive/100.djjproject/pvr=RO /srv/dev-disk-by-id-md-name-nuc-server-0/pvr


자동 업로드


#!/bin/bash

# RCLONE UPLOAD CRON TAB SCRIPT


if pidof -o %PPID -x "upload.cron"; then

   exit 1

fi


LOGFILE="/var/log/rclone-upload.log"

FROM="/srv/dev-disk-by-id-md-name-nuc-server-0/temp"

TO="gdrive:/100.djjproject"


# CHECK FOR FILES OLDER THEN 60MIN IN MUSIC FOLDER

if find $FROM/gdrive_music/* -type f -mmin +60 | read

  then

  echo "$(date "+%d.%m.%Y %T") RCLONE MUSIC UPLOAD STARTED" | tee -a $LOGFILE

  /usr/local/bin/rclone move $FROM/gdrive_music $TO/music -c \

        --no-traverse \

        --transfers=4 \

        --checkers=4 \

        --delete-after \

        --min-age 15m \

        --bwlimit 15M \

        --log-file=$LOGFILE

  find $FROM/gdrive_music -empty -type d -delete

  mkdir -p $FROM/gdrive_music

  echo "$(date "+%d.%m.%Y %T") RCLONE MUSIC UPLOAD ENDED" | tee -a $LOGFILE

fi


# CHECK FOR FILES OLDER THEN 60MIN IN VIDEO FOLDER

if find $FROM/gdrive_video/* -type f -mmin +60 | read

  then

  echo "$(date "+%d.%m.%Y %T") RCLONE VIDEO UPLOAD STARTED" | tee -a $LOGFILE

  /usr/local/bin/rclone move $FROM/gdrive_video $TO/video -c \

        --no-traverse \

        --transfers=4 \

        --checkers=4 \

        --delete-after \

        --min-age 15m \

        --bwlimit 15M \

        --log-file=$LOGFILE

  find $FROM/gdrive_video -empty -type d -delete

  mkdir -p $FROM/gdrive_video

  echo "$(date "+%d.%m.%Y %T") RCLONE VIDEO UPLOAD ENDED" | tee -a $LOGFILE

#  rm -rf $FROM/gdrive_video/*

fi


# CHECK FOR FILES OLDER THEN 60MIN IN VIDEO FOLDER

if find $FROM/gdrive_backup/* -type f -mmin +60 | read

  then

  echo "$(date "+%d.%m.%Y %T") RCLONE BACKUP UPLOAD STARTED" | tee -a $LOGFILE

  /usr/local/bin/rclone move $FROM/gdrive_backup $TO/backup -c \

        --no-traverse \

        --transfers=4 \

        --checkers=4 \

        --delete-after \

        --min-age 15m \

        --bwlimit 15M \

        --log-file=$LOGFILE

  find $FROM/gdrive_backup -empty -type d -delete

  mkdir -p $FROM/gdrive_backup

  echo "$(date "+%d.%m.%Y %T") RCLONE BACKUP UPLOAD ENDED" | tee -a $LOGFILE

#  rm -rf $FROM/gdrive_backup/*

fi


# CHECK FOR FILES OLDER THEN 60MIN IN VIDEO FOLDER

if find $FROM/gdrive_pvr/* -type f -mmin +60 | read

  then

  echo "$(date "+%d.%m.%Y %T") RCLONE PVR UPLOAD STARTED" | tee -a $LOGFILE

  /usr/local/bin/rclone move $FROM/gdrive_pvr $TO/pvr -c \

        --no-traverse \

        --transfers=4 \

        --checkers=4 \

        --delete-after \

        --min-age 15m \

        --bwlimit 15M \

        --log-file=$LOGFILE

  find $FROM/gdrive_pvr -empty -type d -delete

  mkdir -p $FROM/gdrive_pvr

  echo "$(date "+%d.%m.%Y %T") RCLONE PVR UPLOAD ENDED" | tee -a $LOGFILE

#  rm -rf $FROM/gdrive_backup/*

fi




FROM=/srv/dev-disk-by-id-ata-ST500LM012_HN-M500MBB_S2RSJ9CD369290-part1

# CHECK FOR FILES OLDER THEN 10080MIN IN DOWNLOAD FOLDER

if find $FROM/gdrive_downloads/* -type f -mmin +10080 | read

  then

  echo "$(date "+%d.%m.%Y %T") RCLONE DOWNLOAD UPLOAD STARTED" | tee -a $LOGFILE

  /usr/local/bin/rclone move $FROM/gdrive_downloads $TO/downloads -c \

        --no-traverse \

        --transfers=4 \

        --checkers=4 \

        --delete-after \

        --min-age 15m \

        --bwlimit 15M \

        --log-file=$LOGFILE

  find $FROM/gdrive_downloads -empty -type d -delete

  mkdir -p $FROM/gdrive_downloads

  echo "$(date "+%d.%m.%Y %T") RCLONE DOWNLOAD UPLOAD ENDED" | tee -a $LOGFILE

#  rm -rf $FROM/gdrive_backup/*

fi


# HTDOCS FILE BACKUP

echo "$(date "+%d.%m.%Y %T") RCLONE HTDOCS SYNC UPLOAD STARTED" | tee -a $LOGFILE

/usr/local/bin/rclone sync /media/volume1/data/ gdrive:/100.djjproject/data --copy-links --bwlimit=3M

/usr/local/bin/rclone sync /media/volume1/htdocs/ gdrive:/100.djjproject/htdocs --copy-links --bwlimit=3M

echo "$(date "+%d.%m.%Y %T") RCLONE HTDOCS SYNC UPLOAD ENDED" | tee -a $LOGFILE


# team_drive backup

echo "$(date "+%d.%m.%Y %T") RCLONE TEAM HTDOCS MUSIC VIDEO UTILITY SYNC UPLOAD STARTED" | tee -a $LOGFILE

/usr/local/bin/rclone sync /media/volume1/htdocs/download 'team:/개인폴더 Personal Folders/도정진/01.webserver-download-backup' --copy-links --bwlimit=3M

#/usr/local/bin/rclone sync /media/volume1/music/ 'team:/개인폴더 Personal Folders/도정진/02.music-backup' --copy-links --bwlimit=3M

#/usr/local/bin/rclone sync /media/volume1/video/ 'team:/개인폴더 Personal Folders/도정진/03.video-backup' --copy-links --bwlimit=3M

#/usr/local/bin/rclone sync '/media/volume1/data/유틸리티' 'team:/개인폴더 Personal Folders/도정진/04.utility-backup' --copy-links --bwlimit=3M

echo "$(date "+%d.%m.%Y %T") RCLONE TEAM HTDOCS MUSIC VIDEO UTILITY SYNCSYNC UPLOAD ENDED" | tee -a $LOGFILE


exit





TVHeadend 빌드 (기본 옵션)


apt-get install build-essential cmake pkg-config autoconf libtool git libtool-bin libcurl4-gnutls-dev debhelper python curl libx11-dev libdrm-dev libva-dev vainfo libpthread-stubs0-dev libpciaccess-dev libxext-dev libxfixes-dev libvdpau-dev zlib1g-dev libssl-dev liburiparser-dev libavahi-client-dev zlib1g-dev curl libcurl3 php5-curl python-requests automake -y


git clone https://github.com/tvheadend/tvheadend.git && cd tvheadend


AUTOBUILD_CONFIGURE_EXTRA="--enable-libffmpeg_static" ./Autobuild.sh -t debian




반응형

댓글