• gitlab+jenkins+pm2+rsync实现node的自动化部署


    环境配置

    jenkins

    java环境

    yum install -y java

    安装jenkins

    wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo

    rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

    yum install jenkins

    配置jenkins端口

    vi /etc/sysconfig/jenkins

    启动

    service jenkins start

    管理员密码

    vi /var/lib/jenkins/secrets/initialAdminPassword

     

    gitlab

    yum install curl policycoreutils openssh-server openssh-clients postfix

    service postfix start

    service sshd start

    curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

    sudo EXTERNAL_URL=”ip:port” yum -y install gitlab-ee

    sudo mkdir -p /etc/gitlab

    sudo touch /etc/gitlab/gitlab.rb

    sudo chmod 600 /etc/gitlab/gitlab.rb

    sudo gedit /etc/gitlab/gitlab.rb

    配置

    sudo vim /etc/gitlab/gitlab.rb

    启动

    sudo gitlab-ctl reconfigure

    sudo gitlab-ctl status

     

    Node

    cd /usr/local/src

    wget https://nodejs.org/dist/v6.11.1/node-v6.11.1-linux-x64.tar.xz

    tar xvf node-v6.11.1-linux-x64.tar.xz

    ln -s /usr/local/src/node-v6.11.1-linux-x64/bin/node /usr/local/bin/node

    ln -s /usr/local/src/node-v6.11.1-linux-x64/bin/npm /usr/local/bin/npm

     

    Pm2

    npm install pm2 -g

    ln -s /usr/local/src/node-v6.11.1-linux-x64/bin/pm2 /usr/local/bin/pm2

     

    Nginx

    yum install nginx

    nginx -t

    service nginx start

     

    Rsync

    rsync --daemon --config=/app/rsync/rsync.conf

     

    # configuration example:

     uid = root

     gid = root

     use chroot = yes

     max connections = 4

     read only = false

     pid file = /var/run/rsyncd.pid

     exclude = lost+found/

     transfer logging = yes

     timeout = 900

     ignore nonreadable = yes

     dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

     auth users=root

     secrets file = /etc/rsync.password

     [ftp]

            path = /data

     

    创建rsync.password jenkins服务器写密码 目标服务器写用户名:密码

    chmod 600 /etc/rsync.password

     

    配置服务器间免密登陆

    ssh-keygen -t rsa

    ssh-copy-id -i ~/.ssh/id_rsa.pub root@master

     

     

    jenkins部署的shell脚本 jenkins需要root权限

    WEB_SERVER_IP=
    PROJECT=ftp/webserver/$JOB_NAME  (rsync需要配置ftp模块)
    rsync -rtav --password-file=/etc/rsync.password --delete-before $WORKSPACE/ root@$WEB_SERVER_IP::$PROJECT --exclude ".git"

  • 相关阅读:
    给出一个单向链表的头指针,输出该链表中倒数第K个节点的指针
    把二元查找树转变成排序的双向链表
    动态规划0/1背包问题
    判断一字符串是不是对称的
    动态链接库dll,静态链接库lib, 导入库lib(转载)
    基于格点数据分析和表达
    Silverlight Wcf 获取集合数据并绑定(DataContract,DataMember)
    让你学会使用WCF服务端配置
    数据契约(DataContract)
    symbol详解
  • 原文地址:https://www.cnblogs.com/bhan/p/9667474.html
Copyright © 2020-2023  润新知