Skip to end of metadata
Go to start of metadata
Table of Contents

Note: This space is for Artifactory 2.0.
Take me to the latest version!

Overview

Artifactory can be configured to run with almost any JDBC database for its data store. The instructions below describes how to set up Artifactory on MySQL. By using MySQL (over the built-in Derby DB) you can leverage exiting MySQL infrastructure and use the MySQL backup, restore and high-availability features. The setup involves creating the dedicated MySQL database instance and then configuring Artifactory to use that instance.

Create the Artifactory MySQL Database

You can use the $ARTIFACTORY_HOME/misc/mysql/createdb.sql SQL script to execute the SQL commands below to create a database. Please review and edit this script before executing it, according to your environment.

Remote Database Access

In order to avoid network latency issues when reading and writing artifacts data, it is highly recommended to create the database on the same machine on which Artifactory will be running or on a fast SAN disk.

[root@pond artifactory]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database artifactory character set utf8;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on artifactory.* TO 'artifactory_user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

Increasing the MySQL Default Packet Size

Since binaries files are stored in MySQL, it is extremely important to increase the default packet size used by MySQL when serving binaries (see: max_allowed_packet increase, for reference).
We recommend changing this in the /etc/my.cnf file (create this file if it does not already exist):

# The MySQL server
[mysqld]
.
.
# This will be the maximum size of the binary artifacts (e.g. jars) the server can handle
max_allowed_packet=128M
.
.

Configure Artifactory to work against the MySQL database

  1. Add (or uncomment) the following line in $ARTIFACTORY_HOME/etc/artifactory.system.properties:
    artifactory.jcr.configPath=repo/mysql
    
    Note: this path is relative to $ARTIFACTORY_HOME/etc.
  2. Adjust the connection definitions in the file $ARTIFACTORY_HOME/etc/repo/mysql/repo.xml to match the attributes of the Artifactory database you created (if you don't have this file you can grab it from the standalone zip distribution or directly from here.).
    Jackrabbit uses 3 separate connection configurations for each of the following:
    1. The basic JCR repository metadata (configured under FileSystem). Minimal load and no connection pooling.
    2. The JCR datastore for all the binaries (configured under DataStore). Heavily loaded and uses connection pooling.
    3. The JCR workspace (signle in our case) metadata (configured under PersistenceManager).
      For each one of these tags you need to configure which database parameters and username/password to use. The schema and tables will be created on first run of Artifactory against the database.
  3. Download the MySQL JDBC driver and copy the mysql-connector-java-x.x.x.jar jar file into the server's shared lib directory ($ARTIFACTORY_HOME/lib in the standalone version), or to the the WEB-INF/lib directory of an exploded artifactory.war.
  4. Start Artifactory.

    The above process refers to a clean installation of Artifactory. If, by mistake, you started up Artifactory using the built-in database, Artifactory will "stick" to that database. You'd have to move away the $ARTIFACTORY_HOME/data folder (assuming you have no valuable deployments there) in order to be able to change the database to MySQL.

  • No labels