页面“基于Docker的Jenkins持续集成”与“Gitlab社区版安装和配置”之间的差异
(页面间的差异)
跳到导航
跳到搜索
(→报错) |
|||
第1行: | 第1行: | ||
− | |||
− | |||
− | + | == pre == | |
− | + | gitlab社区版安装和配置 | |
− | + | os: centos6.X | |
− | + | ==第零 docker-compose for gitlab == | |
− | |||
<pre> | <pre> | ||
− | |||
− | |||
− | |||
− | |||
+ | 2020 直接 docker-compose 其实可以上 alpine的 | ||
+ | cat docker-compose.yml | ||
− | |||
− | + | web: | |
− | + | image: 'gitlab/gitlab-ce:11.4.3' | |
− | + | #image: 'gitlab/gitlab-ce:latest' | |
− | + | restart: always | |
− | + | hostname: 'mygitlab' | |
− | - | + | environment: |
− | - | + | GITLAB_OMNIBUS_CONFIG: | |
− | + | external_url 'http://gitlab.lliao.net' | |
− | + | #external_url 'https://mygitlab.com' | |
− | + | # Add any other gitlab.rb configuration here, each on its own line | |
− | + | ports: | |
− | + | - '7080:80' | |
− | - | + | - '4433:443' |
− | + | - '2222:22' | |
− | + | volumes: | |
− | + | - ./gitlab/config:/etc/gitlab | |
− | + | - ./gitlab/logs:/var/log/gitlab | |
− | + | - ./gitlab/data:/var/opt/gitlab | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | #这个手工的 线上一般不用了 以前学习用的 | |
− | + | 获取 GitLab 镜像 | |
− | + | docker search gitlab | |
− | |||
− | |||
− | |||
− | + | docker pull gitlab/gitlab-ce:latest | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | 查看本地镜像 | ||
+ | docker images | ||
+ | 创建目录 | ||
− | + | mkdir -p /data/gitlab/{config,data,logs} | |
− | |||
− | + | 创建并运行容器 | |
− | |||
+ | docker run --detach \ | ||
+ | --hostname git.evan.com \ | ||
+ | --publish 443:443 \ | ||
+ | --publish 80:80 \ | ||
+ | --publish 222:22 \ | ||
+ | --name gitlabce\ | ||
+ | --restart always \ | ||
+ | --volume /data/gitlab/config:/etc/gitlab \ | ||
+ | --volume /data/gitlab/logs:/var/log/gitlab \ | ||
+ | --volume /data/gitlab/data:/var/opt/gitlab \ | ||
+ | gitlab/gitlab-ce:latest | ||
+ | 查看运行状态 | ||
− | docker- | + | docker ps |
− | + | netstat -ntulap | grep docker | |
− | + | 访问 GitLab | |
+ | 启动 | ||
+ | docker start gitlabce | ||
+ | docker stop gitlabce | ||
+ | http://git.evan.com/ | ||
+ | 如果没有域名,直接使用 IP 访问即可。 | ||
+ | 初始账户 | ||
+ | 用户: root | ||
+ | 密码: 5iveL!fe 现在一般要自己配置密码的了 | ||
+ | </pre> | ||
− | + | [https://docs.gitlab.com/ee/install/docker.html Install GitLab with Docker] | |
− | [ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ==gitlab搭配ssh默认端口引发的问题 == | |
− | + | <pre> | |
− | + | 明明 docker-compose.yml 用 了222端口但还是有问题 | |
− | |||
− | |||
− | + | 修改sshd_config中的Port | |
− | + | service sshd restart | |
− | |||
− | |||
− | |||
− | |||
− | + | #第一步的我没改哦 好像可以不动 | |
+ | 修改/etc/gitlab/gitlab.rb [再次声明,gitlab.yml中的配置会被这个给覆盖] | ||
− | + | 启用下面这行,并把端口改为自己服务器的sshd端口 | |
− | |||
− | + | gitlab_rails['gitlab_shell_ssh_port'] = 50022 | |
+ | 使之生效,大功告其! | ||
+ | gitlab-ctl reconfigure | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == | + | == 第一种 Install and configure the necessary dependencies == |
− | + | <pre>进入gitlab官方网站,选择对应的操作系统——CentOS 6 (and RedHat/Oracle/Scientific Linux 6), | |
+ | https://about.gitlab.com/downloads/#centos6 | ||
+ | 按照官方的提示进行安装: | ||
+ | 安装配置必要的依赖 | ||
+ | 在Centos 6 和 7 中,以下的命令将会打开HTTP和SSH在系统防火墙中的可访问权限。 | ||
− | + | #sudo lokkit -s http -s ssh | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | [gitlab-ce] | |
− | + | name=gitlab-ce | |
− | + | baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6 | |
− | + | repo_gpgcheck=0 | |
− | + | gpgcheck=0 | |
+ | enabled=1 | ||
+ | gpgkey=https://packages.gitlab.com/gpg.key | ||
− | |||
− | + | sudo yum makecache | |
− | + | # 安装依赖包 | |
− | + | sudo yum install curl openssh-server openssh-clients postfix cronie | |
− | -- | + | # 启动 postfix 邮件服务 |
+ | sudo service postfix start | ||
+ | # 检查 postfix | ||
+ | sudo chkconfig postfix on | ||
+ | # 安装 GitLab 社区版 | ||
+ | sudo yum install gitlab-ce | ||
+ | # 初始化 GitLab 配置并启动GitLab | ||
+ | 打开/etc/gitlab/gitlab.rb,将external_url = ‘http://git.example.com’修改为自己的IP地址:http://xxx.xx.xxx.xx,,然后执行下面的命令,对GitLab进行编译。 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | sudo gitlab-ctl reconfigure | ||
+ | 一直都有更新的。 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | sudo gitlab-ctl reconfigure | ||
+ | 登录GitLab | ||
+ | Username: root | ||
+ | Password: 5iveL!fe | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | 我在ubuntu下的一键安装,如果用汉化版的有问题的。 | |
+ | 所以现在只能用英文原版的。 | ||
− | |||
− | |||
− | + | 现在会要求改密码了 在第一次 | |
− | + | dkm12345678 | |
− | |||
− | |||
− | |||
− | + | git_data_dirs({"default" => "/data/gitlab/git-data"}) | |
− | + | /data/gitlab/git-data | |
− | |||
− | + | gitlab-ctl reconfigure </pre> | |
− | <pre> | ||
− | + | | |
− | |||
− | + | == 第二种 Add the GitLab package server and install the package == | |
+ | <pre>curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash | ||
+ | sudo yum install gitlab-ce </pre> | ||
+ | | ||
− | + | | |
− | |||
− | https:// | + | [https://cloud.tencent.com/developer/article/1114666 【gitlab小症状】gitlab搭配ssh默认端口引发的血战] |
− | + | [https://blog.csdn.net/ming19951224/article/details/105479033 docker安装gitlab并使用非标准端口] | |
− | + | ==gitlab性能优化调化 占用内存过大问题== | |
− | |||
− | == | ||
<pre> | <pre> | ||
− | + | /etc/gitlab/gitlab.rb | |
− | + | ||
− | + | #进程数目 | |
+ | unicorn['worker_processes'] = 2 | ||
+ | #减少数据库缓存 默认为 256M | ||
+ | postgresql['shared_buffers'] = "128MB" | ||
− | |||
− | + | #减少并发数 默认为8 | |
+ | postgresql['max_worker_processes'] = 4 | ||
− | |||
− | |||
+ | #减少 sidekiq并发数 | ||
+ | sidekiq['concurrency'] = 20 | ||
− | + | #最后 reload | |
− | + | gitlab-ctl reconfigure | |
</pre> | </pre> | ||
+ | [https://www.dgstack.cn/archives/1951.html gitlab占用内存过大问题] | ||
− | + | [https://www.cnblogs.com/h--d/p/10153647.html GitLab配置优化及汉化] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == | + | ==Gitlab 重置 root 密码== |
<pre> | <pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | 先登录入容器 | |
− | |||
+ | 要重置root密码,请先使用root权限登录服务器。使用以下命令启动Ruby on Rails控制台: | ||
− | + | gitlab-rails console production | |
− | + | 等到控制台加载完毕,您可以通过搜索电子邮件或用户名等方法找到您的账号。 | |
− | + | user = User.where(id: 1).first | |
− | + | 或者 | |
− | |||
− | |||
− | + | user = User.find_by(email: '[email protected]') | |
− | |||
− | |||
− | |||
− | + | 找出用户以后,可以更改其密码: | |
− | |||
− | |||
− | |||
+ | user.password = 12345678 | ||
+ | user.password_confirmation = 12345678 | ||
− | + | user.save! | |
− | |||
− | + | 最后,保存上面的更改,即可使用新密码登录。 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
− | + | == 报错 == | |
+ | <pre>================================================================================ | ||
+ | Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb | ||
+ | ================================================================================ | ||
− | + | RuntimeError | |
− | + | ------------ | |
− | + | GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/ | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | http:// | ||
+ | 记得前缀有http样 | ||
</pre> | </pre> | ||
− | https:// | + | [https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/ https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/] |
− | https://www. | + | [https://www.linuxchina.net/?p=2750 https://www.linuxchina.net/?p=2750] |
− | + | | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=see also= | =see also= | ||
− | + | [https://docs.gitlab.com/omnibus/docker/ GitLab Docker images] | |
− | |||
− | [https:// | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [https:// | + | [https://my.oschina.net/u/1432614/blog/658568 在 CentOS 7 上使用 Docker 部署安装 GitLab] |
− | [https:// | + | [https://github.com/beginor/docker-gitlab-ce GitLab 中文社区版 Docker 镜像] |
− | [https:// | + | [https://gist.github.com/ouyangzhiping/47fcbf26d213146407f2 ouyangzhiping/docker-gitlab.md] |
− | + | [https://www.cnblogs.com/weifeng1463/p/7714492.html GitLab的安装及使用教程] | |
− | [https://www.cnblogs.com/ | ||
− | + | [[Category:git]] [[Category:ops]] |
2020年11月23日 (一) 08:14的版本
目录
pre
gitlab社区版安装和配置
os: centos6.X
第零 docker-compose for gitlab
2020 直接 docker-compose 其实可以上 alpine的 cat docker-compose.yml web: image: 'gitlab/gitlab-ce:11.4.3' #image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'mygitlab' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://gitlab.lliao.net' #external_url 'https://mygitlab.com' # Add any other gitlab.rb configuration here, each on its own line ports: - '7080:80' - '4433:443' - '2222:22' volumes: - ./gitlab/config:/etc/gitlab - ./gitlab/logs:/var/log/gitlab - ./gitlab/data:/var/opt/gitlab #这个手工的 线上一般不用了 以前学习用的 获取 GitLab 镜像 docker search gitlab docker pull gitlab/gitlab-ce:latest 查看本地镜像 docker images 创建目录 mkdir -p /data/gitlab/{config,data,logs} 创建并运行容器 docker run --detach \ --hostname git.evan.com \ --publish 443:443 \ --publish 80:80 \ --publish 222:22 \ --name gitlabce\ --restart always \ --volume /data/gitlab/config:/etc/gitlab \ --volume /data/gitlab/logs:/var/log/gitlab \ --volume /data/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest 查看运行状态 docker ps netstat -ntulap | grep docker 访问 GitLab 启动 docker start gitlabce docker stop gitlabce http://git.evan.com/ 如果没有域名,直接使用 IP 访问即可。 初始账户 用户: root 密码: 5iveL!fe 现在一般要自己配置密码的了
gitlab搭配ssh默认端口引发的问题
明明 docker-compose.yml 用 了222端口但还是有问题 修改sshd_config中的Port service sshd restart #第一步的我没改哦 好像可以不动 修改/etc/gitlab/gitlab.rb [再次声明,gitlab.yml中的配置会被这个给覆盖] 启用下面这行,并把端口改为自己服务器的sshd端口 gitlab_rails['gitlab_shell_ssh_port'] = 50022 使之生效,大功告其! gitlab-ctl reconfigure
第一种 Install and configure the necessary dependencies
进入gitlab官方网站,选择对应的操作系统——CentOS 6 (and RedHat/Oracle/Scientific Linux 6), https://about.gitlab.com/downloads/#centos6 按照官方的提示进行安装: 安装配置必要的依赖 在Centos 6 和 7 中,以下的命令将会打开HTTP和SSH在系统防火墙中的可访问权限。 #sudo lokkit -s http -s ssh [gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6 repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key sudo yum makecache # 安装依赖包 sudo yum install curl openssh-server openssh-clients postfix cronie # 启动 postfix 邮件服务 sudo service postfix start # 检查 postfix sudo chkconfig postfix on # 安装 GitLab 社区版 sudo yum install gitlab-ce # 初始化 GitLab 配置并启动GitLab 打开/etc/gitlab/gitlab.rb,将external_url = ‘http://git.example.com’修改为自己的IP地址:http://xxx.xx.xxx.xx,,然后执行下面的命令,对GitLab进行编译。 sudo gitlab-ctl reconfigure 一直都有更新的。 sudo gitlab-ctl reconfigure 登录GitLab Username: root Password: 5iveL!fe 我在ubuntu下的一键安装,如果用汉化版的有问题的。 所以现在只能用英文原版的。 现在会要求改密码了 在第一次 dkm12345678 git_data_dirs({"default" => "/data/gitlab/git-data"}) /data/gitlab/git-data gitlab-ctl reconfigure
第二种 Add the GitLab package server and install the package
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash sudo yum install gitlab-ce
【gitlab小症状】gitlab搭配ssh默认端口引发的血战
gitlab性能优化调化 占用内存过大问题
/etc/gitlab/gitlab.rb #进程数目 unicorn['worker_processes'] = 2 #减少数据库缓存 默认为 256M postgresql['shared_buffers'] = "128MB" #减少并发数 默认为8 postgresql['max_worker_processes'] = 4 #减少 sidekiq并发数 sidekiq['concurrency'] = 20 #最后 reload gitlab-ctl reconfigure
Gitlab 重置 root 密码
先登录入容器 要重置root密码,请先使用root权限登录服务器。使用以下命令启动Ruby on Rails控制台: gitlab-rails console production 等到控制台加载完毕,您可以通过搜索电子邮件或用户名等方法找到您的账号。 user = User.where(id: 1).first 或者 user = User.find_by(email: '[email protected]') 找出用户以后,可以更改其密码: user.password = 12345678 user.password_confirmation = 12345678 user.save! 最后,保存上面的更改,即可使用新密码登录。
报错
================================================================================ Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb ================================================================================ RuntimeError ------------ GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/ 记得前缀有http样
https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
https://www.linuxchina.net/?p=2750
see also
在 CentOS 7 上使用 Docker 部署安装 GitLab