🐧 Essential Linux Commands for Oracle DBAs

Post Reply
valgonzalez
Site Admin
Posts: 56
Joined: Fri Aug 30, 2024 4:30 pm

🐧 Essential Linux Commands for Oracle DBAs

Post by valgonzalez »

As an Oracle DBA, mastering Linux commands is just as important as knowing SQL and PL/SQL. Your database runs on Linux, and efficient command-line skills can save time, improve troubleshooting, and enhance database performance.

Here are some must-know Linux commands every DBA should use daily:
πŸ“Œ 1️⃣ Checking System Resources
Monitor CPU, memory, and disk usage to ensure optimal database performance.
βœ… Check CPU Usage:

top
or
mpstat 1 5

βœ… Check Memory Usage:
free -m

βœ… Check Disk Space Usage:

df -h

πŸ“Œ 2️⃣ Managing Oracle Processes
Find and manage running Oracle database processes.
βœ… List all Oracle processes:

ps -ef | grep pmon
βœ… Kill a stuck process (use with caution!):

kill -9 <PID>

πŸ“Œ 3️⃣ Checking Database Listener Status
Ensure that the Oracle Listener is running.
βœ… Check listener status:

lsnrctl status

βœ… Start the listener:

lsnrctl start

βœ… Stop the listener:

lsnrctl stop

πŸ“Œ 4️⃣ Navigating and Managing Files
Find logs, manage backups, and monitor database files.
βœ… Find alert logs:

find /u01/app/oracle/diag/rdbms/ -name alert_*.log

βœ… View last 100 lines of the alert log in real-time:

tail -100f /u01/app/oracle/diag/rdbms/DB_NAME/trace/alert_DB_NAME.log
βœ… Search logs for errors:

grep -i "ORA-" alert_DB_NAME.log

πŸ“Œ 5️⃣ Managing Oracle Services
Start, stop, and check the database instance.
βœ… Check database status:

sqlplus / as sysdba

SELECT status FROM v$instance;
βœ… Start the database:

sqlplus / as sysdba
sql

STARTUP;

βœ… Shutdown the database:
sql

SHUTDOWN IMMEDIATE;

πŸ“Œ 6️⃣ Monitoring Active Sessions & Blocking Locks
βœ… Check active database sessions:
bash
CopyEdit
sqlplus / as sysdba
sql

SELECT username, sid, serial#, status FROM v$session WHERE status='ACTIVE';

βœ… Check for blocking locks:
sql


SELECT blocking_session, sid, serial#, wait_class FROM v$session WHERE blocking_session IS NOT NULL;

πŸ“Œ 7️⃣ Scheduling Jobs with Cron
Automate backups, monitoring scripts, and routine maintenance tasks.
βœ… Edit the cron job list:

crontab -e

βœ… Schedule a backup job to run daily at midnight:
bash
CopyEdit
0 0 * * * /u01/app/oracle/scripts/backup.sh

βœ… View scheduled cron jobs:

crontab -l
Post Reply