前面已经简单介绍jenkins持续集成,今天本篇文章主要针对“阿里云服务器安装Jenkins且进入Jenkins解锁页面”进行讲解。关于“jenkins页面设置”会在下一篇进行说明,希望感兴趣的小伙伴可以坚持看下去同时欢迎提出宝贵的意见让我们一起进步!
第一步:下载安装包
(1)linux命令为:
wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
[root@iZ2zebjpjfqq58nc6ul6hnZ package]# wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
--2020-04-25 17:16:43-- http://mirrors.jenkins.io/war-stable/latest/jenkins.war
Resolving mirrors.jenkins.io (mirrors.jenkins.io)... 52.202.51.185
Connecting to mirrors.jenkins.io (mirrors.jenkins.io)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://mirror.serverion.com/jenkins/war-stable/2.222.3/jenkins.war [following]
--2020-04-25 17:16:44-- http://mirror.serverion.com/jenkins/war-stable/2.222.3/jenkins.war
Resolving mirror.serverion.com (mirror.serverion.com)... 185.126.34.191
Connecting to mirror.serverion.com (mirror.serverion.com)|185.126.34.191|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 66241734 (63M)
Saving to: ‘jenkins.war’
100%[==============================================================================================>] 66,241,734 18.9KB/s in 52m 39s
2020-04-25 18:09:26 (20.5 KB/s) - ‘jenkins.war’ saved [66241734/66241734]
第二步:安装jdk
如何安装jdk在前面文章已介绍,具体见文章“https://www.jianshu.com/p/5ec40e6287c4”
第三步:启动Jenkins
(1)linux控制台启用命令为(退出控制台进程就关闭):
java -jar /root/package/jenkins.war --httpPort=8080
(2)linux后台启用命令为(后台一直运行):nohup java -jar /root/package/jenkins.war --httpPort=8080 &
(3)linux后台启用命令为(打印启动日志):nohup java -jar /root/package/jenkins.war --httpPort=8080 > jenkins.log 2>&1 &
(4)注意:根据自己安装包所在的路径启动命令
[root@iZ2zebjpjfqq58nc6ul6hnZ package]# java -jar /root/package/jenkins.war --httpPort=8080
Running from: /root/package/jenkins.war
webroot: $user.home/.jenkins
2020-04-25 10:17:27.413+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @762ms to org.eclipse.jetty.util.log.JavaUtilLog
2020-04-25 10:17:27.593+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file
2020-04-25 10:17:29.120+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2020-04-25 10:17:29.220+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.27.v20200227; built: 2020-02-27T18:37:21.340Z; git: a304fd9f351f337e7c0e2a7c28878dd536149c6c; jvm 1.8.0_251-b08
2020-04-25 10:17:29.649+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2020-04-25 10:17:29.718+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2020-04-25 10:17:29.720+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2020-04-25 10:17:29.723+0000 [id=1] INFO o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 600000ms
2020-04-25 10:17:30.387+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins home directory: /root/.jenkins found at: $user.home/.jenkins
2020-04-25 10:17:30.566+0000 [id=1] INFO o.e.j.s.handler.ContextHandler#doStart: Started w.@24a1c17f{Jenkins v2.222.3,/,file:///root/.jenkins/war/,AVAILABLE}{/root/.jenkins/war}
2020-04-25 10:17:30.645+0000 [id=1] INFO o.e.j.server.AbstractConnector#doStart: Started ServerConnector@60f00693{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2020-04-25 10:17:30.646+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: Started @3995ms
2020-04-25 10:17:30.649+0000 [id=20] INFO winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2020-04-25 10:17:32.382+0000 [id=25] INFO jenkins.InitReactorRunner$1#onAttained: Started initialization
2020-04-25 10:17:32.405+0000 [id=25] INFO jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2020-04-25 10:17:34.762+0000 [id=26] INFO jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2020-04-25 10:17:34.769+0000 [id=26] INFO jenkins.InitReactorRunner$1#onAttained: Started all plugins
2020-04-25 10:17:34.836+0000 [id=25] INFO jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2020-04-25 10:17:36.006+0000 [id=25] INFO jenkins.InitReactorRunner$1#onAttained: System config loaded
2020-04-25 10:17:36.006+0000 [id=25] INFO jenkins.InitReactorRunner$1#onAttained: System config adapted
2020-04-25 10:17:36.006+0000 [id=25] INFO jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2020-04-25 10:17:36.029+0000 [id=25] INFO jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2020-04-25 10:17:36.621+0000 [id=39] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Started Download metadata
2020-04-25 10:17:36.663+0000 [id=39] INFO hudson.util.Retrier#start: Attempt #1 to do the action check updates server
2020-04-25 10:17:37.360+0000 [id=25] INFO o.s.c.s.AbstractApplicationContext#prepareRefresh: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@1d4bf43: display name [Root WebApplicationContext]; startup date [Sat Apr 25 18:17:37 CST 2020]; root of context hierarchy
2020-04-25 10:17:37.360+0000 [id=25] INFO o.s.c.s.AbstractApplicationContext#obtainFreshBeanFactory: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@1d4bf43]: org.springframework.beans.factory.support.DefaultListableBeanFactory@32504f01
2020-04-25 10:17:37.368+0000 [id=25] INFO o.s.b.f.s.DefaultListableBeanFactory#preInstantiateSingletons: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@32504f01: defining beans [authenticationManager]; root of factory hierarchy
2020-04-25 10:17:37.652+0000 [id=25] INFO o.s.c.s.AbstractApplicationContext#prepareRefresh: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@7696c8e9: display name [Root WebApplicationContext]; startup date [Sat Apr 25 18:17:37 CST 2020]; root of context hierarchy
2020-04-25 10:17:37.653+0000 [id=25] INFO o.s.c.s.AbstractApplicationContext#obtainFreshBeanFactory: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@7696c8e9]: org.springframework.beans.factory.support.DefaultListableBeanFactory@d6894aa
2020-04-25 10:17:37.654+0000 [id=25] INFO o.s.b.f.s.DefaultListableBeanFactory#preInstantiateSingletons: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@d6894aa: defining beans [filter,legacy]; root of factory hierarchy
2020-04-25 10:17:38.129+0000 [id=25] INFO jenkins.install.SetupWizard#init:
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
a168e06e5ee64e5fa4cb60b7737ab0df
This may also be found at: /root/.jenkins/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
2020-04-25 10:20:19.368+0000 [id=25] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
2020-04-25 10:20:19.417+0000 [id=19] INFO hudson.WebAppMain$3#run: Jenkins is fully up and running
第四步:将TCP端口号添加到安全组实例中
(1)阿里云服务器必须将TCP端口号添加到安全组实例中才能访问相关端口,否则在地址栏输入“http://ip:端口号”会报“
无法访问此网站
”错误
(2)如何将TCP端口号添加到安全组实例中前面文章已介绍,具体见文章“https://www.jianshu.com/p/5d1774c412a4”
第五步:进入解锁Jenkins页面
(1)在浏览器网址栏输入“http://59.110.230.1xx:端口号/”
额外补充:
(1)注意:登录Jenkins主页的ip如果是虚拟机用内网IP ;如果是云服务器用外网IP
(2)云服务器查看外网IP命令为:curl cip.cc
[root@iZ2zebjpjfqq58nc6ul6hnZ ~]# curl cip.cc
IP : 59.110.230.1XX
地址 : 中国 北京
运营商 : 阿里云/电信/联通/移动/铁通/教育网
数据二 : 北京市 | 阿里云
数据三 : 中国北京北京 | 阿里云
URL : http://www.cip.cc/59.110.230.1XX
(3)查看端口使用情况命令为:
netstat -nltp
[root@iZ2zebjpjfqq58nc6ul6hnZ ~]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 25074/java
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1022/sshd
(4)杀死一个进程命令为:
kill -9 进程号
[root@iZ2zebjpjfqq58nc6ul6hnZ ~]# ps -ef |grep jenkins
root 25074 23090 1 00:20 pts/1 00:00:11 java -jar /root/package/jenkins.war --httpPort=8080
root 25748 23090 0 00:32 pts/1 00:00:00 grep --color=auto jenkins
root 25760 23090 0 00:33 pts/1 00:00:00 grep --color=auto jenkins
[root@iZ2zebjpjfqq58nc6ul6hnZ ~]# kill -9 25074