{"id":20151,"date":"2024-11-19T17:56:39","date_gmt":"2024-11-19T09:56:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/20151\/"},"modified":"2024-11-19T17:56:39","modified_gmt":"2024-11-19T09:56:39","slug":"gitlab%e6%80%8e%e6%a0%b7%e6%90%9e%e5%88%b0%e8%87%aa%e5%b7%b1%e7%9a%84%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/20151\/","title":{"rendered":"gitlab\u600e\u6837\u641e\u5230\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a"},"content":{"rendered":"<p>\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u642d\u5efagitlab<\/p>\n<p>GitLab\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u4ee3\u7801\u6258\u7ba1\u7ba1\u7406\u5e73\u53f0\uff0c\u5b83\u63d0\u4f9b\u4ee3\u7801\u6258\u7ba1\u3001\u7248\u672c\u63a7\u5236\u3001\u4efb\u52a1\u7ba1\u7406\u3001\u534f\u4f5c\u548cCI\/CD\u7b49\u529f\u80fd\u3002\u5728\u5f00\u53d1\u56e2\u961f\u4e2d\u5e7f\u6cdb\u5e94\u7528\u3002\u867d\u7136GitLab\u5df2\u7ecf\u5728\u4e92\u8054\u7f51\u4e0a\u63d0\u4f9b\u4e86\u6258\u7ba1\u670d\u52a1\uff0c\u4f46\u662f\u5728\u4e00\u4e9b\u7279\u6b8a\u60c5\u51b5\u4e0b\uff08\u5982\u5bf9\u4ee3\u7801\u5b89\u5168\u6027\u6709\u7279\u6b8a\u8981\u6c42\uff09\uff0c\u6211\u4eec\u8fd8\u662f\u9700\u8981\u5728\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\u642d\u5efaGitLab\u3002\u4e0b\u9762\u662fGitLab\u5728\u670d\u52a1\u5668\u4e0a\u7684\u5177\u4f53\u5b9e\u73b0\u8fc7\u7a0b\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u9009\u62e9\u9002\u5408\u7684\u670d\u52a1\u5668<\/p>\n<p>\u5728\u642d\u5efaGitLab\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u9009\u62e9\u9002\u5408\u7684\u670d\u52a1\u5668\u3002\u867d\u7136GitLab\u6ca1\u6709\u7279\u522b\u9ad8\u7684\u786c\u4ef6\u8981\u6c42\uff0c\u4f46\u662f\u8003\u8651\u5230\u56e2\u961f\u89c4\u6a21\u548c\u5c06\u6765\u7684\u6269\u5c55\u6027\uff0c\u901a\u5e38\u9700\u8981\u9009\u62e9\u6bd4\u8f83\u9ad8\u914d\u7f6e\u7684\u670d\u52a1\u5668\uff0c\u5982CPU\u4e3a\u56db\u6838\u4ee5\u4e0a\uff0c\u5185\u5b58\u4e3a16G\u4ee5\u4e0a\u7684\u670d\u52a1\u5668\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u670d\u52a1\u5668\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e5f\u9700\u8981\u8003\u8651\u3002GitLab\u652f\u6301\u7684\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u6709Ubuntu\u3001Debian\u3001CentOS\u3001Fedora\u3001RHEL\u548cSUSE\u7b49\uff0c\u63a8\u8350\u9009\u62e9\u8f83\u65b0\u7248\u672c\u548c\u7a33\u5b9a\u6027\u8f83\u597d\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56<\/p>\n<p>\u5728\u8fdb\u884cGitLab\u7684\u5b89\u88c5\u524d\uff0c\u8fd8\u9700\u8981\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5728Ubuntu\u4e0b\u5b89\u88c5\u76f8\u5173\u4f9d\u8d56\uff1a<\/p>\n<pre>sudo apt-get update \nsudo apt-get install -y curl openssh-server ca-certificates tzdata perl<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5982\u679c\u662f\u5728CentOS\/RHEL\u4e0b\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u76f8\u5173\u4f9d\u8d56\uff1a<\/p>\n<pre>sudo yum install curl openssh-server postfix cronie\nsudo systemctl enable postfix\nsudo systemctl start postfix\nsudo firewall-cmd --permanent --add-service=http\nsudo systemctl reload firewalld<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4ee5\u4e0a\u547d\u4ee4\u53ea\u662f\u5b89\u88c5\u4e86GitLab\u9700\u8981\u7684\u4e00\u4e9b\u57fa\u672c\u4f9d\u8d56\uff0c\u5728\u540e\u7eed\u5b89\u88c5\u4e2d\uff0c\u53ef\u80fd\u8fd8\u9700\u8981\u5b89\u88c5\u5176\u4ed6\u4f9d\u8d56\u3002<\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab<\/p>\n<p>\u5b8c\u6210\u4e0a\u8ff0\u4f9d\u8d56\u7684\u5b89\u88c5\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab\u3002\u9996\u5148\uff0c\u5728\u670d\u52a1\u5668\u4e0a\u4e0b\u8f7dGitLab\u7684\u5b89\u88c5\u5305\uff1a<\/p>\n<pre>curl -LO https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ce\/script.deb.sh<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6ce8\u610f\uff0cGitLab\u5b89\u88c5\u5305\u7684\u4e0b\u8f7d\u5730\u5740\u53ef\u80fd\u4f1a\u53d8\u5316\uff0c\u8bf7\u4ee5\u5b98\u65b9\u7f51\u7ad9\u4e3a\u51c6\u3002<\/p>\n<p>\u7136\u540e\uff0c\u5b89\u88c5GitLab\uff1a<\/p>\n<pre>sudo bash script.deb.sh\nsudo apt-get install gitlab-ce<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u8f93\u5165root\u5bc6\u7801\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u8bbf\u95ee\u670d\u52a1\u5668IP\u5730\u5740\u6216\u57df\u540d\u6765\u8bbf\u95eeGitLab\u9875\u9762\u3002<\/p>\n<p>\u7b2c\u56db\u6b65\uff1a\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u4e3a\u4e86\u4f7fGitLab\u6b63\u5e38\u5de5\u4f5c\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u4e00\u4e9b\u914d\u7f6e\u3002\u5728Ubuntu\u4e0b\uff0c\u914d\u7f6e\u6587\u4ef6\u4f4d\u4e8e\/etc\/gitlab\/gitlab.rb\uff0c\u53ef\u4ee5\u4f7f\u7528vi\u6216nano\u7f16\u8f91\u5668\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6bcf\u6b21\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u540e\uff0c\u90fd\u8981\u91cd\u65b0\u542f\u52a8GitLab\u624d\u80fd\u5e94\u7528\u914d\u7f6e\uff1a<\/p>\n<pre>sudo gitlab-ctl reconfigure\nsudo gitlab-ctl restart<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<ol>\n<li>\u914d\u7f6e\u8bbf\u95eeGitLab\u7684\u57df\u540d\u6216IP<\/li>\n<\/ol>\n<p>\u5c06\u201cexternal_url &#8216;http:\/\/gitlab.example.com&#8217;\u201d\u4e2d\u7684\u201chttp:\/\/gitlab.example.com\u201d\u6539\u4e3a\u670d\u52a1\u5668\u7684IP\u5730\u5740\u6216\u57df\u540d\u3002<\/p>\n<pre>external_url 'http:\/\/192.168.1.100'<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u66f4\u6539\u6570\u636e\u5e93\u7c7b\u578b<\/li>\n<\/ol>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cGitLab\u4f7f\u7528SQLite\u4f5c\u4e3a\u6570\u636e\u5e93\u3002\u4f46\u662f\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528MySQL\u6216PostgreSQL\u4f5c\u4e3a\u6570\u636e\u5e93\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u4fee\u6539\u6570\u636e\u5e93\u7c7b\u578b:<\/p>\n<pre># MySQL \ngitlab_rails['db_adapter'] = 'mysql2' \ngitlab_rails['db_encoding'] = 'utf8mb4' \ngitlab_rails['db_host'] = 'localhost' \ngitlab_rails['db_port'] = '3306' \ngitlab_rails['db_database'] = 'gitlabhq_production' \ngitlab_rails['db_username'] = 'root' \ngitlab_rails['db_password'] = 'your_mysql_password'\n\n# PostgreSQL \ngitlab_rails['db_adapter'] = 'postgresql' \ngitlab_rails['db_encoding'] = 'unicode' \ngitlab_rails['db_host'] = 'localhost' \ngitlab_rails['db_port'] = '5432' \ngitlab_rails['db_database'] = 'gitlabhq_production' \ngitlab_rails['db_username'] = 'gitlab' \ngitlab_rails['db_password'] = 'your_postgresql_password'<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u66f4\u6539SMTP\u4fe1\u606f<\/li>\n<\/ol>\n<p>\u4e3a\u4e86\u80fd\u591f\u6536\u5230GitLab\u7684\u90ae\u4ef6\u901a\u77e5\uff0c\u6211\u4eec\u9700\u8981\u5bf9SMTP\u4fe1\u606f\u8fdb\u884c\u914d\u7f6e\u3002\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u8bbe\u7f6eSMTP\u670d\u52a1\u5668\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u7b49\u4fe1\u606f\uff1a<\/p>\n<pre>gitlab_rails['smtp_enable'] = true \ngitlab_rails['smtp_address'] = \"smtp.example.com\" \ngitlab_rails['smtp_port'] = 465 \ngitlab_rails['smtp_user_name'] = 'user@example.com' \ngitlab_rails['smtp_password'] = 'your_smtp_password' \ngitlab_rails['smtp_domain'] = 'example.com' \ngitlab_rails['smtp_tls'] = true \ngitlab_rails['gitlab_email_from'] = 'gitlab@example.com'<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7b2c\u4e94\u6b65\uff1a\u542f\u52a8GitLab<\/p>\n<p>\u5b8c\u6210\u914d\u7f6e\u6587\u4ef6\u7684\u4fee\u6539\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u542f\u52a8GitLab\uff1a<\/p>\n<pre>sudo gitlab-ctl start<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>GitLab\u4f1a\u5728\u542f\u52a8\u540e\u8fdb\u884c\u81ea\u68c0\uff0c\u4fdd\u8bc1\u4e00\u5207\u6b63\u5e38\u5de5\u4f5c\u3002\u5982\u679c\u51fa\u73b0\u4efb\u4f55\u95ee\u9898\uff0c\u53ef\u4ee5\u901a\u8fc7\u65e5\u5fd7\u6765\u67e5\u627e\u95ee\u9898\uff1a<\/p>\n<pre>sudo gitlab-ctl tail<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u670d\u52a1\u5668\u4e0a\u642d\u5efaGitLab\uff0c\u5e76\u8fdb\u884c\u76f8\u5e94\u7684\u914d\u7f6e\u3002\u540c\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7GitLab\u6765\u8fdb\u884c\u56e2\u961f\u534f\u4f5c\u548c\u4ee3\u7801\u7ba1\u7406\uff0c\u63d0\u5347\u56e2\u961f\u7684\u6548\u7387\u548c\u4ee3\u7801\u7684\u8d28\u91cf\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fgitlab\u600e\u6837\u641e\u5230\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u642d\u5efagitlab GitLab\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u4ee3\u7801\u6258\u7ba1\u7ba1\u7406\u5e73\u53f0\uff0c\u5b83\u63d0\u4f9b\u4ee3\u7801\u6258\u7ba1\u3001\u7248\u672c\u63a7\u5236\u3001\u4efb\u52a1\u7ba1\u7406\u3001\u534f\u4f5c\u548cCI\/CD\u7b49\u529f\u80fd\u3002\u5728\u5f00\u53d1\u56e2\u961f\u4e2d\u5e7f\u6cdb\u5e94\u7528\u3002\u867d\u7136GitLab\u5df2\u7ecf\u5728\u4e92\u8054\u7f51\u4e0a\u63d0\u4f9b\u4e86\u6258\u7ba1\u670d\u52a1\uff0c\u4f46\u662f\u5728\u4e00\u4e9b\u7279\u6b8a\u60c5\u51b5\u4e0b\uff08\u5982\u5bf9\u4ee3\u7801\u5b89\u5168\u6027\u6709\u7279\u6b8a\u8981\u6c42\uff09\uff0c\u6211\u4eec\u8fd8\u662f\u9700\u8981\u5728\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\u642d\u5efaGitLab\u3002\u4e0b\u9762\u662fGitLab\u5728\u670d\u52a1\u5668\u4e0a\u7684\u5177\u4f53\u5b9e\u73b0\u8fc7\u7a0b\u3002 \u7b2c\u4e00\u6b65\uff1a\u9009\u62e9\u9002\u5408\u7684\u670d\u52a1\u5668 \u5728\u642d\u5efaGitLab\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u9009\u62e9\u9002\u5408\u7684\u670d\u52a1\u5668\u3002\u867d\u7136GitLab\u6ca1\u6709\u7279\u522b\u9ad8\u7684\u786c\u4ef6\u8981\u6c42\uff0c\u4f46\u662f\u8003\u8651\u5230\u56e2\u961f\u89c4\u6a21\u548c\u5c06\u6765\u7684\u6269\u5c55\u6027\uff0c\u901a\u5e38\u9700\u8981\u9009\u62e9\u6bd4\u8f83\u9ad8\u914d\u7f6e\u7684\u670d\u52a1\u5668\uff0c\u5982CPU\u4e3a\u56db\u6838\u4ee5\u4e0a\uff0c\u5185\u5b58\u4e3a16G\u4ee5\u4e0a\u7684\u670d\u52a1\u5668\u3002 \u5f53\u7136\uff0c\u670d\u52a1\u5668\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e5f\u9700\u8981\u8003\u8651\u3002GitLab\u652f\u6301\u7684\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u6709Ubuntu\u3001Debian\u3001CentOS\u3001Fedora\u3001RHEL\u548cSUSE\u7b49\uff0c\u63a8\u8350\u9009\u62e9\u8f83\u65b0\u7248\u672c\u548c\u7a33\u5b9a\u6027\u8f83\u597d\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002 \u7b2c\u4e8c\u6b65\uff1a\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56 \u5728\u8fdb\u884cGitLab\u7684\u5b89\u88c5\u524d\uff0c\u8fd8\u9700\u8981\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5728Ubuntu\u4e0b\u5b89\u88c5\u76f8\u5173\u4f9d\u8d56\uff1a sudo apt-get update sudo apt-get install -y curl openssh-server ca-certificates tzdata perl \u767b\u5f55\u540e\u590d\u5236 \u5982\u679c\u662f\u5728CentOS\/RHEL\u4e0b\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u76f8\u5173\u4f9d\u8d56\uff1a sudo yum install curl openssh-server postfix cronie sudo systemctl enable postfix sudo systemctl start postfix sudo firewall-cmd &#8211;permanent &#8211;add-service=http sudo systemctl reload firewalld \u767b\u5f55\u540e\u590d\u5236 \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4ee5\u4e0a\u547d\u4ee4\u53ea\u662f\u5b89\u88c5\u4e86GitLab\u9700\u8981\u7684\u4e00\u4e9b\u57fa\u672c\u4f9d\u8d56\uff0c\u5728\u540e\u7eed\u5b89\u88c5\u4e2d\uff0c\u53ef\u80fd\u8fd8\u9700\u8981\u5b89\u88c5\u5176\u4ed6\u4f9d\u8d56\u3002 \u7b2c\u4e09\u6b65\uff1a\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab \u5b8c\u6210\u4e0a\u8ff0\u4f9d\u8d56\u7684\u5b89\u88c5\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u4e0b\u8f7d\u5e76\u5b89\u88c5GitLab\u3002\u9996\u5148\uff0c\u5728\u670d\u52a1\u5668\u4e0a\u4e0b\u8f7dGitLab\u7684\u5b89\u88c5\u5305\uff1a curl -LO https:\/\/packages.gitlab.com\/install\/repositories\/gitlab\/gitlab-ce\/script.deb.sh \u767b\u5f55\u540e\u590d\u5236 \u6ce8\u610f\uff0cGitLab\u5b89\u88c5\u5305\u7684\u4e0b\u8f7d\u5730\u5740\u53ef\u80fd\u4f1a\u53d8\u5316\uff0c\u8bf7\u4ee5\u5b98\u65b9\u7f51\u7ad9\u4e3a\u51c6\u3002 \u7136\u540e\uff0c\u5b89\u88c5GitLab\uff1a sudo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-20151","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=20151"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20151\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=20151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=20151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=20151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}