目标:
1 弄清楚如何操作postgresql
2 弄清楚mistral中表结构
1 postgresql
1.1 登录
psql
报错:
psql: FATAL: role "root" does not exist
[root@node-1 tmp]# cat ark-values-postgresql
configmap: {postgres_pass: xjkXt5YO}
pod:
replicas: {server: 1}
查看charts
configmap:
postgres_user: mistral-user
postgres_pass: password
postgres_db: mistral
最终:
psql -U mistral-user -d mistral -h 127.0.0.1 -p 5432
样例输出结果:
root@postgresql-0:/# psql -U mistral-user -d mistral -h 127.0.0.1 -p 5432
psql (9.6.7)
Type "help" for help.
mistral=#
参考:
https://www.runoob.com/postgresql/postgresql-tutorial.html
http://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html
1.2 登录数据库
psql mistral
mistral=# psql mistral
mistral-# l
mistral-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
mistral | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
1.3 查看某个数据库的表
mistral-# \d
List of relations
Schema | Name | Type | Owner
--------+-------------------------+-------+--------------
public | action_definitions_v2 | table | mistral-user
public | action_executions_v2 | table | mistral-user
public | cron_triggers_v2 | table | mistral-user
public | delayed_calls_v2 | table | mistral-user
public | environments_v2 | table | mistral-user
public | event_triggers_v2 | table | mistral-user
public | named_locks | table | mistral-user
public | resource_members_v2 | table | mistral-user
public | task_executions_v2 | table | mistral-user
public | workbooks_v2 | table | mistral-user
public | workflow_definitions_v2 | table | mistral-user
public | workflow_executions_v2 | table | mistral-user
(12 rows)
1.4 查看表结构
1.4.1)
\d action_definitions_v2
mistral-# \d action_definitions_v2
Table "public.action_definitions_v2"
Column | Type | Modifiers
--------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(255) |
definition | text |
spec | text |
tags | text |
is_system | boolean |
description | text |
input | text |
action_class | character varying(200) |
attributes | text |
Indexes:
"action_definitions_v2_pkey" PRIMARY KEY, btree (id)
"action_definitions_v2_name_project_id_key" UNIQUE CONSTRAINT, btree (name, project_id)
"action_definitions_v2_action_class" btree (action_class)
"action_definitions_v2_is_system" btree (is_system)
"action_definitions_v2_project_id" btree (project_id)
"action_definitions_v2_scope" btree (scope)
1.4.2)
\d action_executions_v2
mistral-# \d action_executions_v2
Table "public.action_executions_v2"
Column | Type | Modifiers
--------------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(255) |
description | character varying(255) |
workflow_name | character varying(255) |
workflow_namespace | character varying(255) |
workflow_id | character varying(80) |
spec | text |
state | character varying(20) |
state_info | text |
tags | text |
runtime_context | text |
accepted | boolean |
input | text |
output | text |
task_execution_id | character varying(36) |
Indexes:
"action_executions_v2_pkey" PRIMARY KEY, btree (id)
"action_executions_v2_project_id" btree (project_id)
"action_executions_v2_scope" btree (scope)
"action_executions_v2_state" btree (state)
"action_executions_v2_updated_at" btree (updated_at)
Foreign-key constraints:
"action_executions_v2_task_execution_id_fkey" FOREIGN KEY (task_execution_id) REFERENCES task_executions_v2(id) ON DELETE CASCADE
1.4.3)
\d cron_triggers_v2
mistral-# \d cron_triggers_v2
Table "public.cron_triggers_v2"
Column | Type | Modifiers
----------------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(200) |
pattern | character varying(100) |
first_execution_time | timestamp without time zone |
next_execution_time | timestamp without time zone | not null
workflow_name | character varying(255) |
remaining_executions | integer |
workflow_id | character varying(36) |
workflow_params | text |
workflow_params_hash | character(64) |
workflow_input | text |
workflow_input_hash | character(64) |
trust_id | character varying(80) |
Indexes:
"cron_triggers_v2_pkey" PRIMARY KEY, btree (id)
"cron_triggers_v2_name_project_id_key" UNIQUE CONSTRAINT, btree (name, project_id)
"cron_triggers_v2_workflow_input_hash_workflow_name_pattern__key" UNIQUE CONSTRAINT, btree (workflow_input_hash, workflow_name, pattern, project_id, workflow_params_hash, remaining_executions, first_execution_time)
"cron_triggers_v2_next_execution_time" btree (next_execution_time)
"cron_triggers_v2_project_id" btree (project_id)
"cron_triggers_v2_scope" btree (scope)
"cron_triggers_v2_workflow_name" btree (workflow_name)
Foreign-key constraints:
"cron_triggers_v2_workflow_id_fkey" FOREIGN KEY (workflow_id) REFERENCES workflow_definitions_v2(id)
1.4.4)
\d delayed_calls_v2
mistral-# \d delayed_calls_v2
Table "public.delayed_calls_v2"
Column | Type | Modifiers
---------------------+-----------------------------+-----------
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
factory_method_path | character varying(200) |
target_method_name | character varying(80) | not null
method_arguments | text |
serializers | text |
key | character varying(250) |
auth_context | text |
execution_time | timestamp without time zone | not null
processing | boolean | not null
Indexes:
"delayed_calls_v2_pkey" PRIMARY KEY, btree (id)
"delayed_calls_v2_execution_time" btree (execution_time)
1.4.5)
\d environments_v2
mistral-# \d environments_v2
Table "public.environments_v2"
Column | Type | Modifiers
-------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(200) |
description | text |
variables | text |
Indexes:
"environments_v2_pkey" PRIMARY KEY, btree (id)
"environments_v2_name_project_id_key" UNIQUE CONSTRAINT, btree (name, project_id)
"environments_v2_name" btree (name)
"environments_v2_project_id" btree (project_id)
"environments_v2_scope" btree (scope)
1.4.6)
\d event_triggers_v2
mistral-# \d event_triggers_v2
Table "public.event_triggers_v2"
Column | Type | Modifiers
-----------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(200) |
workflow_id | character varying(36) |
workflow_params | text |
workflow_input | text |
exchange | character varying(80) | not null
topic | character varying(80) | not null
event | character varying(80) | not null
trust_id | character varying(80) |
Indexes:
"event_triggers_v2_pkey" PRIMARY KEY, btree (id)
"event_triggers_v2_exchange_topic_event_workflow_id_project__key" UNIQUE CONSTRAINT, btree (exchange, topic, event, workflow_id, project_id)
"event_triggers_v2_project_id_workflow_id" btree (project_id, workflow_id)
Foreign-key constraints:
"event_triggers_v2_workflow_id_fkey" FOREIGN KEY (workflow_id) REFERENCES workflow_definitions_v2(id)
1.4.7)
\d named_locks
mistral-# \d named_locks
Table "public.named_locks"
Column | Type | Modifiers
------------+-----------------------------+-----------
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(250) |
Indexes:
"named_locks_pkey" PRIMARY KEY, btree (id)
"named_locks_name_key" UNIQUE CONSTRAINT, btree (name)
1.4.8)
\d resource_members_v2
mistral-# \d resource_members_v2
Table "public.resource_members_v2"
Column | Type | Modifiers
---------------+-----------------------------+-----------
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
resource_id | character varying(80) | not null
resource_type | character varying(50) | not null
project_id | character varying(80) |
member_id | character varying(80) | not null
status | character varying(20) | not null
Indexes:
"resource_members_v2_pkey" PRIMARY KEY, btree (id)
"resource_members_v2_resource_id_resource_type_member_id_key" UNIQUE CONSTRAINT, btree (resource_id, resource_type, member_id)
1.4.9)
\d task_executions_v2
mistral-# \d task_executions_v2
Table "public.task_executions_v2"
Column | Type | Modifiers
-----------------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(255) |
description | character varying(255) |
workflow_name | character varying(255) |
workflow_namespace | character varying(255) |
workflow_id | character varying(80) |
spec | text |
state | character varying(20) |
state_info | text |
tags | text |
runtime_context | text |
action_spec | text |
unique_key | character varying(250) |
type | character varying(10) |
processed | boolean |
in_context | text |
published | text |
workflow_execution_id | character varying(36) |
Indexes:
"task_executions_v2_pkey" PRIMARY KEY, btree (id)
"task_executions_v2_unique_key_key" UNIQUE CONSTRAINT, btree (unique_key)
"task_executions_v2_project_id" btree (project_id)
"task_executions_v2_scope" btree (scope)
"task_executions_v2_state" btree (state)
"task_executions_v2_updated_at" btree (updated_at)
"task_executions_v2_workflow_execution_id" btree (workflow_execution_id)
"task_executions_v2_workflow_execution_id_name" btree (workflow_execution_id, name)
Foreign-key constraints:
"task_executions_v2_workflow_execution_id_fkey" FOREIGN KEY (workflow_execution_id) REFERENCES workflow_executions_v2(id) ON DELETE CASCADE
Referenced by:
TABLE "action_executions_v2" CONSTRAINT "action_executions_v2_task_execution_id_fkey" FOREIGN KEY (task_execution_id) REFERENCES task_executions_v
2(id) ON DELETE CASCADE
TABLE "workflow_executions_v2" CONSTRAINT "workflow_executions_v2_task_execution_id_fkey" FOREIGN KEY (task_execution_id) REFERENCES task_executio
ns_v2(id) ON DELETE CASCADE
1.4.10)
\d workbooks_v2
Table "public.workbooks_v2"
Column | Type | Modifiers
------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(255) |
definition | text |
spec | text |
tags | text |
is_system | boolean |
Indexes:
"workbooks_v2_pkey" PRIMARY KEY, btree (id)
"workbooks_v2_name_project_id_key" UNIQUE CONSTRAINT, btree (name, project_id)
"workbooks_v2_project_id" btree (project_id)
"workbooks_v2_scope" btree (scope)
1.4.11)
\d workflow_definitions_v2
mistral-# \d workflow_definitions_v2
Table "public.workflow_definitions_v2"
Column | Type | Modifiers
------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(255) |
definition | text |
spec | text |
tags | text |
is_system | boolean |
namespace | character varying(255) |
Indexes:
"workflow_definitions_v2_pkey" PRIMARY KEY, btree (id)
"workflow_definitions_v2_name_namespace_project_id_key" UNIQUE CONSTRAINT, btree (name, namespace, project_id)
"workflow_definitions_v2_is_system" btree (is_system)
"workflow_definitions_v2_project_id" btree (project_id)
"workflow_definitions_v2_scope" btree (scope)
Referenced by:
TABLE "cron_triggers_v2" CONSTRAINT "cron_triggers_v2_workflow_id_fkey" FOREIGN KEY (workflow_id) REFERENCES workflow_definitions_v2(id)
TABLE "event_triggers_v2" CONSTRAINT "event_triggers_v2_workflow_id_fkey" FOREIGN KEY (workflow_id) REFERENCES workflow_definitions_v2(id)
1.4.12)
\d workflow_executions_v2
mistral-# \d workflow_executions_v2
Table "public.workflow_executions_v2"
Column | Type | Modifiers
--------------------+-----------------------------+-----------
scope | character varying(80) |
project_id | character varying(80) |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
id | character varying(36) | not null
name | character varying(255) |
description | character varying(255) |
workflow_name | character varying(255) |
workflow_namespace | character varying(255) |
workflow_id | character varying(80) |
spec | text |
state | character varying(20) |
state_info | text |
tags | text |
runtime_context | text |
accepted | boolean |
input | text |
output | text |
params | text |
context | text |
task_execution_id | character varying(36) |
root_execution_id | character varying(36) |
Indexes:
"workflow_executions_v2_pkey" PRIMARY KEY, btree (id)
"workflow_executions_v2_project_id" btree (project_id)
"workflow_executions_v2_scope" btree (scope)
"workflow_executions_v2_state" btree (state)
"workflow_executions_v2_updated_at" btree (updated_at)
Foreign-key constraints:
"workflow_executions_v2_root_execution_id_fkey" FOREIGN KEY (root_execution_id) REFERENCES workflow_executions_v2(id) ON DELETE SET NULL
"workflow_executions_v2_task_execution_id_fkey" FOREIGN KEY (task_execution_id) REFERENCES task_executions_v2(id) ON DELETE CASCADE
Referenced by:
TABLE "task_executions_v2" CONSTRAINT "task_executions_v2_workflow_execution_id_fkey" FOREIGN KEY (workflow_execution_id) REFERENCES workflow_exec
utions_v2(id) ON DELETE CASCADE
TABLE "workflow_executions_v2" CONSTRAINT "workflow_executions_v2_root_execution_id_fkey" FOREIGN KEY (root_execution_id) REFERENCES workflow_exec
utions_v2(id) ON DELETE SET NULL
1.5)进入数据库
\c mistral
1.6)查看表数据结构
SELECT * FROM action_definitions_v2;
mistral=# SELECT * FROM action_definitions_v2;
scope | project_id | created_at | updated_at | id | name
| definition |
spec
| tags | is_system | description |
input
| action_class |
attributes
--------+-------------------+---------------------+------------+--------------------------------------+-----------------------------------------------
public | <default-project> | 2020-03-30 02:42:04 | | 00179920-a69c-40f7-b66b-c7397c5d22e8 | ceilometer.alarms_update
| |
| | t | | action_region="",
alarm_id, **kwargs
| mistral.actions.openstack.actions.CeilometerAction | {"client_method_name": "alarm
s.update"}
public | <default-project> | 2020-03-30 02:42:05 | | 0195d054-0c46-4266-9b03-8a3e82c684b9 | mistral.services_list
| |
| | t | |
| mistral.actions.openstack.actions.MistralAction | {"client_method_name": "servi
ces.list"}
public | <default-project> | 2020-03-30 02:42:02 | | 89cc19bb-43c3-4b02-b047-f4159619ce86 | nova.availability_zones_find
2)
select * from action_executions_v2;
无内容
3)
select * from cron_triggers_v2;
无
4)
select * from delayed_calls_v2;
无
5)
select * from environments_v2;
无
6)
select * from event_triggers_v2;
无
7)
select * from named_locks;
无
8)
select * from resource_members_v2;
无
9)
select * from workbooks_v2;
无
10)
select * from task_executions_v2;
mistral=# select * from task_executions_v2;
scope | project_id | created_at | updated_at | id | name | description |
workflow_name | workflow_namespace | workflow_id |
spec
| stat
e |
state_info
| tags | runtime_context
| action_spec | unique_key | type | processed |
in_context
published
| workflow_execution_id
---------+-------------------+---------------------+---------------------+--------------------------------------+-------+-------------+---------------
private | <default-project> | 2020-03-29 10:17:41 | 2020-03-29 10:17:43 | 33cc7add-3009-4061-acdf-190074c74296 | task0 | | email.mistral-
network-check | | baed939c-81df-431f-9f03-f2ccde4a34b6 | {"retry": {"count": 5, "delay": 300}, "name": "task0", "on-e
rror": ["task3"], "on-success": ["task1"], "publish": {"subject_en": "[<% task(task0).result.stdout[license][company] %>] Run Network Check Workflow E
rror", "subject_cn": "[<% task(task0).result.stdout[license][company] %>] \\u6267\\u884c\\u7f51\\u7edc\\u68c0\\u67e5\\u0057\\u006f\\u0072\\u006b\\u006
6\\u006c\\u006f\\u0077\\u5931\\u8d25", "env_name": "<% task(task0).result.stdout[license][company] %>", "message_en": "Run network check workflow fail
ed, please check execution history.", "message_cn": "\\u6267\\u884c\\u7f51\\u7edc\\u68c0\\u67e5\\u0057\\u006f\\u0072\\u006b\\u0066\\u006c\\u006f\\u007
7\\u5931\\u8d25\\uff0c\\u8bf7\\u68c0\\u67e5\\u6267\\u884c\\u8bb0\\u5f55\\u3002", "stderr": "<% task(task0).result.stderr %>"}, "version": "2.0", "acti
on": "st2.action", "input": {"ref": "core.local", "parameters": {"cmd": "base64 -d /etc/....../license.lic"}}, "type": "direct"} | SUCCE
SS |
| | {"retry_task_policy": {}}
| | | ACTION | t | {"__task_execution": {"id": "33cc7add-3009-4061-acdf-190074c74296
", "name": "task0"}}
| {"message_en": "Run network check w
orkflow failed, please check execution history.", "subject_en": "......", "stderr": ""}
| 230f380e-82c5-4db1-b3bd-67602a99ce59
private | <default-project> | 2020-03-29 10:17:43 | 2020-03-29 10:18:08 | 3e7c1a4d-2cf7-4fe7-a858-ca0a314d1776 | task1 | | email.mistral-
network-check | | baed939c-81df-431f-9f03-f2ccde4a34b6 | {"retry": {"count": 5, "delay": 300, "continue-on": "<% not
task(task1).result.stdout[exit_code] in list(0, 1) or task(task1).result.stdout[std_out] = '' %>"}, "name": "task1", "on-error": ["task3"], "on-succes
s": [{"task2": "<% task(task1).result.stdout[exit_code] = 1 and task(task1).result.stdout[std_out] != '' %>"}, {"task3": "<% not task(task1).result.st
dout[exit_code] in list(0, 1) or task(task1).result.stdout[std_out] = '' %>"}], "publish": {"ops_message": "<% task(task1).result.stdout %>", "stderr"
: "<% task(task1).result.stderr %>"}, "version": "2.0", "action": "st2.action", "input": {"ref": "core.local", "parameters": {"cmd": "<% $.cmd %>", "t
imeout": "<% $.timeout %>"}}, "type": "direct"}
| SUCCE
SS |
| | {"triggered_by": [{"event": "on-success", "task_id": "33cc7add-3009-4061-acdf-190074c74296"}], "re
try_task_policy": {}} | | | ACTION | t | {"message_en": "Run network check workflow failed, please check e
xecution history.", "subject_en": "......", "env_name": "......", "stderr": "", "__task_execution": {"id": "3e7c1a4d-2cf7-4fe7-a858-ca0a314d1776",
"name": "task1"}}
| {"ops_message": {"std_err": "", "exit_code": 0, "s
td_out": {"message": ""}}, "stderr
": " % Total ......
| 230f380e-82c5-4db1-b3bd-67602a99ce59
private | <default-project> | 2020-03-29 11:17:40 | 2020-03-29 11:17:41 | 9b92cf8f-19eb-45dc-b476-664686a6f17c | task0 | | email.mistral-
network-check | | baed939c-81df-431f-9f03-f2ccde4a34b6 | {"retry": {"count": 5, "delay": 300}, "name": "task0", "on-e
rror": ["task3"], "on-success": ["task1"], "publish": {"subject_en": "[<% task(task0).result.stdout[license][company] %>] Run Network Check Workflow E
rror", "subject_cn": "[<% task(task0).result.stdout[license][company] %>] \\u6267\\u884c\\u7f51\\u7edc\\u68c0\\u67e5\\u0057\\u006f\\u0072\\u006b\\u006
6\\u006c\\u006f\\u0077\\u5931\\u8d25", "env_name": "<% task(task0).result.stdout[license][company] %>", "message_en": "Run network check workflow fail
ed, please check execution history.", "message_cn": "\\u6267\\u884c\\u7f51\\u7edc\\u68c0\\u67e5\\u0057\\u006f\\u0072\\u006b\\u0066\\u006c\\u006f\\u007
7\\u5931\\u8d25\\uff0c\\u8bf7\\u68c0\\u67e5\\u6267\\u884c\\u8bb0\\u5f55\\u3002", "stderr": "<% task(task0).result.stderr %>"}, "version": "2.0", "acti
on": "st2.action", "input": {"ref": "core.local", "parameters": {"cmd": "base64 -d /etc/....../license.lic"}}, "type": "direct"} | SUCCE
SS |
| | {"retry_task_policy": {}}
| | | ACTION | t | {"__task_execution": {"id": "9b92cf8f-19eb-45dc-b476-664686a6f17c
", "name": "task0"}}
| {"message_en": "Run network check w
orkflow failed, please check execution history.", "subject_en": "......", "env_name": "......", "stderr": ""}
| 0bc99cb0-f690-4227-926e-08bdcb3476bb
private | <default-project> | 2020-03-30 01:17:40 | 2020-03-30 01:17:41 | 697df309-2158-42d1-9170-2170fefc9ebb | task0 | | email.mistral-
network-check | | baed939c-81df-431f-9f03-f2ccde4a34b6 | {"retry": {"count": 5, "delay": 300}, "name": "task0", "on-e
rror": ["task3"], "on-success": ["task1"], "publish": {"subject_en": "[<% task(task0).result.stdout[license][company] %>] Run Network Check Workflow E
rror", "subject_cn": "[<% task(task0).result.stdout[license][company] %>] \\u6267\\u884c\\u7f51\\u7edc\\u68c0\\u67e5\\u0057\\u006f\\u0072\\u006b\\u006
6\\u006c\\u006f\\u0077\\u5931\\u8d25", "env_name": "<% task(task0).result.stdout[license][company] %>", "message_en": "Run network check workflow fail
ed, please check execution history.", "message_cn": "\\u6267\\u884c\\u7f51\\u7edc\\u68c0\\u67e5\\u0057\\u006f\\u0072\\u006b\\u0066\\u006c\\u006f\\u007
7\\u5931\\u8d25\\uff0c\\u8bf7\\u68c0\\u67e5\\u6267\\u884c\\u8bb0\\u5f55\\u3002", "stderr": "<% task(task0).result.stderr %>"}, "version": "2.0", "acti
on": "st2.action", "input": {"ref": "core.local", "parameters": {"cmd": "base64 -d /etc/....../license.lic"}}, "type": "direct"} | SUCCE
SS |
| | {"retry_task_policy": {}}
| | | ACTION | t | {"__task_execution": {"id": "697df309-2158-42d1-9170-2170fefc9ebb
", "name": "task0"}}
参考:
https://www.runoob.com/postgresql/postgresql-tutorial.html
http://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html