documentazione_3di_riservata:manuali_sysadmin:linuxreposerver
Questa è una vecchia versione del documento!
Indice
To Set a Network Repository Server on CentOS 7
To Set Up the Repository
- Here we are going to set in HTTP, so we need to install the httpd package first.
[root@linuxhelp ~]# yum install httpd -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net Resolving Dependencies --> Running transaction check . . . Installed: httpd.x86_64 0:2.4.6-40.el7.centos Dependency Installed: apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-40.el7.centos mailcap.noarch 0:2.1.41-2.el7 Complete!
- Run the following command to create directory, for the repository server
[root@linuxhelp ~]# mkdir /var/www/html/centos
- Now initialize the database by installing createrepo
[root@linuxhelp ~]# yum install createrepo -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net Resolving Dependencies --> Running transaction check . . . Updated: createrepo.noarch 0:0.9.9-25.el7_2 Complete!
- Run the following command to start the database.
[root@linuxhelp ~]# createrepo /var/www/html/centos/ Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete
[root@linuxhelp ~]# ls -l /var/www/html/centos/ total 4 drwxr-xr-x. 2 root root 4096 Apr 27 17:44 repodata [root@linuxhelp ~]# ls -l /var/www/html/centos/repodata/ total 28 -rw-r--r--. 1 root root 586 Apr 27 17:44 01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 -rw-r--r--. 1 root root 123 Apr 27 17:44 401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz -rw-r--r--. 1 root root 1131 Apr 27 17:44 5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 -rw-r--r--. 1 root root 123 Apr 27 17:44 6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz -rw-r--r--. 1 root root 575 Apr 27 17:44 7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 -rw-r--r--. 1 root root 134 Apr 27 17:44 dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz -rw-r--r--. 1 root root 2962 Apr 27 17:44 repomd.xml
To Upgrade the Repository
- To upgrade it via internet, go to the CentOS download mirror and choose any link.
https://www.centos.org/download/mirrors/
- Now choose your Version. In my case its Version 7.
- Open the OS directory, choose the required architecture and copy the link to download to the newly created directory inside the server.
- Now use the rsync command to transfer the contents to newly created directory inside the server.
[root@linuxhelp ~]# rsync -avz rsync://mirror.fibergrid.in/centos/7/os/x86_64/ /var/www/html/centos/ --------------------------------------------- Fibergrid Open Source Projects Mirror Hyderabad, India -------------------------------------------- receiving incremental file list ./ .discinfo .treeinfo . . EFI/BOOT/grubx64.efi EFI/BOOT/fonts/ EFI/BOOT/fonts/unicode.pf2 LiveOS/ LiveOS/squashfs.img
- Use the following command to check the disk space after completing the download process.
[root@linuxhelp ~]# du -sch /var/www/html/centos/* 4.0K /var/www/html/centos/CentOS_BuildTag 6.0M /var/www/html/centos/EFI 4.0K /var/www/html/centos/EULA 20K /var/www/html/centos/GPL . . 4.0K /var/www/html/centos/RPM-GPG-KEY-CentOS-7 4.0K /var/www/html/centos/RPM-GPG-KEY-CentOS-Testing-7 4.0K /var/www/html/centos/TRANS.TBL 4.0G total
- Repositories database needs to be updated.
[root@linuxhelp ~]# createrepo --update /var/www/html/centos/ Spawning worker 0 with 3538 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete
- Now start and enable the httpd service and open the port for HTTP in firewall using the following commands.
[root@linuxhelp ~]# systemctl start httpd [root@linuxhelp ~]# systemctl enable httpd ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service' [root@linuxhelp ~]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled) Active: active (running) since Wed 2016-04-27 18:44:24 IST; 3min 18s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 40790 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ??40790 /usr/sbin/httpd -DFOREGROUND ??40791 /usr/sbin/httpd -DFOREGROUND ??40792 /usr/sbin/httpd -DFOREGROUND ??40793 /usr/sbin/httpd -DFOREGROUND ??40794 /usr/sbin/httpd -DFOREGROUND ??40795 /usr/sbin/httpd -DFOREGROUND Apr 27 18:44:24 linuxhelp httpd[40790]: AH00557: httpd: apr_sockaddr_info_get() failed for linuxhelp Apr 27 18:44:24 linuxhelp httpd[40790]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, usi...message Apr 27 18:44:24 linuxhelp systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full.
[root@linuxhelp ~]# firewall-cmd --permanent --add-service=http success [root@linuxhelp ~]# firewall-cmd --reload success
- Use the browser to verify the contents in the directory.
To Configure the Client Machine
- In the /etc/yum.repos.d directory add the configuration files as follows.
[root@linuxhelp ~]# vim /etc/yum.repos.d/network.repo Add the following lines to the configuration file. [Network] name=Network repo baseurl=http://192.168.5.88/centos enabled=1 gpgcheck=0
- Then clean and update the repository file.
[root@linuxhelp ~]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: network Cleaning up everything Cleaning up list of fastest mirrors [root@linuxhelp ~]# yum update all Loaded plugins: fastestmirror, langpacks network | 2.9 kB 00:00:00 network/primary_db | 2.7 MB 00:00:01 Determining fastest mirrors No Match for argument: all No package all available. No packages marked for update [root@linuxhelp ~]# yum repolist all Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile repo id repo name status network network repo enabled:3538 repolist: 3,538
- The repo which is created is displayed in the above output. Now install any package to check the repository is working fine or not.
[root@linuxhelp ~]# yum install httpd -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-17.el7.centos.1 will be installed . . . Installed: httpd.x86_64 0:2.4.6-17.el7.centos.1 Dependency Installed: apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-17.el7.centos.1 mailcap.noarch 0:2.1.41-2.el7 Complete!
The httpd package is installed from the server not from the internet.
To Keep the Repository up-to-date
- To keep the repositories up-to-date, set a cronjob by using rsync command to keep synchronizing new packages from the CentOS mirror server.
[root@linuxhelp ~]# crontab -e -u root no crontab for root - using an empty one crontab: installing new crontab
- Now add the following entry to the crontab file and save it to set a cronjob at every day morning 8:30 AM.
30 8 * * * rsync -avz rsync: http://mirror.fibergrid.in/centos/7/os/x86_64/ /var/www/html/centos/
/data/attic/documentazione_3di_riservata/manuali_sysadmin/linuxreposerver.1537793526.txt.gz · Ultima modifica: 2018/09/24 14:52 da epapakroni