{"id":767,"date":"2022-03-15T15:17:44","date_gmt":"2022-03-15T07:17:44","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=767"},"modified":"2022-03-15T15:34:33","modified_gmt":"2022-03-15T07:34:33","slug":"2-%e4%bb%a3%e7%a0%81%e8%87%aa%e5%8a%a8%e4%b8%8a%e7%ba%bf-gitlab","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=767","title":{"rendered":"2.\u4ee3\u7801\u81ea\u52a8\u4e0a\u7ebf\u2014gitlab"},"content":{"rendered":"\n<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.<strong>gitlab\u5b89\u88c5<\/strong>\u90e8\u7f72<\/h2>\n\n\n\n<p><strong><em>1.\u5b89\u88c5\u4f9d\u8d56<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@gitlab ~]# yum  install -y    curl  openssh-server   postfix  wget<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u5b89\u88c5Gitlab\u7ec4\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@gitlab ~]# yum install -y https:\/\/mirror.tuna.tsinghua.edu.cn\/gitlab-ce\/yum\/el7\/gitlab-ce-12.0.3-ce.0.el7.x86_64.rpm<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u4fee\u6539gitlab\u914d\u7f6e\u6587\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@git ~]# grep -E \"^&#91;a-Z]\" \/etc\/gitlab\/gitlab.rb \nexternal_url 'http:\/\/gitlab.sfy.com'###gitlab\u8bbf\u95ee\u7684url\ngitlab_rails&#91;'gitlab_email_enabled'] = true###\u90ae\u7bb1\uff0c\u5f00\u542f\ngitlab_rails&#91;'gitlab_email_from'] = '2195802440@qq.com'###\u53d1\u4ef6\u90ae\u7bb1\ngitlab_rails&#91;'gitlab_email_display_name'] = 'GitLib_\u901a\u77e5'###\u53d1\u4ef6\u90ae\u7bb1\u540d\ngitlab_rails&#91;'smtp_enable'] = true###\u90ae\u7bb1\u914d\u7f6e\ngitlab_rails&#91;'smtp_address'] = \"smtp.qq.com\"###\u53d1\u4ef6\u90ae\u7bb1\u5730\u5740\ngitlab_rails&#91;'smtp_port'] = 465###\u53d1\u4ef6\u90ae\u7bb1\u7aef\u53e3\ngitlab_rails&#91;'smtp_user_name'] = 2195802440@qq.com###\u53d1\u4ef6\u90ae\u7bb1\u540d\ngitlab_rails&#91;'smtp_password'] = \"upcrzqig\"###\u53d1\u4ef6\u90ae\u7bb1\u5bc6\u7801(\u6388\u6743\u7801)\ngitlab_rails&#91;'smtp_domain'] = \"qq.com\"###\u53d1\u4ef6\u4e3b\u673a\ngitlab_rails&#91;'smtp_authentication'] = \"login\"\ngitlab_rails&#91;'smtp_enable_starttls_auto'] = true\ngitlab_rails&#91;'smtp_tls'] = true\nprometheus&#91;'enable'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\nprometheus&#91;'monitor_kubernetes'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\nalertmanager&#91;'enable'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\nnode_exporter&#91;'enable'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\nredis_exporter&#91;'enable'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\npostgres_exporter&#91;'enable'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\ngitlab_monitor&#91;'enable'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\nprometheus_monitoring&#91;'enable'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\ngrafana&#91;'enable'] = false###\u5173\u95ed\u4e0d\u9700\u8981\u7684\u7ec4\u4ef6\n<\/code><\/pre>\n\n\n\n<p><strong><em>4. \u521d\u59cb\u5316\u64cd\u4f5c<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gitlab-ctl reconfigure##\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u540e\u9700\u8981\u6267\u884c\ngitlab- ctl status##\u67e5\u770b\u72b6\u6001\ngitlab- ctl stop##\u5173\u95ed\ngitlab- ctl start##\u5f00\u542f\n<\/code><\/pre>\n\n\n\n<p><strong><em>5.\u767b\u5f55<\/em><\/strong><\/p>\n\n\n\n<p>\u767b\u5f55\u7684\u65f6\u5019\u9700\u8981\u4fee\u6539\u5bc6\u7801\uff0c\u521d\u59cb\u8d26\u53f7\u4e3aroot<\/p>\n\n\n\n<p><strong><em>6. \u6c49\u5316<\/em><\/strong><\/p>\n\n\n\n<p>###\u4e0b\u8f7d\u6c49\u5316\u5305<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@gitlab ~]# wget https:\/\/gitlab.com\/xhang\/gitlab\/-\/archive\/12-0-stable-zh\/gitlab-12-0-stable-zh.tar.gz\n&#91;root@gitlab ~]# tar xf gitlab-12-0-stable-zh.tar.gz\n&#91;root@gitlab ~]# cat gitlab-12-0-stable-zh\/VERSION #\u67e5\u770b\u6c49\u5316\u7248\u672c\u662f\u5426\u4e0egitlab\u7248\u672c\u4e00\u81f4 12.0.3\n&#91;root@gitlab ~]# rpm -qa |grep gitlab\n<\/code><\/pre>\n\n\n\n<p>###\u505c\u6b62gitlab\uff0c\u8fdb\u884c\u4e2d\u6587\u6c49\u5316<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@gitlab ~]# gitlab-ctl stop\n#\u4e2d\u6587\u7248\u8986\u76d6\u82f1\u6587\u7248\n&#91;root@gitlab ~]# \\cp -r gitlab-12-0-stable-zh\/* \/opt\/gitlab\/embedded\/service\/gitlab-rails\/<\/code><\/pre>\n\n\n\n<p>###\u91cd\u542fgitlab\uff0c\u9a8c\u8bc1\u6c49\u5316\u7ed3\u679c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u91cd\u542f\u914d\u7f6egitlab\u670d\u52a1\n&#91;root@gitlab ~]# gitlab-ctl reconfigure\n#\u91cd\u542fgitlab\u670d\u52a1\n&#91;root@gitlab ~]# gitlab-ctl restart\n<\/code><\/pre>\n\n\n\n<p>##\u518d\u6b21\u767b\u5f55\u63d0\u793a502\uff0c\u7a0d\u7b49\u4e00\u4f1a\u518d\u5237\u65b0\u5373\u53ef<\/p>\n\n\n\n<p>\u767b\u5f55\u4e4b\u540e\u53d1\u73b0\u4ec5\u4ec5\u662f\u90e8\u5206\u6c49\u5316\u6210\u529f\uff0c\u9700\u8981\u5728web\u9875\u9762\u518d\u6b21\u914d\u7f6e<\/p>\n\n\n\n<p>\u70b9\u51fb\u53f3\u4e0a\u89d2\u5934\u50cf\uff0c\u70b9\u51fbsettings<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"195\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-22.png\" alt=\"\" class=\"wp-image-768\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-22.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-22-300x68.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-22-768x173.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p>\u70b9\u51fbPreferences\uff08\u504f\u597d\uff09\u5c06\u8bed\u8a00\u66ff\u6362\u4e3a\u7b80\u4f53\u4e2d\u6587\uff0c\u4fdd\u5b58\u8bbe\u7f6e\u540e\u5237\u65b0\u9875\u9762\uff0c\u6c49\u5316\u6210\u529f<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"417\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-23.png\" alt=\"\" class=\"wp-image-769\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-23.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-23-300x145.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-23-768x370.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">2.<strong>Gitlab\u7528\u6237\u4e0e\u7ec4<\/strong><\/h2>\n\n\n\n<p><strong><em>\u6848\u4f8b1:\u9a8c\u8bc1\u9879\u76ee\u662f\u4e0d\u662f\u96b6\u5c5e\u4e8e\u8be5\u7ec4\u7684\u6210\u5458\u624d\u53ef\u4ee5\u770b\u89c1<\/em><\/strong><\/p>\n\n\n\n<p>1.\u9996\u5148\u521b\u5efadev\u3001ops\u4e24\u4e2a\u7ec4 2.\u7136\u540e\u57fa\u4e8e\u7ec4\u521b\u5efa\u4e24\u4e2a\u9879\u76ee\u9879\u76ee 3.\u6700\u540e\u521b\u5efa\u7528\u6237\u3001\u4e3a\u7528\u6237\u5206\u914d\u7ec4\u3001\u4ee5\u53ca\u7ec4\u4e2d\u7684\u6743\u9650<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"422\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-24.png\" alt=\"\" class=\"wp-image-772\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-24.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-24-300x146.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-24-768x375.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"477\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-25.png\" alt=\"\" class=\"wp-image-773\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-25.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-25-300x165.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-25-768x424.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p>\u5206\u522b\u4e3a\u7ec4\u521b\u5efa\u4e0d\u540c\u7684\u9879\u76ee<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"449\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-26.png\" alt=\"\" class=\"wp-image-774\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-26.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-26-300x156.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-26-768x399.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p>##\u521b\u5efa\u7528\u6237\uff0c\u5e76\u5c06\u5176\u52a0\u5165\u5bf9\u5e94\u7684\u7ec4\uff0c\u767b\u5f55\u7528\u6237\uff0c\u7528\u6237\u53ea\u80fd\u770b\u5230\u7ec4\u5185\u7684\u9879\u76ee<\/p>\n\n\n\n<p><strong><em>\u6848\u4f8b2\u2236\u9a8c\u8bc1\u4e3b\u7a0b\u5e8f\u5458\u548c\u5f00\u53d1\u8005\u8eab\u4efd\u7684\u6743\u9650<\/em><\/strong><\/p>\n\n\n\n<p>1. \u4e3b\u7a0b\u5e8f\u5458\ufe30\u80fd\u591f\u5bf9master\u3001 dev\u5206\u652f\u8fdb\u884c\u64cd\u4f5c\ufe54[\u901a\u8fc7\u547d\u4ee4\u6d4b\u8bd5]\u3002<\/p>\n\n\n\n<p>2. \u6d4b\u8bd5\u666e\u901a\u5f00\u53d1\u8005\ufe30\u4ec5\u80fd\u5bf9\u975emaster \u5206\u652f\u8fdb\u884c\u64cd\u4f5c &nbsp; [\u901a\u8fc7\u547d\u4ee4\u6f14\u793a\u6548\u679c]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">3.<strong>gitlab\u7684\u5907\u4efd\u4e0e\u6062\u590d<\/strong><\/h2>\n\n\n\n<p><strong><em>1.gitlab\u5907\u4efd<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\ngitlab_rails&#91;'manage_backup_path'] = true #\u662f\u5426\u53ef\u4ee5\u6307\u5b9a\u5907\u4efd\u76ee\u5f55\ngitlab_rails&#91;'backup_path'] = \"\/var\/opt\/gitlab\/backups\" #\u5907\u4efd\u76ee\u5f55\ngitlab_rails&#91;'backup_archive_permissions'] = 0644 #\u5907\u4efd\u7684\u538b\u7f29\u5305\u6743\u9650 \ngitlab_rails&#91;'backup_keep_time'] = 604800 #\u5907\u4efd\u4fdd\u7559\u591a\u4e45 7\u5929<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u624b\u52a8\u6267\u884c\u5907\u4efd<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@git ~]# gitlab-rake gitlab:backup:create\n##\u5bf9\u4e8egitlab.rb \u548cgitlab-secrets.json\u5305\u542b\u654f\u611f\u4fe1\u606f,\u9700\u8981\u624b\u52a8\u5907\u4efd.\n&#91;root@git ~]# ll \/var\/opt\/gitlab\/backups\ntotal 200\n-rw------- 1 git git 204800 Aug  2 19:32 1627903944_2021_08_02_12.0.3_gitlab_backup.tar\n<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u81ea\u52a8\u5907\u4efd<\/em><\/strong><\/p>\n\n\n\n<p>\u81ea\u52a8\u5907\u4efd\u5c31\u662f\u5199\u4e2a\u5b9a\u65f6\u4efb\u52a1<\/p>\n\n\n\n<p><strong><em>4.\u5907\u4efd\u6062\u590d<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1.\u505c\u6b62\u6570\u636e\u5199\u5165\u670d\u52a1\ngitlab-ctl stop unicorn\ngitlab-ctl stop sidekiq\n2.\u901a\u8fc7\u547d\u4ee4\u8fdb\u884c\u6062\u590d\uff0c\u6062\u590d\u65f6\u9700\u8981\u6307\u5b9a\u6b64\u524d\u5907\u4efd\u7684\u540d\u79f0\u3002\uff08\u4f46\u4e0d\u9700\u8981\u5199\u540d\u79f0\u7684\u540e\u7f00.tar\uff09\ngitlab-rake gitlab:backup:restore BACKUP=1627903944_2021_08_02_12.0.3\n3.\u91cd\u542fgitlab\u67e5\u770b\u662f\u5426\u6062\u590d\u6210\u529f\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">4.<strong>\u8fc1\u79fb\u4e0e\u5347\u7ea7<\/strong><\/h2>\n\n\n\n<p>###\u5347\u7ea7\u524d\u5efa\u8bae\u505a\u597d\u5907\u4efd\uff0c\u907f\u514d\u51fa\u73b0\u95ee\u9898<br>\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u5347\u7ea7\u6b65\u9aa4\u4ee5\u786e\u4fdd\u4e3b\u7248\u672c\u5347\u7ea7\u6210\u529f\uff1a<br>1.\u5347\u7ea7\u81f3\u4e4b\u524d\u4e3b\u8981\u7248\u672c\u7684\u6700\u65b0\u6b21\u8981\u7248\u672c\u3002<br>2.\u5347\u7ea7\u5230\u76ee\u6807\u4e3b\u8981\u7248\u672c\u7684\u7b2c\u4e00\u4e2a\u6b21\u8981\u7248\u672c\uff08X.0.Z\uff09\u3002<br>3.\u7ee7\u7eed\u5347\u7ea7\u5230\u8f83\u65b0\u7684\u7248\u672c\u3002<br>##\u5347\u7ea7\u76f4\u63a5\u4e0b\u8f7drpm\u5305\u5347\u7ea7\u5373\u53ef<br>##\u8fc1\u79fb\u76f4\u63a5\u5728\u65b0\u673a\u5668\u4e0a\u5b89\u88c5\u5b8c\u670d\u52a1\uff0c\u7136\u540e\u5c06\u65e7\u673a\u5668\u5907\u4efd\u7684\u6587\u4ef6\u5bfc\u8fdb\u53bb\u5c31\u884c<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">5.<strong>gitlab\u7684https\u914d\u7f6e<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u4fee\u6539\u5982\u4e0b\u914d\u7f6e\nexternal_url 'https:\/\/gitlab.sfy.com'\nnginx&#91;'enable'] = true\nnginx&#91;'redirect_http_to_https'] = true\nnginx&#91;'redirect_http_to_https_port'] = 80\nnginx&#91;'ssl_certificate'] = \"\/opt\/5681989_www.buyao007.icu.pem\"\nnginx&#91;'ssl_certificate_key'] = \"\/opt\/5681989_www.buyao007.icu.key\"\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":246,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/767"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=767"}],"version-history":[{"count":4,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/767\/revisions"}],"predecessor-version":[{"id":778,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/767\/revisions\/778"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/media\/246"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}