GitLab: 官方镜像中的PostgreSQL
从12.1版本开始,GitLab正式放弃了对MySQL的支持,转而专心一致地使用PostgreSQL。GitLab的官方镜像提供了一个ALL-in-One的包,这其中就包含PostgreSQL,这篇文章以GitLab 12.10.5的CE版本的官方镜像为例,确认一下镜像之中的PostgreSQL。
目录
- 环境准备
- 数据库配置文件
- psql版本
- 用户名映射
- 连接数据库确认版本
- 查看数据库实例
- 查看schema
- 查看用户和角色
- 查看表空间
- 查看权限
- 查看扩展信息
- 查看用户详细信息
- 查询表信息
- 查看单个表详细
- 查看索引
- 查看视图
- 总结
环境准备
- docker-compose.yml
liumiaocn:gitlab liumiao$ cat docker-compose.yml
version: '2'
services:# Version Control service: Gitlabgitlab:image: gitlab/gitlab-ce:12.10.5-ce.0ports:- "32001:80"- "30022:22"- "443:443"volumes:- ./log/:/var/log/gitlab- ./data/:/var/opt/gitlab- ./conf/:/etc/gitlabrestart: "no"
liumiaocn:gitlab liumiao$
- 启动服务
liumiaocn:gitlab liumiao$ docker-compose up -d
Creating network "gitlab_default" with the default driver
Creating gitlab_gitlab_1 ... done
liumiaocn:gitlab liumiao$
- 结果确认
liumiaocn:gitlab liumiao$ docker-compose psName Command State Ports
---------------------------------------------------------------------------------------------------------------------
gitlab_gitlab_1 /assets/wrapper Up (healthy) 0.0.0.0:30022->22/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:32001->80/tcp
liumiaocn:gitlab liumiao$
数据库配置文件
配置文件:/var/opt/gitlab/gitlab-rails/etc/database.yml
liumiaocn:gitlab liumiao$ docker exec -it gitlab_gitlab_1 sh
# cat /var/opt/gitlab/gitlab-rails/etc/database.yml
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.production:adapter: postgresqlencoding: unicodecollation: database: gitlabhq_productionpool: 1username: "gitlab"password: host: "/var/opt/gitlab/postgresql"port: 5432socket: sslmode: sslcompression: 0sslrootcert: sslca: load_balancing: {"hosts":[]}prepared_statements: falsestatement_limit: 1000fdw: variables:statement_timeout: 60000
#
从上述配置中可以看到如下信息:
- 数据库名:gitlabhq_production
- 用户名:gitlab
psql版本
- 可以看到内置的psql版本为11.7
# which psql
/opt/gitlab/embedded/bin/psql
# psql --version
psql (PostgreSQL) 11.7
#
用户名映射
- GitLab用户为gitlab-psql
# cat /etc/passwd |grep gitlab
git:x:998:998::/var/opt/gitlab:/bin/sh
gitlab-www:x:999:999::/var/opt/gitlab/nginx:/bin/false
gitlab-redis:x:997:997::/var/opt/gitlab/redis:/bin/false
gitlab-psql:x:996:996::/var/opt/gitlab/postgresql:/bin/sh
mattermost:x:994:994::/var/opt/gitlab/mattermost:/bin/sh
registry:x:993:993::/var/opt/gitlab/registry:/bin/sh
gitlab-prometheus:x:992:992::/var/opt/gitlab/prometheus:/bin/sh
gitlab-consul:x:991:991::/var/opt/gitlab/consul:/bin/sh
#
# id gitlab-psql
uid=996(gitlab-psql) gid=996(gitlab-psql) groups=996(gitlab-psql)
#
连接数据库确认版本
- 切换至gitlab-psql用户,确认PostgreSQL服务器端版本也是11.7
# su - gitlab-psql
$ id
uid=996(gitlab-psql) gid=996(gitlab-psql) groups=996(gitlab-psql)
$ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production
psql (11.7)
Type "help" for help.gitlabhq_production=# select version();version
-----------------------------------------------------------------------------------------------------------------PostgreSQL 11.7 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609, 64-bit
(1 row)gitlabhq_production=#
查看数据库实例
gitlabhq_production=# \lList of databasesName | Owner | Encoding | Collate | Ctype | Access privileges
---------------------+-------------+----------+---------+---------+---------------------------------gitlabhq_production | gitlab | UTF8 | C.UTF-8 | C.UTF-8 | postgres | gitlab-psql | UTF8 | C.UTF-8 | C.UTF-8 | template0 | gitlab-psql | UTF8 | C.UTF-8 | C.UTF-8 | =c/"gitlab-psql" +| | | | | "gitlab-psql"=CTc/"gitlab-psql"template1 | gitlab-psql | UTF8 | C.UTF-8 | C.UTF-8 | =c/"gitlab-psql" +| | | | | "gitlab-psql"=CTc/"gitlab-psql"
(4 rows)gitlabhq_production=#
查看schema
gitlabhq_production=# \dnList of schemasName | Owner
--------+-------------public | gitlab-psql
(1 row)gitlabhq_production=#
查看用户和角色
gitlabhq_production=# \duList of rolesRole name | Attributes | Member of
-------------------+------------------------------------------------------------+-----------gitlab | | {}gitlab-psql | Superuser, Create role, Create DB, Replication, Bypass RLS | {}gitlab_replicator | Replication | {}gitlabhq_production=#
查看表空间
gitlabhq_production=# \dbList of tablespacesName | Owner | Location
------------+-------------+----------pg_default | gitlab-psql | pg_global | gitlab-psql |
(2 rows)gitlabhq_production=#
查看权限
gitlabhq_production=# \dpAccess privilegesSchema | Name | Type | Access privileges | Column privileges | Policies
--------+--------------------------------------------------------+----------+-------------------+-------------------+----------public | abuse_reports | table | | | public | abuse_reports_id_seq | sequence | | | public | alerts_service_data | table | | | public | alerts_service_data_id_seq | sequence | | |
...省略public | web_hook_logs | table | | | public | web_hook_logs_id_seq | sequence | | | public | web_hooks | table | | | public | web_hooks_id_seq | sequence | | | public | wiki_page_meta | table | | | public | wiki_page_meta_id_seq | sequence | | | public | wiki_page_slugs | table | | | public | wiki_page_slugs_id_seq | sequence | | | public | x509_certificates | table | | | public | x509_certificates_id_seq | sequence | | | public | x509_commit_signatures | table | | | public | x509_commit_signatures_id_seq | sequence | | | public | x509_issuers | table | | | public | x509_issuers_id_seq | sequence | | | public | zoom_meetings | table | | | public | zoom_meetings_id_seq | sequence | | |
(643 rows)gitlabhq_production=#
查看扩展信息
gitlabhq_production=# \dxList of installed extensionsName | Version | Schema | Description
---------+---------+------------+-------------------------------------------------------------------pg_trgm | 1.4 | public | text similarity measurement and index searching based on trigramsplpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(2 rows)gitlabhq_production=#
查看用户详细信息
gitlabhq_production=# select * from pg_user;usename | usesysid | usecreatedb | usesuper | userepl | usebypassrls | passwd | valuntil | useconfig
-------------------+----------+-------------+----------+---------+--------------+----------+----------+-----------gitlab-psql | 10 | t | t | t | t | ******** | | gitlab | 16384 | f | f | f | f | ******** | | gitlab_replicator | 16386 | f | f | t | f | ******** | |
(3 rows)gitlabhq_production=#
查询表信息
gitlabhq_production=# \dtList of relationsSchema | Name | Type | Owner
--------+-------------------------------------------------+-------+--------public | abuse_reports | table | gitlabpublic | alerts_service_data | table | gitlabpublic | allowed_email_domains | table | gitlabpublic | analytics_cycle_analytics_group_stages | table | gitlabpublic | analytics_cycle_analytics_project_stages | table | gitlabpublic | analytics_language_trend_repository_languages | table | gitlabpublic | appearances | table | gitlab...省略public | web_hook_logs | table | gitlabpublic | web_hooks | table | gitlabpublic | wiki_page_meta | table | gitlabpublic | wiki_page_slugs | table | gitlabpublic | x509_certificates | table | gitlabpublic | x509_commit_signatures | table | gitlabpublic | x509_issuers | table | gitlabpublic | zoom_meetings | table | gitlab
(340 rows)gitlabhq_production=#
查看单个表详细
gitlabhq_production=# \d web_hooksTable "public.web_hooks"Column | Type | Collation | Nullable | Default
----------------------------+-----------------------------+-----------+----------+---------------------------------------id | integer | | not null | nextval('web_hooks_id_seq'::regclass)project_id | integer | | | created_at | timestamp without time zone | | | updated_at | timestamp without time zone | | | type | character varying | | | 'ProjectHook'::character varyingservice_id | integer | | | push_events | boolean | | not null | trueissues_events | boolean | | not null | falsemerge_requests_events | boolean | | not null | falsetag_push_events | boolean | | | falsegroup_id | integer | | | note_events | boolean | | not null | falseenable_ssl_verification | boolean | | | truewiki_page_events | boolean | | not null | falsepipeline_events | boolean | | not null | falseconfidential_issues_events | boolean | | not null | falserepository_update_events | boolean | | not null | falsejob_events | boolean | | not null | falseconfidential_note_events | boolean | | | push_events_branch_filter | text | | | encrypted_token | character varying | | | encrypted_token_iv | character varying | | | encrypted_url | character varying | | | encrypted_url_iv | character varying | | |
Indexes:"web_hooks_pkey" PRIMARY KEY, btree (id)"index_web_hooks_on_group_id" btree (group_id) WHERE type::text = 'GroupHook'::text"index_web_hooks_on_project_id" btree (project_id)"index_web_hooks_on_type" btree (type)
Foreign-key constraints:"fk_0c8ca6d9d1" FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
Referenced by:TABLE "web_hook_logs" CONSTRAINT "fk_rails_666826e111" FOREIGN KEY (web_hook_id) REFERENCES web_hooks(id) ON DELETE CASCADEgitlabhq_production=#
查看索引
gitlabhq_production=# \diList of relationsSchema | Name | Type | Owner | Table --------+-----------------------------------------------------------------+-------+--------+--------------------------------------------
-----public | abuse_reports_pkey | index | gitlab | abuse_reportspublic | alerts_service_data_pkey | index | gitlab | alerts_service_datapublic | allowed_email_domains_pkey | index | gitlab | allowed_email_domainspublic | analytics_cycle_analytics_group_stages_pkey | index | gitlab | analytics_cycle_analytics_group_stagespublic | analytics_cycle_analytics_project_stages_pkey | index | gitlab | analytics_cycle_analytics_project_stagespublic | analytics_index_audit_events_on_created_at_and_author_id | index | gitlab | audit_eventspublic | analytics_index_events_on_created_at_and_author_id | index | gitlab | events
...省略public | web_hook_logs_pkey | index | gitlab | web_hook_logspublic | web_hooks_pkey | index | gitlab | web_hookspublic | wiki_page_meta_pkey | index | gitlab | wiki_page_metapublic | wiki_page_slugs_pkey | index | gitlab | wiki_page_slugspublic | x509_certificates_pkey | index | gitlab | x509_certificatespublic | x509_commit_signatures_pkey | index | gitlab | x509_commit_signaturespublic | x509_issuers_pkey | index | gitlab | x509_issuerspublic | zoom_meetings_pkey | index | gitlab | zoom_meetings
(1308 rows)gitlabhq_production=#
查看视图
gitlabhq_production=# \dv
Did not find any relations.
gitlabhq_production=#
总结
整体确认了一下GitLab中内置的PostgreSQL的版本、表、索引、表空间等诸多信息。
GitLab: 官方镜像中的PostgreSQL相关推荐
- MySQL docker官方镜像介绍
最近在学习docker,在使用mysql镜像时看到dockerhub上的mysql镜像介绍很详细,解决了我大部分疑惑,为了加深印象,决定翻译一下,初次尝试翻译英文文档,有误之处还请多多指教. 原文:m ...
- VMware EXSi5.x 6.x无法识别realtek8168期AR8151网卡的解决方法(封装驱动到EXSi镜像中)...
1.问题描述 之前使用浪潮或者曙光或者自己组装的服务器安装EXSi5.0.5.5.6.0都没有问题至少没有出现说没有可用网卡而退出安装.这次也是很奇怪. 硬件环境描述 电脑型号 技嘉 台式电脑 处理器 ...
- postgresql 配置redis_自建 Gitlab (邮箱配置、拆分 PostgreSQL、Redis) + 随想
前言 最近折腾了一番自建 gitlab,在此做个记录,供君参考.整个构建过程基于 Docker Swarm(近期有计划将微服务移植到 Kubernetes,但还没倒腾顺手,暂时先沿用旧的方案),主题配 ...
- 如何在 GitLab CI 管道中构建 Docker 映像
CI 管道的一个常见用例是构建用于部署应用程序的 Docker 映像.GitLab CI 是一个很好的选择,因为它支持集成的拉代理服务,这意味着更快的管道,以及用于存储构建图像的内置注册表. 在本指南 ...
- GitLab 8.15中引入了自动部署和Web终端
最新的GitLab 8.15版提供了新的持续集成和持续部署(CI/CD)特性,目的在于自动化不同平台上的部署,并使用命令行界面让试机(Staging)或产品部署更加便捷. \\ GitLab的自动部署 ...
- 基于官方镜像MySQL做自定义业务扩充镜像
首先从https://hub.docker.com/_/mysql/拉取官方镜像,如果速度缓慢,建议添加国内加速 [root@docker ~]# docker images REPOSITORY T ...
- 由Docker的MySQL官方镜像配置的容器无法启动问题解决办法(修改配置后无法启动)
前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 为了方便阅读,我在原文基础上加了一些批注,说明我自己的情况,用红色标示. 这篇文章记录了我在使用 D ...
- mysql 镜像数据_mysql官方镜像数据存储问题
mysql官方镜像的Dockerfile中,有这么一条设置,即用了VOLUME这个关键字,同时后面设置了一个路径,/var/lib/mysql,这个路径是用来存储数据库的各种表的数据的. 这一条设置会 ...
- 克服跨洋网络延迟,使用Docker Hub Mirror加速Docker官方镜像下载
Docker Hub并没有在国内部署服务器或者使用国内的CDN服务,因此在国内特殊的网络环境下,镜像下载十分耗时.为了克服跨洋网络延迟,能够快速高效地下载Docker镜像,最为有效的方式之一就是:使用 ...
最新文章
- Maven编译jar出现:无法确定 T 的类型参数的异常的原因和处理方案
- RMAN的一些术语解释
- SAP UI5和Angular的函数防抖(Debounce)和函数节流(Throttle)实现原理介绍
- 数据结构题及c语言版实验报告排序,数据结构二叉排序树实验报告
- alloca函数的风险_alloca的函数范围中的goto是否有效?
- 死锁的 4 种排查工具 !
- 让SH/BAT脚本定位到运行目录的相对位置,实现其脚本可在任意运行目录下被正确执行...
- FarPoint表格数字框中小数点位数的设置
- 常见的系统store procedure
- 基于Windows 7环境的WAPI无线网络应用层控制实现
- CAPL可以读写的几种文件
- EasyUI的Vue版本
- 人在深圳的100怕!——谨以此文献给所有的深圳打拼者
- 朋友圈/评论/点赞/搜索/购物车
- POJ 1753 Flip Game(递归枚举)
- apache jmeter 压力测试工具
- 网络工程师教程(第一部:网络层面介绍)
- 拯救者R9000P AMD处理器 ubunu18.04 外接显示器失败 无法调节亮度 显卡无法驱动 好用
- 安卓培训开发!通宵都要看完这个Android关键技术点,看这一篇就够了!
- Codeforces Round #750 (Div. 2)E. Pchelyonok and Segments (数学+DP)