之前使用Nexus搭建过私服,可惜做完后没怎么用就重装系统了。这次想搭建私服时想起Jcenter和Spring都使用Artifactory私服,看着界面也比Nexus漂亮、顺眼,所以就选择Artifactory作为私服工具了。
本文主要参考:Install Artifactory on CentOS和官方用户指南。
安装手册
Artifactory有多种安装选择,我选择了其中的Service Installation。
Artifactory服务安装说明
Artifactory 是一个内置tomcat的zip包,拥有一个完整的linux服务安装脚本。
当作为一个服务运行Artifactory ,安装脚本创建一个名为Artifactory的用户,并且这个用户必须有安装的目录的运行和执行权限。因此,建议下载安装zip到一个授权所有用户运行、执行的文件夹,如/opt。
下载jfrog-artifactory-oss-4.8.2.zip到/opt
解压jfrog-artifactory-oss-4.8.2.zip,
unzip jfrog-artifactory-oss-4.8.2.zip
修改JVM运行参数,$ARTIFACTORY_HOME/etc/default:``
在vim模式下查找文件内容:按下斜线(/),光标会跑到消息行,然后vim会显示斜线。在输入你要查找的文本后,按下回车键。要继续查找同一个单词,按下n键,表示下一个。
修改JVM运行参数后,需要重启artifactory服务
实际上没有在$ARTIFACTORY_HOME/etc/下找到default文件,反而在$ARTIFACTORY_HOME/bin/下找到了artifactory.default文件,暂且修改这个(如果不生效,再查找其他资料)
修改artifactory.default文件,
export ARTIFACTORY_HOME=/opt/artifactory-oss-4.8.2 ;export ARTIFACTORY_USER=artifactory ;START_TMO=60
安装Artifactory
跳转到$ARTIFACTORY_HOME/bin,以root执行下面的命令:
$ARTIFACTORY_HOME/bin/installService.sh [USER [GROUP]]
实际执行:
bin/installService.sh
Installing artifactory as a Unix service that will run as user artifactory
Installing artifactory with home /opt/artifactory-oss-4.8.2
Creating user artifactory...creating... DONE
Checking configuration link and files in /etc/opt/jfrog/artifactory...
Moving configuration dir /opt/artifactory-oss-4.8.2/etc /opt/artifactory-oss-4.8.2/etc.original...creating the link and updating dir... DONE
Creating environment file /etc/opt/jfrog/artifactory/default...creating... DONE
** INFO: Please edit the files in /etc/opt/jfrog/artifactory to set the correct environment
Especially /etc/opt/jfrog/artifactory/default that defines ARTIFACTORY_HOME, JAVA_HOME and JAVA_OPTIONS
Initializing artifactory service with chkconfig...
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
artifactory 0:关 1:关 2:开 3:开 4:开 5:开 6:关
DONE
Setting file permissions... DONE
************ SUCCESS ****************
Installation of Artifactory completed
Please check /etc/opt/jfrog/artifactory, /opt/artifactory-oss-4.8.2/tomcat and /opt/artifactory-oss-4.8.2 folders
Please check /etc/init.d/artifactory startup script
you can now check installation by running:
> service artifactory check (or /etc/init.d/artifactory check)
Then activate artifactory with:
> service artifactory start (or /etc/init.d/artifactory start)
看执行结果,有很多需要设置而为设置的项。
运行Artifactory无权限
以非root用户运行报错:
service artifactory start
/bin/java
Starting Artifactory tomcat as user artifactory...
/etc/init.d/artifactory: line 80: ulimit: open files: cannot modify limit: Operation not permitted
WARNING: Max number of open files 1024 is too small!
You should add:
artifactory soft nofile 32000
artifactory hard nofile 32000
to your /etc/security/limits.conf file.
Password:
成功运行Artifactory服务
root用户运行:
service artifactory start
/bin/java
Starting Artifactory tomcat as user artifactory...
Max number of open files: 32000
Using ARTIFACTORY_HOME: /opt/artifactory-oss-4.8.2
Using ARTIFACTORY_PID: /opt/artifactory-oss-4.8.2/run/artifactory.pid
Using CATALINA_BASE: /opt/artifactory-oss-4.8.2/tomcat
Using CATALINA_HOME: /opt/artifactory-oss-4.8.2/tomcat
Using CATALINA_TMPDIR: /opt/artifactory-oss-4.8.2/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/artifactory-oss-4.8.2/tomcat/bin/bootstrap.jar:/opt/artifactory-oss-4.8.2/tomcat/bin/tomcat-juli.jar
Using CATALINA_PID: /opt/artifactory-oss-4.8.2/run/artifactory.pid
Tomcat started.
Artifactory Tomcat started in normal mode
浏览器访问,http://localhost:8081/artifactory/
停止Artifactory服务
service artifactory stop
Stopping Artifactory Tomcat...
Max number of open files: 1024
Using ARTIFACTORY_HOME: /opt/artifactory-oss-4.8.2
Using ARTIFACTORY_PID: /opt/artifactory-oss-4.8.2/run/artifactory.pid
Using CATALINA_BASE: /opt/artifactory-oss-4.8.2/tomcat
Using CATALINA_HOME: /opt/artifactory-oss-4.8.2/tomcat
Using CATALINA_TMPDIR: /opt/artifactory-oss-4.8.2/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/artifactory-oss-4.8.2/tomcat/bin/bootstrap.jar:/opt/artifactory-oss-4.8.2/tomcat/bin/tomcat-juli.jar
Using CATALINA_PID: /opt/artifactory-oss-4.8.2/run/artifactory.pid
Tomcat stopped.
Artifactory Tomcat stopped
查看Artifactory服务的状态
Artifactory安装后,可以使用下面的命令查看Artifactory服务的状态:
service artifactory check
如果,Artifactory服务正在运行,你可以查看它的pid:
service artifactory check
Artifactory is running, on pid=5319
如果,Artifactory服务没有启动,你可以看到它的运行参数:
service artifactory check
Checking arguments to Artifactory:
ARTIFACTORY_HOME = /opt/artifactory-oss-4.8.2
ARTIFACTORY_USER = artifactory
TOMCAT_HOME = /opt/artifactory-oss-4.8.2/tomcat
ARTIFACTORY_PID = /opt/artifactory-oss-4.8.2/run/artifactory.pid
JAVA_HOME =
JAVA_OPTIONS = -server -Xms512m -Xmx2g -Xss256k -XX:+UseG1GC -Djruby.compile.invokedynamic=false -Dfile.encoding=UTF8 -Dartdist=zip -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
/bin/java
查看Artifactory日志
可以使用下面的命令查看Artifactory日志:
tail -f $ARTIFACTORY_HOME/logs/artifactory.log
实际运行时,没有找到ARTIFACTORY_HOME环境变量,暂以绝对路径查看:
tail -f /opt/artifactory-oss-4.8.2/logs/artifactory.log
2016-06-25 17:22:30,034 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:301) - Destroying org.artifactory.repo.service.InternalRepositoryService
2016-06-25 17:22:30,035 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:301) - Destroying org.artifactory.schedule.TaskService
2016-06-25 17:22:30,039 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:301) - Destroying org.artifactory.state.model.ArtifactoryStateManager
2016-06-25 17:22:30,043 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:301) - Destroying org.artifactory.config.InternalCentralConfigService
2016-06-25 17:22:30,044 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:301) - Destroying org.artifactory.config.ConfigurationChangesInterceptors
2016-06-25 17:22:30,044 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:301) - Destroying org.artifactory.repo.interceptor.StorageInterceptors
2016-06-25 17:22:30,044 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:301) - Destroying org.artifactory.storage.db.DbService
2016-06-25 17:22:30,045 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:301) - Destroying org.artifactory.md.MetadataDefinitionService
2016-06-25 17:22:30,046 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactoryApplicationContext:315) - Closing Artifactory: startup date [Sat Jun 25 17:20:37 CST 2016]; root of context hierarchy
2016-06-25 17:22:30,054 [localhost-startStop-2] [INFO ] (o.a.s.ArtifactorySchedulerFactoryBean:765) - Shutting down Quartz Scheduler
安全相关
When installing from an RPM or Debian distribution, Artifactory is generally started as root and will su internally to the $ARTIFACTORY_USER user.
For reasons of security, it is not recommended to leave the $ARTIFACTORY_USER variable undefined with Artifactory running as the current user, especially if the current user is root.
安装脚本的执行顺序
The following table describes the sequence of commands performed by the install script
创建用户
创建一个名为artifactory的用户,也可以通过修改/etc/opt/jfrog/artifactory/default中的ARTIFACTORY_USER改变默认用户。
另外,也可以在启动命令中设置默认用户,方法是把user作为第一个参数,也可以在设置user的同时设置group。
etc 配置
创建一个文件夹 /etc/opt/jfrog/artifactory,复制配置文件到文件夹下并创建一个软连接到$ARTIFACTORY_HOME/etc。
Creates the folder /etc/opt/jfrog/artifactory, copies the configuration files there and creates a soft link in$ARTIFACTORY_HOME/etc
etc 默认设置
Creates the file /etc/opt/jfrog/artifactory/default containing the main environment variables needed for Artifactory to run:JAVA_HOME, ARTIFACTORY_USER, ARTIFACTORY_HOME, JAVA_OPTIONS,...
The /etc/opt/jfrog/artifactory/default is included at the top of artifactoryctl and can include any settings.
To modify your JVM parameters modify JAVA_OPTIONS in /etc/opt/jfrog/artifactory/default
init.d
复制服务脚本文件artifactory到/etc/init.d/artifactory
Logs 文件夹
Creates the folder $ARTIFACTORY_HOME/logs, makes it writable for the user ARTIFACTORY_USER and creates a soft link $ARTIFACTORY_HOME/logs.
The $ARTIFACTORY_HOME/tomcat/logs folder is linked to $ARTIFACTORY_HOME/logs/catalina.
Backup 文件夹
Creates the folder $ARTIFACTORY_HOME/backup, so you must create a link if you want this folder to point to a different place (such as /var/backup/artifactory for example). The script makes $ARTIFACTORY_HOME/backup writable for the user ARTIFACTORY_USER
Data folder
Creates the folder $ARTIFACTORY_HOME/data, so you must create a link if you want this folder to point to somewhere else. The script makes it writable for the user ARTIFACTORY_USER.
chkconfig calls
The script calls add and list (you can see the output), and then activates the Artifactory service
一些配置
参考:Artifactory的搭建与使用简介
[用artifactory搭建maven2内部服务器 .
](http://blog.csdn.net/madun/article/details/8961659)
默认管理员:admin/password
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。