Jenkins Quick Start - Part 0 - Install and Configure Jenkins
2018年04月27日
[root@* ~]# yum update -y
[root@* ~]# sudo yum install jenkins java-11-openjdk-devel -y
[root@* ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@* ~]# systemctl status iptables
Unit iptables.service could not be found.
[root@* ~]# sudo systemctl daemon-reload
[root@* ~]# systemctl start jenkins
[root@* ~]# systemctl status jenkins
------删除线开始------
[root@* ~]# yum install -y telnet
[root@* ~]# ps aux | grep jenkins
jenkins 32023 16.2 22.3 2386896 227308 ? Ssl 13:31 0:20 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
root 32106 0.0 0.0 112660 972 pts/0 R+ 13:33 0:00 grep --color=auto jenkins
[root@* ~]# telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
helo
HTTP/1.1 400 No URI
Content-Type: text/html;charset=iso-8859-1
Content-Length: 49
Connection: close
Server: Jetty(9.4.z-SNAPSHOT)
<h1>Bad Message 400</h1><pre>reason: No URI</pre>Connection closed by foreign host.
[root@* ~]# yum install -y nginx
[root@* ~]# cd /etc/nginx/
[root@* nginx]# vim nginx.conf
在“location /”中增加“proxy_pass http://127.0.0.1:8080;”,如下所示:
[root@* nginx]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
------删除线结束------
[root@* nginx]# systemctl start nginx
[root@* nginx]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-04-27 13:43:20 CST; 56s ago
Process: 32255 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 32251 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 32250 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 32258 (nginx)
CGroup: /system.slice/nginx.service
├─32258 nginx: master process /usr/sbin/nginx
└─32259 nginx: worker process
Apr 27 13:43:20 * systemd[1]: Starting The nginx HTTP and reverse proxy server...
Apr 27 13:43:20 * nginx[32251]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Apr 27 13:43:20 * nginx[32251]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Apr 27 13:43:20 * systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
Apr 27 13:43:20 * systemd[1]: Started The nginx HTTP and reverse proxy server.
[root@* nginx]# yum install -y elinks
[root@* nginx]# elinks http://localhost:8080
Note
按q退出
[root@* nginx]# elinks http://localhost
从浏览器访问Jenkins GUI(Jenkins Master node的公网IP地址)
http://public-ip:8080
SELinux怎么影响Nginx proxy 8080端口,怎么解决这个问题(~11:00 - 16:00)。因为实验机上的SELinux是关闭的,所以这一部分略过。
[root@* ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
将上面的初始管理员密码粘贴到浏览器的文本框中
Jenkins版本Jenkins 2.296
安装推荐的插件
-- THE END --
------删除线开始------
参考本页面bottom处的链接,将Jenkins GUI界面语言设置为英文。
点击“Manage Jenkins”,出现报错信息"It appears that your reverse proxy set up is broken."。点击“More Info”,点击链接“Running Jenkins behind Nginx”,把下面{}里的东西补充到/etc/nginx/nginx.conf
[root@* nginx]# vim /etc/nginx/nginx.conf
[root@* nginx]# systemctl restart nginx
从浏览器访问Jenkins GUI,点击“Manage Jenkins”后,不再出现报错信息
------删除线结束------
References
User Handbook
Launch an EC2 instance. In this lab I use OS CentOS7. And this will be used as Jenkins Master node later on.
SSH to the Jenkins Master node.
PS:此时还没有涉及到Jenkins Master node。
[root@* ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
Note
-O –output-document=FILE 把文档写到FILE文件中
[root@* ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
[root@* ~]# yum upgrade -y
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: d36uatko69830t.cloudfront.net * extras: d36uatko69830t.cloudfront.net * updates: d36uatko69830t.cloudfront.net No packages marked for update
[root@* ~]# yum update -y
[root@* ~]# sudo yum install jenkins java-11-openjdk-devel -y
[root@* ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@* ~]# systemctl status iptables
Unit iptables.service could not be found.
[root@* ~]# sudo systemctl daemon-reload
[root@* ~]# systemctl start jenkins
[root@* ~]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled) Active: active (running) since Sun 2021-06-06 03:31:25 UTC; 8s ago Docs: man:systemd-sysv-generator(8) Process: 12603 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS) CGroup: /system.slice/jenkins.service └─12622 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /u... Jun 06 03:31:24 ip-10-0-0-148.us-west-2.compute.internal systemd[1]: Starting LSB: Jenkins Automation Server... Jun 06 03:31:24 ip-10-0-0-148.us-west-2.compute.internal runuser[12608]: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Jun 06 03:31:25 ip-10-0-0-148.us-west-2.compute.internal systemd[1]: Started LSB: Jenkins Automation Server. Jun 06 03:31:25 ip-10-0-0-148.us-west-2.compute.internal jenkins[12603]: Starting Jenkins [ OK ] Hint: Some lines were ellipsized, use -l to show in full.
------删除线开始------
[root@* ~]# yum install -y telnet
[root@* ~]# ps aux | grep jenkins
jenkins 32023 16.2 22.3 2386896 227308 ? Ssl 13:31 0:20 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
root 32106 0.0 0.0 112660 972 pts/0 R+ 13:33 0:00 grep --color=auto jenkins
[root@* ~]# telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
helo
HTTP/1.1 400 No URI
Content-Type: text/html;charset=iso-8859-1
Content-Length: 49
Connection: close
Server: Jetty(9.4.z-SNAPSHOT)
<h1>Bad Message 400</h1><pre>reason: No URI</pre>Connection closed by foreign host.
[root@* ~]# yum install -y nginx
[root@* ~]# cd /etc/nginx/
[root@* nginx]# vim nginx.conf
在“location /”中增加“proxy_pass http://127.0.0.1:8080;”,如下所示:
http { ... ... server { ... ... location / { proxy_pass http://127.0.0.1:8080; } } }
[root@* nginx]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
------删除线结束------
[root@* nginx]# systemctl start nginx
[root@* nginx]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-04-27 13:43:20 CST; 56s ago
Process: 32255 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 32251 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 32250 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 32258 (nginx)
CGroup: /system.slice/nginx.service
├─32258 nginx: master process /usr/sbin/nginx
└─32259 nginx: worker process
Apr 27 13:43:20 * systemd[1]: Starting The nginx HTTP and reverse proxy server...
Apr 27 13:43:20 * nginx[32251]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Apr 27 13:43:20 * nginx[32251]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Apr 27 13:43:20 * systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
Apr 27 13:43:20 * systemd[1]: Started The nginx HTTP and reverse proxy server.
[root@* nginx]# yum install -y elinks
[root@* nginx]# elinks http://localhost:8080
Note
按q退出
[root@* nginx]# elinks http://localhost
从浏览器访问Jenkins GUI(Jenkins Master node的公网IP地址)
http://public-ip:8080
SELinux怎么影响Nginx proxy 8080端口,怎么解决这个问题(~11:00 - 16:00)。因为实验机上的SELinux是关闭的,所以这一部分略过。
[root@* ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
e44**5d6
将上面的初始管理员密码粘贴到浏览器的文本框中
Jenkins版本Jenkins 2.296
安装推荐的插件
-- THE END --
------删除线开始------
参考本页面bottom处的链接,将Jenkins GUI界面语言设置为英文。
点击“Manage Jenkins”,出现报错信息"It appears that your reverse proxy set up is broken."。点击“More Info”,点击链接“Running Jenkins behind Nginx”,把下面{}里的东西补充到/etc/nginx/nginx.conf
location @jenkins { proxy_redirect default; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_max_temp_file_size 0; #this is the maximum upload size client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_request_buffering off; # Required for HTTP CLI commands in Jenkins > 2.54 proxy_set_header Connection ""; # Clear for keepalive }
[root@* nginx]# vim /etc/nginx/nginx.conf
[root@* nginx]# systemctl restart nginx
从浏览器访问Jenkins GUI,点击“Manage Jenkins”后,不再出现报错信息
------删除线结束------
References
User Handbook