Jenkins fails when running “service start jenkins”

前端 未结 21 2301
不知归路
不知归路 2021-01-30 20:46

I installed jenkins on Cnetos 7 using the following:

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --impor         


        
相关标签:
21条回答
  • 2021-01-30 21:21

    I had a similar problem on Ubuntu 16.04. Thanks to @Guna I figured out that I had to manually install Java (sudo apt install openjdk-8-jre).

    0 讨论(0)
  • 2021-01-30 21:22

    I had a similar issue on CentOS 7 while a correct version of Java was installed and java -version gave a nice result.

    Collecting multiple answers from different SO threads I did the following:

    Make sure Java is installed (and version is compatible with Jenkins) There're some tricks if saying about CentOS, this is mentioned in official Jenkins tutorial here

    If Java is installed and available, when running java -v output should look like this:

        ~>$java -version
        openjdk version "1.8.0_161"
        OpenJDK Runtime Environment (build 1.8.0_161-b14)
        OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
    

    Add a path to Java to your /etc/rc.d/init.d/jenkins

       ~>$ sudo vim /etc/rc.d/init.d/jenkins
        candidates="
        /etc/alternatives/java
        /usr/lib/jvm/java-1.8.0/bin/java
        /usr/lib/jvm/jre-1.8.0/bin/java
        /usr/lib/jvm/java-1.7.0/bin/java
        /usr/lib/jvm/jre-1.7.0/bin/java
        /usr/bin/java
        /usr/java/jdk1.8.0_162/bin/java ##add your java path here
        "
    

    How to get your 'real' path to java distributive which is called when you type smth like java -v Follow this SO thread

    If steps above didn't help, try to make sure all permission issues are resolved:

    1. If Jenkins fails to run Java, it could be jenkins user doesn't have permissions to run it, then change jenkins to root in config (described here)
    2. Try to play with chmod setting 755 permissions to java installation folder

    And finally what helped me in result When I did run journalctl -xe as was suggested when I've tried to sudo service jenkins start, I got similar Java stacktrace:

    Starting CloudBees Jenkins Enterprise Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at Main._main(Main.java:140)
    at Main.main(Main.java:98)
    Caused by: java.lang.UnsatisfiedLinkError: /tmp/jna--1712433994/jna7387046629130767794.tmp: /tmp/jna--1712433994/jna7387046629130767794.tmp: failed to map segment from shared object: Operation not permitted
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1822)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
    at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
    at com.sun.jna.Native.<clinit>(Native.java:131)
    at com.sun.akuma.CLibrary.<clinit>(CLibrary.java:89)
    at com.sun.akuma.JavaVMArguments.resolvePID(JavaVMArguments.java:128)
    at com.sun.akuma.JavaVMArguments.ofLinux(JavaVMArguments.java:116)
    at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:104)
    at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.java:92)
    at com.sun.akuma.Daemon.daemonize(Daemon.java:106)
    at com.sun.akuma.Daemon.all(Daemon.java:88)
    ... 6 more
    

    The problem is that Jenkins tries to launch JNA library from /tmp dir which is marked as noexec by default, so we it could be fixed by creating a temporary directory in a /jenkins path so it could be executed. The full way to do this is described here by CloudBees support (thanks a lot for them)

    I hope something from this list will help (as well I mostly leave it for me in the future when I'll have to install Jenkins for CentOs again :)

    0 讨论(0)
  • 2021-01-30 21:22

    In my case, the port 8080 was taken by some other service (Apache Airflow).

    So I edit the HTTP port in this file:

    sudo vi /etc/default/jenkins
    

    And then started the service and it worked:

    sudo service jenkins start
    

    I was on Ubuntu 18.04 and installed openjdk-8

    0 讨论(0)
  • 2021-01-30 21:23

    In my case I were starting jenkins service from root instead of jenkins user

    i did

    sed -i 's/JENKINS_USER="jenkins"/JENKINS_USER="root"/g  /etc/sysconfig/jenkins
    

    then

    service jenkins restart
    

    all work well

    0 讨论(0)
  • 2021-01-30 21:27

    Before you install Jenkins you should install JDK:

    apt install openjdk-8-jre
    

    After this install Jenkins:

    apt-get install jenkins
    

    And check Jenkins status (should be 'active'):

    systemctl status jenkins.service
    
    0 讨论(0)
  • 2021-01-30 21:27

    The easiest possible fix for this issue if it is a AWS linux instance

    sudo yum install java-1.8.0 -y 
    
    sudo yum remove java-1.7.0-openjdk
    
    0 讨论(0)
提交回复
热议问题