■ドキュメント

公式サイト

ドキュメント

 

■インストール要件

 

■インストール

Linuxインストール

・LTSのインストール方法

[centos7copy]$ wget -O /etc/yum.repos.d/jenkins.repo \
>     https://pkg.jenkins.io/redhat-stable/jenkins.repo

[centos7copy]$ ll /etc/yum.repos.d/jenkins.repo
-rw-r--r--. 1 root root 85 Nov 30  2016 /etc/yum.repos.d/jenkins.repo
[centos7copy]$ cat /etc/yum.repos.d/jenkins.repo
[jenkins]
name=Jenkins-stable
baseurl=http://pkg.jenkins.io/redhat-stable
gpgcheck=1                         ←これを一時的に0にしてgpgcheckをチャラく飛ばす

[centos7copy]$ yum install -y jenkins

----(略)----

Installed:
  jenkins.noarch 0:2.249.3-1.1

Complete!

・インストールされたファイル

[centos7copy]$ rpm -ql jenkins
/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins
/var/log/jenkins

・起動スクリプト

[centos7copy]$ cat -n /etc/init.d/jenkins
     1  #!/bin/sh
     2  #
     3  #     RedHat system statup script for Jenkins
     4  #     Based on SUSE system statup script for Jenkins
     5  #     Copyright (C) 2007  Pascal Bleser
     6  #
     7  #     This library is free software; you can redistribute it and/or modify it
     8  #     under the terms of the GNU Lesser General Public License as published by
     9  #     the Free Software Foundation; either version 2.1 of the License, or (at
    10  #     your option) any later version.
    11  #
    12  #     This library is distributed in the hope that it will be useful, but
    13  #     WITHOUT ANY WARRANTY; without even the implied warranty of
    14  #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    15  #     Lesser General Public License for more details.
    16  #
    17  #     You should have received a copy of the GNU Lesser General Public
    18  #     License along with this library; if not, write to the Free Software
    19  #     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
    20  #     USA.
    21  #
    22  ###############################################################################
    23  #
    24  # chkconfig: 35 99 01
    25  # description: Jenkins Automation Server
    26  #
    27  ###############################################################################
    28  ### BEGIN INIT INFO
    29  # Provides:          jenkins
    30  # Required-Start:    $local_fs $remote_fs $network $time $named
    31  # Should-Start: $time sendmail
    32  # Required-Stop:     $local_fs $remote_fs $network $time $named
    33  # Should-Stop: $time sendmail
    34  # Default-Start:     3 5
    35  # Default-Stop:      0 1 2 6
    36  # Short-Description: Jenkins Automation Server
    37  # Description:       Jenkins Automation Server
    38  ### END INIT INFO
    39
    40  # Check for missing binaries (stale symlinks should not happen)
    41  JENKINS_WAR="/usr/lib/jenkins/jenkins.war"
    42  test -r "$JENKINS_WAR" || { echo "$JENKINS_WAR not installed";
    43          if [ "$1" = "stop" ]; then exit 0;
    44          else exit 5; fi; }
    45
    46  # Check for existence of needed config file and read it
    47  JENKINS_CONFIG=/etc/sysconfig/jenkins
    48  test -e "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not existing";
    49          if [ "$1" = "stop" ]; then exit 0;
    50          else exit 6; fi; }
    51  test -r "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not readable. Perhaps you forgot 'sudo'?";
    52          if [ "$1" = "stop" ]; then exit 0;
    53          else exit 6; fi; }
    54
    55  JENKINS_PID_FILE="/var/run/jenkins.pid"
    56  JENKINS_LOCKFILE="/var/lock/subsys/jenkins"
    57
    58  # Source function library.
    59  . /etc/init.d/functions
    60
    61  # Read config
    62  [ -f "$JENKINS_CONFIG" ] && . "$JENKINS_CONFIG"
    63
    64  # Set up environment accordingly to the configuration settings
    65  [ -n "$JENKINS_HOME" ] || { echo "JENKINS_HOME not configured in $JENKINS_CONFIG";
    66          if [ "$1" = "stop" ]; then exit 0;
    67          else exit 6; fi; }
    68  [ -d "$JENKINS_HOME" ] || { echo "JENKINS_HOME directory does not exist: $JENKINS_HOME";
    69          if [ "$1" = "stop" ]; then exit 0;
    70          else exit 1; fi; }
    71
    72  # Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
    73  # see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
    74  candidates="
    75  /etc/alternatives/java
    76  /usr/lib/jvm/java-1.8.0/bin/java
    77  /usr/lib/jvm/jre-1.8.0/bin/java
    78  /usr/lib/jvm/java-1.7.0/bin/java
    79  /usr/lib/jvm/jre-1.7.0/bin/java
    80  /usr/lib/jvm/java-11.0/bin/java
    81  /usr/lib/jvm/jre-11.0/bin/java
    82  /usr/lib/jvm/java-11-openjdk-amd64
    83  /usr/bin/java
    84  "
    85  for candidate in $candidates
    86  do
    87    [ -x "$JENKINS_JAVA_CMD" ] && break
    88    JENKINS_JAVA_CMD="$candidate"
    89  done
    90
    91  JAVA_CMD="$JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"
    92  PARAMS="--logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon"
    93  [ -n "$JENKINS_PORT" ] && PARAMS="$PARAMS --httpPort=$JENKINS_PORT"
    94  [ -n "$JENKINS_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --httpListenAddress=$JENKINS_LISTEN_ADDRESS"
    95  [ -n "$JENKINS_HTTPS_PORT" ] && PARAMS="$PARAMS --httpsPort=$JENKINS_HTTPS_PORT"
    96  [ -n "$JENKINS_HTTPS_KEYSTORE" ] && PARAMS="$PARAMS --httpsKeyStore=$JENKINS_HTTPS_KEYSTORE"
    97  [ -n "$JENKINS_HTTPS_KEYSTORE_PASSWORD" ] && PARAMS="$PARAMS --httpsKeyStorePassword='$JENKINS_HTTPS_KEYSTORE_PASSWORD'"
    98  [ -n "$JENKINS_HTTPS_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --httpsListenAddress=$JENKINS_HTTPS_LISTEN_ADDRESS"
    99  [ -n "$JENKINS_HTTP2_PORT" ] && PARAMS="$PARAMS --http2Port=$JENKINS_HTTP2_PORT"
   100  [ -n "$JENKINS_HTTP2_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --http2ListenAddress=$JENKINS_HTTP2_LISTEN_ADDRESS"
   101  [ -n "$JENKINS_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$JENKINS_DEBUG_LEVEL"
   102  [ -n "$JENKINS_HANDLER_STARTUP" ] && PARAMS="$PARAMS --handlerCountStartup=$JENKINS_HANDLER_STARTUP"
   103  [ -n "$JENKINS_HANDLER_MAX" ] && PARAMS="$PARAMS --handlerCountMax=$JENKINS_HANDLER_MAX"
   104  [ -n "$JENKINS_HANDLER_IDLE" ] && PARAMS="$PARAMS --handlerCountMaxIdle=$JENKINS_HANDLER_IDLE"
   105  [ -n "$JENKINS_EXTRA_LIB_FOLDER" ] && PARAMS="$PARAMS --extraLibFolder=$JENKINS_EXTRA_LIB_FOLDER"
   106  [ -n "$JENKINS_ARGS" ] && PARAMS="$PARAMS $JENKINS_ARGS"
   107
   108  if [ "$JENKINS_ENABLE_ACCESS_LOG" = "yes" ]; then
   109      PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/jenkins/access_log"
   110  fi
   111
   112  RETVAL=0
   113
   114  case "$1" in
   115      start)
   116          echo -n "Starting Jenkins "
   117          daemon --user "$JENKINS_USER" --pidfile "$JENKINS_PID_FILE" $JAVA_CMD $PARAMS > /dev/null
   118          RETVAL=$?
   119          if [ $RETVAL = 0 ]; then
   120              success
   121              echo > "$JENKINS_PID_FILE"  # just in case we fail to find it
   122              MY_SESSION_ID=`/bin/ps h -o sess -p $$`
   123              # get PID
   124              /bin/ps hww -u "$JENKINS_USER" -o sess,ppid,pid,cmd | \
   125              while read sess ppid pid cmd; do
   126                  [ "$ppid" = 1 ] || continue
   127                  # this test doesn't work because Jenkins sets a new Session ID
   128                  # [ "$sess" = "$MY_SESSION_ID" ] || continue
   129                  echo "$cmd" | grep $JENKINS_WAR > /dev/null
   130                  [ $? = 0 ] || continue
   131                  # found a PID
   132                  echo $pid > "$JENKINS_PID_FILE"
   133              done
   134              touch $JENKINS_LOCKFILE
   135          else
   136              failure
   137          fi
   138          echo
   139          ;;
   140      stop)
   141          echo -n "Shutting down Jenkins "
   142          killproc jenkins
   143          rm -f $JENKINS_LOCKFILE
   144          RETVAL=$?
   145          echo
   146          ;;
   147      try-restart|condrestart)
   148          if test "$1" = "condrestart"; then
   149                  echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
   150          fi
   151          $0 status
   152          if test $? = 0; then
   153                  $0 restart
   154          else
   155                  : # Not running is not a failure.
   156          fi
   157          ;;
   158      restart)
   159          $0 stop
   160          $0 start
   161          ;;
   162      force-reload)
   163          echo -n "Reload service Jenkins "
   164          $0 try-restart
   165          ;;
   166      reload)
   167          $0 restart
   168          ;;
   169      status)
   170          status jenkins
   171          RETVAL=$?
   172          ;;
   173      probe)
   174          ## Optional: Probe for the necessity of a reload, print out the
   175          ## argument to this init script which is required for a reload.
   176          ## Note: probe is not (yet) part of LSB (as of 1.9)
   177
   178          test "$JENKINS_CONFIG" -nt "$JENKINS_PID_FILE" && echo reload
   179          ;;
   180      *)
   181          echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
   182          exit 1
   183          ;;
   184  esac
   185  exit $RETVAL

・ログファイル

[起動前]

[centos7copy]$ ll /var/log/jenkins/
total 0

[起動後]

[centos7copy]$ service jenkins start
Starting jenkins (via systemctl):                          [  OK  ]

[centos7copy]$ ll /var/log/jenkins/
total 8
-rw-r--r--. 1 jenkins jenkins 5750 Nov 12 09:54 jenkins.log

[centos7copy]$ wc -l /var/log/jenkins/jenkins.log
55 /var/log/jenkins/jenkins.log

[centos7copy]$ head /var/log/jenkins/jenkins.log
Running from: /usr/lib/jenkins/jenkins.war
2020-11-12 00:54:09.344+0000 [id=1]     WARNING winstone.Logger#logInternal: Parameter handlerCountMax is now deprecated
2020-11-12 00:54:09.358+0000 [id=1]     WARNING winstone.Logger#logInternal: Parameter handlerCountMaxIdle is now deprecated
2020-11-12 00:54:09.368+0000 [id=1]     INFO    org.eclipse.jetty.util.log.Log#initialized: Logging initialized @392ms to org.eclipse.jetty.util.log.JavaUtilLog
2020-11-12 00:54:09.412+0000 [id=1]     INFO    winstone.Logger#logInternal: Beginning extraction from war file
2020-11-12 00:54:11.607+0000 [id=1]     WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2020-11-12 00:54:11.649+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: jetty-9.4.30.v20200611; built: 2020-06-11T12:34:51.929Z; git: 271836e4c1f4612f12b7bb13ef5a92a927634b0d; jvm 1.8.0_262-b10
2020-11-12 00:54:11.953+0000 [id=1]     INFO    o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2020-11-12 00:54:11.985+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2020-11-12 00:54:11.986+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults

[centos7copy]$ tail /var/log/jenkins/jenkins.log

*************************************************************
*************************************************************
*************************************************************

2020-11-12 00:54:36.215+0000 [id=47]    INFO    h.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
2020-11-12 00:54:36.218+0000 [id=47]    INFO    hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1
2020-11-12 00:54:36.220+0000 [id=47]    INFO    hudson.model.AsyncPeriodicWork#lambda$doRun$0: Finished Download metadata. 11,586 ms
2020-11-12 00:54:36.800+0000 [id=29]    INFO    jenkins.InitReactorRunner$1#onAttained: Completed initialization
2020-11-12 00:54:36.811+0000 [id=21]    INFO    hudson.WebAppMain$3#run: Jenkins is fully up and running

・ログローテーション設定

[centos7copy]$ cat /etc/logrotate.d/jenkins
/var/log/jenkins/jenkins.log /var/log/jenkins/access_log {
    compress
    dateext
    maxage 365
    rotate 99
    size=+4096k
    notifempty
    missingok
    create 644
    copytruncate
}



・プロセス確認

[centos7copy]$ ps -ef | grep jenkin[s]
jenkins   36635      1 16 09:54 ?        00:00:24 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20

[centos7copy]$ pstree -p 36635

[centos7copy]$ netstat -naptl | grep 36635
tcp6       0      0 :::8080                 :::*                    LISTEN      36635/java

 

・ブラウザからアクセス

administratorの初期パスワードは、上記の通り

[centos7copy]$ cat /var/lib/jenkins/secrets/initialAdminPassword
9fc18b7d2bcf4b4997bb71c54912669a

上記のパスあーどを入力ると下記の画面に遷移する

上記の「Install suggested plugins」をクリック

※マニュアルによると、「to install the recommended set of plugins, which are based on most common use cases.」とのこと。

→インストールが始まる。

上記セットアップが完了すると下記のようにadministratorパスワード変更画面に遷移する

パスワード変更すると下記のような画面に遷移する。

左ペイン内の「新規ジョブ作成」をクリック

いったん戻って「開発者」をクリック

戻って「jenkinsの管理」をクリック

 

もう一回ログを見てみる。

[centos7copy]$ ls -l /var/log/jenkins/
total 52
-rw-r--r--. 1 jenkins jenkins 48348 Nov 12 10:15 jenkins.log

[centos7copy]$ wc -l /var/log/jenkins/jenkins.log
372 /var/log/jenkins/jenkins.log

 

・コンフィグ確認

[centos7copy]$ cat -n /etc/sysconfig/jenkins
     1  ## Path:        Development/Jenkins
     2  ## Description: Jenkins Automation Server
     3  ## Type:        string
     4  ## Default:     "/var/lib/jenkins"
     5  ## ServiceRestart: jenkins
     6  #
     7  # Directory where Jenkins store its configuration and working
     8  # files (checkouts, build reports, artifacts, ...).
     9  #
    10  JENKINS_HOME="/var/lib/jenkins"
    11
    12  ## Type:        string
    13  ## Default:     ""
    14  ## ServiceRestart: jenkins
    15  #
    16  # Java executable to run Jenkins
    17  # When left empty, we'll try to find the suitable Java.
    18  #
    19  JENKINS_JAVA_CMD=""
    20
    21  ## Type:        string
    22  ## Default:     "jenkins"
    23  ## ServiceRestart: jenkins
    24  #
    25  # Unix user account that runs the Jenkins daemon
    26  # Be careful when you change this, as you need to update
    27  # permissions of $JENKINS_HOME and /var/log/jenkins.
    28  #
    29  JENKINS_USER="jenkins"
    30
    31  ## Type:        string
    32  ## Default: "false"
    33  ## ServiceRestart: jenkins
    34  #
    35  # Whether to skip potentially long-running chown at the
    36  # $JENKINS_HOME location. Do not enable this, "true", unless
    37  # you know what you're doing. See JENKINS-23273.
    38  #
    39  #JENKINS_INSTALL_SKIP_CHOWN="false"
    40
    41  ## Type: string
    42  ## Default:     "-Djava.awt.headless=true"
    43  ## ServiceRestart: jenkins
    44  #
    45  # Options to pass to java when running Jenkins.
    46  #
    47  JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
    48
    49  ## Type:        integer(0:65535)
    50  ## Default:     8080
    51  ## ServiceRestart: jenkins
    52  #
    53  # Port Jenkins is listening on.
    54  # Set to -1 to disable
    55  #
    56  JENKINS_PORT="8080"
    57
    58  ## Type:        string
    59  ## Default:     ""
    60  ## ServiceRestart: jenkins
    61  #
    62  # IP address Jenkins listens on for HTTP requests.
    63  # Default is all interfaces (0.0.0.0).
    64  #
    65  JENKINS_LISTEN_ADDRESS=""
    66
    67  ## Type:        integer(0:65535)
    68  ## Default:     ""
    69  ## ServiceRestart: jenkins
    70  #
    71  # HTTPS port Jenkins is listening on.
    72  # Default is disabled.
    73  #
    74  JENKINS_HTTPS_PORT=""
    75
    76  ## Type:        string
    77  ## Default:     ""
    78  ## ServiceRestart: jenkins
    79  #
    80  # Path to the keystore in JKS format (as created by the JDK 'keytool').
    81  # Default is disabled.
    82  #
    83  JENKINS_HTTPS_KEYSTORE=""
    84
    85  ## Type:        string
    86  ## Default:     ""
    87  ## ServiceRestart: jenkins
    88  #
    89  # Password to access the keystore defined in JENKINS_HTTPS_KEYSTORE.
    90  # Default is disabled.
    91  #
    92  JENKINS_HTTPS_KEYSTORE_PASSWORD=""
    93
    94  ## Type:        string
    95  ## Default:     ""
    96  ## ServiceRestart: jenkins
    97  #
    98  # IP address Jenkins listens on for HTTPS requests.
    99  # Default is disabled.
   100  #
   101  JENKINS_HTTPS_LISTEN_ADDRESS=""
   102
   103  ## Type:        integer(0:65535)
   104  ## Default:     ""
   105  ## ServiceRestart: jenkins
   106  #
   107  # HTTP2 port Jenkins is listening on.
   108  # Default is disabled.
   109  #
   110  # Notice: HTTP2 support may require additional configuration, see Winstone
   111  # documentation for more information.
   112  #
   113  JENKINS_HTTP2_PORT=""
   114
   115  ## Type:        string
   116  ## Default:     ""
   117  ## ServiceRestart: jenkins
   118  #
   119  # IP address Jenkins listens on for HTTP2 requests.
   120  # Default is disabled.
   121  #
   122  # Notice: HTTP2 support may require additional configuration, see Winstone
   123  # documentation for more information.
   124  #
   125  JENKINS_HTTP2_LISTEN_ADDRESS=""
   126
   127  ## Type:        integer(1:9)
   128  ## Default:     5
   129  ## ServiceRestart: jenkins
   130  #
   131  # Debug level for logs -- the higher the value, the more verbose.
   132  # 5 is INFO.
   133  #
   134  JENKINS_DEBUG_LEVEL="5"
   135
   136  ## Type:        yesno
   137  ## Default:     no
   138  ## ServiceRestart: jenkins
   139  #
   140  # Whether to enable access logging or not.
   141  #
   142  JENKINS_ENABLE_ACCESS_LOG="no"
   143
   144  ## Type:        integer
   145  ## Default:     100
   146  ## ServiceRestart: jenkins
   147  #
   148  # Maximum number of HTTP worker threads.
   149  #
   150  JENKINS_HANDLER_MAX="100"
   151
   152  ## Type:        integer
   153  ## Default:     20
   154  ## ServiceRestart: jenkins
   155  #
   156  # Maximum number of idle HTTP worker threads.
   157  #
   158  JENKINS_HANDLER_IDLE="20"
   159
   160  ## Type:        string
   161  ## Default:     ""
   162  ## ServiceRestart: jenkins
   163  #
   164  # Folder for additional jar files to add to the Jetty class loader.
   165  # See Winstone documentation for more information.
   166  # Default is disabled.
   167  #
   168  JENKINS_EXTRA_LIB_FOLDER=""
   169
   170  ## Type:        string
   171  ## Default:     ""
   172  ## ServiceRestart: jenkins
   173  #
   174  # Pass arbitrary arguments to Jenkins.
   175  # Full option list: java -jar jenkins.war --help
   176  #
   177  JENKINS_ARGS=""

 

 

 

■ドキュメント

公式サイトのドキュメント

 

■参考

オフライン環境構築 Nexus Repository3編

Nexus Repository Manager3 を使って yum リポジトリを作る

Sonatype Nexus を CentOS 7 にインストールする手順

 

 

■ダウンロード

ダウンロード

nexus repository oss download

 ※Linux版のtar.gz形式のファイル

 

 

■システム要件

システム要件

・jdk8以上が必要

・デーモンは一般ユーザで実行

・open filesを 65,536以上にする

[centos7copy]$ cp -p /etc/security/limits.conf /etc/security/limits.conf.20201112
[centos7copy]$ vi /etc/security/limits.conf

----(編集)----
[centos7copy]$ diff /etc/security/limits.conf.20201112 /etc/security/limits.conf
69a70,74
> nexus         soft nofile             65536
> nexus         hard nofile             65536

[centos7copy]$ su - nexus -c "ulimit -n"
65536

・systemdのunitファイル

[centos7copy]$ cat /usr/lib/systemd/system/nexus.service

[Unit]
Description=nexus service
After=network.target

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

[Install]
WantedBy=multi-user.target

・CPUとメモリ

----(略)----

・java

ヒープサイズ(Xmxとか)

・ディスクサイズとか

----(略)----

 

■インストール

インストール

・JDK8の確認

[centos7copy]$ rpm -qa | grep jdk
java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64
java-1.7.0-openjdk-headless-1.7.0.261-2.6.22.2.el7_8.x86_64
copy-jdk-configs-3.3-10.el7_5.noarch
java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64
java-1.8.0-openjdk-devel-1.8.0.262.b10-0.el7_8.x86_64
java-1.8.0-openjdk-headless-1.8.0.262.b10-0.el7_8.x86_64

[centos7copy]$ which java
/usr/bin/java
[centos7copy]$ ll /usr/bin/java
lrwxrwxrwx. 1 root root 22 Nov  1 23:55 /usr/bin/java -> /etc/alternatives/java
[centos7copy]$ ll /etc/alternatives/java
lrwxrwxrwx. 1 root root 73 Nov  1 23:55 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/bin/java

・ユーザとグループの追加

[centos7copy]$ groupadd nexus
[centos7copy]$ useradd nexus -g nexus
[centos7copy]$ id nexus

uid=54334(nexus) gid=54334(nexus) groups=54334(nexus)

・上記の⑥からダウンロードしたtarボールを下記に保存

[centos7copy]$ ls -l /usr/local/src/nexus-3.28.1-01-unix.tar.gz
-rw-r--r--. 1 root root 166494026 Nov 12 07:20 /usr/local/src/nexus-3.28.1-01-unix.tar.gz

[centos7copy]$ cd /usr/local/src

[centos7copy]$ tar xf nexus-3.28.1-01-unix.tar.gz

[centos7copy]$ cd sonatype-work/
[centos7copy]$ ll

total 4
drwxr-xr-x. 5 root root 4096 Nov 12 07:31 nexus3

[centos7copy]$ ll nexus3/
total 12
-rw-r--r--. 1 root root    0 Oct 15 03:18 clean_cache
drwxr-xr-x. 2 root root 4096 Nov 12 07:31 log
drwxr-xr-x. 3 root root 4096 Nov 12 07:31 orient
drwxr-xr-x. 2 root root 4096 Nov 12 07:31 tmp

[centos7copy]$ ls -lR
total 12
-rw-r--r--. 1 root root    0 Oct 15 03:18 clean_cache
drwxr-xr-x. 2 root root 4096 Nov 12 07:31 log
drwxr-xr-x. 3 root root 4096 Nov 12 07:31 orient
drwxr-xr-x. 2 root root 4096 Nov 12 07:31 tmp

./log:
total 0

./orient:
total 4
drwxr-xr-x. 2 root root 4096 Nov 12 07:31 plugins

./orient/plugins:
total 7980
-rw-r--r--. 1 root root 8168747 Jun 12  2018 studio.zip

./tmp:
total 0

[centos7copy]$ cd /usr/local/src/nexus-3.28.1-01/
[centos7copy]$ ll

total 92
drwxr-xr-x.  3 root root  4096 Nov 12 07:31 bin
drwxr-xr-x.  2 root root  4096 Nov 12 07:31 deploy
drwxr-xr-x.  7 root root  4096 Nov 12 07:31 etc
drwxr-xr-x.  5 root root  4096 Nov 12 07:31 lib
-rw-r--r--.  1 root root   395 Oct 15 03:24 NOTICE.txt
-rw-r--r--.  1 root root 17321 Oct 15 03:24 OSS-LICENSE.txt
-rw-r--r--.  1 root root 41954 Oct 15 03:24 PRO-LICENSE.txt
drwxr-xr-x.  3 root root  4096 Nov 12 07:31 public
drwxr-xr-x. 21 root root  4096 Nov 12 07:31 system

[centos7copy]$ cd /usr/local/src
[centos7copy]$ chown -R nexus.nexus nexus-3.28.1-01

[centos7copy]$ chown -R nexus.nexus sonatype-work/
[centos7copy]$ ln -s /usr/local/src/nexus-3.28.1-01 /usr/local/nexus

 

・nexus起動

nexusはTCP8081をデフォルトで使う

[centos7copy]$ netstat -naplt | grep LISTEN | grep 8081
[centos7copy]$ echo $?

1

[centos7copy]$ su - nexus -c "/usr/local/nexus/bin/nexus start"
Starting nexus

[centos7copy]$ ps -ef | grep nexu[s]
nexus     26224      1  2 08:00 ?        00:00:01 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/bin/java -server -Dinstall4j.jvmDir=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre -Dexe4j.moduleName=/usr/local/nexus/bin/nexus -XX:+UnlockDiagnosticVMOptions -Dinstall4j.launcherId=245 -Dinstall4j.swt=false -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=../sonatype-work/nexus3/log/jvm.log -XX:-OmitStackTraceInFastThrow -Djava.net.preferIPv4Stack=true -Dkaraf.home=. -Dkaraf.base=. -Dkaraf.etc=etc/karaf -Djava.util.logging.config.file=etc/karaf/java.util.logging.properties -Dkaraf.data=../sonatype-work/nexus3 -Dkaraf.log=../sonatype-work/nexus3/log -Djava.io.tmpdir=../sonatype-work/nexus3/tmp -Dkaraf.startLocalConsole=false -Djava.endorsed.dirs=lib/endorsed -Di4j.vpt=true -classpath /usr/local/nexus/.install4j/i4jruntime.jar:/usr/local/nexus/lib/boot/nexus-main.jar:/usr/local/nexus/lib/boot/activation-1.1.1.jar:/usr/local/nexus/lib/boot/jakarta.xml.bind-api-2.3.3.jar:/usr/local/nexus/lib/boot/jaxb-runtime-2.3.3.jar:/usr/local/nexus/lib/boot/txw2-2.3.3.jar:/usr/local/nexus/lib/boot/istack-commons-runtime-3.0.10.jar:/usr/local/nexus/lib/boot/org.apache.karaf.main-4.2.9.jar:/usr/local/nexus/lib/boot/osgi.core-6.0.0.jar:/usr/local/nexus/lib/boot/org.apache.karaf.specs.activator-4.2.9.jar:/usr/local/nexus/lib/boot/org.apache.karaf.diagnostic.boot-4.2.9.jar:/usr/local/nexus/lib/boot/org.apache.karaf.jaas.boot-4.2.9.jar com.install4j.runtime.launcher.UnixLauncher start 9d17dc87 0 0 org.sonatype.nexus.karaf.NexusMain

[centos7copy]$ netstat -naplt | grep LISTEN | grep 26224
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      26224/java
tcp        0      0 127.0.0.1:33281         0.0.0.0:*               LISTEN      26224/java

[centos7copy]$ pstree 26224
java---78*[{java}]

・ブラウザでアクセスしてもアクセスできない

[centos7copy]$ openssl s_client -connect 192.168.19.201:8081
CONNECTED(00000003)
140680646010768:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 289 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : 0000
    Session-ID:
    Session-ID-ctx:
    Master-Key:
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    Start Time: 1605136873
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---

→サーバ証明書が居ない

localhostからアクセスするしかない?

adminのパスワードは、/usr/local/src/sonatype-work/nexus3/admin.passwordにあるらしい。

「next」をクリックしてadminのパスワードを再設定(admin123にした)

 

■ログ

[centos7copy]$ ll /usr/local/src/sonatype-work/
total 4
drwxr-xr-x. 14 nexus nexus 4096 Nov 12 08:41 nexus3

[centos7copy]$ ll /usr/local/src/sonatype-work/nexus3/
total 68
drwxr-xr-x.   3 nexus nexus  4096 Nov 12 07:54 blobs
drwxrwxr-x. 316 nexus nexus 12288 Nov 12 08:02 cache
drwxr-xr-x.   6 nexus nexus  4096 Nov 12 07:53 db
drwxr-xr-x.   3 nexus nexus  4096 Nov 12 07:56 elasticsearch
drwxr-xr-x.   3 nexus nexus  4096 Nov 12 07:53 etc
drwxr-xr-x.   2 nexus nexus  4096 Nov 12 07:52 generated-bundles
drwxr-xr-x.   2 nexus nexus  4096 Nov 12 07:52 instances
-rw-r--r--.   1 nexus nexus     5 Nov 12 08:01 karaf.pid
drwxr-xr-x.   3 nexus nexus  4096 Nov 12 07:53 keystores
-rw-r--r--.   1 nexus nexus    28 Nov 12 08:01 lock
drwxr-xr-x.   3 nexus nexus  4096 Nov 12 07:54 log
drwxr-xr-x.   3 nexus nexus  4096 Nov 12 07:31 orient
-rw-r--r--.   1 nexus nexus     5 Nov 12 08:02 port
drwxr-xr-x.   2 nexus nexus  4096 Nov 12 07:53 restore-from-backup
drwxr-xr-x.   8 nexus nexus  4096 Nov 12 08:02 tmp

[centos7copy]$ ll /usr/local/src/sonatype-work/nexus3/log
total 344
drwxr-xr-x. 2 nexus nexus   4096 Nov 12 07:52 audit
-rw-r--r--. 1 nexus nexus  81920 Nov 12 08:28 jvm.log
-rw-r--r--. 1 nexus nexus    688 Nov 12 08:01 karaf.log
-rw-r--r--. 1 nexus nexus      0 Nov 12 07:52 nexus_cluster.log
-rw-r--r--. 1 nexus nexus 150830 Nov 12 08:43 nexus.log
-rw-r--r--. 1 nexus nexus 105982 Nov 12 08:49 request.log

[centos7copy]$ ll /usr/local/src/sonatype-work/nexus3/log/audit/
total 32
-rw-r--r--. 1 nexus nexus 28487 Nov 12 08:50 audit.log