Showing posts with label Unix commands for dba's. Show all posts
Showing posts with label Unix commands for dba's. Show all posts
How to use OS commands to diagnose Database Performance issues
$ man vmstat
Here is some sample output from these commands:
$ prtconf |grep -i "Memory size"
Memory size: 4096 Megabytes
$ swap -s
total: 7443040k bytes allocated + 997240k reserved = 8440280k used, 2777096k available
$ df -k
...
$ top
$ vmstat 5 100
$ iostat -c 2 100
$ iostat -D 2 100
$ mpstat 2 100
HP-UX 11.0:
============
$ grep Physical /var/adm/syslog/syslog.log
$ df -k
$ sar -w 2 100
$ sar -u 2 100
$ /bin/top
$ vmstat -n 5 100
$ iostat 2 100
$ top
For example:
$ grep Physical /var/adm/syslog/syslog.log
Nov 13 17:43:28 rmtdchp5 vmunix: Physical: 16777216 Kbytes, lockable: 13405388 Kbytes, available: 15381944 Kbytes
$ sar -w 1 100
HP-UX rmtdchp5 B.11.00 A 9000/800 12/20/02
$ sar -u 2 100 # This command generates CPU % usage information.
HP-UX rmtdchp5 B.11.00 A 9000/800 12/20/02
$ iostat 2 100
AIX:
=======
$ /usr/sbin/lsattr -E -l sys0 -a realmem
$ /usr/sbin/lsps -s
$ vmstat 5 100
$ iostat 2 100
$ /usr/local/bin/top # May not be installed by default in the server
For example:
$ /usr/sbin/lsattr -E -l sys0 -a realmem
realmem 33554432 Amount of usable physical memory in Kbytes False
NOTE: This is the total Physical + Swap memory in the system.
Use top or monitor command to get better breakup of the memory.
$ /usr/sbin/lsps -s
Total Paging Space Percent Used
30528MB 1%
Linux [RedHat 7.1 and RedHat AS 2.1]:
=======================================
$ dmesg | grep Memory
$ vmstat 5 100
$ /usr/bin/top
For example:
$ dmesg | grep Memory
Memory: 1027812k/1048568k available (1500k kernel code, 20372k reserved, 103k d)$ /sbin/swapon -s
Tru64:
========
$ vmstat -P| grep -i "Total Physical Memory ="
$ /sbin/swapon -s
$ vmstat 5 100
For example:
$ vmstat -P| grep -i "Total Physical Memory ="
Total Physical Memory = 8192.00 M
$ /sbin/swapon -s
Swap partition /dev/disk/dsk1g (default swap):
Here is some sample output from these commands:
$ prtconf |grep -i "Memory size"
Memory size: 4096 Megabytes
$ swap -s
total: 7443040k bytes allocated + 997240k reserved = 8440280k used, 2777096k available
$ df -k
...
$ top
$ vmstat 5 100
$ iostat -c 2 100
$ iostat -D 2 100
$ mpstat 2 100
HP-UX 11.0:
============
$ grep Physical /var/adm/syslog/syslog.log
$ df -k
$ sar -w 2 100
$ sar -u 2 100
$ /bin/top
$ vmstat -n 5 100
$ iostat 2 100
$ top
For example:
$ grep Physical /var/adm/syslog/syslog.log
Nov 13 17:43:28 rmtdchp5 vmunix: Physical: 16777216 Kbytes, lockable: 13405388 Kbytes, available: 15381944 Kbytes
$ sar -w 1 100
HP-UX rmtdchp5 B.11.00 A 9000/800 12/20/02
$ sar -u 2 100 # This command generates CPU % usage information.
HP-UX rmtdchp5 B.11.00 A 9000/800 12/20/02
$ iostat 2 100
AIX:
=======
$ /usr/sbin/lsattr -E -l sys0 -a realmem
$ /usr/sbin/lsps -s
$ vmstat 5 100
$ iostat 2 100
$ /usr/local/bin/top # May not be installed by default in the server
For example:
$ /usr/sbin/lsattr -E -l sys0 -a realmem
realmem 33554432 Amount of usable physical memory in Kbytes False
NOTE: This is the total Physical + Swap memory in the system.
Use top or monitor command to get better breakup of the memory.
$ /usr/sbin/lsps -s
Total Paging Space Percent Used
30528MB 1%
Linux [RedHat 7.1 and RedHat AS 2.1]:
=======================================
$ dmesg | grep Memory
$ vmstat 5 100
$ /usr/bin/top
For example:
$ dmesg | grep Memory
Memory: 1027812k/1048568k available (1500k kernel code, 20372k reserved, 103k d)$ /sbin/swapon -s
Tru64:
========
$ vmstat -P| grep -i "Total Physical Memory ="
$ /sbin/swapon -s
$ vmstat 5 100
For example:
$ vmstat -P| grep -i "Total Physical Memory ="
Total Physical Memory = 8192.00 M
$ /sbin/swapon -s
Swap partition /dev/disk/dsk1g (default swap):
Configuring Telnet/FTP to login as root (Linux)
Red Hat Enterprise Linux: RHEL3 / RHEL4
Enabling Telnet and FTP Services
Linux is configured to run the Telnet and FTP server, but by default, these services are not enabled. To enable the telnet service, login to the server as the root user account and run the following commands:
# chkconfig telnet on
# service xinetd reload
Reloading configuration: [ OK ]
Starting with the Red Hat Enterprise Linux 3.0 release (and in CentOS Enterprise Linux), the FTP server (wu-ftpd) is no longer available with xinetd. It has been replaced with vsftp and can be started from /etc/init.d/vsftpd as in the following:
# /etc/init.d/vsftpd start
Starting vsftpd for vsftpd: [ OK ]
If you want the vsftpd service to start and stop when recycling (rebooting) the machine, you can create the following symbolic links:
# ln -s /etc/init.d/vsftpd /etc/rc3.d/S56vsftpd
# ln -s /etc/init.d/vsftpd /etc/rc4.d/S56vsftpd
# ln -s /etc/init.d/vsftpd /etc/rc5.d/S56vsftpd
Allowing Root Logins to Telnet and FTP Services
Now before getting into the details of how to configure Red Hat Linux for root logins, keep in mind that this is VERY BAD security. Make sure that you NEVER configure your production servers for this type of login.
Configure Telnet for root logins
Simply edit the file /etc/securetty and add the following to the end of the file:
pts/0
pts/1
pts/2
pts/3
pts/4
pts/5
pts/6
pts/7
pts/8
pts/9
This will allow up to 10 telnet sessions to the server as root.
Configure FTP for root logins
Edit the files /etc/vsftpd.ftpusers and /etc/vsftpd.user_list and remove the 'root' line from each file.
Disable Root SSH Login on Linux
vi /etc/ssh/sshd_config
Find this section in the file, containing the line with "PermitRootLogin" in it.
#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
Make the line look like this to disable logging in through ssh as root.
PermitRootLogin no
Now you'll need to restart the sshd service:
/etc/init.d/sshd restart
Task: Disable / Turn off Linux Firewall (Red hat/CentOS/Fedora Core)
Type the following two commands (you must login as the root user):
# /etc/init.d/iptables save# /etc/init.d/iptables stop
Howto disable the iptables firewall in Linux
Task: Enable / Turn on Linux Firewall (Red hat/CentOS/Fedora Core)
Type the following command to turn on iptables firewall:
# /etc/init.d/iptables startOther Linux distribution
If you are using other Linux distribution such as Debian / Ubuntu / Suse Linux etc, try following generic procedure.
Save firewall rules
# iptables-save > /root/firewall.rules
OR
$ sudo iptables-save > /root/firewall.rulesNow type the following commands (login as root):
# iptables -X
# iptables -t nat -F
# iptables -t nat -X
# iptables -t mangle -F
# iptables -t mangle -X
# iptables -P INPUT ACCEPT
# iptables -P FORWARD ACCEPT
# iptables -P OUTPUT ACCEPT
To restore or turn on firewall type the following command:
# iptables-restore < /root/firewall.rulesGUI tools
Enabling Telnet and FTP Services
Linux is configured to run the Telnet and FTP server, but by default, these services are not enabled. To enable the telnet service, login to the server as the root user account and run the following commands:
# chkconfig telnet on
# service xinetd reload
Reloading configuration: [ OK ]
Starting with the Red Hat Enterprise Linux 3.0 release (and in CentOS Enterprise Linux), the FTP server (wu-ftpd) is no longer available with xinetd. It has been replaced with vsftp and can be started from /etc/init.d/vsftpd as in the following:
# /etc/init.d/vsftpd start
Starting vsftpd for vsftpd: [ OK ]
If you want the vsftpd service to start and stop when recycling (rebooting) the machine, you can create the following symbolic links:
# ln -s /etc/init.d/vsftpd /etc/rc3.d/S56vsftpd
# ln -s /etc/init.d/vsftpd /etc/rc4.d/S56vsftpd
# ln -s /etc/init.d/vsftpd /etc/rc5.d/S56vsftpd
Allowing Root Logins to Telnet and FTP Services
Now before getting into the details of how to configure Red Hat Linux for root logins, keep in mind that this is VERY BAD security. Make sure that you NEVER configure your production servers for this type of login.
Configure Telnet for root logins
Simply edit the file /etc/securetty and add the following to the end of the file:
pts/0
pts/1
pts/2
pts/3
pts/4
pts/5
pts/6
pts/7
pts/8
pts/9
This will allow up to 10 telnet sessions to the server as root.
Configure FTP for root logins
Edit the files /etc/vsftpd.ftpusers and /etc/vsftpd.user_list and remove the 'root' line from each file.
Disable Root SSH Login on Linux
vi /etc/ssh/sshd_config
Find this section in the file, containing the line with "PermitRootLogin" in it.
#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
Make the line look like this to disable logging in through ssh as root.
PermitRootLogin no
Now you'll need to restart the sshd service:
/etc/init.d/sshd restart
Task: Disable / Turn off Linux Firewall (Red hat/CentOS/Fedora Core)
Type the following two commands (you must login as the root user):
# /etc/init.d/iptables save# /etc/init.d/iptables stop
Howto disable the iptables firewall in Linux
Task: Enable / Turn on Linux Firewall (Red hat/CentOS/Fedora Core)
Type the following command to turn on iptables firewall:
# /etc/init.d/iptables startOther Linux distribution
If you are using other Linux distribution such as Debian / Ubuntu / Suse Linux etc, try following generic procedure.
Save firewall rules
# iptables-save > /root/firewall.rules
OR
$ sudo iptables-save > /root/firewall.rulesNow type the following commands (login as root):
# iptables -X
# iptables -t nat -F
# iptables -t nat -X
# iptables -t mangle -F
# iptables -t mangle -X
# iptables -P INPUT ACCEPT
# iptables -P FORWARD ACCEPT
# iptables -P OUTPUT ACCEPT
To restore or turn on firewall type the following command:
# iptables-restore < /root/firewall.rulesGUI tools
VNCserver Configure on Linux
What is VNCserver?
VNC stands for Virtual Network Computing.
Why use VNCserver?
In Linux, everything can be done from a shell. However, there may be a time when you need to access the machine as if you were at the console.
Getting Started
You will need several things to get started:
root privledges
VNC client software (tightVNC)
A good password!
As I mentioned above, this example is done with RHEL, which comes standard with VNCserver installed. To start the vncserver simply invoke the following commands:
[root@eit etc]# service vncserver start
Starting VNC server: [ OK ]
[root@eit etc]#
[root@eit etc]# vncpasswd
Password:
Verify:
[root@eit etc]#
[root@eit etc]# vncserver
New 'eit:1 (root)' desktop is eit:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/eit:1.log
[root@eit etc]#
[root@eit .vnc]# vi xstartup
Using vi (vim) to edit the xstartup file, make sure your file matches this one:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
OR
startx &
VNC stands for Virtual Network Computing.
Why use VNCserver?
In Linux, everything can be done from a shell. However, there may be a time when you need to access the machine as if you were at the console.
Getting Started
You will need several things to get started:
root privledges
VNC client software (tightVNC)
A good password!
As I mentioned above, this example is done with RHEL, which comes standard with VNCserver installed. To start the vncserver simply invoke the following commands:
[root@eit etc]# service vncserver start
Starting VNC server: [ OK ]
[root@eit etc]#
[root@eit etc]# vncpasswd
Password:
Verify:
[root@eit etc]#
[root@eit etc]# vncserver
New 'eit:1 (root)' desktop is eit:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/eit:1.log
[root@eit etc]#
[root@eit .vnc]# vi xstartup
Using vi (vim) to edit the xstartup file, make sure your file matches this one:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
OR
startx &
CONFIGURING NFS
Among the many different file systems that FreeBSD supports is the Network File System, also known as NFS. NFS allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files.
Some of the most notable benefits that NFS can provide are:
Local workstations use less disk space because commonly used data can be stored on a single machine and still remain accessible to others over the network.
There is no need for users to have separate home directories on every network machine. Home directories could be set up on the NFS server and made available throughout the network.
Storage devices such as floppy disks, CDROM drives, and Zip® drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.
SERVER SIDE
1. UP the Network card
2. And edit the vi /etc/hosts [insert the server & client IP and hostname]
3. vi /etc/hostname.hme0
[insert the server & client IP and hostname]
STEP 1:
# vi /etc/dfs/dfstab
..
..
..
share -o ro /usr/share/man
:wq!
STEP 2:
[Note: Stop and start the NFS server daemons]
#/etc/init.d/nfs.server stop
#/etc/init.d/nfs.server start
STEP 3:
Verify the share dir:
# share
- /usr/share/man ro " "
# dfshares [it will display the current share name]
RESOURCE SERVER ACCESS TRANSPORT
server:/usr/share/man server - -
CLIENT SIDE
# mv /usr/share/man /usr/share/man.bak
Create a new man directory (/usr/share/man) to use as a mount point.
# cd /usr/share
# mkdir man
# mount server:/usr/share/man /usr/share/man
# man ls
[now man page will work, but in the client side we moved the man page as man.bak even though it will work this is because of the NFS ]
1. To verify the list of mounts in the client provide by server
Ans: # dfmounts server
RESOURCE SERVER PATHNAME CLIENTS
- server /usr/share/man client
2. To UNMOUNT
Ans: # umount /usr/share/man
# dfmounts server
output: No output
NOTE: TO CHANGE THE HOST NAME OF THE SERVER EDIT THE BELOW FILE
/etc/inet/hosts
/etc/nodename
/etc/hostname.hme0
/etc/net/ticlts/host
/etc/net/ticots/host
/etc/net/ticotsord/host
i.e. to rename the hostname
Some of the most notable benefits that NFS can provide are:
Local workstations use less disk space because commonly used data can be stored on a single machine and still remain accessible to others over the network.
There is no need for users to have separate home directories on every network machine. Home directories could be set up on the NFS server and made available throughout the network.
Storage devices such as floppy disks, CDROM drives, and Zip® drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.
SERVER SIDE
1. UP the Network card
2. And edit the vi /etc/hosts [insert the server & client IP and hostname]
3. vi /etc/hostname.hme0
[insert the server & client IP and hostname]
STEP 1:
# vi /etc/dfs/dfstab
..
..
..
share -o ro /usr/share/man
:wq!
STEP 2:
[Note: Stop and start the NFS server daemons]
#/etc/init.d/nfs.server stop
#/etc/init.d/nfs.server start
STEP 3:
Verify the share dir:
# share
- /usr/share/man ro " "
# dfshares [it will display the current share name]
RESOURCE SERVER ACCESS TRANSPORT
server:/usr/share/man server - -
CLIENT SIDE
# mv /usr/share/man /usr/share/man.bak
Create a new man directory (/usr/share/man) to use as a mount point.
# cd /usr/share
# mkdir man
# mount server:/usr/share/man /usr/share/man
# man ls
[now man page will work, but in the client side we moved the man page as man.bak even though it will work this is because of the NFS ]
1. To verify the list of mounts in the client provide by server
Ans: # dfmounts server
RESOURCE SERVER PATHNAME CLIENTS
- server /usr/share/man client
2. To UNMOUNT
Ans: # umount /usr/share/man
# dfmounts server
output: No output
NOTE: TO CHANGE THE HOST NAME OF THE SERVER EDIT THE BELOW FILE
/etc/inet/hosts
/etc/nodename
/etc/hostname.hme0
/etc/net/ticlts/host
/etc/net/ticots/host
/etc/net/ticotsord/host
i.e. to rename the hostname
Subscribe to:
Posts (Atom)

