Merge pull request #336 from vito-L/master

translated by Vito
This commit is contained in:
vito-L 2013-11-03 03:48:34 -08:00
commit 433b8783d5
2 changed files with 292 additions and 293 deletions

View File

@ -1,293 +0,0 @@
Vito
Raspberry Pi: the Perfect Home Server
================================================================================
Ever since the announcement of the Raspberry Pi, sites all across the Internet have offered lots of interesting and challenging uses for this exciting device. Although all of those ideas are great, the most obvious and perhaps least glamorous use for the Raspberry Pi (**RPi**) is creating your perfect home server.
If you've got several different computers in need of a consistent and automated backup strategy, the RPi can do that. If you have music and video you'd like to be able to access from almost any screen in the house, the RPi can make that happen too. Maybe you have a printer or two you'd like to share with everyone easily? The Raspberry Pi can fill all those needs with a minimal investment in hardware and time.
**Raspberry Pi Benefits**
Low cost: for $35, the RPi model B is nearly a complete computer with 512MB of RAM, 100Mb Ethernet, an SD card slot, two USB ports, audio out and HDMI or RCA video out. I've seen HDMI cables that cost more than that.
Energy efficient: hardware costs are only one component of a server's expense, because you also need to consider the energy cost to keep the device running constantly. The services needed for home use aren't going to tax the CPU much, and most of the time it will just be idling, waiting for something to do. The RPi's ultra-low power components are a perfect fit for this workload, which helps keep your power bill down. My model B unit plus external hard drive consume only 8 watts total, while the old Athlon-based box it replaced drew 54 watts at idle. Assuming 10 cents per kilowatt hour, that puts the yearly power bill for an RPi at $7 vs. $47 for an Athlon-based machine. The RPi basically pays for itself in less than a year!
Low noise: because the RPi doesn't have fans or moving parts, the only component in your final configuration that generates noise or any appreciable heat will be the hard disk. If you're concerned about noise, enthusiast sites like [Silent PC Review][1] often include noise benchmarks in their storage reviews. My experience is that any modern drive is quiet enough to avoid detection anywhere there's something else already running (such as a media center, gaming console or other computer). If your home doesn't provide a lot of flexibility for wiring options, the RPi's small size, minimal thermal output and low-noise footprint may make it possible to sneak in a server where it was difficult to justify one in the past.
![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/large-550px-centered/u1002061/11454f1.jpg)
Figure 1. A Compact, but Highly Capable Home Server
New opportunities: a less tangible benefit is the simple joy of trying something new! For me, this was my first time really working on a Debian-based distribution, and it's probably the first time many Linux enthusiasts will have a chance to try an ARM-based architecture.
**Arranging the Hardware**
For a home server, you'll need a medium-size SD Flash card for local storage. It's possible to use a USB thumbdrive for booting, but that would use up one of the two precious USB slots. The Flash storage card doesn't need to be large, but the faster the better. I chose a name-brand SD card with an 8GB capacity and class 10 speed rating. For backups and multimedia files, a large hard drive with a USB dock is a must. I chose a 1.5TB hard drive and a Calvary EN-CAHDD-D 2-bay USB 2.0 hard drive dock. This dock has a feature to run two drives in RAID-0 mode, which could be useful someday. Finally, the RPi doesn't come with a power supply, but most smartphone chargers supply the required 5v-over-micro USB. To see if the RPi was fussy about the power source, I swapped through three different micro-USB cell-phone chargers for power supplies. I tried each one for about a week, with no issues on any of the units.
**Installing the Operating System**
Installing the RPi operating system is covered in extensive detail elsewhere, but here are a few home-server-specific tips, roughly in the order needed.
1) Get the Raspbian "Wheezy" install image directly from [http://www.raspberrypi.org/downloads][2], and copy it onto the SD card, using the steps listed on the site.
2) When booting the RPi for the first time, attach a keyboard, mouse and monitor. Don't forget to turn on the monitor before booting the RPi, so that it can detect the correct HDMI or composite output port.
3) The RPi has a nice "raspi-config" screen that you'll see on first boot. For a home server, the following selections will be useful:
- expand_rootfs: resizes the default 2GB OS image to fill the rest of the Flash card.
- change_pass: the default password is "raspberry", but something more secure than that would be better.
- Set your locale and timezone.
- memory_split: assign the minimum amount possible (16) to the GPU to leave as much room as possible for services.
- SSH: don't forget to enable the SSH server.
- boot_behaviour: turn off boot to desktop (again, to save memory for your services).
When finished, you'll be at the `pi@raspberrypi` prompt. The setup script can be re-run at any time via `sudo raspi-config`.
There are just a few more configuration items, and then the operating system is ready to go.
1) A static IP makes everything easier, so switch the network settings for eth0:
>> sudo nano -w /etc/network/interfaces
change the eth0 line `iface eth0 inet dhcp` to the following (modify to meet your home network setup):
======/etc/network/interfaces======
...
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
...
======/etc/network/interfaces======
2) Create a local user, and put it in the users and sudo group:
>> sudo adduser YOURUSERIDHERE
>> sudo usermod -a -G users YOURUSERIDHERE
>> sudo usermod -a -G sudo YOURUSERIDHERE
3) Update the system to ensure that it has the latest and greatest copies of all the libraries:
>> sudo apt-get update; sudo apt-get upgrade
4) At this point, you're ready to go headless! Shut down the PI:
>> sudo /sbin/shutdown -h now
Once it's down (monitor the green status LEDs on the RPi circuit board to know when it has finished shutting down), unplug the monitor, keyboard, mouse and power cord. Attach the USB storage, then restart the RPi by plugging the power back in.
5) Once the RPi starts up (again, those green LEDs are the clue to its state), you can ssh in to the RPi from any other machine on the network and finish all the configuration remotely from here on out (modify the following for your static IP):
`>> ssh YOURUSERIDHERE@192.168.1.10`
Congratulations, you have a working Raspberry Pi!
**Peripherals**
The first order of business is to get the external storage device mounted. Use dmesg to look for where the storage device was found—it almost certainly will be /dev/sda. I like using automounter to handle mounting removable storage devices, as it is more flexible about handing devices that may not be present or ready at boot time:
>> sudo apt-get install autofs
>> sudo nano -w /etc/auto.master
======/etc/auto.master======
...
/misc /etc/auto.misc
...
======/etc/auto.master======
>> sudo nano -w /etc/auto.misc
Note, my external storage device is formatted with ext4—modify this for your needs if required:
======/etc/auto.misc======
...
storage -fstype=ext4:/dev/sda1
...
======/etc/auto.misc======
>> sudo /etc/init.d/autofs restart
>> ls -lat /misc/storage
Optionally, create a symlink to shorten the path a smidgen:
>> ln -s /misc/storage /storage
**Backup Repository**
At the top of any home server feature list is providing rock-solid backups. With the RPi, this is pretty simple, due to the wide range of network-sharing options in Linux: Samba/CIFS for Windows machines, NFS for UNIX-based devices and even SFTP for more advanced backup clients like deja-dup. Because the RPi has only 100Mb Ethernet, and the storage device is on USB, it's not going to have super-fast transfer speeds. On the other hand, good backup clients run automatically and in the background, so it's unlikely that you'll notice the slightly slower transfer speeds.
My home network includes one Windows 7 machine. For it, I exported a backup directory on the RPi's external USB storage device via Samba. Because the backup utility in the basic version of Windows 7 doesn't support network drives as a backup destination, I used [SyncBack Free][3] to set up automated, daily backups.
Configuring Samba is simple.
1) Install the samba and common-bin library (which has the smbpasswd utility):
>> sudo apt-get install samba samba-common-bin
2) Use `smbpasswd` to let your local ID have access:
>> sudo smbpasswd -a YOURUSERIDHERE
3) Edit the samba configuration file:
>> sudo nano -w /etc/samba/smb.conf
4) Change the `workgroup = WORKGROUP` line to match your Windows workgroup name.
5) Comment out or delete the [homes] and [printers] share. (Printer sharing will be done later via direct CUPS access.)
6) Add an entry for the Windows backup paths. Here's my example, which I placed at the bottom of the file:
======/etc/samba/smb.conf======
...
[win7pc]
comment=Backup for windows PC
path=/storage/win7pc
writeable=Yes
create mask=0777
directory mask=0777
browsable=Yes
public=Yes
valid users=YOURUSERIDHERE
...
======/etc/samba/smb.conf======
7) Restart Samba to implement your edits:
>> sudo /etc/init.d/samba restart
8) Test connectivity from the Windows machine by mapping a network drive from the file explorer.
For Linux devices, deja-dup is brilliantly simple to set up and use. It's been installed by default on both my Fedora 18 and Ubuntu 12.10 installs. While the package name is "deja-dup", the front end is simply called "Backup". Although the RPi easily could support NFS export, I've found that using deja-dup's SSH option is easier and more portable, and it eliminates the need for an additional service on the RPi. Specifying a deja-dup encryption password is probably a good idea, unless you like the idea of all your files walking off if someone pockets the storage drive:
>> sudo mkdir /storage/linuxlaptop
>> sudo chown -R YOURUSERIDHERE:YOURUSERIDHERE /storage/linuxlaptop
From the client Linux machine, launch the backup utility, choose "SSH" as the backup location, and enter the RPi's IP address and the storage location you just created. The first backup will be slow, but future runs will be sending only incremental changes, which is significantly faster.
![](http://www.linuxjournal.com/files/linuxjournal.com/ufiles/imagecache/medium-350px-centered/u1002061/11454f2.png)
Figure 2. Deja-dup Client Setup
**Multimedia Server: DLNA**
Now that everyone's files are backed up safely, let's move on to some fun! A DLNA server will give you a central place to store your movies, music and pictures. From this central repository, DLNA clients from every screen in the house can play back this content with ease.
At least, that's the promise. The reality is that the DNLA specs don't quite nail down many important things like which formats or encodings are supported. Each client typically has a slightly different idea of what formats and server features it would like to support. A much higher-power server might be able to transcode local content to device-supported formats on the fly, but that's not possible on the RPi, and the on-the-fly transcoding often messes up other features like pause, fast-forward and rewind. In general, higher-powered devices like the PS3, Xbox and WD TV devices can handle most formats without any transcoding. Lower-end devices like smart TVs or Blu-ray players support a much more limited list of codecs.
For the RPi, your best bet is simply to encode to the standards your primary DLNA device supports and then test your other DLNA clients. If they won't play nicely, the tips in the next section may help. In my case, my PlayStation 3 acts as the DLNA client, which plays nicely with the compact .m4v files generated by Handbrake.
Minidlna is a great choice for the RPi DLNA server. It's already in the Raspbian distribution, is quite simple to set up and uses minimal server resources while running:
>> sudo apt-get install minidlna
>> sudo nano -w /etc/minidlna.conf
Here are the relevant sections of my /etc/minidlna.conf:
...
# I found keeping video + audio in different paths helpful
media_dir=V,/storage/dlna/video
media_dir=A,/storage/dlna/music
...
presentation_url=http://192.168.1.10:8200/
...
friendly_name=MyRPi
...
# Since I add new media infrequently, turning off
# inotify keeps minidlna for polling for
# content changes. It's simple enough to run
# sudo /etc/init.d/minidlna force-reload
# when new content is added.
inotify=no
Once done editing, tell minidlna to restart and rescan for content:
>> sudo /etc/init.d/minidlna force-reload
Minidlna has the ability to provide movie-poster thumbnails for your movies for devices that support it (like the PS3). It makes finding a specific movie when scrolling through dozens of movie files much more convenient. I've found that the most compatible file layout is to have one directory per movie, containing just the movie file plus the thumbnail image named "Cover.jpg". Using a format like "MovieName.m4v" and "MovieName.jpg" works fine for the PS3, but it breaks VLC (if you can convince the VLC uPNP plugin to find the server in the first place).
From the PS3, you can test connectivity by going to "Video" on the XMB bar. The "friendly_name" you set previously should be visible when scrolling down in the Video section. If you cant find it, test to ensure that Minidlna is up by going to http://192.168.1.10:8200/ with a Web browser.
**Multimedia for Non-DLNA Devices**
Once you get DNLA working with some of your devices, you may find devices it doesn't want to work with, so a multimedia plan B is a good idea. The nginx Web server has an MP4 plugin that tries to improve streaming over plain-old HTTP, but browser playback performance varied widely, and fast-forwarding within a movie didn't work consistently either. It seems like the lowest common denominator for multimedia sharing across fussy or non-DLNA devices is a good-old-fashioned Samba share with guest read-only access.
Here's an sample section from /etc/samba/smb.conf:
[dlna]
path=/storage/dlna
read only=yes
browsable=yes
public=yes
After defining the share and restarting Samba (`sudo /etc/init.d/samba restart`), you can start to test out your clients.
I tested the following clients with a mix of videos encoded with Handbrake as m4v files:
- Android 4.0.4 phone: "ES File Explorer" with "ES Media Player" (player comes with install).
- Android 4.1.2 tablet: "ES File Explorer" with "ES Media Player" (player comes with install).
- Linux devices: automount ://192.168.1.10/dlna, then use VLC or MPlayer.
- Windows: mount //192.168.1.10:/dlna, then use VLC.
All devices were able to start playing almost instantly and fast-forward with no delays.
**Print Server**
The RPi runs CUPS quite well, so it's easy to share an older printer that doesn't have native networking features.
Install CUPS and any packages needed by your printer. I needed hplip-cups since I have an HP inkjet printer:
>> sudo apt-get install cups hplip-cups
Update the "Listen" line and add the `Allow @LOCAL` block to the Location directives as shown below (so you can use other machines on your LAN to administer CUPS):
======/etc/cups/cupsd.conf======
#Listen localhost:631 #Comment this out
Listen 192.168.1.10:631 #Add this line
...
<Location />
Order allow,deny
Allow @LOCAL
</Location>
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow @LOCAL
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow @LOCAL
</Location>
======/etc/cups/cupsd.conf======
Add your local ID to the lpadmin group so you can administer CUPS:
>> sudo usermod -a -G lpadmin YOURUSERIDHERE
Restart CUPS:
>> sudo /etc/init.d/cups restart
Then, go to http://192.168.1.10:631/ and click "Adding Printers and Classes" to set up your printer. My printer was auto-discovered on the USB, so all I had do to was click "share". Also access https://192.168.1.10:631/admin, and make sure to check "Share printers connected to this system".
Once you're done, you can set up your clients the usual way. My Linux clients auto-discovered the printer and picked the right printer drivers once I entered the hostname. On my Windows 7 machine, once I selected "Network Printer", I had to click "The printer that I want isn't listed", select "Select a shared printer by name" and then enter the URL from the CUPS Web interface: http://192.168.1.10:631/printers/HP_J4500.
**Conclusion**
With a minimal amount of additional hardware and configuration, the Raspberry Pi can be a highly capable, compact home server. It can bring the wide range of enterprise services offered by Linux into a home environment with minimal hardware expense.
--------------------------------------------------------------------------------
via: http://www.linuxjournal.com/content/raspberry-pi-perfect-home-server
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
[1]:http://www.silentpcreview.com/
[2]:http://www.raspberrypi.org/downloads
[3]:http://www.2brightsparks.com/freeware/freeware-hub.html

View File

@ -0,0 +1,292 @@
树莓派Raspberry Pi完美的家庭服务器
---
自从树莓派发布公告,所有在互联网上的网站为此令人兴奋的设备提供了很多有趣和具有挑战性的使用方法。虽然这些想法都很棒,最明显和至少最迷人的是用树莓派( **RPi** )创建你的家庭服务器。
如果你有几个不同的电脑需要同步和自动化备份RPI可以做到。如果你有音乐和视频在房子里你想要能够从几乎任何屏幕上访问到RPi也可以让这种事情发生。也有你有一个或两个打印机你想要很容易的共享其中一个树莓派在硬件和时间上用最小投资就能满足你的这些需求。
**树莓派的好处**
低成本35美元约合242元RMBRPi模型B接近一台完整的电脑512M内存100Mb以太网SD卡插槽2个USB接口音频输出和HDMI或RCA视频输出。我见过的HDMI电缆其费用超过RPI。
能源效率硬件成本只是服务器费用的一部分因为你需要考虑能源成本去不断运行设备。多CPU所需的家用不会去支付大部分时间它都处于空闲中等待做什么。RPi's超低功率组件非常适合这个工作负载这有助于使你的电力账单下降。我的模型B单个加上外部硬盘消耗总共只有8瓦while the old Athlon-based box it replaced drew 54 watts at idle.假设10美分每千瓦一小时这使得一个RPi每年电力账单在7美元。一个基于速龙的机器是47美元。在不到一年的时间里RPI基本上支付其自身。
低噪音因为RPi没有风扇和移动部件在你最终配置中的唯一组件上生成噪音或任何明显热量的将在硬盘上。如果你担心噪音像[Silent PC Review][1]发烧友网站经常在他们的评论中包括噪声基准。我的经验是现代驱动器是安静的足够避免检测任何地方有其他东西已在运行如媒体中心游戏控制台或其他电脑。如果你家里没有为布线提供更多的灵活性RPi's的小尺寸最小热输出和低噪音排放量也许使它可能偷偷的在服务器中在过去很难证明。
![](https://github-camo.global.ssl.fastly.net/37922c152a6abd82b42ca0a965a311e8914fbb16/687474703a2f2f7777772e6c696e75786a6f75726e616c2e636f6d2f66696c65732f6c696e75786a6f75726e616c2e636f6d2f7566696c65732f696d61676563616368652f6c617267652d35353070782d63656e74657265642f75313030323036312f313134353466312e6a7067)
图1,一个紧凑但高能力的家庭服务器
新机会一个不那么有实质的好处是简单快乐的尝试新事物对我来说我第一时间工作在基于Debian的发行版它大概在第一时间有很多linux爱好者将尝试改变一个基于ARM的体系结构。
**布置硬件**
对于一个家庭服务器来说你将为本地存储需要一个中等大小的SD闪存卡。它可以使用一个USB引导但那会用两个宝贵的USB插槽之一。闪存卡不需要很大但是速度越快越好。我选择了一个名牌SD卡8GB容量和10级速度等级。为了备份和多媒体文件一个大的硬盘与USB连接插槽是必须的。我选择一个1.5TB的硬盘和一个Calvary EN-CAHDD-D 2-bay USB 2.0硬盘连接插槽。这个连接插槽有个功能在RAID-0模式中运行两个驱动器总有一天会有用。最后RPi不带电源线但大多数智能手机充电器电源线所需的5v以上微型USB。看看RPi是否在意电源我为电源已换了三个不同的微型USB手机充电器。我在这周里尝试了每一个在任何一个上都没有问题。
**安装操作系统**
安装RPi操作系统在其他地方涵盖广泛细节但是有一些家庭服务器特定的提示大致按需要的顺序。
1直接通过[http://www.raspberrypi.org/downloads][2]获取Raspbian "Wheezy"安装镜像并复制到SD卡用网站上已列出的步骤。
2第一次引导RPi时附加一个键盘鼠标和显示器。在引导RPi之前别忘打开显示器可以检测更正HDMI或合并输出端口。
3RPi有一个很好的"raspi-config"屏幕,在第一次启动时你会看到。对于家庭服务器来说,以下选择将会有用:
- expand_rootfs调整默认2GB OS镜像来填充剩余的闪存卡。
- change_pass默认密码是"raspberry",但是,比这更安全的会更好。
- 设置你的地点和时区。
- memory_split分配最小值尽可能为GPU服务留下更多空间。
- SSH别忘开启SSH服务。
- boot_behaviour关闭启动至桌面再次为你的服务保存内存
完成后,你将在 `pi@raspberrypi` 提示符下。安装脚本可以在任何时间通过 `sudo raspi-config` 重新运行。
只是一些配置项,然后操作系统已经准备就绪。
1一个静态IP让一切变得更容易切换eth0的网络设置
>>> sudo nano -w /etc/network/interfaces
更改eth0 `iface eth0 inet dhcp` 行,如下所示(更改以满足你的家庭网络设置):
======/etc/network/interfaces======
...
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
...
======/etc/network/interfaces======
2创建本地用户并加入到users组和sudo组
>> sudo adduser YOURUSERIDHERE
>> sudo usermod -a -G users YOURUSERIDHERE
>> sudo usermod -a -G sudo YOURUSERIDHERE
3更新系统确保所有的库是最新最好的
>> sudo apt-get update; sudo apt-get upgrade
4这里准备无脑吧关闭PI
>> sudo /sbin/shutdown -h now
一旦关闭显示器绿色指示灯在RPi电路板知道当完成关闭拔下显示器键盘鼠标和电源线。附加USB存储器然后插回电源重启RPi。
5一旦RPi开启再次这些绿色指示灯提示其状态你可以从远程网络上从任何其他机器ssh到RPi并完成所有的配置更改以下命令里的IP为你的静态IP
`>> ssh YOURUSERIDHERE@192.168.1.10`
祝贺你,有了一个工作中的树莓派!
**外围设备**
第一要务是要装入外围设备。用dmesg来寻找你的存储设备会发现--几乎可以肯定是/dev/sda。我喜欢使用自动挂载去处理挂载远程存储设备因为关于交换设备可能不存在或准备在启动时间更灵活
>> sudo apt-get install autofs
>> sudo nano -w /etc/auto.master
======/etc/auto.master======
...
/misc /etc/auto.misc
...
======/etc/auto.master======
>> sudo nano -w /etc/auto.misc
注意我的外部存储设备是ext4格式--如果需要为你需求更改这个:
======/etc/auto.misc======
...
storage -fstype=ext4:/dev/sda1
...
======/etc/auto.misc======
>> sudo /etc/init.d/autofs restart
>> ls -lat /misc/storage
可选,创建一个符号链接至短路径:
>> ln -s /misc/storage /storage
**备份仓库**
在任何家庭服务器功能列表的顶端是提供坚如磐石的备份。RPi这是漂亮而简单在Linux中基于范围广泛的网络共享选项Samba/CIFS用于Windows机器NFS用于基于UNIX的设备并且甚至SFTP用于更多先进的备份客户端像deja-dup。由于RPi只有100MB以太网和在USB上的存储设备它没有非常快的传送速度。在其他方面好的备份客户端在后台自动运行所以它不会注意稍慢的传输速度。
我的家庭网络包括一台Windows7电脑。对于它我通过Samba在RPi's外部USB存储设备上导出一个备份目录。因为备份程序在Windows7的基础版本不支持网络设备作为一个备份目标我使用[SyncBack Free][3]去设置使其自动化,每日备份。
简单设置Samba。
1安装samba和common-bin库具有smbpasswd效用
>> sudo apt-get install samba samba-common-bin
2使用 `smbpasswd` 让你的本地ID能访问
>> sudo smbpasswd -a YOURUSERIDHERE
3编辑samba配置文件
>> sudo nano -w /etc/samba/smb.conf
4)更改 `workgroup = WORKGROUP` 行去匹配你的Windows工作组名称。
5注释掉或删除[homes]和[printers]共享。(打印机通过CUPS访问。)
6为Windows备份路径增加一个条目。这是我的示例放置在该文件的底部
======/etc/samba/smb.conf======
...
[win7pc]
comment=Backup for windows PC
path=/storage/win7pc
writeable=Yes
create mask=0777
directory mask=0777
browsable=Yes
public=Yes
valid users=YOURUSERIDHERE
...
======/etc/samba/smb.conf======
7重启Samba使你的编辑生效
>> sudo /etc/init.d/samba restart
8从Windows机器文件资源管理器通过映射一个网络设备测试连通。
对Linux设备来说deja-dup是智能简单的设置和使用。它被默认安装在我的Fedora 18和Ubuntu 12.10上。包的名称是“deja-dup”前端简单的称为“Backup备份”。虽然RPi很容易支持NFS导出我发现使用deja-dup的SSH选项更容易更方便在RPi上它消除了对额外服务的需要。指定一个deja-dup加密密码是一个好主意除非你喜欢的好主意全都进入别人的存储设备
>> sudo mkdir /storage/linuxlaptop
>> sudo chown -R YOURUSERIDHERE:YOURUSERIDHERE /storage/linuxlaptop
从linux客户端启动备份程序选择“SSH”作为备份位置输入RPi's IP地址和你创建的存储位置。首次备份会很慢但是未来运行将只发送增量变化速度更快。
![](https://github-camo.global.ssl.fastly.net/08111990037d492b22d45de49816f5bc2b02933a/687474703a2f2f7777772e6c696e75786a6f75726e616c2e636f6d2f66696c65732f6c696e75786a6f75726e616c2e636f6d2f7566696c65732f696d61676563616368652f6d656469756d2d33353070782d63656e74657265642f75313030323036312f313134353466322e706e67)
图2,Deja-dup客户端设置
**多媒体服务器DLNA**
现在每个人的文件安全的备份。让我们继续一些乐趣一个DLNA服务器将给你一个集中地去存储你的电影音乐和图片。DLNA客户端可以在房子的每个屏幕不费力的重放这个内容。
至少这是承诺。现实情况是DLNA规格不相当使很多重要的事情固定像格式或编码。每个客户端通常希望支持什么格式和服务器功能的一个稍微不同的想法。很多高功率服务器也许能转码本地内容到移动设备支持的格式但是在RPi上不是问题在即时烧录转码上经常扰乱其他功能如暂停快进和倒带。一般情况下高功率设备如PS3,Xbox和WD TV设备大多数格式无需任何转码。低端设备如智能TVs或Blu-ray播放器支持更多的编码限制列表。
对于RPi来说最好的办法是简单的进行标准编码去支持你的初级DLNA设备然后测试你的其他DLNA客户端。如果没有完美播放在下一节提示中也许有帮助。在我的案例中我的PlayStation 3充当DLNA客户端which plays nicely with the compact .m4v files generated by Handbrake。对于DLNA服务器Minidlna是个很好的选择。它已经在Raspbian发行版中易于设置和使用最小服务资源运行
>> sudo apt-get install minidlna
>> sudo nano -w /etc/minidlna.conf
这是我/etc/minidlna.conf文件的有关部分
...
# I found keeping video + audio in different paths helpful
media_dir=V,/storage/dlna/video
media_dir=A,/storage/dlna/music
...
presentation_url=http://192.168.1.10:8200/
...
friendly_name=MyRPi
...
# Since I add new media infrequently, turning off
# inotify keeps minidlna for polling for
# content changes. It's simple enough to run
# sudo /etc/init.d/minidlna force-reload
# when new content is added.
inotify=no
一旦完成编辑告诉minidlna重启并重新扫描内容
>> sudo /etc/init.d/minidlna force-reload
Minidlna有能力为你的设备支持的电影提供电影海报缩略图像PS3。这让找到一个特定的电影在滚动几十个电影文件时更方便。我发现最兼容文件布局的是每个电影一个目录只是包含影片文件的缩略图图像命名为“Cover.jpg”。使用像"MovieName.m4v"和"MovieName.jpg"的格式为PS3正常工作。但它破坏VLC如果你能说服VLC uPNP插件首先查找服务器
通过PS3你可以通过转到在XMB栏上的"Video"测试连通性。当视频向下滚动时,你以前设置的"friendly_name"应该是可见的测试确保Minidlna是通过浏览器转到http://192.168.1.10:8200/。
**对于非 DLNA 设备多媒体**
一旦DLNA与你的设备工作你会发现它不想工作所以多媒体计划B是个好主意。Nginx网站服务器有一个MP4插件尝试改善流传输plain-old HTTP但是浏览器重放性能差别很大快进在一部电影里也一贯不工作。它看起来像为多媒体共享或非 DLNA 设备最低的共同标准是好旧的老式的 Samba 共享与来宾只读访问。
这是/etc/samba/smb.conf的部分示例
[dlna]
path=/storage/dlna
read only=yes
browsable=yes
public=yes
定义所占份额和重启Samba后 `sudo /etc/init.d/samba restart` ),你可以开始测试你的客户端。
我测试了以下客户端与一个混合视频编码with Handbrake作为m4v文件
- Android 4.0.4手机:"ES File Explorer"与"ES Media Player"(播放器附带安装)。
- Android 4.1.2平板电脑:"ES File Explorer"与"ES Media Player"(播放器附带安装)。
- Linux设备自动挂载//192.168.1.10/dlna然后使用VLC或MPlayer。
- Windows挂载//192.168.1.10:/dlna然后使用VLC。
所有设备都能几乎立即开始播放和快进没有延迟的情况。
**打印服务器**
RPi运行CUPS相当不错所以它易于共享一个较旧的没有本机网络功能的打印机。
安装你的打印机所需的CUPS和任何软件包。我需要hplip-cups因为我也有HP喷墨打印机
>> sudo apt-get install cups hplip-cups
更新“Listen”行和增加 `Allow @LOCAL` 到位置指令如下所示你可以使用其他机器在你的LAN上去管理CUPS
======/etc/cups/cupsd.conf======
#Listen localhost:631 #Comment this out
Listen 192.168.1.10:631 #Add this line
...
<Location />
Order allow,deny
Allow @LOCAL
</Location>
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow @LOCAL
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow @LOCAL
</Location>
======/etc/cups/cupsd.conf======
添加你的本地ID到lpadmin组就能管理CUPS
>> sudo usermod -a -G lpadmin YOURUSERIDHERE
重启CUPS
>> sudo /etc/init.d/cups restart
然后转到http://192.168.1.10:631/并点击 "Adding Printers and Classes"去设置你的打印机。我的打印机是自动发现USB所以我的一切被点击“share”。同样访问https://192.168.1.10:631/admin确保检查“Share printers connected to this system共享打印机连接至这个系统”。
一旦你做完你可以用通常的方式设置你的客户端。一旦我输入主机名我的Linux客户端自动发现打印机并挑选正确的打印机设备。在我的Windows7的机器上一旦我选择“Network Printer网络打印机我必须点击“The printer that I want isn't listed我想要的打印机未列出选择“Select a shared printer by name通过名称选择共享的打印机然后从CUPS网络接口输入URLhttp://192.168.1.10:631/printers/HP_J4500。
**结论**
用最少的额外的硬件和配置树莓派可以是高可用的简洁的家庭服务器。它通过Linux进入家庭环境与最少硬件费用带来提供广泛的企业服务。
--------------------------------------------------------------------------------
via: http://www.linuxjournal.com/content/raspberry-pi-perfect-home-server
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
译者:[译者ID](https://github.com/vito-L) 校对:[校对者ID](https://github.com/校对者ID)
[1]:http://www.silentpcreview.com/
[2]:http://www.raspberrypi.org/downloads
[3]:http://www.2brightsparks.com/freeware/freeware-hub.html