美文网首页
docker自动化部署

docker自动化部署

作者: 蕤秋 | 来源:发表于2021-03-01 19:33 被阅读0次

    Jenkins安装

    1.检测是否有java环境

    java -version
    

    2.启用Jenkins仓库

    wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
    rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
    

    3.安装Jenkins

    yum install jenkins
    

    4.启动Jenkins服务,有需要可以执行第二条命令将Jenkins设置成开机自启动

    service jenkins start
    chkconfig jenkins on
    

    5.访问服务器地址的8080 端口,初始化密码在以下文件夹

    cat /var/jenkins/secrects/initialAdminPassword
    

    几个遇到的问题

    1.更新默认插件、安装新插件失败

    sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
            at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:145)
            at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)
            at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
            at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
    Caused: sun.security.validator.ValidatorException: PKIX path building failed
            at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
            at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
            at sun.security.validator.Validator.validate(Validator.java:260)
            at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
            at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
            at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
            at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1351)
    Caused: javax.net.ssl.SSLHandshakeException
            at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
            at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1917)
            at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:301)
            at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:295)
            at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1369)
            at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:156)
            at sun.security.ssl.Handshaker.processLoop(Handshaker.java:925)
            at sun.security.ssl.Handshaker.process_record(Handshaker.java:860)
            at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1043)
            at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1343)
            at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1371)
            at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
    

    1.修改插件中的配置

    http://ip:8080/jenkins/pluginManager/advanced替换成http://updates.jenkins.io/update-center.json,然后重启服务

    2.进入Jenkins站点修改默认json配置

     cd /var/lib/jenkins/updates/
    sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json
    sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
    

    3.查找证书所在路径并将这个路径添加到配置文件中

    -Djavax.net.ssl.trustStore=/etc/pki/ca-trust/extracted/java/cacerts

    find / -type f -name cacerts
     vi /etc/sysconfig/jenkins
    JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Djavax.net.ssl.trustStore=/etc/pki/ca-trust/extracted/java/cacerts"
    

    2.链接Git失败

    Failed to connect to repository : Command "git ls-remote -h -- https://gitee.com/***/***.git HEAD" returned status code 128:
    
    stdout:
    
    stderr: remote: [31mIncorrect username or password ( access token )[0m
    
    fatal: Authentication failed for 'https://gitee.com/***/***.git/'
    

    在配置中设置默认用户名密码 Jenkins默认生成的用户名密码是Jenkins/Jenkins

    docker安装

    1.添加软件包

    yum install -y yum-utils  device-mapper-persistent-data lvm2
    

    2.添加yum源

    yum-config-manager \
    --add-repo \
        https://download.docker.com/linux/centos/docker-ce.repo
    

    3.安装最新版本

    yum install docker-ce -y
    

    4.尝试启动docker

    systemctl start docker
    systemctl enable docker
    

    5.如果出现以下错误,说明当前内核不支持selinux,编辑docker配置文件关闭selinux再重新启动就行

    Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Either boot into a newer kernel or disable selinux in docker (--selinux-enabled=false)
    
    vi /etc/sysconfig/docker
    

    将这个文件中的OPTIONS='--selinux-enable '改成--selinux-enabled=false即可

    相关文章

      网友评论

          本文标题:docker自动化部署

          本文链接:https://www.haomeiwen.com/subject/hhlafltx.html