Repositori rpm prasaja nggunakake Inotify lan webdav

Ing kirim iki, kita bakal ndeleng repositori artefak rpm nggunakake skrip inotify + createrepo sing prasaja. Artefak diunggah liwat webdav nggunakake apache httpd. Napa apache httpd bakal ditulis ing pungkasan postingan.

Dadi, solusi kasebut kudu nyukupi syarat ing ngisor iki kanggo ngatur mung panyimpenan RPM:

  • Gratis

  • Kasedhiyan paket ing gudang sawetara detik sawise diunggah menyang gudang artefak.

  • Gampang kanggo nginstal lan njaga

  • Kemampuan kanggo nggawe kasedhiyan dhuwur

    Apa ora SonaType Nexus utawa pulp:

  • Panyimpenan ing SonaType Nexus utawa pulp akeh jinis artefak ndadΓ©kakΓ© kanggo kasunyatan sing SonaType Nexus utawa pulp dadi siji titik kegagalan.

  • kasedhiyan dhuwur ing SonaType Nexus wis mbayar.

  • pulp Katon kaya solusi over-engineered kanggo kula.

  • Artefak ing SonaType Nexus disimpen ing blob. Yen tiba-tiba mati listrik, sampeyan ora bakal bisa mulihake blob yen sampeyan ora duwe serep. Kita duwe kesalahan iki: 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. Blob ora tau dibalekake.

Sumber kode

β†’ Kode sumber dumunung kene

Skrip utama katon kaya iki:

#!/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 &

Instalasi

inotify-createrepo mung bisa digunakake ing CentOS 7 utawa luwih dhuwur. Ora bisa digunakake ing CentOS 6.

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

Konfigurasi

Kanthi gawan, inotify-createrepo ngawasi direktori /var/www/repos/rpm-repo/.

Sampeyan bisa ngganti direktori iki ing file /etc/inotify-createrepo.conf.

Gunakake

Nalika nambah file menyang direktori /var/www/repos/rpm-repo/ inotifywait bakal nggawe file /tmp/need_create. Fungsi run_createrepo mlaku ing daur ulang tanpa wates lan ngawasi file kasebut /tmp/need_create. Yen file ana, banjur mbukak createrepo --update.

Entri bakal katon ing 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

Kemampuan kanggo nggawe kasedhiyan dhuwur

Kanggo kasedhiyan dhuwur saka solusi ana, Aku sampeyan bisa nggunakake 2 server, Keepalived kanggo HA lan Lsyncd kanggo sinkronisasi artefak. Lsyncd - daemon sing ngawasi owah-owahan ing direktori lokal, nglumpukake, lan sawise wektu tartamtu, rsync wiwit nyinkronake. Rincian lan setelan diterangake ing kirim "Sinkronisasi cepet saka milyar file".

webdav

Ana sawetara cara kanggo ngunggah file: SSH, NFS, WebDav. WebDav misale jek dadi pilihan modern lan prasaja.

Kanggo WebDav, kita bakal nggunakake Apache httpd. Napa Apache httpd ing 2020 lan dudu nginx?

Aku pengin nggunakake alat otomatis kanggo mbangun modul Nginx + (contone, Webdav).

Ana proyek kanggo mbangun modul Nginx + - nginx-builder. Yen sampeyan nggunakake nginx + wevdav kanggo ngunggah file, sampeyan butuh modul nginx-dav-ext-modul. Nalika nyoba mbangun lan nggunakake Nginx karo nginx-dav-ext-modul kanthi pitulung nginx-builder kita bakal entuk kesalahan Digunakake dening http_dav_module tinimbang nginx-dav-ext-module. Bug sing padha ditutup ing musim panas nginx: [emerg] arahan dav_methods sing ora dingerteni.

Aku nggawe panjalukan narik Tambah mriksa git_url kanggo ditempelake, refactored --with-{}_module ΠΈ yen modul == "http_dav_module" append --with. Nanging padha ora ditampa.

config 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>

Aku mikir sampeyan bakal nindakake kabeh konfigurasi Apache httpd dhewe.

Nginx ing ngarep Apache httpd

Ora kaya Apache, Nginx nggunakake model pangolahan panjalukan adhedhasar acara, tegese mung siji proses server HTTP sing dibutuhake kanggo sawetara klien. Sampeyan bisa nggunakake nginx lan nyuda beban server.

nginx-front.conf config. Aku mikir sampeyan bakal nindakake kabeh konfigurasi nginx dhewe.

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;
    }
}

Ngundhuh file liwat WebDav

Ngundhuh rpm gampang banget.

curl -T ./nginx-1.16.1-1.el7.ngx.x86_64.rpm https://ваш-Π²ΠΈΡ€Ρ‚ΡƒΠ°Π»ΡŒΠ½Ρ‹ΠΉ-хост/rpm/

Source: www.habr.com

Add a comment