Using Linux commands is crucial for Oracle DBAs to manage databases effectively. Here's a guide to essential Linux commands for Oracle DBA beginners, categorized based on their usage:-
1. Basic Linux Commands:-
These commands help navigate and interact with the Linux environment
Check the current directory:-
pwd
List files in a directory:-
ls -l
Change directory:-
cd /path/to/directory
View file content:-
cat filename
Edit files (e.g., configuration files):-
vi filename
Copy files:-
cp source_file target_file
Move or rename files:-
mv source_file target_file
Delete files:-
rm filename
Check disk space usage:
df -h
Check memory usage
free -h
2. User and Permission Management
Oracle software often requires specific users and permissions.
Switch to Oracle user:
su - oracle
Check current user:
whoami
Change file permissions:
chmod 755 filename
Change file owner to oracle:
chown oracle:oinstall filename
3. Oracle Environment Setup:-
Before running Oracle commands, set environment variables.
Set ORACLE_HOME:
export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
Set ORACLE_SID:
export ORACLE_SID=orcl
Update PATH:
export PATH=$ORACLE_HOME/bin:$PATH
Verify environment variables:
env | grep ORACLE
4. Managing Oracle Database
Basic commands for starting, stopping, and checking the database.
Check listener status:
lsnrctl status
Start listener:
lsnrctl start
Stop listener:
lsnrctl stop
Login to SQL*Plus:
sqlplus / as sysdba
Start the database:
startup;
Shut down the database:
shutdown immediate;
5. Monitoring Logs
Log files are critical for troubleshooting Oracle issues.
Navigate to log directory:
cd $ORACLE_HOME/diag/rdbms/orcl/orcl/trace
View alert log file:
tail -f alert_orcl.log
6. Backup and Restore Commands
Database backups often involve file management.
Copy database files:
cp /path/to/source /path/to/backup
Compress files:
tar -czvf backup.tar.gz /path/to/backup
Uncompressed files:
tar -xzvf backup.tar.gz
7. Performance Monitoring
Monitor system performance to ensure optimal database operation.
Check CPU usage:
top
Check running processes:
ps -ef | grep oracle
Check open ports:
netstat -tuln | grep 1521
8. Scheduling Jobs
Automate tasks using cron jobs.
Edit crontab:
crontab -e
Example cron job to run a backup script daily at midnight:
0 0 * * * /path/to/backup_script.sh
9. Secure Database Access
Manage database security with file and process restrictions.
Restrict file access:
chmod 600 filename
Monitor unauthorized access:
last
10. Debugging and Troubleshooting
Identify and resolve common issues.
Check system logs:
tail -f /var/log/messages
Identify memory leaks:
vmstat 1
Check Oracle process details:
ps -ef | grep pmon
Very informative and useful.
ReplyDelete