In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use apt-mirror to build Ubuntu software source", the explanation content in the article is simple and clear, easy to learn and understand, please follow the idea of Xiaobian slowly in-depth, together to study and learn "how to use apt-mirror to build Ubuntu software source"!
There are many reasons to build your own Ubuntu source
Save external network bandwidth
Download ahead of time, ease slow download of foreign sources
Private custom package release
This article tests the environment
ubuntu 14.04(LTS) 64 bit
apt-mirror version 0.5.1-1
nginx version 1.4.6-1ubuntu3.1
Install apt-mirror
The code is as follows:
# sudo apt-get update
# sudo apt-get install apt-mirror=0.5.1-1
Configure apt-mirror
The apt-mirror configuration file is located at/etc/apt/mirror.list
To modify the corresponding content according to the comments, generally only need to modify the base_path and change, add software sources. I only added Ubuntu 14.04 and MongoDB software sources for the following profiles, you can add other Ubuntu software sources according to your needs.
The code is as follows:
############# config ##################
#
#Configure Database Directory
set base_path /data/apt-mirror
#Configure mirror storage location
# set mirror_path $base_path/mirror
#Configure temporary download index location
# set skel_path $base_path/skel
#Configure days,URLs and MD5 check information storage locations
# set var_path $base_path/var
#Configure delete expired source script location (default does not delete, easy to install older versions of software)
# set cleanscript $var_path/clean.sh
#Set default architecture, you can fill in: amd64 or i386, default is a native architecture
# set defaultarch
#
#Set the location of scripts to run after download
# set postmirror_script $var_path/postmirror.sh
#Set whether to execute the downloaded script operation, default is 1(but default no postmirror.sh script)
set run_postmirror 0
#Set the number of download threads
set nthreads 20
#Do you want to replace the wavy line in the URL with %7E (HTML code), otherwise the download will be skipped
set _tilde 0
#
############# end config ##############
#Configure Ubuntu trusty sources
deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
# clean http://archive.ubuntu.com/ubuntu
#Configure MongoDB Source
#Official address http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
#
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
# clean http://localhost/downloads-distro.mongodb.org
Because I customized the apt-mirror data directory, I need to grant apt-mirror user rights, otherwise synchronization will not work correctly:
The code is as follows:
# sudo chown -R apt-mirror:apt-mirror /data/apt-mirror
Run the first synchronization
Make sure you have enough disk space in your base directory. Configure it as above, and you will need at least 150 gigabytes of disk space. It is recommended that you have more than 200 gigabytes of disk space. Later version updates, adding software sources, etc. will require a lot of disk space.
Because it takes a long time to download 135G content, it is recommended to switch to apt-mirror users with the following command to run in the background
The code is as follows:
# sudo su apt-mirror
# nohup /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log &
Install Nginx, configure HTTP access
With the above configuration, you can already see several generated data files under the/data/apt-mirror directory./ Data/apt-mirror/mirror is the software mirror. But how do you distribute that data to other computers? This is clearly possible with HTTP services. We publish the contents of the mirror directory over HTTP by using Nginx.
install Nginx
The code is as follows:
# sudo apt-get install nginx=1.4.6-1ubuntu3.1
nginx configuration file location: /etc/nginx/sites-enabled/default, replace it with the following file:
The code is as follows:
server {
listen 80;
#Fill in your domain name here, fill in localhost and access it directly via IP address
server_name localhost;
#Show directory
autoindex on;
location / {
index index.html index.htm;
#Fill in the mirror save location here
root /data/apt-mirror/mirror;
}
access_log /var/log/nginx/localhost.log;
}
After changing the configuration, test the configuration first. If the test passes, restart nginx.
The code is as follows:
# sudo nginx -t
# sudo service nginx restart
At this point visit http://server IP to access your published image
Configure timing synchronization
Of course we can't manually synchronize our mirrors every day. We need to configure apt-mirror daily timing synchronization, which is actually configuring cron.
Here apt-mirror provides cron template file. In/etc/cron.d/apt-mirror, cancel the #comment in the last line to take effect:
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
The above settings are synchronized once a day at 4:00
client configuration
Now that we've configured the server, find an Ubuntu 14.04 64-bit one to test.
Backup source.list
The code is as follows:
# sudo mv /etc/apt/source.list /etc/apt/source.list.bak
Create/etc/apt/source.list and write the following (replace "self-built source IP" with DNS or IP of the above server)
The code is as follows:
deb [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trust-security main restricted universe multiverse
deb [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trust-updates main restricted universe multiverse
deb [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
deb [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trust-backports main restricted universe multiverse
The code is as follows:
deb-src [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb-src [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trust-security main restricted universe multiverse
deb-src [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trust-updates main restricted universe multiverse
deb-src [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trust-proposed main restricted universe multiverse
deb-src [arch=amd64] http://self-built source IP/archive.ubuntu.com/ubuntu trust-backports main restricted universe multiverse
The code is as follows:
#Configure MongoDB Source
deb [arch=amd64] http://self-source IP/downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
By comparing apt-mirror to the source.list file, you are essentially turning the original domain name into a directory. Note: [arch= amd64] is also added to the above client configuration to specify the architecture, otherwise it will appear
Err http://192.168.1.71 trusty/main i386 Packages
404 Not Found
Err http://192.168.1.71 trusty/restricted i386 Packages
404 Not Found
Err http://192.168.1.71 trusty/universe i386 Packages
404 Not Found
...
Similar error, because my test environment is x64, only synchronized 64-bit architecture source, so must specify architecture 64, now the client does not need i386 software.
After adding source.list, run
The code is as follows:
# sudo apt-get update
ubuntu part of the normal update, but found that the following error prompt will appear
W: GPG error: http://192.168.1.111 dist Release:
The following signatures couldn't be verified
because the public key is not available: NO_PUBKEY 9ECBEC467F0CEB10
You need to add a GPG key. When adding some packages, you basically need to add a GPG key. The official website will generally give it.
The code is as follows:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
At this point, you can use your own source to install software ~~
MongoDB and htop are installed below for testing
The code is as follows:
sudo apt-get install -y mongodb-org=2.6.5 htop
Thank you for reading, the above is "how to use apt-mirror to build Ubuntu software source" content, after the study of this article, I believe we have a deeper understanding of how to use apt-mirror to build Ubuntu software source, the specific use of the situation also needs to be verified. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.