Cov txheej txheem:

Lub Thawv Liab: 3 Kauj Ruam (nrog Duab)
Lub Thawv Liab: 3 Kauj Ruam (nrog Duab)

Video: Lub Thawv Liab: 3 Kauj Ruam (nrog Duab)

Video: Lub Thawv Liab: 3 Kauj Ruam (nrog Duab)
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Lub Thawv Liab
Lub Thawv Liab

Tsim koj tus kheej lub server huab uas ntseeg tau

Kauj ruam 1: Kho vajtse

Kho vajtse
Kho vajtse
  • Siv lub thawv hlau thiab pleev xim rau xim uas koj nyiam. (Kuv siv tus tswj hwm qub qub)
  • Hobbycolor phaj uas tiv taus tsawg kawg 75 C.
  • Raspberry pib 3
  • Micro SD daim npav (Kuv siv 16GB tab sis koj tuaj yeem siv txhua qhov loj> = 4GB)
  • USB hub nrog lub zog hluav taws xob sab nraud
  • Usb rau sata adapters
  • Disk tsav
  • Network cable + network phab ntsa qhov (socket)
  • Cov xov hlau + lub hwj chim nkag
  • Bolts rov zoo los ntawm lub khoos phis tawj qub serial lossis vga chaw nres nkoj
  • Cov chaw nres nkoj Usb rov qab los ntawm lub khoos phis tawj qub

Raspberry pi tau txuas rau lub hobbycolor phaj nrog ntsia liaj qhov rooj los ntawm vga chaw nres nkoj.

Disks tau txuas nrog cov ntsia hlau niaj hnub nyob tom qab.

Kauj ruam 2: Kev thaiv kab

Thaiv
Thaiv

Lub hwj chim tawm tswv yim txuas rau ob qho tib si rov qab tau cov chaw nres nkoj usb

Thawj usb (tom qab txhua lub xov hlau nyob rau sab laug) tau siv los ua lub zog, tsuas yog siv cov xim liab thiab dub thiab txuas nrog lub hwj chim nkag. Thawj usb cable hauv qhov chaw nres nkoj no muab lub zog rau pi, tus thib ob usb cable muab lub zog rau USB hub.

Thib ob usb (ib qho nyob tom qab - muaj txiaj ntsig zoo rau kev txuas txuas ntxiv) muaj liab thiab dub txuas ncaj qha rau lub zog siv, thaum dawb thiab ntsuab ntawm txhua qhov chaw nres nkoj txuas nrog lub usb cable zoo los ntawm qee tus nas qub (dawb dawb ncaj qha txuas nrog pi)

Lan cable txuas rau sab nrauv network phab ntsa rau lub raspberry pi LAN chaw nres nkoj

Disks txuas nrog ntawm usb rau sata adapters rau sab nraud siv USB hub (lub peev xwm loj dua disks xav tau lub zog ntau dua thiab peb tsis xav ua pi tsis ruaj khov), uas txuas nrog hauv ib qho ntawm pi chaw nres nkoj

Kauj ruam 3: Software

Software
Software

Nruab qhov Operating System

Siv Centos 7 rau caj npab rau kev nyab xeeb siab dua. (https://mirror.centos.org/altarch/7/isos/armhfp/); sim: CentOS-Userland-7-armv7hl-Minimal-1611-RaspberryPi3.img.xz, qhia ntawm no:

Muab daim duab tso rau ntawm daim npav micro sd los ntawm koj lub khoos phis tawj Linux (rau lub Windows xyuas:

xzcat CentOS-Userland-7-armv7hl-Tsawg heev-1611-RaspberryPi3.img.xz | sudo dd ntawm = $/path/to/sd/card status = progress bs = 4M

cag lo lus zais: centos

siv nmtui los teeb tsa lub network thiab teeb tsa tus IP zoo li qub

Teeb tsa cov disks

Tsim ib qho kev faib tawm ntawm txhua daim disk (zoo dua kom me dua me me ntawm tag nrho daim disk - cia peb hais 1GB me dua - sib txawv ntawm cov peev txheej zoo ib yam - ex: wd vs toshiba - muaj ntau qhov sib txawv:)). Txoj hauv kev no koj yuav nyab xeeb yog tias koj xav hloov ib qho ntawm cov disks

Tsim btrfs raid 1 filesystem ntawm koj lub disks

mkfs.btrfs -d raid1 -m raid1 /dev /sda1 /dev /sdb1

btrfs filesystem daim ntawv lo /dev /sda1 rpi3

Mount lub fileystem siv autofs (tiv thaiv tsis booting ntawm pi yog tias qee yam ua tsis raug nrog lub disks)

yum nruab -y autofs

ntxiv qhov fllowing rau /etc/auto.master:

/-/etc/auto.ext-usb-timeout = 300

Tsim /etc/auto.ext-usb nrog cov ntsiab lus:

/srv -fstype = auto, compress = lzo, noatime:/dev/disk/by -label/rpi3

kev pabcuam autofs rov pib dua

ls /srv, df -h, paub meej tias nws tau teeb tsa

Nruab owncloud

Yam yuavtsum tau kawm uantej (apache, php, mariadb):

yum nruab -y httpd; yum nruab -y mod_ssl; yum nruab -y mariadb -server; yum nruab -y php*

Nruab owncloud 9 uas yog sib xws nrog php54 uas los nrog centos7, kev qhia zoo rau qhov ntawd:

download.owncloud.org/download/repositories…

Tom qab owncloud tau nce thiab khiav, txav cov ntaub ntawv dir los ntawm qhov chaw nyob mus rau lub zog tshiab (/srv)

kev pabcuam httpd nres

kho /var/www/html/owncloud/config/config.php thiab hloov qhov no:

'datadirectory' => '/srv/owncloud/cov ntaub ntawv', mkdir /srv /owncloud; mv/var/www/html/owncloud/data/srv/owncloud && chown -R apache: apache/srv/owncloud/data/

kev pabcuam httpd pib

Koj tuaj yeem nruab owncloud desktop tus thov kev pabcuam ntawm linux / windows thiab rau cov xov tooj Kuv siv foldersync

  • Pab kom thiab teeb tsa SELinux

    (ua haujlwm version yog: selinux-txoj cai-3.13.1-166.el7.5.noarch, selinux-txoj cai-phiaj-3.13.1-166.el7.5.noarch)

nco ntsoov tias koj tsis tau hloov kho txoj cai ntawd (hauv /etc/yum.conf txuas ntxiv: tshem tawm = selinux-txoj cai*)

restorecon -Rv /

/boot/cmdline.txt yuav tsum muaj: selinux = 1 kev ruaj ntseg = selinux siv = 1

/etc/sysconfig/selinux yuav tsum muaj: SELINUX = yuam thiab SELINUXTYPE = tsom

rov pib dua

Ua cov chaw hauv qab no tom qab rov pib dua:

yum nruab -y policycoreutils -python

semange fcontext -a -t httpd_sys_rw_content_t /srv/owncloud(/.*)?

setsebool -P httpd_builtin_scripting = 1; setsebool -P httpd_can_network_connect = 1; setsebool -P httpd_enable_cgi = 1; setsebool -P httpd_graceful_shutdown = 1

yog tias koj ntsib teeb meem tso sd card rau lwm lub khoos phis tawj thiab hloov cmdline.txt kom muaj: selinux = 0

Ruaj ntseg koj lub thawv

Hloov hauv paus lo lus zais

Tsim koj tus kheej cov neeg siv (adduser -s /bin /bash "kuv") thiab teeb tsa tus password zoo (passwd "kuv")

teeb tsa sshd mloog ntawm lwm qhov chaw nres nkoj thiab tsis tso cai nkag mus hauv paus

Hauv/etc/ssh/sshd_config, teeb Chaw

(hais tias 2222), Tso Cai RootLogin tsis tau

Qhia SELinux thiab tua hluav taws txog koj lub hom phiaj:

semanage chaw nres nkoj -a -t ssh_port_t -p tcp 2222

kev pabcuam firewalld pib && systemctl pab firewalld.service

firewall-cmd --permanent --add-port 2222/tcp

firewall-cmd-rov ua dua

service sshd rov pib dua

Ua rau pej xeem

Ntawm koj lub router internet xa cov chaw nres nkoj no mus rau koj tus IP zoo li qub hauv thawj kauj ruam: 80, 443, 2222.

Teeb DDNS ntawm koj lub router kom koj tuaj yeem nkag mus rau koj lub npov los ntawm txhua qhov chaw.

Ua kom zoo

Teeb apache rau 5 procs raws li lub cim xeeb tsawg:

/etc/httpd/conf.modules.d/00-mpm.conf

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

PibServers 5

MinSpareServers 5

MaxSpareServers 5

ServerLimit 5

MaxClients 5

MaxRequestsPerChild 3000

kev pabcuam httpd rov pib dua

Teeb tsa cron rau txhua lub limtiam txhuam cov disks thiab ua qhov snapshot txhua hmo (hauv /etc /crontab)

01 02 * * 6 hauv paus btrfs txhuam pib/srv01 01 * * * hauv paus/usr/sbin/btrfs subvolume snapshot -r/srv/srv/@$ (printf "%s" $ (/bin/hnub + +%d \%b \%Y-\%k-\%M))

xyuas ib ntus dhau ib ntus ntim nrog: btrfs dev stats /srv

Siv tus saib xyuas kom rov pib dua yog tias nws tsis teb (raspberry pi3 muaj kho vajtse ib):

yum nruab -y watchdog

/etc/watchdog.conf

watchdog-device = /dev /watchdogwatchdog-timeout = 15

interval = 1logtick = 1 log-dir =/var/log/watchdog

realtime = yog qhov tseeb = 1

kev pabcuam saib xyuas pib && systemctl pab kom watchdog.service

Pom zoo: