Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centeros7 installation and configuration environment jdk1.8 tutorials

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Uninstall centeros with jdk first

Rpm-qa | grepopenjdk

Self-contained openjdk from the query

two。 Delete

Rpm-e--nodeps

3. Inquire again

Rpm-qa | grepjdk

4. Create a folder in usr/local

Cd/usr/localmkdirjava

5. Put jdk1.8 in the file you just created

Cd/usr/local/java

Decompress after uploading with xftp

Tar-zxvfjdk-8u181-linux-x64.tar.gz

6. Go to the folder you just unzipped

Cdjdk1.8.0_181/pwd# (this step records the path of jdk1.8, which can be used to configure the environment later)

7. Configure the environment

Vim/etc/profile

Press I to insert the following path

ExportJAVA_HOME=/usr/local/java/jdk1.8.0_181exportCLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexportPATH=$PATH:$JAVA_HOME/bin

Press Esc: after wq exits

Source/etc/profile

8. Check to see if it is successful

Java-version

Maven environment configuration

1. Create a maven folder under / usr/local

Cd/usr/localmkdirmaven

two。 Go to the newly created folder

Cdmaven

Upload apache-maven-3.5.4-bin.zip

3. Decompression

Unzipapache-maven-3.5.4-bin.zip

4. Enter the extracted folder

Cdapache-maven-3.5.4/pwd# (record this path, which will be used later in the configuration environment)

5. Configure the environment

Vim/etc/profile

Press I to insert below

ExportMAVEN_HOME=/usr/local/maven/apache-maven-3.5.4exportPATH=$PATH:$MAVEN_HOME/bin

Press Esc: after wq saves

Source/etc/profile

6. Check to see if it is successful

Mvn-v

Centeros7 install git

Yuminstallgit

Just y all the way down.

Check to see if it is successful

Git--version

View the git command address

Which-agit

At this point, the environment has been set up, and we have started to build maven and gitlab.

Gitlab building

1. New / etc/yum.repos.d/gitlab-ce.repo

Vim/etc/yum.repos.d/gitlab-ce.repo

Then press the I key to insert the following

[gitlab-ce] name=GitlabCERepositorybaseurl= https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1

two。

Sudoyummakecachesudoyuminstallgitlab-ce# (latest installation) or sudoyuminstallgitlab-ce-12.0.4# (specified version number)

3. Configure external_url

Vim/etc/gitlab/gitlab.rb

Modify the external_url address to: http:// native address: Port number /

Local address view: ifconfig

View the application running by the port number lsof-I: Port number

4.

Gitlab-ctlreconfigure

5.

Gitlab-ctlrestart# starts gitlab-ctlstart | stop | status | other restart# operations

6. Visit

Http:// native address: Port number /

FAQ gitlab502: this is where the port is occupied

After ensuring that the port is not occupied, continue to do it again from 4.

Centeros7 builds maven private server

Download nexus3.x:

Https://www.sonatype.com/download-oss-sonatype

1. Create a nexus file under / usr/local

Cd/usr/localmkdirnexuscdnexus

two。 Upload the nexus package you just downloaded and decompress it

Tar-zxvfnexus-3.18.1-01-unix.tar.gz

3.

Cdnexus-3.18.1-01/bin/ls

4. Start

. / nexusrun&

5. Open remote access port

Firewall-cmd--zone=public--add-port=8081/tcp--permanentfirewall-cmd--reload

Browser access

6. Set Boot self-boot

1. Create a service

Vim/usr/lib/systemd/system/nexus.service

two。 Press I to copy the following

[Unit] Description= nexus service [service] Type=forkingLimitNOFILE=65536# warning processing ExecStart=/usr/local/nexus/nexus-3.7.1-02/bin/nexusstartExecReload=/usr/local/nexus/nexus-3.7.1-02/bin/nexusrestartExecStop=/usr/local/nexus/nexus-3.7.1-02/bin/nexusstopRestart=on-failure [Install] WantedBy=multi-user.target

3. Add service to boot boot

Systemctlenablenexus.service

4. Reload the configuration file

Systemctldaemon-reload

7. The running user is root (edit nexus.rc under nexus bin)

Cd/usr/local/nexus/nexus-3.18.1-01/bin/vimnexus.rc

The content is changed to:

Run_as_user= "root"

8. Modify the jdk version to be used when nexus3 starts

Cd/usr/local/nexus/nexus-3.18.1-01/bin/vimnexus

Press I to add the following

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/java/jdk1.8.0_181

Java_home address can be output with echo $JAVA_HOME (provided / etc/profile has export)

9. Modify nexus3 default port

The file is in nexus-xx

Etc/nexus-default.properties

Here has been built, the following is deploy to private server and download from private server to test

1. Create facade and upload it to private server

Create a projects under / usr

Cd/usrmkdirprojects

Unzip the changed zip to projects and enter the directory where pom.xml is located.

Mvndeploy-Dmaven.test.skip=true-U

Has been uploaded successfully

Here we want to put Allow anonymous users to access the server (allowing anonymous users to access the server)

Because the local maven does not have a user configured

You can also use the idea maven command depoly

4.0.0 com.netease maven_test_demo 1.0.0-SNAPSHOT jar 1.8 UTF-8 3.6.1 192.168.20.143 com.netease maven_test_demo 1.0.0-SNAPSHOT jar 8081 nexus-releases Nexus Private Release Repository http://${nexus.host}/repository/maven-releases nexus-snapshots Nexus Private Snapshot Repository http://${nexus.host}/repository/maven-snapshots ${project.artifactId}-${project.version} org.apache.maven.plugins maven-compiler-plugin ${maven-compiler-plugin.version} ${java.version} ${java.version} ${project.build.sourceEncoding}

The id defined in servers in settings.xml is consistent

Add the following image in settings

Central http://repo1.maven.org/maven2central

Finally, the settings file. At this point, the jar package can be released to the private server.

Let's see how to pull it.

Pom.xml of the maven_demo_impl project

4.0.0 com.netease maven_demo_impl 1.0-SNAPSHOT org.springframework.boot spring-boot-starter-parent 2.0.5.RELEASE 1.8 UTF-8 3.6.1 192.168.20.143:8081 Finchley.SR1 nexus-aliyun-repo nexus aliyun repo http://maven.aliyun.com/nexus/content/groups/public maven -public maven public http://192.168.20.143:8081/repository/maven-public/ org.springframework.cloud spring-cloud-dependencies ${spring-cloud.version} pom import org.springframework.cloud spring-cloud-starter-netflix-eureka-server com.netease maven_test_demo 1.0.0-SNAPSHOT org.springframework.boot spring-boot-maven-plugin

After the configuration is completed, you will automatically download jar from the private server.

Jenkins building

1. View the environment version

If there is no java-version#, check the above jdk1.8 installation mvn-v#. If there is no maven installation, check the above git installation.

two。 Install jenkenis

Add Jenkins source:

Sudowget-O/etc/yum.repos.d/jenkins.repo http://jenkins-ci.org/redhat/jenkins.reposudorpm--importhttp://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

3. Installation

Yuminstalljenkins

4. Start

Sudoservicejenkinsstart

5. Visit

Http://ip:8080/#jenkenis defaults to 8080

First password:

Vim / var/lib/jenkins/secrets/initialAdminPassword

Click to install the recommended plug-in (I don't know what to install later)

Modify jenkins port

Vim/etc/sysconfig/jenkins

Modify JENKINS_PORT= "8080" = = > to not occupy the port JENKINS_PORT= "8089" you want to modify

Restart the service

Servicejenkinsrestart

Problem encountered: JDK reinstalled, java address changed

Start jenkins to report error: Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl-xe" for details.

Enter systemctl status jenkins.service as prompted

Solution:

1 > View the environment variables of the current Java

Echo$JAVA_HOME

2 > copy the environment variable address of Java, edit the / etc/init.d/jenkins file, specify the location to add the address, and append the suffix / bin/java

Vim/etc/init.d/jenkins

The point is to configure Jenkins:

1. Configure global jdk maven git

Point Manage Jenkins (system Management)-> Global Tool Configuaration (Global tool configuration)

1.maven configuration: configuring settings.xml addr

two。 Configure the jdk address (which can be obtained with echo $JAVA_HOME)

3.git configuration address can be used (which-a git view)

4.maven configuration address

two。 Create a new task

3. Configuration task

1. Configure source code management the following version is the version number of gitlab

Repository URL: name of warehouse accessed Credentials: access account password or ssh certificate Branch Specifier (blank for 'any'): branch accessed, multiple source code database browsers: select source code database server URL: source code warehouse url Version: source code database server version number

two。 Configuration construction

Cleancompilepackageinstalldeploy-Dmaven.test.skip=true-U# publishes jar

Then apply and complete the configuration!

3. Go to my view (my View)-> find the new project-- > Click build now (build now)

Click the just build in the construction history as shown in the following figure: # 1: build id, console output: you can see the specific output

The following is the input log. You can see the master branch that was previously pulled to the specified project.

Started by user rootRunning as SYSTEMBuilding in workspace/ var/lib/jenkins/workspace/firstusing credential fad2813a-c894-4386-ae16-11d6e6d349d4Cloning the remote Git repositoryCloning repository http://192.168.20.137:9029/root/wx-ssm.git> / usr/local/git/bin/git init / var/lib/jenkins/workspace/first # timeout=10Fetching upstream changes from http://192.168.20.137:9029/root/wx-ssm.git> / usr/local/git/bin/git-- version # timeout=10using GIT_ASKPASS to Set credentials > / usr/local/git/bin/git fetch-- tags-- progress http://192.168.20.137:9029/root/wx-ssm.git + refs/heads/*:refs/remotes/origin/* > / usr/local/git/bin/git config remote.origin.url http://192.168.20.137:9029/root/wx-ssm.git # timeout=10 > / usr/local/git/bin/git config-- add remote.origin.fetch + refs/heads/*:refs/ Remotes/origin/* # timeout=10 > / usr/local/git/bin/git config remote.origin.url http://192.168.20.137:9029/root/wx-ssm.git # timeout=10Fetching upstream changes from http://192.168.20.137:9029/root/wx-ssm.gitusing GIT_ASKPASS to set credentials > / usr/local/git/bin/git fetch-- tags-- progress http://192.168.20.137:9029/root/wx-ssm.git + refs/heads/* : refs/remotes/origin/* > / usr/local/git/bin/git rev-parse refs/remotes/origin/ master ^ {commit} # timeout=10 > / usr/local/git/bin/git rev-parse refs/remotes/origin/origin/ master ^ {commit} # timeout=10Checking out Revision 47d13c3ca0bc12fc0465c3e4c582b2c542276eb6 (refs/remotes/origin/master) > / usr/local/git/bin/git config core.sparsecheckout # timeout=10 > / usr/local/git/bin/git checkout-f 47d13c3ca0bc12fc0465c3e4c582b2c542276eb6Commit message: update pom.xml First time build. Skipping changelog. [first] $/ project/java/maven/apache-maven-3.6.1/bin/mvn-s / project/java/maven/apache-maven-3.6.1/conf/settings.xml-gs / project/java/maven/apache-maven-3.6.1/conf/settings.xml clean package [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for com.guojin:gjmetal-wx-ssm:jar:1.0.0. 1-SNAPSHOT [WARNING] 'dependencies.dependency. (groupId:artifactId:type:classifier)' must be unique: org.apache.httpcomponents:httpclient:jar-> version (?) Vs 4.5.6 @ line 155, column 21 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO]-

< com.guojin:gjmetal-wx-ssm >

[INFO] Building gjmetal-wx-ssm 1.0.0.1-SNAPSHOT [INFO]-- [jar]-- [INFO] [INFO]- -- maven-clean-plugin:2.5:clean (default-clean) @ gjmetal-wx-ssm-[INFO] [INFO]-jacoco-maven-plugin:0.7.9:prepare-agent (pre-test) @ gjmetal-wx-ssm-[INFO] argLine set to-javaagent:/var/lib/jenkins/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile= / var/lib/jenkins/workspace/first/target/jacoco.exec Includes=com.gjmetal.* [INFO] [INFO]-maven-resources-plugin:2.6:resources (default-resources) @ gjmetal-wx-ssm-[INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO]-maven-compiler-plugin:3.6.1:compile (default-compile) @ gjmetal-wx-ssm-[INFO] Changes detected-recompiling the module! [INFO] Compiling 27 source files to / var / lib/jenkins/workspace/first/target/classes [INFO]-[ERROR] COMPILATION ERROR: [INFO]-- -- [ERROR] / var/lib/jenkins/workspace/first/src/main/java/com/gjmetal/Swagger2.java: [4Jing 40] package org.fuelteam.springboot.swagger2 does not exist [ERROR] / var/lib/jenkins/workspace/first/src/main/java/com/gjmetal/Swagger2.java: [21 Jue 2] cannot find symbol: class EnableSwagger2 [ INFO] 2 errors [INFO]-[INFO] -[INFO] BUILD FAILURE [INFO]-[INFO] Total time: 9.183 s [INFO] Finished At: 2019-08-23T17:05:09+08:00 [INFO]-[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default- Compile) on project gjmetal-wx-ssm: Compilation failure: Compilation failure: [ERROR] / var/lib/jenkins/workspace/first/src/main/java/com/gjmetal/Swagger2.java: [4Magazine 40] package org.fuelteam.springboot.swagger2 does not exist [ERROR] / var/lib/jenkins/workspace/first/src/main/java/com/gjmetal/Swagger2.java: [21 ERROR 2] symbol not found [ERROR] symbol: class EnableSwagger2 [ERROR]-> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors Re-run Maven with the-e switch. [ERROR] Re-run Maven using the-X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExceptionBuild step 'Invoke top-level Maven targets' marked build as failureFinished: FAILURE

The error reported above is a problem with the project, and you can see that the project has been pulled. So make sure the project is correct.

Here are two correct project running examples to automatically send jar to the private server and start the jar project after setting up the gitlab nexus jenkins

Background: the gitlab nexus jenkins has been completed.

1. Release jar to private server after downloading the project from gitlab

Reconfigure the gitlab address:

Configure the maven command:

Cleancompilepackageinstalldeploy-Dmaven.test.skip=true-U

Click build now and look at the console output as follows

Started by user rootRunning as SYSTEMBuilding in workspace/ var/lib/jenkins/workspace/maven_homeusing credential fad2813a-c894-4386-ae16-11d6e6d349d4 > / usr/local/git/bin/git rev-parse-- is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > / usr/local/git/bin/git config remote.origin.url http://192.168.20.143:8083/root/maven_demo.git # timeout=10Fetching upstream changes from http://192.168.20.143:8083/root/maven_ Demo.git > / usr/local/git/bin/git-- version # timeout=10using GIT_ASKPASS to set credentials > / usr/local/git/bin/git fetch-- tags-- progress http://192.168.20.143:8083/root/maven_demo.git + refs/heads/*:refs/remotes/origin/* > / usr/local/git/bin/git rev-parse refs/remotes/origin/ master^ {commit} # timeout=10 > / usr/local/git/bin/git rev-parse refs/remotes/origin / origin/ master ^ {commit} # timeout=10Checking out Revision a26adc740d331eabe5b0fb2a46b372dbf6673d2c (refs/remotes/origin/master) > / usr/local/git/bin/git config core.sparsecheckout # timeout=10 > / usr/local/git/bin/git checkout-f a26adc740d331eabe5b0fb2a46b372dbf6673d2cCommit message: "Update pom.xml" > / usr/local/git/bin/git rev-list-- no-walk a26adc740d331eabe5b0fb2a46b372dbf6673d2c # timeout=10 [maven_home] $/ project/java/maven/apache-maven-3.6.1/bin/mvn-s / project/java/maven/apache -maven-3.6.1/conf/settings.xml-gs / project/java/maven/apache-maven-3.6.1/conf/settings.xml clean compile package install deploy-Dmaven.test.skip=true-U [INFO] Scanning for projects... [INFO] [INFO]-

< com.netease:maven_test_demo >

< com.netease:maven_demo_impl >

-[INFO] Building maven_demo_impl 1.0-SNAPSHOT [INFO]-- [jar]-- Downloading from nexus-aliyun-repo: http://maven .aliyun.com / nexus/content/groups/public/com/netease/maven_test_demo/1.0.0-SNAPSHOT/maven-metadata.xmlDownloading from maven-public: http://192.168.20.143:8081/repository/maven-public/com/netease/maven_test_demo/1.0.0-SNAPSHOT/maven-metadata.xmlProgress (1): 776 BDownloaded from maven-public: http://192.168.20.143:8081/repository/maven-public/com/netease/maven _ test_demo/1.0.0-SNAPSHOT/maven-metadata.xml (776B at 4.2 kB/s) Downloading from nexus-aliyun-repo: http://maven.aliyun.com/nexus/content/groups/public/com/netease/maven_test_demo/1.0.0-SNAPSHOT/maven_test_demo-1.0.0-20190827.062446-3.pomDownloading from maven-public: http://192.168.20.143:8081/repository/maven-public/com/netease / maven_test_demo/1.0.0-SNAPSHOT/maven_test_demo-1.0.0-20190827.062446-3.pomProgress (1): 2.1kBDownloaded from maven-public: http://192.168.20.143:8081/repository/maven-public/com/netease/maven_test_demo/1.0.0-SNAPSHOT/maven_test_demo-1.0.0-20190827.062446-3.pom (2.1kB at 47 kB/s) Downloading from maven-public : http://192.168.20.143:8081/repository/maven-public/com/netease/maven_test_demo/1.0.0-SNAPSHOT/maven_test_demo-1.0.0-20190827.062446-3.jarProgress (1): 2.6 kBDownloaded from maven-public: http://192.168.20.143:8081/repository/maven-public/com/netease/maven_test_demo/1.0.0-SNAPSHOT/maven_test_demo-1.0.0 -20190827.062446-3.jar (2.6 kB at 67 kB/s) [INFO] [INFO]-maven-clean-plugin:3.0.0:clean (default-clean) @ maven_demo_impl-[INFO] Deleting / var/lib/jenkins/workspace/maven_demo_impl/ target [info] [INFO]-maven-resources-plugin:3.0.2:resources (default-resources) @ maven_demo_impl-[INFO] Using' UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 0 resource [INFO] [INFO]-maven-compiler-plugin:3.6.1:compile (default-compile) @ maven_demo_impl-[INFO] Changes detected-recompiling the module! [INFO] Compiling 2 source files to / var/lib/jenkins/workspace/maven_demo_impl/target/ classes [info] [INFO]-maven-resources-plugin:3.0.2:resources ( Default-resources) @ maven_demo_impl-[INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 0 resource [INFO] [INFO]-maven-compiler-plugin:3.6.1:compile (default-compile) @ maven_demo_impl-[INFO] Nothing to compile-all classes are up to date [INFO] [INFO]-maven-resources-plugin:3.0.2:testResources (default-testResources) @ maven_demo_impl-[INFO] Not copying test resources [INFO] [INFO]-maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ maven_demo_impl-[INFO] Not compiling test sources [INFO] [INFO]-maven-surefire-plugin:2.21.0:test (default-test) @ maven_demo_impl-[INFO] Tests are skipped. [INFO] [INFO]-maven-jar -plugin:3.0.2:jar (default-jar) @ maven_demo_impl- [INFO] Building jar: / var/lib/jenkins/workspace/maven_demo_impl/target/maven_demo_impl-1.0-SNAPSHOT.jar [INFO] [INFO]-- spring-boot-maven-plugin:2.0.5.RELEASE:repackage (default) @ maven_demo_impl- [INFO]- -[INFO] BUILD SUCCESS [INFO]- -[INFO] Total time: 11.163 s [INFO] Finished at: 2019-08-27T15:00:40+08:00 [INFO]- -- SSH: Connecting from host [localhost.localdomain] SSH: Connecting with configuration [192.168.20.143]... SSH: EXEC: STDOUT/STDERR from command [sh / projects/scripts/run.sh maven_demo_impl 10010]... starting service...nohup: append the output to "nohup.out" maven_demo_impl: 4406 SUCCESSSSH: EXEC: completed after 20262 msSSH: Disconnecting configuration [192.168.20.143]... SSH: Transferred 1 file (s) Finished: SUCCESS

You can see that ssh already has jar and is running.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report