nginxs

运维博客

gitlab里面postgresql几个操作

2016/02/25 13:05 于 数据分析 0

微信 微博 豆瓣 人人

\h:查看SQL命令的解释,比如\h select。
\?:查看psql命令列表。
\l:列出所有数据库。
\c [database_name]:连接其他数据库。
\d:列出当前数据库的所有表格。
\d [table_name]:列出某一张表格的结构。
\du:列出所有用户。
\e:打开文本编辑器。
\conninfo:列出当前数据库和连接的信息。

切换到对应用户
[root@git-node4 ~]# su - gitlab-psql
登录到postgresql
-sh-4.1$ psql -d gitlabhq_production
psql (9.2.8)
Type "help" for help.

查看所有库
gitlabhq_production=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------------+-------------+----------+---------+-------+---------------------------------
gitlabhq_production | gitlab | UTF8 | C | C |
postgres | gitlab-psql | UTF8 | C | C |
template0 | gitlab-psql | UTF8 | C | C | =c/"gitlab-psql" +
| | | | | "gitlab-psql"=CTc/"gitlab-psql"
template1 | gitlab-psql | UTF8 | C | C | =c/"gitlab-psql" +
| | | | | "gitlab-psql"=CTc/"gitlab-psql"
(4 rows)

查看所有表
gitlabhq_production=# \dt
List of relations
Schema | Name | Type | Owner

--------+----------------------+-------+--------
public | application_settings | table | gitlab
public | broadcast_messages | table | gitlab
public | deploy_keys_projects | table | gitlab
public | emails | table | gitlab
public | events | table | gitlab
public | forked_project_links | table | gitlab
public | identities | table | gitlab
public | issues | table | gitlab
public | keys | table | gitlab
public | label_links | table | gitlab
public | labels | table | gitlab
public | members | table | gitlab
public | merge_request_diffs | table | gitlab
public | merge_requests | table | gitlab
public | milestones | table | gitlab
public | namespaces | table | gitlab
public | notes | table | gitlab
public | oauth_access_grants | table | gitlab
public | oauth_access_tokens | table | gitlab
public | oauth_applications | table | gitlab
public | projects | table | gitlab
public | protected_branches | table | gitlab
public | schema_migrations | table | gitlab
public | services | table | gitlab
public | snippets | table | gitlab
public | subscriptions | table | gitlab
public | taggings | table | gitlab
public | tags | table | gitlab
public | users | table | gitlab
public | users_star_projects | table | gitlab
public | web_hooks | table | gitlab
(31 rows)

以下SQL 基本和mysql一致:SELECT,UPDATE,INSERT,DELETE,CREATE,ALTER

微信扫描二维码了解更多 ->

[运维博客]
【数据分类】

postgresql操作 postgresqlgitlab里面postgresql

mysql show slave status

1970/01/01 08:00 于 数据分析 0

微信 微博 豆瓣 人人

这里详细介绍一下各个参数意思:

mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: #mysql 从库io状态
Master_Host: 192.168.0.116 #mysql 主节点
Master_User: wordpress_slave #从库使用用户
Master_Port: 3306 #主库的端口
Connect_Retry: 60 #连接超时重试间隔
Master_Log_File: mysql-bin.012602 #同步主库的binlog日志
Read_Master_Log_Pos: 19091467 #主库读取到的pos
Relay_Log_File: web-node1-relay-bin.000358 #读取的延时日志文件
Relay_Log_Pos: 114046814 #从库执行到延时日志pos
Relay_Master_Log_File: mysql-bin.012598 #从库执行到延时日志所在的binlog文件
Slave_IO_Running: No #从库的IO进程
Slave_SQL_Running: No #从库的sql执行进程
Replicate_Do_DB: #同步的数据库
Replicate_Ignore_DB: #忽略同步的数据库
Replicate_Do_Table: #同步的表
Replicate_Ignore_Table: #忽略同步的表
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error: 0
Exec_Master_Log_Pos: 114046644
Relay_Log_Space: 1092700446
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1594
Last_SQL_Error: 0
Replicate_Ignore_Server_Ids:
Master_Server_Id: 633306
Master_UUID: 629ea5e6-93f4-11e4-8cfa-b82a72dd31d0
Master_Info_File: /usr/local/mysql-5.6.21-linux-glibc2.5-x86_64/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 160229 21:18:27
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 619ea5e6-93f4-11e4-8cfa-b82a72dd31d0:2271219917-2291736581:2291736708-2292305169
Executed_Gtid_Set: 619ea5e6-93f4-11e4-8cfa-b82a72dd31d0:2271219917-2291736582
Auto_Position: 0
1 row in set (0.00 sec)

微信扫描二维码了解更多 ->

[运维博客]

mysqlshow slave statusshow slave status详情

管理