我正在使用以下Bootstrap脚本在Amazon Linux OS中安装Sonatype Nexus 3.16.1.02。但是在安装Nexus之后,网站显示“ 502 Bad Gateway”错误。 我按照下面的链接更新了nexus.properties文件:-
https://help.sonatype.com/repomanager3/security/configuring-ssl
以下是我登录ssh服务器时显示的运行状态。
[ec2-user@ip-10-123-123-123 ~]$ sudo service nexus status
Last login: Thu May 30 16:06:38 UTC 2019
nexus is running.
Script.sh
#!/bin/bash
sudo yum -y install chrony
sudo yum erase ntp* -y
sudo sed -i '7i server 169.254.169.123 prefer iburst' /etc/chrony.conf
sudo systemctl start chronyd
sudo cat /etc/chrony.conf
sudo systemctl enable chronyd
sudo yum -y update
sudo yum -y upgrade
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py
sudo yum install -y python3 python3-pip python3-devel python3-setuptools rubygems mlocate git python nfs-utils jq wget curl vim zip unzip tar java-1.8.0-openjdk-devel java-1.8.0-openjdk patch npm gcc-c++ readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel sqlite-devel
sudo updatedb
sudo $(which pip3) install --upgrade awscli boto boto3 ansible
cd /opt/
sudo mkdir efs
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-b12314as.efs.eu-central-1.amazonaws.com:/ efs
sudo echo -e "fs-b12314as.efs.eu-central-1.amazonaws.com:/ /opt/efs nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2" | sudo tee -a /etc/fstab
sudo mkdir -p /opt/efs/
cd /tmp/
if [ ! -d /opt/efs/nexus ]
then
sudo wget -O nexus-3.16.1-02-unix.tar.gz https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.16.1-02-unix.tar.gz
sudo tar -xvzf /tmp/nexus-3.16.1-02-unix.tar.gz
sudo mv nexus-3.16.1-02 /opt/efs/nexus/
sudo mv sonatype-work /opt/efs/sonatype-work
sudo sed -i 's|#run_as_user=""|run_as_user="nexus"|g' /opt/efs/nexus/bin/nexus.rc
sudo rm --force /opt/efs/nexus/keystore.jks
cd /opt/efs/nexus/
sudo keytool -genkey -alias prod-nexus.ca.org.com -keyalg RSA -dname 'CN=prod-nexus.ca.org.com, OU=ABCD, O=ABCD, C=AS, ST=example, L=Hannover' -storepass Pa55w0rd -validity 3650 -keystore keystore.jks -keypass laL3y0naK -deststoretype pkcs21
sudo echo -e "application-port-ssl=8443" | sudo tee -a /opt/efs/sonatype-work/nexus3/etc/nexus.properties
sudo echo -e 'nexus-args=$${jetty.etc}/jetty.xml,$${jetty.etc}/jetty-https.xml,$${jetty.etc}/jetty-https.xml,$${jetty.etc}/jetty-requestlog.xml' | sudo tee -a /opt/efs/sonatype-work/nexus3/etc/nexus.properties
sudo echo -e "application-port=8443" | sudo tee -a /opt/efs/sonatype-work/nexus3/etc/nexus.properties
sudo sed -i 's|<Set name="KeyStorePath"><Property name="ssl.etc"/>/keystore.jks</Set>|<Set name="KeyStorePath">/opt/efs/nexus/keystore.jks</Set>|g' /opt/efs/nexus/etc/jetty/jetty-https.xml
sudo sed -i 's|<Set name="TrustStorePath"><Property name="ssl.etc"/>/keystore.jks</Set>|<Set name="TrustStorePath">/opt/efs/nexus/keystore.jks</Set>|g' /opt/efs/nexus/etc/jetty/jetty-https.xml
sudo sed -i 's|password|Pa55w0rd|g' /opt/efs/nexus/etc/jetty/jetty-https.xml
fi
sudo adduser nexus
sudo chown -R nexus:nexus /opt/efs/nexus /opt/efs/sonatype-work
sudo ln -s /opt/efs/nexus/bin/nexus /etc/init.d/nexus
sudo chkconfig --add nexus
sudo chkconfig --levels 345 nexus on
sudo service nexus start
下面是
的输出$ ps -ef|grep nexus
nexus 4244 1 7 16:06 ? 00:01:23 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64/jre/bin/java -server -Dinstall4j.jvmDir=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64/jre -Dexe4j.moduleName=/opt/efs/nexus/bin/nexus -XX:+UnlockDiagnosticVMOptions -Dinstall4j.launcherId=245 -Dinstall4j.swt=false -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Xms1200M -Xmx1200M -XX:MaxDirectMemorySize=2G -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -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 -Djava.io.tmpdir=../sonatype-work/nexus3/tmp -Dkaraf.startLocalConsole=false -Di4j.vpt=true -classpath /opt/efs/nexus/.install4j/i4jruntime.jar:/opt/efs/nexus/lib/boot/nexus-main.jar:/opt/efs/nexus/lib/boot/org.apache.karaf.main-4.0.9.jar:/opt/efs/nexus/lib/boot/org.osgi.core-6.0.0.jar:/opt/efs/nexus/lib/boot/org.apache.karaf.diagnostic.boot-4.0.9.jar:/opt/efs/nexus/lib/boot/org.apache.karaf.jaas.boot-4.0.9.jar com.install4j.runtime.launcher.UnixLauncher start 9d17dc87 0 0 org.sonatype.nexus.karaf.NexusMain
ec2-user 4866 4475 0 16:25 pts/0 00:00:00 grep --color=auto nexus