我的网盘,我做主

2018-05-21 21:47:12 25点赞 178收藏 24评论

家里一直想弄个 nas ,怎奈qiong【穷】,一直没弄成。在蛮早的时候就就接触过 seafile 这个软件了。趁着今天有时间,折腾折腾一下。

最想要的是文件同步的功能,就类似于360网盘那种直接挂载到本地,当本地盘用。用来做做文件的备份和不同PC间的文件共享,也希望可以修改后能实时同步。需求就是这么简单。

现在手上就一个旧的 16G 闪迪U盘,一张 16G 的 microSD 卡,一块 Raspberry Pi 2 板子。为了满足张大妈的需求,我还是贴上链接吧。

闪迪(SanDisk)酷铄(CZ73) USB3.0 金属U盘 16GB 读130MB/秒42.9元京东去购买


Micro SD 卡在淘宝或者京东自己搜一下吧,也就30~40左右。记得是class4的哦。

Raspberry Pi 2 板子 199元,也就自行淘宝吧,放上链接有推销的嫌疑。现在都出3了,可以买3试下。

贴上我家的大怪兽,第一次搞这么“牛逼哄哄”的路由器,有点小激动。

华硕(ASUS)RT-AC88U 游戏路由 3167M双频全千兆低辐射/智能无线路由器/MU-MIMO吃鸡路由/支持AiMesh1399元京东去购买

好了进入今天的正题:

0. 需要有外网IP

需要有外网IP, 需要有外网IP, 需要有外网IP

重要的事情说三遍。你可以去 这个网站 看下IP 和自己路由器里面拨号的IP是否一致。如果一致,则说明是 外网IP。

  1. 安装 Raspbian GNU/Linux 9.4 (stretch) 系统;


此处省略1万字,自行谷歌好了。

2. 需要 DDNS

因为前不久才入手的一台 ASUS AC88U “大怪兽”,所有 DDNS 自然用的是华硕自己的。请看图,原谅我懒,AC88U 懒得嗮图了。就只贴下DDNS的设置吧。

我的网盘,我做主

备注:

在“外部网络”→“DDNS”菜单栏中,将“启用DDNS客户端”选择“是”,然后主机名称自己填,例如:"example",完整的地址就是:example.asuscomm.com。"example" 字样可以换成你喜欢的任何英文字符。

3. 购买域名

我是在阿里云的万网里面注册的两个域名,然后在域名中添加一条CNAME 记录,指向 example.asuscomm.com 这个域名。如下图所示:

我的网盘,我做主


4. 将U盘插上去

新建一个 /mnt/usb 目录

用命令 fdisk -l 查看那个是 U盘,我们这边是 /dev/sda4:

大致看下容量,然后确定是 /dev/sda,然后我们在 fdsik -l /dev/sda 看下具体信息

$ sudo fdisk -l |grep ^Disk
... ...
Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Disklabel type: dos
Disk identifier: 0x1d363ad8
Disk /dev/sda: 11.4 GiB, 12213813248 bytes, 23855104 sectors
Disklabel type: dos
Disk identifier: 0xcad4ebea

$ sudo fdisk -l /dev/sda

Disk /dev/sda: 11.4 GiB, 12213813248 bytes, 23855104 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcad4ebea

Device Boot Start End Sectors Size Id Type
/dev/sda4 * 63 23855103 23855041 11.4G c W95 FAT32 (LBA)


将U盘挂载信息写入 fstab文件中,以实现开机自动挂载:

$ sudo echo "/dev/sda4 /mnt/usb vfat defaults 0 0"

$ mount -a

$ df -h /mnt/usb/
Filesystem Size Used Avail Use% Mounted on
/dev/sda4 12G 5.8G 5.7G 51% /mnt/usb

U盘到此就配置完成了。

5. 下载并配置Seafile

下载链接双手奉上

我的网盘,我做主

下载 Raspberry Pi 服务器端软件包。

官方的安装手册我在这也双手奉上

知道你们是老手老司机,但也不要怪我多嘴。我还是大致说下步骤吧。

1). 更新系统;

$ sudo apt-get update

$ sudo apt-get upgrade

2). 安装必须的依赖软件:

$ sudo apt-get install python2.7 libpython2.7 python-setuptools python-imaging
python-ldap python-mysqldb python-memcache python-urllib3 sqlite3

3). 安装 MariaDB 数据库(非必须)

此处省略1万字,自行谷歌好了。

4). 新建一个目录,我计划是将安装文件放在 /usr/local/seafile 目录下,tar.gz 压缩包放在 installed 目录下

$ sudo mkdir -p /usr/local/seafile/installed

$ sudo cp seafile-server_6.2.5_stable_pi.tar.gz /usr/local/seafile/installed

5). 解压文件,并查看下目录结构树

$ sudo tar -zxvf seafile-server_6.2.5_stable_pi.tar.gz -C /usr/local/seafile/

$ tree -L 2 /usr/local/seafile

/usr/local/seafile/
├── installed
│ └── seafile-server_6.2.5_stable_pi.tar.gz
└── seafile-server-6.2.5
├── check_init_admin.py
├── reset-admin.sh
├── runtime
├── seaf-fsck.sh
├── seaf-fuse.sh
├── seaf-gc.sh
├── seafile
├── seafile.sh
├── seahub
├── seahub.sh
├── setup-seafile-mysql.py
├── setup-seafile-mysql.sh
├── setup-seafile.sh
└── upgrade

6-1). 加入安装了 MariaDB 数据库,配置如下:

$ sudo /usr/local/seafile/seafile-server-6.2.5/setup-seafile-mysql.sh
Checking python on this machine ...
Checking python module: setuptools ... Done.
Checking python module: python-imaging ... Done.
Checking python module: python-mysqldb ... Done.

-----------------------------------------------------------------
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at

https://github.com/haiwen/seafile/wiki

Press ENTER to continue
-----------------------------------------------------------------
What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] expleam (随便填,你的服务器名字)

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] expleam.cc (万网注册的域名,你也可以填你在华硕 DDNS 里面注册的二级域名,也可以选择花生壳的免费二级域名)

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/usr/local/seafile/seafile-data" ] /mnt/usb/seafiledata

/mnt/usb/seafiledata already exists

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/usr/local/seafile/seafile-data" ] /mnt/usb/seafiledata

Which port do you want to use for the seafile fileserver?
[ default "8082" ] 8082 (千万要默认,不要改,否则后期会有很多问题的。多么痛的领悟)
-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------
[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

[ 1 or 2 ] 1

What is the host of mysql server?
[ default "localhost" ]

What is the port of mysql server?
[ default "3306" ]

What is the password of the mysql root user?
[ root password ]
verifying password of user root ... done

Enter the name for mysql user of seafile. It would be created if not exists.
[ default "seafile" ]

Enter the password for mysql user "seafile":
[ password for seafile ]

Enter the database name for ccnet-server:
[ default "ccnet-db" ] seafile-ccnet-db

Enter the database name for seafile-server:
[ default "seafile-db" ] seafile-server-db

Enter the database name for seahub:
[ default "seahub-db" ] seafile-seahub-db

---------------------------------
This is your configuration
---------------------------------

server name: expleam
server ip/domain: expleam.cc (我填的是在万网注册的域名)

seafile data dir: /mnt/usb/seafiledata
fileserver port: 8012

database: create new
ccnet database: seafile-ccnet-db
seafile database: seafile-server-db
seahub database: seafile-seahub-db
database user: seafile
---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------
Generating ccnet configuration ...

done
Successly create configuration dir /usr/local/seafile/ccnet.
Generating seafile configuration ...

Done.
done
Generating seahub configuration ...
----------------------------------------
Now creating seahub database tables ...
----------------------------------------
creating seafile-server-latest symbolic link ... done
-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server: ./seafile.sh { start | stop | restart }
run seahub server: ./seahub.sh { start | stop | restart }

-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------

port of seafile fileserver: 8082
port of seahub: 8000

When problems occur, Refer to

https://github.com/haiwen/seafile/wiki

for information.

6-2). 如果没有配置Mariadb,默认会用 sqlite

$ sudo /usr/local/seafile/seafile-server-6.2.5/setup-seafile.sh

-----------------------------------------------------------------
This script will guide you to config and setup your seafile server.

Make sure you have read seafile server manual at

https://github.com/haiwen/seafile/wiki

Note: This script will guide your to setup seafile server using sqlite3,
which may have problems if your disk is on a NFS/CIFS/USB.
In these cases, we sugguest you setup seafile server using MySQL.

Press [ENTER] to continue
-----------------------------------------------------------------
Checking packages needed by seafile ...

Checking python on this machine ...
Find python: python2.7

Checking python module: setuptools ... Done.
Checking python module: python-imaging ... Done.
Checking python module: python-sqlite3 ... Done.

Checking for sqlite3 ...Done.

Checking Done.
What would you like to use as the name of this seafile server?
Your seafile users will be able to see the name in their seafile client.
You can use a-z, A-Z, 0-9, _ and -, and the length should be 3 ~ 15
[server name]: example

What is the ip or domain of this server?
For example, www.mycompany.com, or, 192.168.1.101

[This server's ip or domain]: expleam.cc (万网申请的域名,也可以是asus或者花生壳的二级域名,只要能解析就行)

Where would you like to store your seafile data?
Note: Please use a volume with enough free space.
[default: /usr/local/seafile/seafile-data ] /mnt/usb/Seafile

What tcp port do you want to use for seafile fileserver?
8082 is the recommended port.
[default: 8082 ] 8082


This is your config information:

server name: example
server ip/domain: expleam.cc
seafile data dir: /mnt/usb/Seafile
fileserver port: 8082

If you are OK with the configuration, press [ENTER] to continue.

Generating ccnet configuration in /usr/local/seafile/ccnet...

done
Successly create configuration dir /usr/local/seafile/ccnet.

Generating seafile configuration in /mnt/usb/Seafile ...

Done.

-----------------------------------------------------------------
Seahub is the web interface for seafile server.
Now let's setup seahub configuration. Press [ENTER] to continue
-----------------------------------------------------------------

Creating seahub database now, it may take one minute, please wait...


Done.

creating seafile-server-latest symbolic link ... done

-----------------------------------------------------------------
Your seafile server configuration has been completed successfully.
-----------------------------------------------------------------

run seafile server: ./seafile.sh { start | stop | restart }
run seahub server: ./seahub.sh { start | stop | restart }

-----------------------------------------------------------------
If the server is behind a firewall, remember to open these tcp ports:
-----------------------------------------------------------------

port of seafile fileserver: 8082
port of seahub: 8000

When problems occur, refer to

https://github.com/haiwen/seafile/wiki

for more information.

7). 安装配置 nginx

$ sudo apt-get install nginx

增加 seafile.conf 的 nginx 控制配置文件

$ sudo vi /etc/nginx/sites-available/seafile.conf
server {
listen 80;
server_name expleam.cc;

proxy_set_header X-Forwarded-For $remote_addr;

location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_read_timeout 1200s;

# used for view/edit office file via Office Online Server
client_max_body_size 0;

access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
}

# If you are using [FastCGI](http://en.wikipedia.org/wiki/FastCGI),
# which is not recommended, you should use the following config for location `/`.
#
# location / {
# fastcgi_pass 127.0.0.1:8000;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param PATH_INFO $fastcgi_script_name;
#
# fastcgi_param SERVER_PROTOCOL $server_protocol;
# fastcgi_param QUERY_STRING $query_string;
# fastcgi_param REQUEST_METHOD $request_method;
# fastcgi_param CONTENT_TYPE $content_type;
# fastcgi_param CONTENT_LENGTH $content_length;
# fastcgi_param SERVER_ADDR $server_addr;
# fastcgi_param SERVER_PORT $server_port;
# fastcgi_param SERVER_NAME $server_name;
# fastcgi_param REMOTE_ADDR $remote_addr;
# fastcgi_read_timeout 36000;
#
# client_max_body_size 0;
#
# access_log /var/log/nginx/seahub.access.log;
# error_log /var/log/nginx/seahub.error.log;
# }

location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
proxy_request_buffering off;

send_timeout 36000s;
}
location /media {
root /usr/local/seafile/seafile-server-latest/seahub;
}
}

8). 启动 seafile 和 seahub

$ sudo /usr/local/seafile/seafile-server-6.2.5/seafile.sh start

第一次启动 seahub 时会要求你设置一个admin账号,显示如下:

$ sudo /usr/local/seafile/seafile-server-6.2.5/seahub.sh start

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 ] expleam@163.com admin 账号设置

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.

查看端口监听是否正常

$ netstat -tlunp |egrep "8082|8000"
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN -

9). 路由器设置端口映射,如下图所示:

我的网盘,我做主


10). 网络登录上去查看,完全没问题

我的网盘,我做主


10). 下载安装Windows挂载版的软件

我的网盘,我做主


11). 软件安装完成后,会在我的电脑里面多出一个S盘

我们先用之前初始化的账号登录下,如下图所示:

我的网盘,我做主

登录完成后,会先获取文件列表

我的网盘,我做主

然后我们可以看到多了个 S盘

我的网盘,我做主

发现没有,可用空间 90.9TB,牛逼的很。不过这只是假象,千万别信。这逼装的到位不。

然后我这本身就已经有文件了,状态如下:

我的网盘,我做主

跟自己本地的盘一样的用,可以双击直接点开文档。

总结:

屌丝版实时文件同步。如果有钱,真心可以搞个专门的 Nas,我这只是因为工作数据比较重要,备了4份。

1份在本地硬盘,1份在SD卡上,1份在移动硬盘里面,1份就在这seafile服务器上。

经常换电脑,或者说笔记本和台式机上无缝实时拷贝,或者说修改文档,那是相当的好用。

花费总共:二级域名不用钱 + Micro SD + U盘 + Raspberry Pi 2 = 0 + 35 + 40 + 199 = 274

像我这样装个比,买个*级域名也就 15一年,原谅我qiong只买的起 .cc 结尾的。总工 274 就能搭建一个实时共享使用起来像本地硬盘的网络共享存储。那是相当的值啊。这个软件支持 MAC ,安卓,IOS,Window,Linux,ARM 几乎全平台适用。强大的一逼。喜欢动手的可以搞搞。下次自己租个 Nas ,装个 Linux 在慢慢折腾一下更牛逼的 Nas 好了。

我们的宗旨是:花小钱,办大事。我是“美国短跑名将”琼斯。

谢谢各位听我在这吹了这么久的水,灰常感谢。


展开 收起

Xiaomi 小米 AX3000T 双频3000M 家用千兆Mesh路由器 Wi-Fi 6 白色 单个装

Xiaomi 小米 AX3000T 双频3000M 家用千兆Mesh路由器 Wi-Fi 6 白色 单个装

99元起

Xiaomi 小米 BE6500 Pro 双频6500M 家用千兆Mesh无线路由器 Wi-Fi 7

Xiaomi 小米 BE6500 Pro 双频6500M 家用千兆Mesh无线路由器 Wi-Fi 7

535元起

Ruijie 锐捷 雪豹 X30E 双频3000M 家用千兆Mesh无线路由器 Wi-Fi 6 白色 单个装

Ruijie 锐捷 雪豹 X30E 双频3000M 家用千兆Mesh无线路由器 Wi-Fi 6 白色 单个装

159元起

ZTE 中兴 AX3000 巡天版 双频3000M 家用千兆Mesh无线路由器 Wi-Fi 6 单个装 白色

ZTE 中兴 AX3000 巡天版 双频3000M 家用千兆Mesh无线路由器 Wi-Fi 6 单个装 白色

164元起

Redmi 红米 AX6000 双频5952M 家用千兆Mesh无线路由器 Wi-Fi 6 单个装黑色

Redmi 红米 AX6000 双频5952M 家用千兆Mesh无线路由器 Wi-Fi 6 单个装黑色

343元起

Xiaomi 小米 BE3600 2.5G版 3600M 双频千兆家用无线路由器 Wi-Fi 7 白色

Xiaomi 小米 BE3600 2.5G版 3600M 双频千兆家用无线路由器 Wi-Fi 7 白色

229元起

ASUS 华硕 RT-BE88U 双频7200M 家用Mesh无线路由器 Wi-Fi 7 黑色 单个装

ASUS 华硕 RT-BE88U 双频7200M 家用Mesh无线路由器 Wi-Fi 7 黑色 单个装

1999元起

Xiaomi 小米 AX6000 双频6000M 家用千兆Mesh无线路由器 Wi-Fi 6 单个装 黑色

Xiaomi 小米 AX6000 双频6000M 家用千兆Mesh无线路由器 Wi-Fi 6 单个装 黑色

299元起

HUAWEI 华为 BE3 Pro 双频3000M 千兆家用路由器 Wi-Fi 7 黑色

HUAWEI 华为 BE3 Pro 双频3000M 千兆家用路由器 Wi-Fi 7 黑色

253.55元起

Xiaomi 小米 BE7000 三频千兆Mesh无线路由器 Wi-Fi 7

Xiaomi 小米 BE7000 三频千兆Mesh无线路由器 Wi-Fi 7

406元起

HUAWEI 华为 AX2 Pro 双频1500M 家用千兆无线路由器 Wi-Fi 6 白色

HUAWEI 华为 AX2 Pro 双频1500M 家用千兆无线路由器 Wi-Fi 6 白色

130元起

ZTE 中兴 问天BE7200Pro+ 双频7200M 家用千兆Mesh无线路由器 WiFi 7 黑色

ZTE 中兴 问天BE7200Pro+ 双频7200M 家用千兆Mesh无线路由器 WiFi 7 黑色

579元起

TP-LINK 普联 BE5100 双频5100M 家用千兆Mesh无线路由器 Wi-Fi 7 黑色 单个装

TP-LINK 普联 BE5100 双频5100M 家用千兆Mesh无线路由器 Wi-Fi 7 黑色 单个装

279元起

TP-LINK 普联 飞流系列 TL-XDR5480 易展Turbo版 双频5400M 家用千兆Mesh无线路由器 WiFi 6 单个装 灰色

TP-LINK 普联 飞流系列 TL-XDR5480 易展Turbo版 双频5400M 家用千兆Mesh无线路由器 WiFi 6 单个装 灰色

369元起

HUAWEI 华为 Q6 网线版 双频3000M 千兆Mes无线分布式路由器 Wi-Fi 6 一母三子装 白色

HUAWEI 华为 Q6 网线版 双频3000M 千兆Mes无线分布式路由器 Wi-Fi 6 一母三子装 白色

408.8元起

ZTE 中兴 巡天AX3000Pro+ 双频3000M 家用千兆Mesh无线路由器 Wi-Fi 6 白色 单个装

ZTE 中兴 巡天AX3000Pro+ 双频3000M 家用千兆Mesh无线路由器 Wi-Fi 6 白色 单个装

269元起

文中相关商品

24评论

  • 精彩
  • 最新
  • 1399路由器还穷。。。

    校验提示文案

    提交
    说起这个路由器,又能吹上一宿了。 [喜极而泣] ,不过想想现在心中都有一万头小动物奔过的痕迹。

    校验提示文案

    提交
    收起所有回复
  • 感觉有梅林,88u直接插个u盘,ftp访问,易用性上和这个没多大差距啊,Raspberry Pi的作用体现在哪里?

    校验提示文案

    提交
    易用性还是ftp差一点,不过数据转移方便,优盘一拔,到哪都能识别。不过我的树莓派里面还搭了一个博客, HA+HB,还有一个网页访问的ftp。后期还要很多服务可以折腾。可玩性还是很高的。

    校验提示文案

    提交
    收起所有回复
  • seafile的存储模式不建议个人搞,因为一旦出问题,它的文件都不是完整的,有很多时候挺折腾人的

    校验提示文案

    提交
    他是通过block,分块存储的。啥东西都要备份,给这seafile做备份,又能开一篇文章说了。哈哈。我还用的有备份软件。就是不想丢数据。不想再给自己唱凉凉了,多么痛的领悟。 [装大款] [装大款] [装大款]

    校验提示文案

    提交
    而且分块存储还有一个问题,就是想要访问文件,必须要经过客户端。如果存个视频照片什么的,就不要想在电视上面观看了。

    校验提示文案

    提交
    还有3条回复
    收起所有回复
  • 总是弄不明白这种 靠百度云过活

    校验提示文案

    提交
    只能说不太相信这种网盘,除非你把数据加密,再同步到网盘还是可以的。而且这个也仅局限于数据备份而已。没有达到预期的目的

    校验提示文案

    提交
    只觉菜鸟的网络世界没有隐私 [喜极而泣]

    校验提示文案

    提交
    收起所有回复
  • 这还穷,我等只能撸撸K3了

    校验提示文案

    提交
    我去 k3要1999,我等只能仰视了

    校验提示文案

    提交
    收起所有回复
  • 琼斯可是女的............

    校验提示文案

    提交
    "穷死"不分男女 [苦恼]

    校验提示文案

    提交
    收起所有回复
  • 我也是进来说:穷还用这么好的路由器 [鬼脸]

    校验提示文案

    提交
  • 不说白的威联通和群晖的入门版也就1k出头 黑裙几百块也能搞定了 性能不比usb2.0好多了

    校验提示文案

    提交
  • 过段时间你就会觉得还是给上NAS,然后再过一段时间你会发现除了群晖没一个能打,最后你会发现不买群晖plus系列就有种被欺骗的感觉。 [难过]

    校验提示文案

    提交
    QNAP还是不错的选择了

    校验提示文案

    提交
    看中了铁威马准备入怎么办?

    校验提示文案

    提交
    收起所有回复
  • 码农还是应该打赏的

    校验提示文案

    提交
  • 这个网盘如果断网了,本地还有吗?

    校验提示文案

    提交
提示信息

取消
确认
评论举报

相关好价推荐
查看更多好价

相关文章推荐

更多精彩文章
更多精彩文章
最新文章 热门文章
178
扫一下,分享更方便,购买更轻松