Here are some Greenplum DBA commands with examples:

  1. Starting and Stopping Greenplum:
    • Start Greenplum: gpstart
    • Stop Greenplum: gpstop
  2. Managing Database Instances:

Create a New Database: createdb <database_name>

                    createdb mydb

Drop a Database: dropdb <database_name>

    dropdb mydb

Cluster Management:

  • Initialize the Greenplum cluster: gpinitsystem

                    gpinitsystem -a

Add a New Segment: gpexpand

gpexpand -d new_segment_directory

Monitoring and Maintenance:

  • Monitor the Database Status: gpstate

                    gpstate

View Resource Consumption: gp_top

gp_top

Backup and Restore:

  • Perform a Backup: gpcrondump

                    gpcrondump -d mydb

Restore from Backup: gpdbrestore

gpdbrestore -d mydb -a /path/to/backup

User and Security Management:

  • Create a User: CREATE USER <username> PASSWORD '<password>'

                    CREATE USER myuser PASSWORD 'mypassword';

Grant Privileges: GRANT <privilege> ON <object> TO <username>

                    GRANT SELECT, INSERT ON mytable TO myuser;

Revoke Privileges: REVOKE <privilege> ON <object> FROM <username>

REVOKE INSERT ON mytable FROM myuser;

Query Performance Tuning:

  • Analyze Query Plans: Use EXPLAIN and EXPLAIN ANALYZE to understand query execution plans.

                     EXPLAIN SELECT * FROM mytable WHERE column = 'value';

Create Indexes: Use CREATE INDEX to improve query performance.

CREATE INDEX idx_column ON mytable (column);

 

Greenplum Utilities:

    • gpconfig: Modify Greenplum configuration settings.
    • gpload: Load data into Greenplum tables.
    • gpfdist: Data distribution utility for parallel data loading.
    • psql: The PostgreSQL command-line tool for interacting with Greenplum databases.

These examples showcase various commands a Greenplum DBA might use to manage, maintain, and optimize the Greenplum database environment. Remember that Greenplum is built on PostgreSQL, so many PostgreSQL commands and SQL statements can be used in Greenplum as well. Always refer to Greenplum documentation and consider your specific environment's requirements while using these commands.

 

Important SQL's for Greenplum DBA's

  • select count(*) from pg_tables where schemaname='sachi';
  • select rolname from pg_roles where rolcanlogin is TRUE; -- List users
  • select rolname from pg_roles where rolcanlogin is FALSE; --- List Roles
  • select * from pg_views ;
  • select * from information_schema.table_privileges;
  • select * from pg_user;
  • select * from pg_views where viewname like '%priv%';
  • select * from pg_views where viewname like '%role%';
  • select * from pg_views where viewname like '%gran%';
  • select * from pg_views where viewname like '%part%';
  • select * from pg_views where viewname like '%schema%';
  • select * from pg_views where viewname like '%stat%';
  • select * from information_schema.role_table_grants;
  • select * from information_schema.role_routine_grants;
  • select * from information_schema.applicable_roles;
  • select * from information_schema.enabled_roles;
  • select * from gp_toolkit.gp_roles_assigned;

 

أحدث أقدم