{"id":294774,"date":"2019-11-18T09:00:39","date_gmt":"2019-11-18T09:00:39","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=294774"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=294774","title":{"rendered":"\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0431\u0430\u0437\u044b GitLab \u043d\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 PostgreSQL"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\">\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0431\u0430\u0437\u044b GitLab \u0441 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e PostgreSQL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 GitLab, \u043d\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 PostgreSQL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xc\/2l\/gc\/xc2lgcwnx8zb3ksut8bridiklou.png\"><a name=\"habracut\"><\/a>  <\/p>\n<blockquote><p><b>\u041f\u0420\u0418\u041c\u0415\u0427\u0410\u041d\u0418\u0415<\/b><br \/>  \u0412\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 CentOS 7.7.1908, PostgreSQL 12 \u0438 GitLab 12.4.2-ee.0.  <\/p><\/blockquote>\n<h2>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>  <b>\u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0442\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/b><\/p>\n<p>  1. \u041d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 PostgreSQL \u0432 \u0444\u0430\u0439\u0435\u0440\u0432\u043e\u043b \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u0440\u0442 PostgreSQL 5432\/TCP.<\/p>\n<p>  <b>\u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<\/b><\/p>\n<pre><code class=\"bash\">firewall-cmd --add-service=postgresql --zone=internal --permanent success firewall-cmd --reload success<\/code><\/pre>\n<p>  2. \u0422\u0430\u043c \u0436\u0435, \u043d\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 postgresql.conf \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438\u0437\u0432\u043d\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b postgresql.conf, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 &#171;<i>#listen_addresses = &#8216;localhost&#8217;<\/i>&#187; \u0438 \u043f\u043e\u0434 \u043d\u0435\u0439 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u0430\u043a \u043d\u0438\u0436\u0435. \u0413\u0434\u0435 \u2014 10.0.0.2, \u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<p>  <b>\u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<\/b><\/p>\n<pre><code class=\"bash\">vi \/var\/lib\/pgsql\/12\/data\/postgresql.conf # - Connection Settings -  #listen_addresses = 'localhost'         # what IP address(es) to listen on; listen_addresses = 'localhost, 10.0.0.2'                                         # comma-separated list of addresses;<\/code><\/pre>\n<p>  3. \u0422\u0430\u043a \u043a\u0430\u043a \u0441\u0435\u0440\u0432\u0435\u0440 GitLab \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0431\u0430\u0437\u0435, \u0442\u043e \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 PostgreSQL \u043d\u0430\u0434\u043e \u044d\u0442\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 pg_hba.conf. \u0410\u0434\u0440\u0435\u0441 \u043c\u043e\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 GitLab 10.0.0.4.<\/p>\n<p>  <b>\u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0444\u0430\u0439\u043b pg_hba.conf \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0443\u0434\u0430 \u0441\u0442\u0440\u043e\u043a\u0443:<\/b><\/p>\n<pre><code class=\"bash\">host    all             gitlab               10.0.0.4\/24             md5<\/code><\/pre>\n<p>  <b>\u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a:<\/b><\/p>\n<pre><code class=\"bash\"># TYPE  DATABASE        USER            ADDRESS                 METHOD  # \"local\" is for Unix domain socket connections only local   all             postgres                                     md5  # IPv4 local connections: host    all             postgres             127.0.0.1\/32            md5 host    all             gitlab               10.0.0.4\/24             md5<\/code><\/pre>\n<p>  <b>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 postgresql:<\/b><\/p>\n<pre><code class=\"bash\">systemctl restart postgresql-12.service<\/code><\/pre>\n<p>  <\/p>\n<h2>\u042d\u043a\u0441\u043f\u043e\u0440\u0442 \u0431\u0430\u0437\u044b GitLab<\/h2>\n<p>  <b>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c, \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 GitLab, \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0437\u044b:<\/b>  <\/p>\n<pre><code class=\"bash\">sudo -u gitlab-psql \/opt\/gitlab\/embedded\/bin\/pg_dumpall -U gitlab-psql --host=\/var\/opt\/gitlab\/postgresql &gt; \/tmp\/internal-gitlab.sql<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0435\u0440\u0432\u043d\u0430\u044f \u043a\u043e\u043f\u0438\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 \/tmp:<\/b><\/p>\n<pre><code class=\"bash\">ls -lh total 836K -rw-r--r--. 1 root root 836K Nov 18 12:59 internal-gitlab.sql<\/code><\/pre>\n<p>  <b>\u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0443 \u043a\u043e\u043f\u0438\u044e \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 PostgreSQL:<\/b><\/p>\n<pre><code class=\"bash\">scp \/tmp\/internal-gitlab.sql 10.0.0.2:\/tmp\/ internal-gitlab.sql                                                                               100%  835KB  50.0MB\/s   00:00<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0418\u043c\u043f\u043e\u0440\u0442 \u00abinternal-gitlab.sql\u00bb \u0432 PostgreSQL<\/h2>\n<p>  <b>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0430\u0437\u0443 \u0432 PostgreSQL:<\/b><\/p>\n<pre><code class=\"bash\">sudo -u postgres psql -f \/tmp\/internal-gitlab.sql<\/code><\/pre>\n<p>  <b>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0430\u0437\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 PostgreSQL:<\/b><\/p>\n<pre><code class=\"bash\">sudo -u postgres psql -l<\/code><\/pre>\n<p>  <b>\u0414\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430:<\/b><\/p>\n<pre><code class=\"bash\">gitlabhq_production | gitlab   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 GitLab<\/h2>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0432 PostgreSQL \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c gitlab. \u0412\u0430\u043c \u043d\u0430\u0434\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  <b>\u041c\u0435\u043d\u044f\u0435\u043c \u043f\u0430\u0440\u043e\u043b\u044c: <\/b><\/p>\n<pre><code class=\"bash\">sudo -u postgres psql -c \"ALTER USER gitlab ENCRYPTED PASSWORD '\u041f\u0410\u0420\u041e\u041b\u042c' VALID UNTIL 'infinity';\" Password for user postgres: ALTER ROLE<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 GitLab \u0432 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \/etc\/gitlab\/gitlab.rb \u0443\u043a\u0430\u0436\u0435\u043c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e PostgreSQL.<\/p>\n<p>  <b>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e \u0444\u0430\u0439\u043b\u0430 gitlab.rb:<\/b><\/p>\n<pre><code class=\"bash\">cp \/etc\/gitlab\/gitlab.rb \/etc\/gitlab\/gitlab.rb.orig<\/code><\/pre>\n<p>  <b>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430 gitlab.rb \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438:<\/b><\/p>\n<pre><code class=\"bash\"># \u041e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 PostgreSQL. postgresql['enable'] = false  # \u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0431\u0430\u0437\u0435. \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0438. gitlab_rails['db_adapter'] = 'postgresql' gitlab_rails['db_encoding'] = 'utf8' gitlab_rails['db_host'] = '10.0.0.2' gitlab_rails['db_port'] = 5432 gitlab_rails['db_database'] = \"gitlabhq_production\" gitlab_rails['db_username'] = 'gitlab' gitlab_rails['db_password'] = '******'<\/code><\/pre>\n<p>  <b>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0444\u0430\u0439\u043b \/etc\/gitlab\/gitlab.rb \u0438 \u043f\u0435\u0440\u0435\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c GitLab:<\/b><\/p>\n<pre><code class=\"bash\">gitlab-ctl reconfigure &amp;&amp; gitlab-ctl restart<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451 \ud83d\ude42<\/p>\n<blockquote><p>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0441\u044c\u0431\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043c\u0438\u043d\u0443\u0441, \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p><\/blockquote>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/476258\/\"> https:\/\/habr.com\/ru\/post\/476258\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\">\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0431\u0430\u0437\u044b GitLab \u0441 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e PostgreSQL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 GitLab, \u043d\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 PostgreSQL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xc\/2l\/gc\/xc2lgcwnx8zb3ksut8bridiklou.png\"><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-294774","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294774"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294774\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}