背景:
计划使用Centos7 Core 作为 docker host,搭建测试平台,只有4台主机,就使用Swarm方案。
环境:
主机名称 | 系统 | IP地址 | 部署应用、节点 |
docker-host1 | CentOS7 Core | xxx.xxx.xxx.80 | Jenkins,部署java,nginx |
docker-host2 | CentOS7 Core | xxx.xxx.xxx.81 | Gitlab 部署java,nginx |
docker-host3 | CentOS7 Core | xxx.xxx.xxx.82 | postgres,geode |
docker-host4 | CentOS7 Core | xxx.xxx.xxx.83 | postgres,geode |
前置工作:
配置各个主机相互ssh免秘钥
docker-host1安装 Jenkins
1. 从https://prodjenkinsreleases.blob.core.windows.net/redhat-stable/jenkins-2.222.4-1.1.noarch.rpm 下载安装程序
2. 使用yum install 安装: sudo rpm -ivh jenkins-2.222.4-1.1.noarch.rpm
3. 参照 https://www.cnblogs.com/fangts/p/11095316.html ,直接配置使用/etc/sysconfig/jenkins文件中的 JENKINS_USER="root"
修改目录权限
sudo chown -R root:root /var/lib/jenkins
sudo chown -R root:root /var/cache/jenkins
sudo chown -R root:root /var/log/jenkins
重启
sudo service jenkins restart
提示:Starting Jenkins bash: /usr/bin/java: No such file or directory
Failed to start LSB: Jenkins Automation Server.
参考https://blog.csdn.net/qq_34208844/article/details/87865672,修改 /etc/init.d/jenkins
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/lib/jvm/java-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/programs/jdk1.8.0_211/bin/java
"
上面是修改后的,这里需要注意的是指向的是java文件完整路径,可以使用whereis java 查看,需要删除/usr/bin/java,这一行。
$ sudo systemctl daemon-reload
$ sudo systemctl start jenkins
启动成功,在浏览器中输入地址:http:
然后就是一直停留在这里了,参考https://blog.csdn.net/weixin_44679832/article/details/104409862
在/var/lib/jenkins安装目录下,找到hudson.model.UpdateCenter.xml,把http://updates.jenkins-ci.org/update-center.json,修改成http://mirror.xmission.com/jenkins/updates/update-center.json,并保存
$ sudo vim hudson.model.UpdateCenter.xml
$ cat hudson.model.UpdateCenter.xml
default
http://mirror.xmission.com/jenkins/updates/update-center.json
$ sudo systemctl restart jenkins
或是参考https://blog.csdn.net/hiXavier/article/details/103662275,使用web配置
重启服务,然后刷新页面,等待
然后根据需要安装插件,这里选择推荐插件
然而插件安装失败,可以参考https://jenkins-zh.cn/wechat/articles/2019/11/2019-11-11-update-center-mirror-announcement/
首先下载最新版,下载地址https://github.com/jenkinsci/localization-zh-cn-plugin/releases
解压到某个目录,使用idea或是其他ide,构建项目,最后构建成两个文件,
把这两个文件放到 Jenkins的plugins 文件夹,在浏览器打开Jenkins的插件高级管理 http://10.10.10.80:6080/pluginManager/advanced
选择hpi文件,点击上传,等待安装成功,然后重启Jenkins。
注意:打开浏览器的desktop机器不是部署服务器,需要desktop机器也有hpi文件
重启后,进入Jenkins后,点击右下角Jenkins中文社区,
点击 设置更新中心地址
修改升级站点成https://updates.jenkins-zh.cn/update-center.json,然后依次点击提交,立即获取
docker-host2安装 Gitlab
参考链接:
https://blog.csdn.net/duyusean/article/details/80011540
https://segmentfault.com/a/1190000021753705
1. 从https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/ 选择需要安装的rpm文件,并下载;
2. 使用yum install 安装:sudo yum install gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
3. 根据提示修改/etc/gitlab/gitlab.rb文件
# 修改成具体ip,这里是所有ip
external_url 'http://0.0.0.0:6900'
4. 初始化Gitlab
sudo gitlab-ctl reconfigure
5. 等待配置完成后启动Gitlab
Running handlers:
Running handlers complete
Chef Client finished, 362/515 resources updated in 02 minutes 11 seconds
gitlab Reconfigured!
$ sudo gitlab-ctl restart
ok: run: gitaly: (pid 21040) 0s
ok: run: gitlab-monitor: (pid 21057) 0s
ok: run: gitlab-workhorse: (pid 21061) 1s
ok: run: logrotate: (pid 21107) 0s
ok: run: nginx: (pid 21114) 1s
ok: run: node-exporter: (pid 21124) 0s
ok: run: postgres-exporter: (pid 21131) 0s
ok: run: postgresql: (pid 21140) 0s
ok: run: prometheus: (pid 21149) 0s
ok: run: redis: (pid 21160) 1s
ok: run: redis-exporter: (pid 21164) 0s
ok: run: sidekiq: (pid 21172) 0s
ok: run: unicorn: (pid 21181) 0s
$ netstat -nlutp
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6900 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 ::1:9168 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -
udp 0 0 0.0.0.0:111 0.0.0.0:* -
udp 0 0 0.0.0.0:964 0.0.0.0:* -
udp 0 0 0.0.0.0:34490 0.0.0.0:* -
udp6 0 0 :::111 :::* -
udp6 0 0 :::964 :::* -
[
7. 测试环境就直接关闭firewalld
systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-05-29 06:37:46 EDT; 1 day 20h ago
Docs: man:firewalld(1)
Main PID: 816 (firewalld)
Tasks: 2
Memory: 308.0K
CGroup: /system.slice/firewalld.service
└─816 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
$ sudo systemctl stop firewalld.service
$ sudo systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
8. 访问Gitlab地址 ,输入root用户重置密码,然后重新用root 和新密码登录
完成Gitlab初始安装。
docker-host3安装
暂无
docker-host4安装
暂无