Oracle DBA Linux Scripts - Lab Exercise

Oracle DBA Linux Scripts - Lab Exercise
Practice Questions
  1)Write a shell script that displays the following menu and prompts the user for a choice:

  markdown
  Copy
  ========================================================================================
  CHOOSE ANY ONE
  ========================================================================================
  1. CPU information
  2. RAM information
  3. Kernel information
  4. OS version
  5. Hostname
  6. IP address
  7. Exit
2) Write a shell script that creates a folder at /home/oracle/sfile/, and continuously checks for 
the existence of a file named excel_19112020.txt in that folder. Every 2 seconds, the script should 
display the word 'checking' with additional periods appended (e.g., checking.......). Once the file is found, 
it should print 'File received'.
                  
3) Create a shell script named greetme.sh that accepts an integer input as the time of day (ranging from 0 to 24). 
Based on the input, the script should print:

Good Morning!!! if the time is between 0 and 12
Good Afternoon if the time is between 13 and 18
Good Night if the time is between 19 and 24
                  
4) Create a shell script CreateDB.sh that takes two inputs: a database name (dbname) and a file path (path). 
The script should perform the following tasks:

Use the given inputs to create the database.
  1. Set the following tablespace sizes:
    SYSTEM 500 MB
    SYSAUX 500 MB
    UNDOTBS 100 MB
    TEMP 100 MB
  2. Write a PFILE (parameter file) with these settings:
    sga_target=800m
    undo_management=AUTO
    undo_tablespace=UNDOTBS
  3. Ensure catalog and catproc were executed.
                  
5) Create a shell script that monitors the alertlog file for any new entries or changes. The script should run in a loop, 
periodically checking for updates and printing any new lines or important alerts to the terminal.
                  
6) Create a shell script that handles log rotation. The script should delete logs that are older than two days from the 
current system date.
7) Write a shell script named Dupcontrol.sh that accepts a database name (DBname) and a number as arguments. 
The number indicates how many control files should be multiplexed for the specified database. 
The script should copy the original control file to the required number of new control files. For example:
  ./Dupcontrol.sh DBname 3.
8) Create a shell script that starts the database when executed. The script should ensure the database is 
started and ready for use.
9) Create a shell script that stops the specified database when executed. The script should ensure that the database 
is safely shut down.
10) Write a shell script that:

Verifies whether the listener is currently running.
If the listener is not running, the script should start it.
11) Write a shell script that:

Checks if the listener is running, If the listener is running, the script should stop it.
12) Create a shell script that checks for fragmentation in the system and reports if fragmentation is detected
    
13) Write a shell script that:

Identifies all the tables in the database.
Defragments each table to optimize storage and performance.
    
14)Write a shell script that:

Identifies all unusable indexes in the database.
Rebuilds only those indexes that are marked as unusable.
  
15) Create a shell script that monitors the mount point usage. If the usage exceeds 85%, it should 
send an email to DBA@tesdbacademy.com notifying them of the issue
    
16) Write a shell script that:

Scans the server for active Oracle databases.
Outputs the number of Oracle databases running on the system.
    
17) Create a shell script that:

Accepts the database name as a parameter.
Checks the database's state (NOMOUNT, MOUNT, OPEN).
Outputs the current state of the database
    
18) Create a shell script called DBanalyze.sh that:

Accepts an argument for the analysis type (full, fix, dict, schema).
Depending on the argument:
For full, it should gather statistics for the entire database using dbms_stats.gather_database_stats.
For fix, it should gather statistics for fixed objects using dbms_stats.gather_fixed_objects_stats.
For dict, it should gather statistics for dictionary objects using dbms_stats.gather_dictionary_stats.
For schema, it should analyze statistics for a specified table within the given schema using dbms_stats.gather_table_stats.
The script should handle the database name or schema name accordingly and run the appropriate DBMS_STATS function
    
19) Write a script named Cleanschema.sh that:

Accepts a schema name as a parameter.
Connects to the database and retrieves all objects within the specified schema.
Drops each object (tables, views, indexes, etc.) from the schema to clean it
    
20) Write a shell script that:

Disables all constraints in the database to allow truncation of tables.
Truncates all tables in the schema to remove all data.
Enables all constraints again after the tables are truncated.