📜 ⬆️ ⬇️

Raise your own Nexus Maven repository on OpenShift

image


Recently, articles about OpenShift began to appear on Habré, which attracted my attention, because the platform is really interesting and it’s a sin not to pick it up, and it just so happened that I started thinking about finding an alternative to my cozy Dropbox-Maven repository due to the cancellation of the ability to have direct Public links and folders in general (proof: habrahabr.ru/post/145864 ).

So, today we are going to install the Maven repository under Nexus management for your own needs, and your humble servant will share the crutches of knowledge acquired as a pioneer in this matter.
')


Introduction


First of all, we need to register and create an application, this process is well described in the article habrahabr.ru/post/145203 , I just have a brief summary:
  1. We register by reference if you have not done this before;
  2. Create a DIY application (for example, I created a habr application with a tryspic namespace)
  3. Next, in the application settings, add your ssh-key.
  4. We execute git clone as written on the page. For example, I have:
    $ git clone ssh://a3cf48bc92174721a2c49fd823243b3a@habr-trylogic.rhcloud.com/~/git/habr.git/ 

Pay attention to the address specified in the link for cloning (something like it is on- heh@app_name-namespace.rhcloud.com), it is useful to us for further access to the application via ssh.

Tomcat


Why did I choose Tomcat, you ask, and did not use the JBoss container already configured for us by the OpenShift team? Yes, because Nexus does not work in it :)

Despite the presence of an article on Habré describing the installation of Tomcat, I decided to use the article on the OpenShift website , there they chewed better, and there are steps to install IP and ports for those who work with Tomcat mediocre.
For those who do not speak English (or just someone too lazy :)) try again briefly
  1. Remember I talked about the git-link? We use it to log in via ssh to our server (For Windows users, I advise you to use Putty):
     ssh a3cf48bc92174721a2c49fd823243b3a@habr-trylogic.rhcloud.com 
  2. Disable the standard Ruby stub:
     sh ~/habr/repo/.openshift/action_hooks/stop #  habr -   . 
  3. We consistently execute (we follow the name of the application, my habr is used in the example):
     cd ~/habr/data wget http://www.bizdirusa.com/mirrors/apache/tomcat/tomcat-7/v7.0.27/bin/apache-tomcat-7.0.27.tar.gz tar zxvf apache-tomcat-7.0.27.tar.gz rm apache-tomcat-7.0.27.tar.gz env |grep INTERNAL_IP 
  4. If now the correct phase of the moon, we, having executed the last command, will receive the IP address of our server. Save it somewhere, it will be useful to us now.
  5. I would be grateful in the sed comments, which will replace what is needed, and I will show you how to fix the server.xml file manually. The server is only vim, so lovers of nano will have to suffer:
     $ vim ~/habr/data/apache-tomcat-7.0.27/conf/server.xml 
  6. Change IP and ports:
    •  <Server port="8005" shutdown="SHUTDOWN"> 
      on
       <Server port="15005" shutdown="SHUTDOWN"> 

    •  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 
      on
       <Connector port="15009" protocol="AJP/1.3" redirectPort="8443" /> 

    •  <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 
      on
       <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" address="IP___” redirectPort="15443" /> 

    •  <Engine name="Catalina" defaultHost="localhost"> 
      on
       <Engine name="Catalina" defaultHost="IP___"> 

    •  <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> 
      on
       <!--     habr-trylogic.rhcloud.com    --> <Host name="habr-trylogic.rhcloud.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> 

  7. Tomcat has his manager out of the box, sin will not use it. Add to ~ / habr / data / apache-tomcat-7.0.27 / conf / tomcat-users.xml
     <role rolename="manager-gui"/> <user username="admin" password="mySupaPass" roles="manager-gui"/> 
    After that, the manager will be available at http: // YOUR_APP_LINK / manager /
  8. In the folder with your recently downloaded git repository, go to the folder .openshift / action_hooks . Edit the start file so that it looks like this:
     #    habr     ~/habr/data/apache-tomcat-7.0.27/bin/startup.sh 
    As well as the stop file:
     ~/habr/data/apache-tomcat-7.0.27/bin/shutdown.sh 
    This will allow you to start and stop the server through
     rhc app start -a habr 
  9. Do not forget to commit and push the changes you made.


Not so briefly, of course, but better so than nothing :)


Nexus


Finally, we come to the hero of our story - a product of Sonatype company called Nexus.

It would seem that it can be difficult to simply install an application in a JavaEE container, I thought, and without thinking twice, I put the Nexus in a fresh Tomcat. Naturally, nothing earned $) Reading the logs showed that Nexus is trying to create the $ {user.home} / sonatype-work folder, but OpenShift doesn’t give a different opinion on this matter, and it doesn’t give us any rights to write to USER_HOME Only 3 folders: data, repo and tmp. NE GUSTO, I thought, could at least replace the Java Property "user.home" with some sort of data thread, but the platform is completely fresh, maybe it is screwed.

Keeping in mind the information received, which, by the way, is useful not only for Nexus, but also for other Java applications writing in USER_HOME, let's start:
  1. Open our Tomcat Manager (see above)
  2. Download the Nexus war distribution: www.sonatype.org/downloads/nexus-2.0.5.war
  3. While it is swinging, we click Undeploy of the application, whose Path is specified as /
  4. Waiting for the download, rename the downloaded file nexus-2.0.5.war to ROOT.war
  5. specify it in the manager via Select WAR file to upload and click deploy
  6. At the end we must see
     OK - Deployed application at context path / 
  7. Again we go to the server via SSH, where we will need to edit the plexus.properties file by running the command
     #  ,     habr     ;) vim habr/data/apache-tomcat-7.0.27/webapps/ROOT/WEB-INF/plexus.properties 
    where you need to correct the parameter nexus-work
     nexus-work=${user.home}/habr/data/sonatype-work/nexus 
  8. Save, proudly go to Tomcat Manager, zhamkaem Start on our Nexus Application. Koshak should report, they say, everything started perfectly and our Nexus is available at http: // YOUR_APP_LINK /. If this does not happen - write in the comments, I will help you figure it out.


Conclusion


Thus, we learned how to correctly run our applications in the Tomcat container using the example of Nexus. What are my impressions of OpenShift, you say? Extremely positive! The machines are very responsive, there is access via ssh, there is an opportunity to install there what your heart desires (if only pleasers of the soul worked correctly with the environment;)), 1GB is quite enough for the programmer's everyday needs, plus the channel they have, apparently, about 10 Mbps instans, so throwing files with the server pretty quickly.

Thanks for attention,
Admin!

Source: https://habr.com/ru/post/145936/


All Articles