依赖安装
常用工具安装
yum install vim gcc gcc-c++ glibc glibc-devel pcre git \
pcre-devel openssl openssl-devel zip unzip zlib-devel net-tools \
telnet lsof tcpdump wget -y
基础安装环境准备
# 准备安装目录 替换实际安装路径
mkdir -p /app/{mars,jupiter,saturn}
mkdir /app/mars/{server,client}
# 准备supervisor日志路径
mkdir -p /data/log/supervisor/{mars,jupiter,saturn}
# 准备项目日志路径
mkdir -p /data/log/{mars,jupiter,saturn}
# 准备前端页面目录
mkdir -p /var/www/fe
supervisor 安装
yum install epel-release
yum install -y supervisor
systemctl enable supervisord
systemctl start supervisord
mars supervisor配置
vim /etc/supervisord.d/mars.ini
# 配置如下:
[program:mars]
# 替换实际工作路径
directory=/app/mars/server
command=/app/mars/server/mars start -c config.yml
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/data/log/supervisor/mars/mars.log
startretries=10
mars客户端 supervisor配置
vim /etc/supervisord.d/mars.ini
# 配置如下:
[program:mars]
# 替换实际工作路径
directory=/app/mars/client
command=/app/mars/client/mars-client start -c config.yml
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/data/log/supervisor/mars/mars-client.log
startretries=10
jupiter supervisor配置
vim /etc/supervisord.d/jupiter.ini
#配置如下:
[program:jupiter]
# 替换实际工作路径
directory=/app/jupiter
command=/app/jupiter/jupiter start -c config.yml
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/data/log/supervisor/jupiter/jupiter.log
startretries=10
Saturn supervisor配置
vim /etc/supervisord.d/jupiter.ini
#配置如下:
[program:saturn]
# 替换实际工作路径
directory=/app/saturn
command=/app/saturn/saturn start -c config.yml
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/data/log/supervisor/saturn/saturn.log
startretries=10
Ngin安装配置 如果使用现有nginx 忽略nginx安装
#查看80端口占用情况
netstat -tunlp | grep 80
yum install nginx
systemctl enable nginx
systemctl start nginx
# nginx安装好后修改默认配置
vim /etc/nginx/nginx.conf
# 注释掉默认server段
# server {
# listen 80;
# listen [::]:80;
# server_name _;
# root /usr/share/nginx/html;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# error_page 404 /404.html;
# location = /404.html {
# }
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
#创建gops代理配置
vim /etc/nginx/conf.d/gops.conf
# gops.conf配置如下
upstream mars{
server 127.0.0.1:9001;
}
upstream jupiter{
server 127.0.0.1:9002;
}
upstream saturn{
server 127.0.0.1:9003;
}
server {
listen 80 default;
# 修改域名或ip
server_name 127.0.0.1 ;
location ^~ /mars/ {
proxy_pass http://mars/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /jupiter/ {
proxy_pass http://jupiter/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /saturn/ {
proxy_pass http://saturn/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
root /var/www/fe;
index index.html;
try_files $uri $uri/ /index.html;
}
}
Docker 安装配置
# docker 17.06+ 版本以上
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce-18.09.9-3.el7
# docker-compose 1.18.0+ 版本以上
curl -SL https://github.com/docker/compose/releases/download/v2.10.0/docker-compose-linux-x86_64 -o /usr/bin/docker-compose
chmod u+x /usr/bin/docker-compose
# vim /etc/docker/daemon.json
# 添加harbor地址 注意如果harbor非80端口,在insecure-registers列表中添加 ip:端口号
{
"registry-mirrors": ["https://pqbap4ya.mirror.aliyuncs.com"],
"insecure-registries": ["127.0.0.1/8","harborIp:81"],
"max-concurrent-downloads": 10,
"log-driver": "json-file",
"log-level": "warn",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
systemctl restart docker
Harbor安装配置 已经有harbor服务忽略此安装配置
# 下载harbor安装包
curl -SL https://github.com/goharbor/harbor/releases/download/v2.6.0/harbor-offline-installer-v2.6.0.tgz
# 解压后修改harbor.yml配置如下:
hostname: 172.25.2.174
http:
# 修改对应端口号,不要与本机端口冲突
port: 80
# harbor默认用户admin的密码
harbor_admin_password: Harbor12345
database:
password: root123
max_idle_conns: 100
max_open_conns: 900
# harbor数据挂载路径
data_volume: /root/harbor/shared
trivy:
ignore_unfixed: false
skip_update: false
offline_scan: false
insecure: false
jobservice:
max_job_workers: 10
notification:
webhook_job_max_retry: 10
chart:
absolute_url: disabled
log:
level: info
local:
rotate_count: 50
rotate_size: 200M
location: /root/harbor/log
_version: 2.6.0
proxy:
http_proxy:
https_proxy:
no_proxy:
components:
- core
- jobservice
- trivy
upload_purging:
enabled: true
age: 168h
interval: 24h
dryrun: false
cache:
enabled: false
expire_hours: 24
# 开始安装
./install.sh
# 查看harbor容器启动情况
docker-compose ps
# harbor安装成功后,登录harbor
docker login ip:端口号
# 生成base64镜像仓库认证秘钥 应用mars安装后配置到配置文件中用于cicd拉取镜像
cat ~/.docker/config.json | base64 -w 0
ewoJImF1dGhzIjogewoJCSIxNzIuMjUuMi4xNzQiOiB7CgkJCSJhdXRoIjogIllXUnRhVzQ2U0dGeVltOXlNVEl6TkRVPSIKCQl9Cgl9LAoJIkh0dHBIZWFkZXJzIjogewoJCSJVc2VyLUFnZW50IjogIkRvY2tlci1DbGllbnQvMTguMDkuOSAobGludXgpIgoJfQp9
最后更新于