Cov txheej txheem:

2 Raspberry Pis kom yooj yim thiab Pheej Yig RAID Chaw Taws Teeb: 19 Cov Kauj Ruam
2 Raspberry Pis kom yooj yim thiab Pheej Yig RAID Chaw Taws Teeb: 19 Cov Kauj Ruam

Video: 2 Raspberry Pis kom yooj yim thiab Pheej Yig RAID Chaw Taws Teeb: 19 Cov Kauj Ruam

Video: 2 Raspberry Pis kom yooj yim thiab Pheej Yig RAID Chaw Taws Teeb: 19 Cov Kauj Ruam
Video: Часы G Shock до 100 долларов-15 лучших часов Casio G Shock до 100 дол... 2024, Hlis ntuj nqeg
Anonim
2 Raspberry Pis rau RAID Yooj Yim thiab Pheej Yig
2 Raspberry Pis rau RAID Yooj Yim thiab Pheej Yig
2 Raspberry Pis rau RAID Yooj Yim thiab Pheej Yig
2 Raspberry Pis rau RAID Yooj Yim thiab Pheej Yig

Lub Hom Phiaj

  1. Thaum muaj xwm txheej tshwm sim hauv tsev, kuv xav kom muaj peev xwm rov qab tau kuv cov ntaub ntawv digital loj (duab, daim ntawv qhia tus kheej, thiab lwm yam), thiab xaiv tau qhov sib koom lawv.
  2. Kuv xav qhia qhov kev daws teeb meem no nrog lwm tus neeg (ib tus neeg kuv ntseeg, niam txiv, lossis phooj ywg)
  3. Kuv tsis xav kom nyob ntawm huab huab (kev tso npe, tus nqi, hloov pauv GTC, thiab lwm yam)

Txoj Cai

  1. Tsim 2 lub tshuab khaws khoom zoo ib yam, muab tso rau hauv 2 qhov chaw sib txawv (piv txwv li, 2 lub tsev).
  2. Muab lub chaw cia khoom tshwj xeeb rau txhua qhov chaw ntawm txhua lub tshuab.
  3. Ua ntu zus ua ke 2 qhov chaw cia khoom.

Khoom siv

Kho vajtse

Txhua lub tshuab muaj:

  • 1x Raspberry Pi 4 B 1GB
  • 1x lub thawv rau Raspberry Pi 4
  • 1x fais fab mov USB C 5V 3A
  • 1x SD daim npav Kingston SDC10/16GB
  • 1x NAS HDD 1To WD Red Mobile
  • 1x HDD lub thawv BX-2525U3

Software Windows

  • balenaEtcher
  • Raspbian buster desktop puv
  • mobaxterm
  • VNC saib (xaiv tau)

Cov pob Raspbian

  • Rsync
  • samba ua

Kauj ruam 1: Pro & Cons

Pro & Cons
Pro & Cons

Zoo

  1. Qhov kev daws teeb meem no pheej yig: Kuv tsis muaj tus nqi xaj thiab khoom siv kho vajtse yog qhov yooj yim.
  2. Qhov "RAID nyob deb" no yooj yim heev ua. Kuv tsis xav tau cov ntaub ntawv ntxiv lossis cov cuab yeej los ua nws.
  3. Raspberry Pi tuaj yeem siv rau kev thov ntxiv xws li chaw nruab nrab (kodi,…), lossis domotic (jeedom, domoticz,…).
  4. Kuv cov ntaub ntawv tsis muaj nyob ntawm huab huab uas tuaj yeem yog lub hom phiaj rau cov ntaub ntawv nyiag loj.
  5. Siv lub HDD ntawm 1To, qhov nruab nrab kev siv hluav taws xob zoo ib yam li huab.
  6. Firewall ntawm kuv lub router thiab SSH encryption ntawm kuv qhov kev sib txuas ruaj ntseg cov ntaub ntawv sib pauv.

Qhov tsis zoo/txhim kho

  1. Lwm tus neeg muaj daim ntawv theej ntawm kuv cov ntaub ntawv. Hauv kuv qhov xwm txheej, tus neeg no yog los ntawm kuv tsev neeg yog li kuv tsis quav ntsej.
  2. Kuv siv lub neej ntawd "pi" tus account, nrog tus lej zais rau ob lub tshuab. Kuv tuaj yeem ruaj ntseg nkag tau me ntsis ntxiv los ntawm kev siv tus lej tshwj xeeb cais ntawm txhua sab es tsis yog tus lej "pi".
  3. Kuv vam khom kuv tus muab kev pabcuam Internet thiab SSH encryption rau kev nyab xeeb ntawm kev sib txuas ntawm 2 lub tsev. Kev tshawb fawb tuaj yeem ua tau los txhim kho qib kev nyab xeeb.
  4. Txog tam sim no, Kuv tsuas yog ua 2 ntu rau ib tus tsav. Qhov faib thib 3 me me (~ 5Go) tuaj yeem muaj txiaj ntsig zoo rau lwm yam haujlwm Raspbian, txhawm rau khaws daim npav µSD.

Kauj ruam 2: Npaj SD: Upload Raspbian

Los ntawm lub khoos phis tawj (Windows 10 hauv kuv rooj plaub), ua raws cov lus qhia teeb tsa ua haujlwm (https://www.raspberrypi.org/downloads/raspbian/) txhawm rau nruab "Raspbian Buster nrog desktop".

Ntxiv cov ntaub ntawv khoob hu ua "ssh" hauv "/boot/" disk

Ntxiv cov ntaub ntawv npe "wpa_supplicant.conf" hauv "/boot/" disk

Qhib wpa_supplicant.conf thiab sau cov ntawv:

teb chaws = US

ctrl_interface = DIR =/var/run/wpa_supplicant GROUP = netdev update_config = 1 network = {ssid = "MyWiFiNetwork" psk = "aVeryStrongPassword" key_mgmt = WPA-PSK}

Txuag thiab kaw cov ntawv.

Kauj Ruam 3: Npaj SD: Kho Daim Npav

Npaj SD: Kho Daim Npav
Npaj SD: Kho Daim Npav

Ntxiv cov ntaub ntawv khoob hu ua "ssh" hauv "/boot/" disk

Ntxiv cov ntaub ntawv npe "wpa_supplicant.conf" hauv "/boot/" disk

Qhib wpa_supplicant.conf thiab sau cov ntawv:

teb chaws = US

ctrl_interface = DIR =/var/run/wpa_supplicant GROUP = netdev update_config = 1 network = {ssid = "MyWiFiNetwork" psk = "aVeryStrongPassword" key_mgmt = WPA-PSK}

Txuag thiab kaw cov ntawv.

Kauj Ruam 4: Npaj Raspberry Pi

Ntxig koj daim npav SD hauv Pi

Fais fab Raspberry Pi, xaiv txoj hauv kev qhib lub desktop:

  1. Siv hdmi cable, tshuaj ntsuam, keyboard thiab nas
  2. Siv VNC los ntawm koj lub computer.

Yog xav paub ntxiv, mus saib

Kauj Ruam 5: Txoj Kev 1: Txuas rau Pi Siv Screen, Keyboard, Mouse

Txoj Kev 1: Txuas rau Pi Siv Screen, Keyboard, Mouse
Txoj Kev 1: Txuas rau Pi Siv Screen, Keyboard, Mouse
Txoj Kev 1: Txuas rau Pi Siv Screen, Keyboard, Mouse
Txoj Kev 1: Txuas rau Pi Siv Screen, Keyboard, Mouse

Txuas lub Raspberry Pi chaw nres nkoj HDMI0 rau lub vijtsam nrog micro-hdmi rau hdmi cable

Txuas lub usb keyboard thiab nas (lossis lub wireless mini keyboard zoo li "Rii Mini i8 Wireless")

Txuas lub USB C fais fab mov thiab txhawb nqa Raspberry Pi.

Raspbian yuav tsum pib ntawm koj lub vijtsam.

Thaum lub desktop tshwm, teb cov lus teeb tsa kom ua tiav kev teeb tsa ntawm koj Pi.

Kauj Ruam 6: Txoj Kev 2: Txuas rau Pi Siv VNC Los Ntawm Koj Lub Computer

Txoj Kev 2: Txuas rau Pi Siv VNC Los Ntawm Koj Lub Computer
Txoj Kev 2: Txuas rau Pi Siv VNC Los Ntawm Koj Lub Computer
Txoj Kev 2: Txuas rau Pi Siv VNC Los Ntawm Koj Lub Computer
Txoj Kev 2: Txuas rau Pi Siv VNC Los Ntawm Koj Lub Computer
Txoj Kev 2: Txuas rau Pi Siv VNC Los Ntawm Koj Lub Computer
Txoj Kev 2: Txuas rau Pi Siv VNC Los Ntawm Koj Lub Computer

Txuas Raspberry Pi mus rau koj lub network ethernet (los ntawm wifi lossis nrog ib kab).

Los ntawm koj lub khoos phis tawj, qhib Mobaxterm (lossis putty), pib txuas tshiab ssh txuas (nkag mus pi, tus lej nkag mus raspberry) thiab teeb tsa koj Pi:

ssh pib@raspberry_ip

sudo raspi-teeb tsa

  • hauv kev xaiv cuam tshuam / VNC: teeb tsa Yog
  • hauv Kev xaiv qib siab / Kev daws teeb meem: teeb tsa DMT Hom 82 1920x1080 1920x1080 60Hz 16: 9
  • hauv Kev xaiv Advanced / GL tsav tsheb: teeb tsa G1 Legacy Original non-GL desktop drive

Txuag thiab tawm raspi-teeb tsa

Reboot Pi:

sudo rov pib dua

Los ntawm koj lub khoos phis tawj, qhib VNC Viewer, thiab txuas rau Pi siv tus ID nkag mus pi, tus password raspberry: Pi desktop yuav tsum tshwm.

Teb cov lus teeb tsa kom ua tiav kev teeb tsa ntawm koj Pi.

Thaum koj tau hloov tus Pi lo lus zais, VNC kev txuas tuaj yeem kaw. Pib dua nws siv koj tus password tshiab.

Kauj Ruam 7: Npaj HDD

Npaj HDD
Npaj HDD
Npaj HDD
Npaj HDD
  1. Txuas lub HDD rau koj lub computer.
  2. Qhib Windows tus thawj tswj hwm faib, xaiv koj HDD, thiab tsim 2 NTFS faib (lossis 3, yog tias koj xav tau qhov chaw me me los khaws cardSD daim npav). Piv txwv li, kuv npe 2 ntu "loic" thiab "vincent"
  3. Txuas lub HDD mus rau Pi: Raspbian yuav tsum tau txiav 2 lub disks ntawm lub desktop. Cov tsav tau txuas rau daim nplaub tshev/media/pi/loic/, thiab/media/pi/vincent/

Kauj Ruam 8: Kho Rsync: Tsim Synchro Script

Kho Rsync: Tsim Synchro Script
Kho Rsync: Tsim Synchro Script

qhib qhov kev ceeb toom ntawm Pi desktop

Hauv/tsev/pi/, tsim ib tsab ntawv:

mkdir/tsev/pi/scriptsnano/tsev/pi/ntawv/SB_sync

sau cov ntawv:

#!/bin/sh

######### CONFIGURER ########### ip_distante = "192.168.0.19" port_distant = "xxxxx" media_local = "/media/pi/loic" media_distant = "pi@$ { ip_distante}:/media/pi/loic "machine_locale =" RPi4_loic "machine_distante =" RPi4_vincent "############################ ## log_local = "/home/pi/SB_sync_logs" log_distant = "pi@$ {ip_distante}:/home/pi/SB_sync_logs" currentDate = `date+"%Y-%m-%d%T "` mkdir -p/ tsev/pi/SB_sync_logs #synchro de $ {machine_locale} $ {media_local}/vers $ {machine_distante} $ {media_distant}/echo $ currentDate> $ {log_local} /0.synchro_en_cours _ $ {machine_locale} _vers _ $ {machine_distante} echo " Synchronization en cours: de $ {machine_locale} $ {media_local}/ vers $ {machine_distante} $ {media_distant}/ ">> $ {log_local} /0.synchro_en_cours _ $ {machine_locale} _vers _ $ {machine_distante} $ {machine_distante} $ { media_distant}/">> $ {log_distant} /0.synchro_en_cours _ $ {machine_locale} _vers _ $ {machine_distante} echo" Compte `whoami`"> $ {log_local}/1. $ {machine_locale} _vers _ $ {machine_distante}.log echo "--------------- -Début: "` date +"%Y-%m-%d%T" `" ---------- ">> $ {log_local}/1. $ {machine_locale} _vers _ $ {machine_distante}.log/usr/bin/rsync -avhPS --chmod = a+rwx --delete -e "ssh -p $ {port_distant}" $ {media_local}/$ {media_distant}/2> & 1 >> $ {log_local} /1.${machine_locale}_vers_${machine_distante}.log

ncha "---------- Fin:" `date +"%Y-%m-%d%T "` "----------" >> $ {log_local}/ 1. $ {Machine_locale} _vers _ $ {machine_distante}.log

rm $ {log_local} /0.synchro_en_cours _ $ {machine_locale} _vers_ $ {machine_distante}

Kho kab 3 txog 7:

  • hloov "loic" thiab "vincent" los ntawm koj lub npe tsav
  • port_distant: rau tam sim no, siv 22 ua chaw nres nkoj nyob deb. Thaum kawg, koj yuav tsum hloov nws los ntawm lwm tus nqi uas koj xaiv (piv txwv: 34567)

txuag cov ntaub ntawv thiab tawm.

Kauj Ruam 9: Kho Rsync: Ua Synchro Ib Hnub Ib Hnub

Hauv qhov hais kom ua, qhib crontab:

sudo crontab -u pi -e

Thaum kawg ntawm cov ntawv, ntxiv cron:

0 1 * * */usr/bin/flock -xn /tmp/flocktmp.lock -c "/home/pi/scripts/SB_sync"

Hauv qhov cron no, tsab ntawv SB_sync yuav pib ua txhua hnub thaum 1:00 teev sawv ntxov. Xaiv lub sijhawm koj xav tau, tab sis hloov nws ntawm 2 lub tshuab, yog li 2 synchros yuav ua tiav ib qho tom qab ib qho.

Txuag thiab kaw cov ntawv.

Kauj ruam 10: Npaj Samba

Samba txuas lub linux cia rau windows network.

Qhib qhov sai thiab nruab pob khoom:

sudo apt-tau nruab samba samba-common-bin -y

Autorize tus account "pi" txhawm rau nkag mus rau Samba:

sudo smbpasswd -a pib

Txuag lub neej ntawd Samba teeb tsa cov ntaub ntawv:

cp /etc/samba/smb.conf /etc/samba/smb.old

Qhib cov ntawv:

sudo nano /etc/samba/smb.conf

Thiab thaum kawg ntawm cov ntawv, ntxiv cov kab no los teeb tsa koj lub zog kom faib:

[Cov ntaub ntawv LOIC]

tawm tswv yim = NAS de loic path =/media/pi/loic siv tau cov neeg siv = @users quab yuam pab pawg = cov neeg siv tsim daim npog ntsej muag = 0660 daim npog ntsej muag = 0775 nyeem nkaus xwb = tsis tuaj yeem tshawb pom = muaj pej xeem = yog

Txuag cov ntaub ntawv thiab tawm.

Kauj ruam 11: [Yeem tsis tau] Samba: teeb tsa Nyeem Ntawv nkag mus rau Network Drive Vincent

Qhib cov ntaub ntawv teeb tsa Samba:

sudo nano /etc/samba/smb.conf

Thiab thaum kawg ntawm cov ntawv, ntxiv cov kab no los teeb tsa lwm tsav uas koj xav nkag mus:

[DOCUMENTS VINCENT]

tawm tswv yim = thaub qab de vincent path =/media/pi/vincent siv tau cov neeg siv = @users quab yuam pab pawg = cov neeg siv tsim daim npog ntsej muag = 0660 daim npog qhov ncauj = 0775 nyeem nkaus xwb = yog tuaj yeem nkag tau = muaj pej xeem = yog

Txuag cov ntaub ntawv thiab tawm.

Kauj Ruam 12: [Yeem Tsis Tau] Samba: Nkag Mus Rau Log

Qhib cov ntaub ntawv teeb tsa Samba:

sudo nano /etc/samba/smb.conf

Thiab thaum kawg ntawm cov ntawv, ntxiv cov kab no nkag los ntawm lub qhov rais mus rau qhov xwm txheej synchro:

[LOG SYNCHRO] tawm tswv yim = "cav de synchro entre tshuab"

path =/home/pi/SB_sync_logs/siv tau cov neeg siv = @users quab yuam pab pawg = cov neeg siv tsim daim npog ntsej muag = 0660 daim npog ntsej muag = 0771 nyeem nkaus xwb = yog tuaj yeem nkag tau = muaj pej xeem = yog

Txuag cov ntaub ntawv thiab tawm.

Kauj Ruam 13: [Tsis teb los tau] Samba: Hide Useless Folder "/home/pi"

Qhib cov ntaub ntawv teeb tsa Samba:

sudo nano /etc/samba/smb.conf

Hauv cov ntawv, nrhiav kab hauv qab no thiab ntxiv ";" thaum pib los tawm tswv yim nws:

; [tsev]

; tawm tswv yim = Lub Tsev Qhia Ntawv; browseable = tsis muaj; nyeem nkaus xwb = yog; tsim daim npog ntsej muag = 0700; daim npog qhov ncauj = 0700; cov neeg siv raug = %S

Txuag cov ntaub ntawv thiab tawm.

Kauj Ruam 14: Nkag Mus Rau Network Drive Los Ntawm Windows

Nkag mus rau Network Drive Los ntawm Windows
Nkag mus rau Network Drive Los ntawm Windows

Los ntawm lub khoos phis tawj Windows, qhib tus neeg tshawb nrhiav.

Nyem rau ntawm "Network" thiab kho qhov rai tshiab.

Lub khoos phis tawj nrog lub npe ntawm koj li Rapberry Pi yuav tshwm sim.

Qhib nws siv tus lej "pi" thiab koj tus password.

Koj yuav tsum pom cov ntawv tais ceev tseg ntxiv yav tas los hauv Samba cov ntawv teeb tsa.

Kauj Ruam 15: Npaj Lub Tshuab Thib Ob

Koj lub tshuab thib 1 tau npaj lawm.

Rov ua cov kauj ruam dhau los rau lub tshuab thib 2, hloov (piv txwv) "loic" los ntawm "vincent".

Thaum 2 lub tshuab yuav tau npaj, koj yuav tsum tau pauv ssh qhov tseem ceeb txhawm rau tso cai nkag mus nruab nrab ntawm lawv, saib cov kauj ruam tom ntej.

Kauj Ruam 16: Tsim SSH Ntawm Lub Tshuab Hauv Zos thiab Chaw Taws Teeb

Txhawm rau ua kom yooj yim sib koom ntawm SSH qhov tseem ceeb, txhua Raspberry Pi yuav tsum txuas nrog tib lub network ethernet.

Ntawm txhua tus Raspberry Pi, qhib qhov hais kom sai ntawm Pi desktop thiab nkag mus:

ssh -keygen -q -t rsa -b 2048 -N ''

ssh-copy-id pi@IP_of_other_raspberry

Kauj ruam 17: Kuaj Synchro

Kuaj Synchro
Kuaj Synchro
Kuaj Synchro
Kuaj Synchro
Kuaj Synchro
Kuaj Synchro

Koj 2 tshuab tau npaj txhij.

Koj tuaj yeem sim synchro ntawm koj lub khoos phis tawj Windows:

  1. ntxiv cov ntaub ntawv hauv koj lub network tsav hauv nroog (piv txwv li / Rpi4-loic / cov ntaub ntawv loic / test / test.txt),
  2. khiav tsab ntawv ntawm koj lub desktop Pi hauv zos (ua haujlwm SB_sync hauv/home/pi/scripts)
  3. xyuas tias koj cov ntaub ntawv tshwm nyob rau hauv lub network thaub qab tsav (piv txwv li / Rpi4-vincent / cov ntaub ntawv loic / test / test.txt).

Koj yuav tsum muaj peev xwm nyeem thiab sau cov ntawv hauv / Rpi4-loic / cov ntaub ntawv loic / test \, tab sis tsuas yog nyeem cov ntawv hauv / Rpi4-vincent / cov ntaub ntawv loic / test \.

Cov kauj ruam tom ntej thiab zaum kawg yog txav lub tshuab "nyob deb" sab hauv lub network ntawm lwm qhov chaw, thiab teeb tsa kev sib txuas ntawm 2 routers hauv internet.

Kauj Ruam 18: Txhim Kho Txoj Kev Siv Internet

Hauv kuv qhov xwm txheej, rau lub tshuab hauv tsev hauv tsev, kuv sau npe nkag rau internet suav nrog lub router thiab tus IP ruaj.

Rau lub tshuab nyob deb, Cov muab kev pabcuam Is Taws Nem yog tib yam, yog li teeb tsa tau yooj yim dua, thiab kuv tsis xav tau DNS.

Hauv kuv lub tsev:

  • Hauv kuv tus router, kuv tsim chaw nres nkoj txoj hauv kev los ntawm "remote_internet_fixed_IP" ntawm "port_34567" mus rau "my_raspberry_IP" ntawm chaw nres nkoj "22"
  • Hauv kuv cov txiv pos nphuab, hauv/tsev/pi/ntawv sau/SB_sync, Kuv hloov qhov "port_distant" tus nqi "22" los ntawm "port_34567"

Hauv qhov chaw deb:

  • Hauv router, Kuv tsim chaw nres nkoj txoj hauv kev los ntawm "my_internet_fixed_IP" ntawm "port_34567" mus rau "my_raspberry_IP" ntawm chaw nres nkoj "22"
  • Hauv raspberry nyob deb, hauv/tsev/pi/scripts/SB_sync, Kuv hloov qhov "port_distant" tus nqi "22" los ntawm "port_34567"

Rau koj daim ntawv thov:

  • Koj yuav tsum hloov IPs thiab chaw nres nkoj_34567 los ntawm koj tus kheej.
  • Nyob rau hauv rooj plaub ntawm kev siv internet zoo IP, koj yuav tsum sau npe rau DNS.

Nrog kev pab los ntawm tus tswv raspberry nyob deb, rov ua qhov kev sim ntawm cov kauj ruam dhau los.

Tiav lawm!

Kauj Ruam 19: Cov ntawv sau

Nruab Raspbian ntawm daim npav SD

Customize cardSD daim npav tom qab tsim (SSH thiab WiFi)

Siv koj li Raspberry Pi

Raspberry Pi Sync nrog rysnc los ntawm feralhosting

Tshwj xeeb SSH chaw nres nkoj rau Rsync

Nruab thiab siv Samba

Pom zoo: