Repository rpm basajan nganggo Inotify sareng webdav

Dina postingan ieu, urang bakal ningali gudang artefak RPM nganggo skrip saderhana sareng inotify sareng createrepo. Artefak diunggah via WebDAV nganggo Apache httpd. Alesan keur Apache httpd bakal dibahas deukeut tungtung pos.

Janten, solusina kedah nyumponan sarat di handap ieu pikeun ngatur ukur neundeun RPM:

  • Gratis

  • Paket janten sayogi dina gudang dina sababaraha detik saatos diunggah ka toko artefak.

  • Gampang masang sareng ngajaga

  • Kamampuhan pikeun nerapkeun kasadiaan tinggi

    Naha henteu? SonaType Nexus atawa bubur:

  • Panyimpenan di SonaType Nexus atawa bubur loba jenis artefak ngabalukarkeun kanyataan yén SonaType Nexus atawa bubur janten titik tunggal kagagalan.

  • kasadiaan tinggi di SonaType Nexus nyaéta layanan mayar.

  • bubur Sigana mah kawas solusi overcomplicated.

  • Artefak di SonaType Nexus Éta disimpen dina gumpalan. Upami kakuatan pareum, anjeun moal tiasa mulangkeun gumpalan kecuali anjeun gaduh cadangan. Kami ngagaduhan kasalahan ieu: ERROR [ForkJoinPool.commonPool-worker-2] *SYSTEM [com.orientechnologies.orient.core.storage](http://com.orientechnologies.orient.core.storage/).fs.OFileClassic - $ANSI{green {db=security}} Error during data read for file 'privilege_5.pcl' 1-th attempt [java.io](http://java.io/).IOException: Bad address. Gumpalan henteu pernah disimpen deui.

Kode sumber

→ Kode sumber aya di dieu

Skrip utama sapertos kieu:

#!/bin/bash

source /etc/inotify-createrepo.conf
LOGFILE=/var/log/inotify-createrepo.log

function monitoring() {
    inotifywait -e close_write,delete -msrq --exclude ".repodata|.olddata|repodata" "${REPO}" | while read events 
    do
      echo $events >> $LOGFILE
      touch /tmp/need_create
    done
}

function run_createrepo() {
  while true; do
    if [ -f /tmp/need_create ];
    then
      rm -f /tmp/need_create
      echo "start createrepo $(date --rfc-3339=seconds)"
      /usr/bin/createrepo --update "${REPO}"
      echo "finish createrepo $(date --rfc-3339=seconds)"
    fi
    sleep 1
  done
}

echo "Start filesystem monitoring: Directory is $REPO, monitor logfile is $LOGFILE"
monitoring >> $LOGFILE &
run_createrepo >> $LOGFILE &

setting

Inotify-createrepo ngan ukur tiasa dianggo dina CentOS 7 atanapi langkung luhur. Hurung CentOS 6 teu bisa ngajalankeunnana.

yum -y install yum-plugin-copr
yum copr enable antonpatsev/inotify-createrepo
yum -y install inotify-createrepo
systemctl start inotify-createrepo

Konfigurasi

Sacara standar, inotify-createrepo ngawas diréktori /var/www/repos/rpm-repo/.

Anjeun tiasa ngarobih diréktori ieu dina file /etc/inotify-createrepo.conf.

pamakean

Nalika nambahkeun file wae kana diréktori /var/www/repos/rpm-repo/ inotifywait bakal nyiptakeun file /tmp/need_createFungsi run_createrepo dijalankeun dina loop anu henteu terbatas sareng ngawas file /tmp/need_createUpami filena aya, éta jalan. createrepo --update.

Éntri di handap ieu bakal muncul dina file:

/var/www/repos/rpm-repo/ CREATE nginx-1.16.1-1.el7.ngx.x86_64.rpm
start createrepo 2020-03-02 09:46:21+03:00
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 0 pkgs
Spawning worker 2 with 0 pkgs
Spawning worker 3 with 0 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
finish createrepo 2020-03-02 09:46:22+03:00

Kamampuhan pikeun nerapkeun kasadiaan tinggi

Pikeun nyieun kasadiaan tinggi tina solusi aya, Jigana anjeun bisa make 2 server, Keepalived pikeun HA na Lsyncd pikeun sinkronisasi artefak. Lsyncd - daemon nu ngawas parobahan dina diréktori lokal, aggregates aranjeunna, sarta sanggeus sababaraha waktu, dimimitian rsync pikeun nyingkronkeun aranjeunna. Rincian sareng konfigurasi dijelaskeun dina tulisan "Sinkronisasi gancang-gancang tina samilyar file".

webdav

Aya sababaraha cara pikeun unggah file: SSH, NFS, sareng WebDav. WebDav sigana pilihan modéren sareng saderhana.

Urang bakal ngagunakeun Apache httpd pikeun WebDav. Naha Apache httpd di 2020 sareng sanés nginx?

Abdi hoyong nganggo alat otomatis pikeun ngawangun modul Nginx + (contona, Webdav).

Aya proyék pikeun assembling Nginx + modul - Nginx-pembinaUpami anjeun nganggo nginx + wevdav pikeun ngaunduh file, anjeun peryogi modul nginx-dav-ext-modulNalika nyobian nyusun sareng nganggo Nginx sareng nginx-dav-ext-modul kalayan bantosan Nginx-pembina urang bakal meunang kasalahan Dipaké ku http_dav_module tinimbang nginx-dav-ext-modulBug anu sami dilereskeun dina usum panas. nginx: [emerg] diréktif kanyahoan dav_methods.

Kuring nyieun pamundut tarik Tambahkeun centang git_url pikeun diselapkeun, refactored —with-{}_module и lamun modul == "http_dav_module" append --withTapi maranéhna teu ditarima.

Konpigurasikeun webdav.conf

DavLockDB /var/www/html/DavLock
<VirtualHost localhost:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog /var/log/httpd/error.log
    CustomLog /var/log/httpd/access.log combined

    Alias /rpm /var/www/repos/rpm-repo
    <Directory /var/www/repos/rpm-repo>
        DAV On
        Options Indexes FollowSymlinks SymLinksifOwnerMatch IncludesNOEXEC
        IndexOptions NameWidth=* DescriptionWidth=*
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>

Jigana anjeun tiasa ngalakukeun sesa konfigurasi Apache httpd sorangan.

Nginx di hareup Apache httpd

Beda sareng Apache, Nginx nganggo modél pamrosésan anu didorong ku acara, hartosna ngan ukur hiji prosés server HTTP anu diperyogikeun pikeun sajumlah klien. Anjeun tiasa nganggo Nginx sareng ngirangan beban server.

nginx-front.conf config. Jigana anjeun tiasa ngalakukeun sesa konfigurasi nginx sorangan.

upstream nginx_front {
    server localhost:80;
}

server {
    listen 443 ssl;
    server_name ваш-виртуальных-хост;
    access_log /var/log/nginx/nginx-front-access.log main;
    error_log /var/log/nginx/nginx-front.conf-error.log warn;

    location / {
        proxy_pass http://nginx_front;
    }
}

Ngunggah file via WebDav

Ngundeur rpm basajan pisan.

curl -T ./nginx-1.16.1-1.el7.ngx.x86_64.rpm https://ваш-виртуальный-хост/rpm/

sumber: www.habr.com

Mésér hosting anu dipercaya pikeun situs anu gaduh panyalindungan DDoS, server VPS VDS 🔥 Meser hosting situs wéb anu tiasa dipercaya nganggo panyalindungan DDoS, server VPS VDS | ProHoster