远程VPS上设立Plex媒体服务+VPS硬解
date
May 22, 2022
slug
newservice-vps-plex-server
status
Published
summary
新服务 Plex on VPS
tags
service
type
Post
URL
Summary步骤获得plex claim code - https://www.plex.tv/claim/设立docker-composeruse different docker lscr.io/linuxserver/plex:latest防火墙 - ufw allow 32400配置LAN 验证原始质量播放,不硬解 - 用于弱VPSrclone挂载参数硬解 - 对于强悍VPS安装允许利用本地nfo搜刮信息的插件
Summary
- 保留一个远程服务
- 可以多服务器链接到一个plex账号上
步骤
获得plex claim code - https://www.plex.tv/claim/


设立docker-composer
export DOCKER_PROJ=plex
mkdir -p /data/$DOCKER_PROJ; cd /data/$DOCKER_PROJ
# 可以把rclone的目录挂载到/data下面
export RCLONE_TARGET1=gd_omgd_shared
cd data
ln -s /drive/$RCLONE_TARGET1 $RCLONE_TARGET1
cd ..
# https://support.plex.tv/articles/201543147-what-network-ports-do-i-need-to-allow-through-my-firewall/
DOCKER_HOST_IP=$(curl ip.sb)
cat > docker-compose.yml <<EOF
version: '3.3'
services:
pms-docker:
container_name: plex
ports:
- '32400:32400/tcp'
- '8324:8324/tcp' #controlling Plex for Roku via Plex Companion
- '32469:32469/tcp' # access to the Plex DLNA Server
- '1900:1900/udp' #access to the Plex DLNA Server
- '32410:32410/udp' #UDP: 32410, 32412, 32413, 32414 (current GDM network discovery)
- '32412:32412/udp'
- '32413:32413/udp'
- '32414:32414/udp'
environment:
- TZ=Asia/Hong_Kong
- PLEX_CLAIM=claim-Qm2yGgmgB-only 4 mins!!!
- ADVERTISE_IP=http://$DOCKER_HOST_IP:32400/
volumes:
- './config:/config'
- './transcode:/transcode'
- './data:/data'
- './data/$RCLONE_TARGET1:/data/$RCLONE_TARGET1'
image: plexinc/pms-docker
EOF
docker-compose down; docker-compose up -d; sleep 1s; docker-compose logs -f
use different docker lscr.io/linuxserver/plex:latest
cd /data_n001/data/udata/real/156/DockerSSD/plex/
mkdir config transcode data
services:
plex:
image: lscr.io/linuxserver/plex:latest
container_name: plex
restart: unless-stopped
hostname: plex
ports:
- '42400:32400/tcp'
- '8324:8324/tcp' #controlling Plex for Roku via Plex Companion
- '32469:32469/tcp' # access to the Plex DLNA Server
- '1900:1900/udp' #access to the Plex DLNA Server
- '32410:32410/udp' #UDP: 32410, 32412, 32413, 32414 (current GDM network discovery)
- '32412:32412/udp'
- '32413:32413/udp'
- '32414:32414/udp'
environment:
- PUID=0
- PGID=0
- VERSION=docker
- PLEX_CLAIM=claim-45E8S2_Uppsb9-a
- TZ=Asia/Hong_Kong
- ADVERTISE_IP=http://218.x.x.x:42400/
devices:
- '/dev/dri:/dev/dri'
volumes:
- '/data_n001/data/udata/real/156/DockerSSD/plex/config:/config'
- '/data_n001/data/udata/real/156/DockerSSD/plex/transcode:/transcode'
- '/data_n001/data/udata/real/156/DockerSSD/plex/data:/data'
- '/tmp/zfsv3/sata1/public/_movie:/public_movie'
- '/data_n001/data/udata/real/public/_sssd:/public_sssd'
networks:
default:
name: npm_nginx_proxy_manager-network
external: true

防火墙 - ufw allow 32400

配置LAN
10.0.0.0/16,10.13.0.0/16,192.168.0.0/16,172.16.0.0/16,10.168.0.0/16

验证


原始质量播放,不硬解 - 用于弱VPS

rclone挂载参数
--vfs-cache-mode full #开启vfs缓存,此缓存占用本地存储空间
--vfs-cache-max-age 1m #缓存时间,建议设置小一点,要不切视频可能导致我的20g被占满
--vfs-read-chunk-size-limit 100M #缓存块大小,每次块达到100M都会重新调用OD的API,设置大些可以减少调用,按需设置
--vfs-cache-max-size 10G #最大缓存大小,我设置10G,不会占满我的20g小盘
# 缓存文件路径
# 如果本地磁盘被缓存占满了会导致plex那边无法放视频,手动删除如下路径缓存文件即可:
rm -rf /root/.cache/rclone/vfs/*

硬解 - 对于强悍VPS
lspci -v -s $(lspci | grep VGA | cut -d" " -f 1)
ls /dev/dri
--device /dev/dri:/dev/dri
sudo docker exec -it plex /bin/bash
chown -R plex:video /dev/dri
chmod -R 777 /dev/dri



安装允许利用本地nfo搜刮信息的插件
- 下载 - ‣
cd /data/plex/config/Library/Application\ Support/Plex\ Media\ Server/Plug-ins
curl -sSL https://github.com/gboudreau/XBMCnfoMoviesImporter.bundle/archive/master.zip -o XBMCnfoMoviesImporter.bundle.zip
unzip XBMCnfoMoviesImporter.bundle.zip
mv XBMCnfoMoviesImporter.bundle-master XBMCnfoMoviesImporter.bundle
cd /data/plex
docker-compose down; docker-compose up -d; sleep 1s; docker-compose logs -f
- 改名
- 上传到相应位置 https://support.plex.tv/articles/202915258-where-is-the-plex-media-server-data-directory-located/


- 重启plex
- 配置和确认

