Author Photo

Ahmer's SysAdmin Recipes is a blog for Linux System Administrators. This blog provides recipes for Installation & Configuration of Linux, Ubuntu, Oracle Database, MySQL, Apache, Nginx, Oracle Cloud Control, FreeIPA, Kerberos & OpenLDAP, Subversion, PXE, DevOps, etc. over Red Hat Enterprise Linux (RHEL), CentOS, Ubuntu and Windows.

Please give me your feedback and help me improve this blog. Please let me know If you want me to write on a specific topic.

Sunday, 13 January 2019

Installing JFrog Artifactory on CentOS / RHEL 7

installing-jfrog-artifactory-on-centos-rhel-7Artifactory is a universal repository manager created by JFrog. A repository manager is software application designed to manage binary components related to an application. Being a universal repository manager, Artifactory supports all major packaging formats like Apache Maven, Gradle, Docker and many more.

In DevOps environments, Artifactory is used by build tools such as Apache Ant, Maven and Gradle to serve as the local repository for their respective artifacts. Although using Artifactory is not mandatory in DevOps environment, but it can be used to accelerate the CI/CD process.

JFrog Artifactory is a commercial product. However, there is an OSS (Open Source Software) version is available with limited features. We will use this OSS version in our article. We will install JFrog Artifactory OSS on CentOS / RHEL 7 server and deploy and use MariaDB database as the backend database for Artifactory.

For more information on DevOps best practices and CI/CD implementation, please read Continuous Delivery for Java Apps: Build a CD Pipeline Step by Step Using Kubernetes, Docker, Vagrant, Jenkins, Spring, Maven and Artifactory by Jorge Acetozi.

 

System Specification:

We have used a CentOS 7 virtual machine with following specification for this article.

Hostname: artifactory-01.example.com
IP Address: 192.168.116.130/24
Operating System: CentOS 7.6

 

Installing Java Development Kit on CentOS 7:

JFrog Artifactory requires Java Development Kit (JDK) 8 update 45 or above.

In CentOS 7, the OpenJDK (an open-source Java Development Kit) can be installed using yum command. However, if you are using a Red Hat Enterprise Linux (RHEL) 7 then you have to configure a Local yum Repository and then you will be able to install OpenJDK using yum command.

[root@artifactory-01 ~]# yum install -y java-1.8.0-openjdk-devel ... Installed: java-1.8.0-openjdk-devel.x86_64 1:1.8.0.191.b12-1.el7_6 Dependency Installed: copy-jdk-configs.noarch 0:3.3-10.el7_5 dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 fontconfig.x86_64 0:2.13.0-4.3.el7 fontpackages-filesystem.noarch 0:1.44-8.el7 giflib.x86_64 0:4.1.6-9.el7 java-1.8.0-openjdk.x86_64 1:1.8.0.191.b12-1.el7_6 java-1.8.0-openjdk-headless.x86_64 1:1.8.0.191.b12-1.el7_6 javapackages-tools.noarch 0:3.4.1-11.el7 libICE.x86_64 0:1.0.9-9.el7 libSM.x86_64 0:1.2.2-2.el7 libX11.x86_64 0:1.6.5-2.el7 libX11-common.noarch 0:1.6.5-2.el7 libXau.x86_64 0:1.0.8-2.1.el7 libXcomposite.x86_64 0:0.4.4-4.1.el7 libXext.x86_64 0:1.3.3-3.el7 libXi.x86_64 0:1.7.9-1.el7 libXrender.x86_64 0:0.9.10-1.el7 libXtst.x86_64 0:1.2.3-1.el7 libfontenc.x86_64 0:1.1.3-3.el7 libjpeg-turbo.x86_64 0:1.2.90-6.el7 libxcb.x86_64 0:1.13-1.el7 lksctp-tools.x86_64 0:1.0.17-2.el7 python-javapackages.noarch 0:3.4.1-11.el7 python-lxml.x86_64 0:3.2.1-4.el7 ttmkfdir.x86_64 0:3.0.9-42.el7 tzdata-java.noarch 0:2018i-1.el7 xorg-x11-font-utils.x86_64 1:7.5-21.el7 xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 Complete!

Since, our server is minimal installed, therefore, yum has installed various dependent packages along with OpenJDK.

Set JAVA_HOME environment variable.

[root@artifactory-01 ~]# echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64" >> /etc/profile [root@artifactory-01 ~]# . /etc/profile [root@artifactory-01 ~]# env | grep JAVA JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64

OpenJDK has been installed on CentOS 7.

 

Installing JFrog Artifactory OSS on CentOS 7:

Install preqrequisite packages using yum command.

[root@artifactory-01 ~]# yum install -y net-tools rsync Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ges.net.pk * extras: mirrors.ges.net.pk * updates: mirrors.ges.net.pk Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed ---> Package rsync.x86_64 0:3.1.2-4.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: net-tools x86_64 2.0-0.24.20131004git.el7 base 306 k rsync x86_64 3.1.2-4.el7 base 403 k Transaction Summary ================================================================================ Install 2 Packages Total download size: 709 k Installed size: 1.7 M Downloading packages: (1/2): net-tools-2.0-0.24.20131004git.el7.x86_64.rpm | 306 kB 00:03 (2/2): rsync-3.1.2-4.el7.x86_64.rpm | 403 kB 00:03 -------------------------------------------------------------------------------- Total 190 kB/s | 709 kB 00:03 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : rsync-3.1.2-4.el7.x86_64 1/2 Installing : net-tools-2.0-0.24.20131004git.el7.x86_64 2/2 Verifying : net-tools-2.0-0.24.20131004git.el7.x86_64 1/2 Verifying : rsync-3.1.2-4.el7.x86_64 2/2 Installed: net-tools.x86_64 0:2.0-0.24.20131004git.el7 rsync.x86_64 0:3.1.2-4.el7 Complete!

Download latest JFrog Artifactory OSS RPM and copy it to the home directory of root user.

Install Jfrog Artifactory RPM.

[root@artifactory-01 ~]# yum install -y jfrog-artifactory-oss-6.6.5.rpm Loaded plugins: fastestmirror Examining jfrog-artifactory-oss-6.6.5.rpm: jfrog-artifactory-oss-6.6.5-60605900.noarch Marking jfrog-artifactory-oss-6.6.5.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package jfrog-artifactory-oss.noarch 0:6.6.5-60605900 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: jfrog-artifactory-oss noarch 6.6.5-60605900 /jfrog-artifactory-oss-6.6.5 103 M Transaction Summary ================================================================================ Install 1 Package Total size: 103 M Installed size: 103 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Checking if group artifactory exists... Group artifactory doesn't exist. Creating ... Checking if user artifactory exists... User artifactory doesn't exist. Creating ... Checking if ARTIFACTORY_HOME exists Removing tomcat work directory Installing : jfrog-artifactory-oss-6.6.5-60605900.noarch 1/1 Adding the artifactory service to auto-start DONE NOTE: The following procedures change the ownership of files and may take several minutes. Do not stop the installation/upgrade process. The installation of Artifactory has completed successfully. PLEASE NOTE: It is highly recommended to use Artifactory with conjunction with an external database (MySQL, Oracle, Microsoft SQL Server, PostgreSQL, MariaDB). For details about how to configure the database, refer to https://www.jfrog.com/confluence/display/RTF/Configuring+the+Database You can activate artifactory with: > systemctl start artifactory.service Then check the status with: > systemctl status artifactory.service Verifying : jfrog-artifactory-oss-6.6.5-60605900.noarch 1/1 Installed: jfrog-artifactory-oss.noarch 0:6.6.5-60605900 Complete!

Set ARTIFACTORY_HOME environment variable.

[root@artifactory-01 ~]# echo "export ARTIFACTORY_HOME=/opt/jfrog/artifactory" >> /etc/profile [root@artifactory-01 ~]# . /etc/profile [root@artifactory-01 ~]# env | grep ARTIFACTORY_HOME ARTIFACTORY_HOME=/opt/jfrog/artifactory

JFrog Artifactory has been installed on CentOS 7.

 

Installing MariaDB Database on CentOS 7:

It is recommended to use JFrog Artifactory with an external database. Being a hardcore FOSS (Fan of Open Source Software), we selected MariaDB Database for this purpose.

Install MariaDB Server from CentOS yum repository.

[root@artifactory-01 ~]# yum install -y mariadb-server ... Installed: mariadb-server.x86_64 1:5.5.60-1.el7_5 Dependency Installed: mariadb.x86_64 1:5.5.60-1.el7_5 perl.x86_64 4:5.16.3-293.el7 perl-Carp.noarch 0:1.26-244.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 perl-Pod-Escapes.noarch 1:1.04-293.el7 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-293.el7 perl-macros.x86_64 4:5.16.3-293.el7 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 Complete!

Start and Enable MariaDB Service.

[root@artifactory-01 ~]# systemctl start mariadb.service [root@artifactory-01 ~]# systemctl enable mariadb.service Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

Configure MariaDB database instance as follows.

[root@artifactory-01 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

Create and configure Artifactory database.

[root@artifactory-01 ~]# /opt/jfrog/artifactory/bin/configure.mysql.sh ######################################################## # Welcome to the Artifactory MySQL configuration tool! # ######################################################## Stopping the Artifactory service... Please enter the MySQL server admin username [root]: Please enter the MySQL server admin password: Please enter the Artifactory database username [artifactory]: Please enter the Artifactory database password [password]: Creating the Artifactory MySQL user and database... No MySQL JDBC connector found. Download or copy one needed. Does the current server has access to the Internet? [Y/n]Y Downloading mysql-connector-java-5.1.24.jar to /opt/jfrog/artifactory/tomcat/lib... Configuration completed successfully! You can now start up the Artifactory service to use Artifactory with MySQL. Press enter to exit... [root@artifactory-01 ~]#

There is a known issue with PIDs in new versions of systemd, due to the more restricted handling of PID files by systemd. Therefore, you may encounter some PIDs error while starting artifactory.service.

[root@artifactory-01 ~]# systemctl start artifactory.service Job for artifactory.service failed because the control process exited with error code. See "systemctl status artifactory.service" and "journalctl -xe" for details.

Thanks to vivin, who has provided a complete wayaround of this problem at his blog.

The same steps have been reproduced below for completeness of this article.

Edit artifactory.service and add the user and group who own the service.

[root@artifactory-01 ~]# vi /lib/systemd/system/artifactory.service

Add following directives under the [service] section.

User=artifactory Group=artifactory

Set open file limits for the artifactory user.

[root@artifactory-01 ~]# echo "artifactory soft nofile 32000" >> /etc/security/limits.conf [root@artifactory-01 ~]# echo "artifactory hard nofile 32000" >> /etc/security/limits.conf

Now edit the artifactoryManage.sh script.

[root@artifactory-01 ~]# vi /opt/jfrog/artifactory/bin/artifactoryManage.sh

Find and replace the following 4 lines of code with the given code (Find yellow code and replace it with green code).

#su -s "/bin/sh" ${ARTIFACTORY_USER} -c "${replicatorScript} start" ${replicatorScript} start #su -s "/bin/sh" ${ARTIFACTORY_USER} -c "${replicatorScript} stop" ${replicatorScript} stop #su -s "/bin/sh" ${ARTIFACTORY_USER} -c "export JAVA_HOME='$JAVA_HOME'; $TOMCAT_HOME/bin/startup.sh" $TOMCAT_HOME/bin/startup.sh #su -s "/bin/sh" ${ARTIFACTORY_USER} -c "export JAVA_HOME='$JAVA_HOME'; $TOMCAT_HOME/bin/shutdown.sh" $TOMCAT_HOME/bin/shutdown.sh

Start and enable Artifactory service.

[root@artifactory-01 ~]# systemctl start artifactory.service [root@artifactory-01 ~]# systemctl enable artifactory.service Created symlink from /etc/systemd/system/multi-user.target.wants/artifactory.service to /usr/lib/systemd/system/artifactory.service.

Artifactory service has been started successfully.

Now allow artifactory service port to make it accessible from the network.

[root@artifactory-01 ~]# firewall-cmd --permanent --add-port=8081/tcp success [root@artifactory-01 ~]# firewall-cmd --reload success

Browse URL http://artifactory-01.example.com:8081 from a client browser.

jfrog-artifactory-webui-welcome-01

Click on Next.

jfrog-artifactory-webui-set-admin-password-02

Set the password for default admin user of Artifactory and click on Next.

jfrog-artifactory-webui-configure-proxy-03

If this server access the Internet through a proxy, then configure it here or click on Skip.

jfrog-artifactory-webui-create-repositories-04

Select the package types for which you want to create repositories. The default repositories for the selected package types will be created by the Artifactory. Or click on Skip.

jfrog-artifactory-webui-config-completed-05

The initial configuration of Artifactory has been completed. Click on Finish.

jfrog-artifactory-webui-dashboard-01

You have reached at the Dashboard of Jfrog Artifactory Web UI. This dashboard is enriched with links to guides and documentation related to JFrog Artifactory. You can browse these links and start using JFrog Artifactory accordingly.

JFrog Artifactory has been successfully installed and configured on CentOS / RHEL 7 server.

Installing JFrog Artifactory on CentOS / RHEL 7


YOU MIGHT ALSO LIKE:

3 comments:

  1. Hi Dear,

    According to your blog, I have created setup but I have found issues in it, Please suggest me. for your reference I have append below logs of Artifactory server.

    Logs:


    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    ... 105 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accessJdbcHelperImpl': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Could not initialize database: Unable to load class: com.mysql.jdbc.Driver from ClassLoader:ParallelWebappClassLoader
    context: access
    delegate: false
    ----------> Parent Classloader:
    java.net.URLClassLoader@3a71f4dd
    ;ClassLoader:ParallelWebappClassLoader
    context: access
    delegate: false
    ----------> Parent Classloader:
    java.net.URLClassLoader@3a71f4dd

    ReplyDelete
    Replies
    1. Hi Ashish,

      Thanks for using my article.

      Although, the given log isn't enough to pin-point the actual problem. But, I have intuition that the problem is somehow related to MySQL Java connector. Therefore, I suggest you to repeat step /opt/jfrog/artifactory/bin/configure.mysql.sh again and check.

      Delete