Linux OpenSSH Advanced Video Tutorial

Jephe Wu - http://linuxtechres.blogspot.com

Objective: Value-add advanced Linux OpenSSH video tutorial made free to everyone.

Video course 1: OpenSSH chroot sftp part I  with PDF tutorial

Video course 2: OpenSSH chroot sftp part II with PDf tutorial

Video course 3: OpenSSH chroot sftp Part III with PDF tutorial

Video course 4: SSH passwordless login with PDF tutorial

Video course 5: SSH transparent proxy with PDF tutorial


Video course 6: SSH local port forwarding with PDF tutorial

Video course 7: SSH remote port forwarding with PDF tutorial

Video course 8: SSH gateway ports local  with PDF tutorial

Video course 9: SSH gateway ports remote with PDF tutorial

Video course 10: SSH socks proxy with PDF tutorial

Video course 11: SSH http proxy with PDF tutorial 


Video course 12: SSH agent with PDF tutorial 

Video course 13: OpenSSH screen with PDF tutorial

Video course 14: OpenSSH keepalive with PDF tutorial

Video course 15: OpenSSH troubleshooting I with PDF tutorial

Video course 16: OpenSSH troubleshooting II with PDF tutorial

How to Install Oracle VM Server 3.2 and 3.3 from USB Key

Jephe Wu - http://linuxtechres.blogspot.com


Objective:  to install Oracle VM server 3.2.8 or 3.3.2 from USB key for those server without DVD/CDROM drive

Steps on Linux Mint 17 

Preparing USB key
Make partition by fdisk /dev/sdb1, make it as W95 FAT32 (b) type
fdisk /dev/sdb
L , b , wq
format it by running mkfs -t vfat /dev/sdb1

use unetbootin 

install unetbootin software from Mint 17 software manager. 

copy ISO file into /dev/sdb1

mount /dev/sdb1 under Linux mint , copy OVS3.2.8 iso file to it directly, without creating any folder.

boot from USB to install OVMS 3.2.8

choose installation method 'Hard drive', selection partiton /dev/sdb1 which contain installation image 
at partition type screen, deselect sdb
at 'boot loader configuration' screen, choose 'change drive order' to use sda, then use sda to install MBR

Steps on Windows

Install unetbootin
format USB key as FAT format
use unetbootin to write iso file to it as above
copy iso file into USB key directly

FAQ

format it as ext2 or ext3 and use unetbootin to write iso file doesn't boot if you didn't install extlinux package from Mint software manager.
Notes
The size of OVM 3.3 iso file size is now doubled compared to OVMS 3.2.9. 1GB USB key is now not able to fit.



How to decide ethX layout after Oracle VM Server 3.2 Installation

Jephe Wu - http://linuxtechres.blogspot.com

Objective: to decide ethX layout remotely after Oracle VM Server 3.2 installation.
Environment: Oracle VM server 3.2.9

If you are in front of the physical server, you can decide ethX layout easily by running 'ethtool -p ethX' etc to blink each NIC light. e.g. ethtool -p eth0

How Oracle VM server to decide which NIC for which ethX
based on pci bus address from low to high to assign eth0, eth1 etc

Theory behind

  • Os will assign ethX sequence based on NIC PCI bus address sequence
  • 4 NICs onboard are actually 2 dualports cards
  • For additional PCI card, the ports near the bottom pins are getting high pci bus number, from ethX is assigned from top to bottom.
  • Sometimes, pci bus address has primary-secondary relationships, 


Check steps

Get server model, pci NIC slot direction, PCI numbering sequence physically etc first
/sys/class/net 
[root@cpnrglobovms13 device]# more /sys/class/net/eth0/device/label
Intel 82576 Ethernet Controller.
to decide pci bus address and ethX alighment
ll /sys/class/net
List ethX bus information - ethtool -i ethX
[root@ovms01 ~]# for i in `ifconfig -a | grep ^eth | awk '{print $1}' | xargs`; do echo -n "$i " && ethtool -i $i| grep -i bus ; done
eth0 bus-info: 0000:01:00.0
eth1 bus-info: 0000:01:00.1
eth2 bus-info: 0000:02:00.0
eth3 bus-info: 0000:02:00.1
eth4 bus-info: 0000:04:00.0
eth5 bus-info: 0000:04:00.1
eth6 bus-info: 0000:07:00.0
eth7 bus-info: 0000:07:00.1
eth8 bus-info: 0000:08:00.0
eth9 bus-info: 0000:08:00.1
lspci to get ethernet NICs - lspci | grep -i eth

[root@ovms01 ~]# lspci | grep -i eth
01:00.0 Ethernet controller: Broadcom Corporation Device 165f
01:00.1 Ethernet controller: Broadcom Corporation Device 165f
02:00.0 Ethernet controller: Broadcom Corporation Device 165f
02:00.1 Ethernet controller: Broadcom Corporation Device 165f
04:00.0 Ethernet controller: Intel Corporation Device 154d (rev 01)
04:00.1 Ethernet controller: Intel Corporation Device 154d (rev 01)
07:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)
07:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)
08:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)
08:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)

lspci bridge to secondary  - lspci -vvv | grep primary
05:00 -> 06:00 -> 07:00 and 08:00
[root@hmspglobovms01 device]# lspci -vvv | grep primary
Bus: primary=00, secondary=02, subordinate=02, sec-latency=0
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
Bus: primary=00, secondary=04, subordinate=04, sec-latency=0
Bus: primary=00, secondary=03, subordinate=03, sec-latency=0
Bus: primary=00, secondary=05, subordinate=08, sec-latency=0
Bus: primary=00, secondary=09, subordinate=09, sec-latency=0
Bus: primary=00, secondary=0a, subordinate=0a, sec-latency=0
Bus: primary=00, secondary=0b, subordinate=0f, sec-latency=0
Bus: primary=00, secondary=10, subordinate=10, sec-latency=32
Bus: primary=05, secondary=06, subordinate=08, sec-latency=0
Bus: primary=06, secondary=07, subordinate=07, sec-latency=0
Bus: primary=06, secondary=08, subordinate=08, sec-latency=0
Bus: primary=0b, secondary=0c, subordinate=0f, sec-latency=0
Bus: primary=0c, secondary=0d, subordinate=0e, sec-latency=0
Bus: primary=0c, secondary=0f, subordinate=0f, sec-latency=0
Bus: primary=0d, secondary=0e, subordinate=0e, sec-latency=0
dmidecode to list PCI slot information 
[root@ovms01 ~]# dmidecode -t 9
# dmidecode 2.10
SMBIOS 2.7 present.
# SMBIOS implementations newer than version 2.6 are not
# fully supported by this version of dmidecode.

Handle 0x0900, DMI type 9, 17 bytes
System Slot Information
Designation: PCI1
Type: x8 <OUT OF SPEC>
Current Usage: In Use
Length: Long
Characteristics:
3.3 V is provided
PME signal is supported
Bus Address: 0000:04:00.0

Handle 0x0901, DMI type 9, 17 bytes
System Slot Information
Designation: PCI2
Type: x16 <OUT OF SPEC>
Current Usage: In Use
Length: Long
Characteristics:
3.3 V is provided
PME signal is supported
Bus Address: 0000:05:00.0

dmidecode to get onboard device information
[root@ovms01 ~]# dmidecode -t 41  or dmidecode -t slot
# dmidecode 2.10
SMBIOS 2.7 present.
# SMBIOS implementations newer than version 2.6 are not
# fully supported by this version of dmidecode.
Handle 0x2900, DMI type 41, 11 bytes
Onboard Device
Reference Designation: Integrated NIC 1
Type: Ethernet
Status: Enabled
Type Instance: 1
Bus Address: 0000:01:00.0
Handle 0x2901, DMI type 41, 11 bytes
Onboard Device
Reference Designation: Integrated NIC 2
Type: Ethernet
Status: Enabled
Type Instance: 2
Bus Address: 0000:01:00.1
Handle 0x2902, DMI type 41, 11 bytes
Onboard Device
Reference Designation: Integrated NIC 3
Type: Ethernet
Status: Enabled
Type Instance: 3
Bus Address: 0000:02:00.0
Handle 0x2903, DMI type 41, 11 bytes
Onboard Device
Reference Designation: Integrated NIC 4
Type: Ethernet
Status: Enabled
Type Instance: 4
Bus Address: 0000:02:00.1

lspci to get ethernet NIC information
[root@ovms01 ~]# lspci | grep -i ethernet

dmidecode to get PCI card information
[root@ovms01 ~]# dmidecode -t slot | grep -e Designation -e Bus

use ethtool to decide bus info
[root@ovms10 ~]# for i in `ifconfig -a | grep ^eth | awk '{print $1}' | xargs`; do echo -n "$i " && ethtool -i $i| grep -i bus ; done 
eth0 bus-info: 0000:01:00.0
eth1 bus-info: 0000:01:00.1
eth2 bus-info: 0000:04:00.0
eth3 bus-info: 0000:04:00.1
eth4 bus-info: 0000:42:00.0
eth5 bus-info: 0000:42:00.1
eth6_rename bus-info: 0000:07:00.0
eth7_rename bus-info: 0000:07:00.1
dmesg to get PCI slot cards MAC address
[root@ovms01 ~]# dmesg | grep 'PCI Express'
pciehp: PCI Express Hot Plug Controller Driver version: 0.4
ixgbe: Intel(R) 10 Gigabit PCI Express Network Driver - version 3.4.8-k
ixgbe 0000:08:00.0: (PCI Express:5.0GT/s:Width x8) 90:e2:ba:19:a6:80
ixgbe 0000:08:00.1: (PCI Express:5.0GT/s:Width x8) 90:e2:ba:19:a6:81
ixgbe 0000:0e:00.0: (PCI Express:5.0GT/s:Width x8) 90:e2:ba:19:a5:ac
ixgbe 0000:0e:00.1: (PCI Express:5.0GT/s:Width x8) 90:e2:ba:19:a5:ad
ixgbe 0000:0f:00.0: (PCI Express:5.0GT/s:Width x8) 90:e2:ba:19:58:20
ixgbe 0000:0f:00.1: (PCI Express:5.0GT/s:Width x8) 90:e2:ba:19:58:21
bnx2 0000:01:00.0: eth0: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem f2000000, IRQ 36, node addr d4:ae:52:e6:83:a0
bnx2 0000:01:00.1: eth1: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem f4000000, IRQ 48, node addr d4:ae:52:e6:83:a2
bnx2 0000:02:00.0: eth2: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem f6000000, IRQ 37, node addr d4:ae:52:e6:83:a4
bnx2 0000:02:00.1: eth3: Broadcom NetXtreme II BCM5709 1000Base-T (C0) PCI Express found at mem f8000000, IRQ 49, node addr d4:ae:52:e6:83:a6


to get each PCI bus address MAC address:
[root@ovms1 ~]# dmesg | grep 02:00.0 | grep 'PCI Express'
Kickstart to swap eth2/eth3 and eth6/eth7 for better reading if necessary
echo "fixing ethX device sequence"
ETH2=`dmesg | grep Express | grep "30:00.0" | awk '{print $NF}'`
ETH3=`dmesg | grep Express | grep "30:00.1" | awk '{print $NF}'`
ETH6=`dmesg | grep Express | grep "88:00.0" | awk '{print $NF}'`
ETH7=`dmesg | grep Express | grep "88:00.1" | awk '{print $NF}'`


cd /etc/sysconfig/network-scripts
sed -i -e "s/^HWADDR.*/HWADDR=$ETH6/g" ifcfg-eth2
sed -i -e "s/^HWADDR.*/HWADDR=$ETH7/g" ifcfg-eth3
sed -i -e "s/^HWADDR.*/HWADDR=$ETH2/g" ifcfg-eth6
sed -i -e "s/^HWADDR.*/HWADDR=$ETH3/g" ifcfg-eth7

Draw ethX layout at last step
example below:
PCI1
RAID Controller
PCI2
00:42.00.1(eth5)(pin) 00:42.00.0(eth4)
PCI3
00:04:00.0(eth2) 00:04:00.1(eth3)(pin)
eth0
00:01:00.0
eth1
00:01:00.1
eth6 (X)
00:07:00.0
eth7 (X)
00:07:00.1
Ultimate way to associate ethX with PCI bus address
[root@ovms10 rules.d]# more 99-ethernet.rules
KERNEL=="eth*", ID=="0000:01:00.0", name="eth0"
KERNEL=="eth*", ID=="0000:01:00.1", name="eth1"
KERNEL=="eth*", ID=="0000:04:00.0", name="eth2"
KERNEL=="eth*", ID=="0000:04:00.1", name="eth3"
KERNEL=="eth*", ID=="0000:42:00.0", name="eth4"
KERNEL=="eth*", ID=="0000:42:00.1", name="eth5"
KERNEL=="eth*", ID=="0000:07:00.0", name="eth6"
KERNEL=="eth*", ID=="0000:07:00.1", name="eth7"

[root@ovms10 rules.d]# ethtool -i eth0
driver: ixgbe
version: 3.4.8-k
firmware-version: 4.2-8
bus-info: 0000:01:00.0

Calculate Oracle Database Size


Objective:  to calculate all kinds of database sizes.
Items:

Size of datafiles in MB
select sum(bytes)/(1024*1024) from dba_data_files;
 
 
Size of tempfiles in MB
select sum(bytes)/(1024*1024) from dba_temp_files;
 
 
Size of redo logs in MB 
Not accounting for mirrored redolog files:
select sum(bytes)/(1024*1024) from v$log;
 
 
To get the used-up space of your datafiles:
This will give you the total used-up space inside the database in MB.
select sum(bytes)/(1024*1024) from dba_segments;
 
 
Total Size of the database:
Also accounting for controlfiles and mirrored redolog files.
select a.data_size+b.temp_size+c.redo_size+d.cont_size "total_size"
from ( select sum(bytes) data_size
       from dba_data_files ) a,
     ( select nvl(sum(bytes),0) temp_size
       from dba_temp_files ) b,
     ( select sum(bytes) redo_size
       from sys.v_$logfile lf, sys.v_$log l
       where lf.group# = l.group#) c,
     ( select sum(block_size*file_size_blks) cont_size
       from v$controlfile ) d;
 
 
 
Total Size and free size:
select round(sum(used.bytes) / 1024 1024 ) || ' MB' "Database Size"
, round(free.p / 1024 1024) || ' MB' "Free space"
from (select bytes from v$datafile
 union all
 select bytes from v$tempfile
 union all
 select bytes from v$log) used
, (select sum(bytes) as p from dba_free_space) free
group by free.p;
 
Individual tablespace size:
select tablespace_name as "Tablespace Name",sum(bytes)/(1024*1024) as "Size"
from dba_data_files
 group by tablespace_name
 ORDER BY 1;
 
Individual tablespace used size:
select tablespace_name as "Tablespace Name",sum(bytes)/(1024*1024) as "Used Size"
from dba_segments
 GROUP BY TABLESPACE_NAME
 order by 1;
 
Individual tablespace free space:
select tablespace_name as "Tablespace Name", sum(bytes)/(1024*1024) as "Free Space"
 from dba_free_space
 group by tablespace_name
 order by 1;

References:
How to Calculate the Size of the Database (Doc ID 1360446.1)