Jenkins添加slave节点遇到的问题
slave节点镜像制作1.0:
先下载带jdk8的镜像,在此基础上安装ssh,git等
dockerfile:
FROM 10.19.248.12:30100/library/gongan-jdk8:2.0
RUN rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \
&& yum install -y yum-priorities
RUN yum install -y \
net-tools \
openssh-clients \
openssh-server \
vim \
sshpass \
sudo \
git
RUN echo “root:123456”|chpasswd
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N “”
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key
RUN ssh-keygen -t rsa -P “” -f ~/.ssh/id_rsa && \
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys && \
sed -i “s/#.StrictHostKeyChecking./ StrictHostKeyChecking no/g” /etc/ssh/ssh_config
RUN mkdir /var/run/sshd
jenkins上slave的配置:
遇到的问题:
1、master连不上slave: ssh: connect to host 172.16.47.38 port 22: Connection refused
解决方式:安装上文的dockerfile重新制作镜像,启动后执行/usr/sbin/sshd启动ssh服务
2、docker启动缺少docker-runc 命令
cd /usr/libexec/docker/
ln -s docker-runc-current docker-runc
3、No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
Key exchange was not finished, connection is closed.
解决方式:进入master,修改配置文件“~/.ssh/config”,加上这两行,重启服务器。
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
或者手动清空known_hosts文件
然后修改jenkins的slave节点配置:
slave节点镜像制作2.0:
FROM 10.19.248.12:30100/staging/centos-jxy:latest
RUN yum -y install openssh-clients;yum -y install bridge-utils;yum -y install iproute;yum -y install openssh-server;yum -y install vim;yum -y install docker;yum -y install git;yum -y install sshpass;yum -y install sudo;yum -y install java-1.8.0-openjdk*; yum clean all; systemctl enable sshd.service;
RUN echo "root:123456"|chpasswd
RUN systemctl enable docker.service
COPY config /etc/selinux/config
COPY docker.service /usr/lib/systemd/system/docker.service
COPY docker /etc/sysconfig/docker
CMD ["/usr/sbin/init"]
/etc/sysconfig/docker修改内容
/usr/lib/systemd/system/docker.service修改内容
ExecStart=/usr/bin/dockerd --insecure-registry=10.19.248.12:30100 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
安装maven3.2.3
1.创建一个maven文件夹
mkdir /usr/local/maven
2.上传apache-maven-3.2.3-bin.tar.gz到/usr/local/maven/目录下
3.解压
tar -zxvf apache-maven-3.2.3-bin.tar.gz -C /usr/local/maven/
4.设置环境变量
vim /etc/profile
在/etc/profile的文件末尾添加以下配置:
export M2_HOME=/usr/local/maven/apache-maven-3.2.3
export PATH=
J
A
V
A
H
O
M
E
/
b
i
n
:
JAVA_HOME/bin:
JAVAHOME/bin:JAVA_HOME/jre/bin:
M
2
H
O
M
E
/
b
i
n
:
M2_HOME/bin:
M2HOME/bin:PATH
执行source命令让新配置立即生效:
source /etc/profile
5.让环境变量永久生效
vim ~/.bashrc
加入source /etc/profile
6.测试
mvn -v
安装 Nodejs
安装版本:10.10.0
1、安装必要的编译软件包
yum install gcc gcc-c++
2、从源码下载Nodejs
yum install wget
cd /usr/local/src
wget https://npm.taobao.org/mirrors/node/v10.10.0/node-v10.10.0.tar.gz
3、解压 nodejs 安装包
tar xvf node-v10.10.0.tar.gz
4、进入解压的 node 文件夹,开始编译
cd node-v10.10.0/
./configure
make -j 4
5、安装Nodejs
make install
6、验证是否正确安装
node -v
docker启动缺少docker-runc 命令
cd /usr/libexec/docker/
ln -s docker-runc-current docker-runc
安装 go
先下载对应版本https://studygolang.com/dl
tar -C /usr/local -zxvf go1.10.3.linux-amd64.tar.gz
vim /etc/profile
// 在最后一行添加
export GOROOT=/usr/local/go
export PATH=
P
A
T
H
:
PATH:
PATH:GOROOT/bin
// wq保存退出后source一下
source /etc/profile
安装glide
export GOROOT=/root/go GOROOT是go语言安装的路径
export PATH=
P
A
T
H
:
PATH:
PATH:GOROOT/bin:
G
O
P
A
T
H
/
b
i
n
G
O
P
A
T
H
是
项
目
的
存
放
路
径
e
x
p
o
r
t
G
O
P
A
T
H
=
/
r
o
o
t
/
g
o
p
a
t
h
e
x
p
o
r
t
G
O
B
I
N
=
GOPATH/bin GOPATH是项目的存放路径 export GOPATH=/root/gopath export GOBIN=
GOPATH/binGOPATH是项目的存放路径exportGOPATH=/root/gopathexportGOBIN=GOROOT/bin
curl https://glide.sh/get | sh
更多推荐
所有评论(0)