svn co --config-option config:miscellany:use-commit-times=yes http://IPADDRESS:9880/xyz/branches/2014.20.20
Tuesday, May 6, 2014
Sunday, May 12, 2013
Setting up PXE server on Centos 6.4 and doing network install
Centos Release :
$ cat /etc/redhat-releaseCentOS release 6.4 (Final)
We will need the following packages installed
yum install dhcp httpd tftp-server syslinux xinetd
- dhcp; Will hand out IP addresses to the clients during the boot process.
- tftp-server; This is a PXE compliant FTP server that serves the core boot files to the remote machine.
- syslinux; Handles special boot files that the remote machine needs to boot.
- httpd; Apache webserver that will host the Centos iso image or the DVD using HTTP.
Their IP addresses are
eth0 : 192.168.1.22 (connected to home router and internet - setup as static ip)
eth1 : 192.168.0.21 (connected to a switch , PXE client also will be connected to this switch)
Make sure both devices eth0 and eth1 show up when u run the command "system-config-network" as root.
If not simply add by selecting
This will create the interface files in /etc/sysconfig/network-scripts namely
ifcfg-eth0 and ifcfg-eth1
File contents below.
ifcfg-eth0
[root@xpsi7 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID="fc145c85-edb5-46a6-aef1-c6edbcd2f189"
IPADDR=192.168.1.22
PREFIX=24
GATEWAY=192.168.1.1
DNS1=209.18.47.61
DNS2=209.18.47.62
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
HWADDR=00:25:64:EE:DD:52
LAST_CONNECT=1350566375
USERCTL=no
ifcfg-eth1
[root@xpsi7 network-scripts]# cat ifcfg-eth1
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
GATEWAY=192.168.1.1
DNS1=209.18.47.61
DEVICE=eth1
BOOTPROTO=none
NETMASK=255.255.255.0
DNS2=209.18.47.62
TYPE=Ethernet
IPADDR=192.168.0.21
HWADDR=00:22:6B:C3:6D:09
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
UUID=9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04
ONBOOT=yes
[root@xpsi7 network-scripts]#
Next edit the file /etc/sysconfig/dhcpd
This will make sure that just eth1 will be used to serve dhcp.
[root@xpsi7 sysconfig]# cat dhcpd
# Command line options here
DHCPDARGS="eth1";
File : /etc/dhcp/dhcpd.conf
Change your IP's appropriately if required.
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server 192.168.0.21;
filename "/pxelinux.0";
subnet 192.168.0.0 netmask 255.255.255.0{
range 192.168.0.100 192.168.0.200;
option routers 192.168.0.21; # default gateway
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option domain-name-servers 192.168.0.10; # This DNS server does not exist.
option domain-name "xpsi7.lan";
}
Start the dhcp service
[root@xpsi7 #] service dhcpd start
Setting up Apache
Once you install Apache by "yum install apache"
it will create its Document Root in
/var/www/html
[root@xpsi7 #] mkdir centos-inst
[root@xpsi7 #] cp -r Centos_6.4_Final/* /var/www/html/centos-inst/
(you may be able to mount the .iso file if you have not burned it to a dvd using the command
mkdir /mnt/centos
mount -o loop CentOS-6.4-x86_64-bin-DVD1.iso /mnt/centos/
cp -r /mnt/centos/* /var/www/html/centos-inst/
)
Test the Apache installation by
[root@xpsi7 #] service httpd start
Try to access the page http://192.168.1.22 or http://localhost
and also http://192.168.1.22/centos-inst/
You should be able to see the Apache test page and
You should be able to see the contents of the Centos DVD that you just copied above.
Disable SELinux
# vim /etc/sysconfig/selinux
Set the line SELINUX=enforcing to
SELINUX=disabled
SELINUX=disabled
Disable SELinux immediately without a reboot
setenforce 0
setenforce 0
TFTP Setup
# mkdir /tftpboot
# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
# cp /usr/share/syslinux/menu.c32 /tftpboot/
# cp /usr/share/syslinux/memdisk /tftpboot/
# cp /usr/share/syslinux/mboot.c32 /tftpboot/
# cp /usr/share/syslinux/chain.c32 /tftpboot/
Create a directory to store your pxe config
# mkdir /tftpboot/pxelinux.cfg
PXE MENU
# vim pxelinux.cfg/default
Add the following to the default file
# create new
timeout 100
default menu.c32
menu title ########## PXE Boot Menu ##########
label 1
menu label ^1) Install CentOS 6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img method=http://192.168.1.22/centos-inst devfs=nomount
label 2
menu label ^2) Boot from local drive
localboot
configure xinit for tftp
You need to update the following two lines
server_args = -s /tftpboot
disable = no
Now the config file looks like this
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
Restart xinit for your changes to take effect
# /etc/init.d/xinetd restart
you can make sure the tftp service is running by running the "chkconfig --list" command and you should see tftp on under xinetd based services:
tftp: on
Debugging Issues:
Whenever you start a service and it FAILED check /var/log/messages to see detailed error messages and google for help.
Install Centos using PXE.
1. Connect the machine on which Centos will be installed using PXE to the switch which is also connected to the PXE server (eth1)
2. Make sure the BIOS is setup to boot using PXE and Press F12 for Boot menu and select network install.
3. The DHCP server on the Centos PXE server should hand out the IP and should present you the PXE menu.
4. Now simply install Centos following on screen instructions.
Next Steps
I want to setup virtual machines using KVM and do a network install on the same Centos server.
The host will act as PXE server and the virtual machines will be installed on the same host using network install.
Monday, February 11, 2013
Sync directories between 2 hosts using rsync
rsync -avz . -e 'ssh -p 23421' remoteuser@remote_ip:/gb500
- syncs the current directory (source) with the destination directory /gb500.
- connects on remote ssh port 23421 (changed 22 to 23421)
- syncs the current directory (source) with the destination directory /gb500.
- connects on remote ssh port 23421 (changed 22 to 23421)
Sunday, December 16, 2012
Emacs cheatsheet
emacs customization files
--------------------------------------
.emacs.d (customizations)
init.el (loaded everytime)
Starter Kit
----------------
emacs-starter-kit (github)
Frames
-----------
M-x make-frame
M-x make-frame-on-display
Misc
--------
M-x man
C-x h (select all text of current buffer)
M-x untabify (to replace tabs with spaces)
Region
----------
Mark region then
C-x C-i (to indent the region)
Open Lines Like vi
The
‘o’ and ‘O’ commands of vi are closely equivalent to ‘C-a C-M-o’ and ‘C-e C-j’ Switching between buffers
---------------------------------------
C-x b <----> C-x b (switch buffers)---->
C-x C-b D - Delete , U - undo , X - when done.
Help
------
C-h k
C-h i (info page)
C-h f (describe function)
C-h a (apropos)
C-h t (tutorial)
CUA MODE
----------------
M-x cua-mode
C-space (mark) then C-ENTER then move cursor to select region
press C-enter again.
Now start editing anywhere in the block. The effect will be that
the text will appear on all lines of the region.
M-n (to start line numbering within the region)
Commenting
------------------
M-; (acts on a region or when no region then single line)
Completion
----------------
M-/
? send buffer to end of list.
TAGS
--------
ctags -a -e -f TAGS *
find ... | xargs ctags -a -e -f TAGS
M-. (find the tag for the text at cursor)
M-x visit-tags-table
Modes
----------
M-x whitespace-mode ( colors - yellow - mixed
black - too long
red - trailing white spaces)
M-x follow-mode
M-x whitespace-report
C-h a whitespace
M-x fly-spell-mode (spell checking)
- to see the suggestions for spelling fix , middle mouse click on word
or Esc-\t in text mode
M-x flymake-mode (to check syntax for the lang as u type)
Hooks?
M-x eval-buffer ?
Version Control
-----------------------
M-x vc-mode
C-x v (diff against HEAD)
C-x vn revision ??
C-x vl (view commit log)
C-x vi (add file)
magit -- git extension for emacs
SHELL
---------
M-x shell
M-x shell-command
M-x shell-command-on-region
M-x eshell
$ ls > #
ELPA (Emacs Lisp Package Archive)
--------
M-x package-list-packages
i (mark package)
x (install marked packages)
download to .emacs.d
color-theme.el
yasnippet.el (textmate)
M-x irc
M-x tetris
Good Websites for Emacs
www.emacswiki.com
planet.emacsen.org
Monday, September 10, 2012
calculating running total with Oracle SQL
-Analytical functions in Oracle.
SELECT rownum ,
SUM(rownum) over (order by rownum rows BETWEEN unbounded preceding AND CURRENT row) AS running_total , (rownum * (rownum+1))/2 as formula
FROM dual
CONNECT BY rownum < 11;
The above can be used with a real table. The order by can be any columns that you wish to order the rows by and sum() can be on a column that you wish to calculate running total on.
SELECT rownum ,
SUM(rownum) over (order by rownum rows BETWEEN unbounded preceding AND CURRENT row) AS running_total , (rownum * (rownum+1))/2 as formula
FROM dual
CONNECT BY rownum < 11;
The above can be used with a real table. The order by can be any columns that you wish to order the rows by and sum() can be on a column that you wish to calculate running total on.
Friday, August 17, 2012
PL/SQL function to create insert script for a table
-- The following function will create an insert script for a given table.
-- Usage : select get_insert_script('EMP') from dual;
-- This will output to stdout the insert script.
-- Now you may later change the where clause to select a subset of rows from the table.
-- Where its userful:
-- I dont have export priv on production database. I can't really use export the table.
-- This provides an easy way to pull data and then insert into DEV environment to REFRESH the table
--Another alternative way is to select the data as delimited by say comma and then
-- write a sqlloader control file to load the data. This will be faster.
create or replace
FUNCTION GET_INSERT_SCRIPT (V_TABLE_NAME VARCHAR2)
RETURN VARCHAR2 AS
B_FOUND BOOLEAN := FALSE;
V_TEMPA VARCHAR2 (8000);
V_TEMPB VARCHAR2 (8000);
V_TEMPC VARCHAR2 (255);
BEGIN
FOR TAB_REC IN (SELECT TABLE_NAME
FROM ALL_TABLES
WHERE TABLE_NAME = UPPER (V_TABLE_NAME)) LOOP
B_FOUND := TRUE;
V_TEMPA := 'select ''insert into ' || TAB_REC.TABLE_NAME || ' (';
FOR COL_REC IN (SELECT *
FROM ALL_TAB_COLUMNS
WHERE TABLE_NAME = TAB_REC.TABLE_NAME
ORDER BY COLUMN_ID) LOOP
IF COL_REC.COLUMN_ID = 1 THEN
--V_TEMPA := V_TEMPA || '''||chr(10)||''';
null;
ELSE
V_TEMPA := V_TEMPA || ',';
V_TEMPB := V_TEMPB || ',';
END IF;
V_TEMPA := V_TEMPA || COL_REC.COLUMN_NAME;
IF INSTR (COL_REC.DATA_TYPE, 'CHAR') > 0 THEN
V_TEMPC := '''''''''||' || COL_REC.COLUMN_NAME || '||''''''''';
ELSIF INSTR (COL_REC.DATA_TYPE, 'DATE') > 0 THEN
V_TEMPC :=
'''to_date(''''''||to_char('
|| COL_REC.COLUMN_NAME
|| ',''mm/dd/yyyy hh24:mi:ss'')||'''''',''''mm/dd/yyyy hh24:mi:ss'''')''';
ELSIF INSTR (COL_REC.DATA_TYPE, 'TIMESTAMP') > 0 THEN
V_TEMPC :=
'''to_timestamp(''''''||to_char('
|| COL_REC.COLUMN_NAME
|| ',''mm/dd/yyyy hh24:mi:ss.ff'')||'''''',''''mm/dd/yyyy hh24:mi:ss.ff'''')''';
ELSE
V_TEMPC := COL_REC.COLUMN_NAME;
END IF;
V_TEMPB :=
V_TEMPB
|| '''||decode('
|| COL_REC.COLUMN_NAME
|| ',Null,''Null'','
|| V_TEMPC
|| ')||''';
END LOOP;
V_TEMPA :=
V_TEMPA
|| ') values ('
|| V_TEMPB
|| ');'' from '
|| TAB_REC.TABLE_NAME
|| ';';
END LOOP;
IF NOT B_FOUND THEN
V_TEMPA := '-- Table ' || V_TABLE_NAME || ' not found';
ELSE
V_TEMPA := V_TEMPA || CHR (10) || 'select '' commit;'' from dual;';
END IF;
RETURN V_TEMPA;
END;
-- Usage : select get_insert_script('EMP') from dual;
-- This will output to stdout the insert script.
-- Now you may later change the where clause to select a subset of rows from the table.
-- Where its userful:
-- I dont have export priv on production database. I can't really use export the table.
-- This provides an easy way to pull data and then insert into DEV environment to REFRESH the table
--Another alternative way is to select the data as delimited by say comma and then
-- write a sqlloader control file to load the data. This will be faster.
create or replace
FUNCTION GET_INSERT_SCRIPT (V_TABLE_NAME VARCHAR2)
RETURN VARCHAR2 AS
B_FOUND BOOLEAN := FALSE;
V_TEMPA VARCHAR2 (8000);
V_TEMPB VARCHAR2 (8000);
V_TEMPC VARCHAR2 (255);
BEGIN
FOR TAB_REC IN (SELECT TABLE_NAME
FROM ALL_TABLES
WHERE TABLE_NAME = UPPER (V_TABLE_NAME)) LOOP
B_FOUND := TRUE;
V_TEMPA := 'select ''insert into ' || TAB_REC.TABLE_NAME || ' (';
FOR COL_REC IN (SELECT *
FROM ALL_TAB_COLUMNS
WHERE TABLE_NAME = TAB_REC.TABLE_NAME
ORDER BY COLUMN_ID) LOOP
IF COL_REC.COLUMN_ID = 1 THEN
--V_TEMPA := V_TEMPA || '''||chr(10)||''';
null;
ELSE
V_TEMPA := V_TEMPA || ',';
V_TEMPB := V_TEMPB || ',';
END IF;
V_TEMPA := V_TEMPA || COL_REC.COLUMN_NAME;
IF INSTR (COL_REC.DATA_TYPE, 'CHAR') > 0 THEN
V_TEMPC := '''''''''||' || COL_REC.COLUMN_NAME || '||''''''''';
ELSIF INSTR (COL_REC.DATA_TYPE, 'DATE') > 0 THEN
V_TEMPC :=
'''to_date(''''''||to_char('
|| COL_REC.COLUMN_NAME
|| ',''mm/dd/yyyy hh24:mi:ss'')||'''''',''''mm/dd/yyyy hh24:mi:ss'''')''';
ELSIF INSTR (COL_REC.DATA_TYPE, 'TIMESTAMP') > 0 THEN
V_TEMPC :=
'''to_timestamp(''''''||to_char('
|| COL_REC.COLUMN_NAME
|| ',''mm/dd/yyyy hh24:mi:ss.ff'')||'''''',''''mm/dd/yyyy hh24:mi:ss.ff'''')''';
ELSE
V_TEMPC := COL_REC.COLUMN_NAME;
END IF;
V_TEMPB :=
V_TEMPB
|| '''||decode('
|| COL_REC.COLUMN_NAME
|| ',Null,''Null'','
|| V_TEMPC
|| ')||''';
END LOOP;
V_TEMPA :=
V_TEMPA
|| ') values ('
|| V_TEMPB
|| ');'' from '
|| TAB_REC.TABLE_NAME
|| ';';
END LOOP;
IF NOT B_FOUND THEN
V_TEMPA := '-- Table ' || V_TABLE_NAME || ' not found';
ELSE
V_TEMPA := V_TEMPA || CHR (10) || 'select '' commit;'' from dual;';
END IF;
RETURN V_TEMPA;
END;
Saturday, August 11, 2012
perl one liners
Social Engineering, Cooperating with Command Interpreters - Very good chapter in Programming Perl book.
To print the last field in a tab delimited text
ls -al | perl -ane 'print pop(@F), "\n"'
-- The main thing to take away here is the -an flag and the @F list.
-- different delimiter can be provided with -F flag.
or in awk.
ls -al | awk '{print $NF}'
To print the last field in a tab delimited text
ls -al | perl -ane 'print pop(@F), "\n"'
-- The main thing to take away here is the -an flag and the @F list.
-- different delimiter can be provided with -F flag.
or in awk.
ls -al | awk '{print $NF}'
Subscribe to:
Posts (Atom)
Followers
About Me
- reiki
- Torrance, CA, United States