Configure Linux Yum repository Agent with Nexus

Source: Internet
Author: User
Tags gpg sonatype


First, the use of the scene





In the production environment, we cannot all the servers can connect to the external network update RPM package, the ideal environment is: There is a Linux server can connect the network, the remaining servers through this Yum server update. Traditionally, it was more time-consuming to download the package to a Yum server on the intranet and then generate the local repository via the Createrepo command, which is accessed by the rest of the server via HTTP. There is a better way, let us directly through this server Agent connected to the public network 163, Ali Yum Warehouse, this is the introduction of the Nexus Agent. Whether your client is CentOS6 or CentOS7 or Ubuntu, whether you want to use Yum or Pip or NPM Package Manager, the Nexus will meet your needs.






Second, install Nexus



Here I use CentOS7 as a Yum repository proxy server


# Confirm that JRE8 is installed
# java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

# Create a nexus user and set the user's File Handle Limits
# useradd nexus
# echo "nexus-nofile 65536" >> /etc/security/limits.conf

# Download and decompress nexus to the / opt directory, and set nexus user permissions
# wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
# tar -xzvf latest-unix.tar.gz -C / opt
# mv / opt / nexus * / opt / nexus
# chown -R nexus: nexus / opt / nexus / opt / sonatype-work /

# Set service startup user
# echo 'run_as_user = "nexus"'> /opt/nexus/bin/nexus.rc

# Use systemd management service here
# cat << EOF> /etc/systemd/system/nexus.service
[Unit]
Description = nexus service
After = network.target

[Service]
Type = forking
ExecStart = / opt / nexus / bin / nexus start
ExecStop = / opt / nexus / bin / nexus stop
User = nexus
Restart = on-abort

[Install]
WantedBy = multi-user.target
EOF

# systemctl daemon-reload
# systemctl enable nexus.service
# systemctl start nexus.service
 
# Finally, check the log for service running status
# tail -f /opt/sonatype-work/nexus3/log/nexus.log





Third, configure Nexus


      1. Use the browser to open http://IP:8081/, user name password is admin:admin123

      2. Click Configure->repositories-> Select Type (yum proxy)

      3. Customize a name, for example: Yum-proxy

      4. Input url:http://mirrors.163.com/centos/

      5. Save





Iv. Client Configuration yum Repo file


# cat nexus.repo
[nexus]
name=Nexus Repository
baseurl=http://IP:8081/repository/yum-proxy/$releasever/os/$basearch/
enabled=1
gpgcheck=0





V. Attach 163 server CentOS7 repo file contents


[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7


At this point, the client can connect its own repo server to download the RPM, if the required package is the first download, then proxy will connect to the specified extranet yum repository download, but if it is already exist, then directly from the proxy agent server down, Speed will be much faster than the external network download!



Configure Linux Yum repository Agent with Nexus


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.