Notes For SysAdmins PDF Print E-mail
Written by notes-for-sysadmins   
Thursday, 22 October 2009 18:00

  • Script to import latest ldif

=====================
////////////////////
=====================
#!/bin/bash
set -e
host= uname -n
read -s -p "Enter Password: " mypassword
ldapsearch -x -h ldap-vip -D cn=admin,dc=netflix, \
dc=net -w $mypasswd -LL > latest.ldif
service ldap stop
date=`date +%Y%m%d`
mv /var/lib/ldap /var/lib/ldap.$date
mkdir -p /var/lib/ldap
chown ldap /var/lib/ldap
ldapadd -x -h $host -D cn=admin, dc=netflix, \
dc=net -w $mypasswd < latest.ldif
service ldap start
exit

  • Tar and Save Home Dirs

===============
///////////////
===============

#!/usr/bin/perl

@namelist = qw(bmcarthy dwells emertz lkilgore \
dhyman jbecker blo arendich smclendon nsavage koss \
sswasey benderwick nrothstein twillerer mstern \
poeschger tsarandos slee pkirincich jmeir lbritton \
mlowe eziegler);
foreach $name (@namelist) {
system("tar cvf - ./$name | gzip -c > ./$name.tar.gz");
}
exit;

  • changeip of lpar


===============
///////// Top
===============
get on blade
open lpar link
choose ethernet tab
choose the network number of the ip
you were assigned i.e.., 10.192.24.77 would be (24)
click ok
activate machine
change ip
you're done
what about dns?
goto ako and change the a record

  • Kickstart Notes

==============
//////// Top
==============
Here is the kickstart server information to kickstart et01.enc.
Please verify with Dax if he needs to retain any data before kickstarting the server.
With this process, we may lose data on this host.
Please confirm before proceeding.
Kickstart server – 10.195.96.50 – you can only login to this server from
another etxx server. Password is in getpp and it is the rackable password Abl3Rack


Update dhcpd.conf to include the IP address for et01.enc.

OS distribution -- /apps/rdm/dist/es40u4

Kickstart file to use -- /apps/rdm/dist/es40u4/ks/et.ks


You may need to tweak the et.ks file a little to make it work as I just copied the file from another server.

Give it a try and let me know if you experience any issues.

Cannot obtain the MAC address on the machine~

[brbills@mvs101]~ 22> sudo su -

[root@mvs101]~ 1000> telnet netcons01.enc1.netflix.com 7043
Trying 10.195.2.32...
Connected to netcons01.enc1.netflix.com (10.195.2.32).
Escape character is '^]'.

Could not find it in the wiki or on itinv.


The file should be /etc/dhcpd.conf to update.

We need to –

1. Update /etc/dhcpd.conf with the mac address for the host.
2. Restart dhcpd daemon on the host – check /var/log/messages to ensure they are restarted properly.
3. Create file in /tftpboot/pxelinux.cfg directory to include the ks file we want to use.
4. Reboot the server and dhcp client should pick up the configuration.
5. Good luck!

Cindy

  • Install perl modules

=================
/////////// Top
=================
Perl Module install –

perl -MCPAN -e shell
Install IO::String
install Bundle::CPAN
install DBD::Oracle

  • Oracle DB Connect

=================
//////////// Top
=================

BEGIN {

# Check for ORACLE_HOME set
if (! $ENV{ORACLE_HOME}) {
my $cmd = "export ORACLE_HOME=" . `pwd`;
die "Please run the following command:\n $cmd\n";
}
my $home = $ENV{ORACLE_HOME};

my @questions = (
["What platform is this (solaris, linux, hpux-risc, windows)", "linux"],
["What version is the Application Server (10.1.2, 10.1.3)", "10.1.2"],
["What is the database server name", "server.us.oracle.com"],
["What is the database port", "1521"],
["What is the database SID", "orcl"],
["What is the database username", "scott"],
["What is the database password", "tiger"],
);

@values;
for(my $x=0; $x<@questions; $x++) {
print $questions[$x][0] . ' [' . $questions[$x][1] . '] ? ';
my $tmp = <STDIN>;
chomp($tmp);
if ($tmp =~ /\S+/) { push @values, $tmp; }
else { push @values, $questions[$x][1]; }
}

my $platform = shift(@values);
my $version = shift(@values);

# Check for LD_LIBRARY_PATH set if linux
if (! $ENV{LD_LIBRARY_PATH} && $platform =~ /linux/) {
my $cmd = "export LD_LIBRARY_PATH=$home/lib32:$home/lib";
die "Please run the following command:\n $cmd\n";
}

$perl_version = "5.6.1" if ($version =~ /10.1.2/);
$perl_version = "5.8.3" if ($version =~ /10.1.3/);

$perl_platform = "i686-linux" if ($platform =~ /linux/);
$perl_platform = "sun4-solaris" if ($platform =~ /solaris/);
$perl_platform = "PA-RISC2.0" if ($platform =~ /hpux-risc/);
$perl_platform = "MSWin32-x86" if ($platform =~ /windows/);

# Set the appropriate classpaths
unshift
print "Test DBI\n========\n";
foreach my $row (@row_ary) { print $row . "\n"; }
print "\n\n";

  • The following replaces white spaces
  • in file names with under scores:

===============================================
///////////////////////////////// Top
===============================================

Administrator@helios ~
$ more changename.pl
#!/usr/bin/perl
use strict;
use warnings;
opendir(FH, ".") or die "Could not open directory: $!\n";
my @files = readdir FH;
closedir FH;

foreach my $old_name (@files) {
next if ($old_name eq '..' or $old_name eq '.');
my $new_name = $old_name;
$new_name =~ s/\s/_/g;
# replacing whitespace with underscore
if ($old_name ne $new_name) {
rename($old_name, $new_name) or die "Could not rename $old_name to
$new_name: $!";
print "Renamed '$old_name' to '$new_name'.\n"
}

}

Bash replace file extensions
==================================
#!/usr/bin/bash
for i in *.htm ; do mv $i `echo $i | sed 's/htm/html/'` ; done


Same as above but recursive:
==================================
brbills@lglt-brbills /var/www/htdocs
$ find . -name "*.htm" -exec bash -c "mv \$1 \`echo \$1 | sed s/.htm/.html/\`" \
-- {} \;


Same as above different method:
==================================
old_ext=htm
new_ext=html
find . -type f -name "*.$old_ext" -print | while read file
do
mv $file ${file%${old_ext}}${new_ext}
done


Here’s how Python deals with replacing spaces in file names with an underscore:
====================================
import os

for dirpath, dirs, files in os.walk(your_path):

for filename in files:
if ' ' in filename:

os.rename(

os.path.join(dirpath, filename),

os.path.join(dirpath, filename.replace(' ', '_')

)
)

  • Create LPAR

================
///////// Top
================
BC contains blades which have lpars which can be aix or linux ppc
VIO = IVM, Webgui, i.e.., http://bs2304-vio
blogicas:/apps/sysadmin/lbin
createLPAR -b blade -h hostname -v vlan
weburl = blogicas/lpar/cgi-bin
blogic10:/apps/rdm/setupRemote (for post install)
PROD / TES
FE = www, nccp, api, prize
MT = wcs, mds
b4 you run the setup remote you must first ip
the machine and put it's a record in dns.
You boot up the lpar and press 1
select the disk you want to boot off of
boot single
run script to ip the machine
for prizeqa2
boot all the way up
setupRemote -c TEST -l FE -t prize -i prizeqa2
if you're migrating you can use a fake ip
prize100 10.192.32.70
prize100-new 10.192.32.71
do a post install on the .71 address because
the other is still production
the php.ini file is still in
monster:/tmp get it and store it somewhere safe
-i prize100:10.192.32.701

[root@blogicas(qw)]/apps/sysadmin/lbin 695> ./createLPAR bs2213-vio prizeqa2 32

./createLPAR -b BLADNAME -h HOSTNAME -v VLAN

b - blade name
h - host name
v - vlan

optional:

g - goldimage vdisk
t - type (linux or aix) defaults to linux

Notes:

goldimages are default for linux per DC1 and DC2 (svcprod/svcprod2)
defined per blade center)

options g and t are NOT required for linux builds unless you want to
copy a different disk image than the pre-defined gold.

  • clearing space on fds10

============================
///////////////////// Top
============================

Delete only log files that are two or more days old.

find /apps/fds/tomcat/logs -name *.log -mtime +2 -exec rm -f {} \;
find /apps/fds/tomcat/logs/cores -name *.log -mtime +2 -exec rm -f {};
find /var/spool/clientmqueue -name *.log -mtime +2 -exec rm -f {};

  • Install test kernel

================
////////// Top
================
go to http://bs2103-vio or the blade that you lpar is on
terminal windows
login
0:mon>zr
login from putty
cd /tmp
scp nimmaster:/export/nim/sw/redhat/kernel-2.6.9-78.0.4.EL.0.IT221934.ppc64.rpm .
rpm -ivh kernel-2.6.9-78.0.4.EL.0.IT221934.ppc64.rpm
reboot
uname -a 2.6.9-78.0.4.EL.0.IT221934

  • Update external DNS

========================
/////////////////// Top
========================

Editing any zone:

Checkout the zone you need to edit from either the forward or reverse directory

$ cd /apps/named/var/named/forward # or reverse

$ p4 -u username edit nameofzonefile

Perform the necessary changes and *UPDATE* the serial number in the SOA

$ vi nameofzonefile

Check your edits against Perforce

$ /apps/named/check.sh

Restart named

$ /apps/named/named.sh restart

Audit /var/log/messages to confirm all is well

$ grep -A 4 'zone {zonename}/IN' /var/log/messages

Test zone lookups from another host ( preferably external ) using nslookup.
Pay close attention that the SOA value has actually been updated

$ nslookup -type=SOA www.somedomain.com dns.netflix.com

Commit changes to perforce

$ p4 -u username submit filename

be sure to be descriptive in the description field for the change

ssh aladdin (I have to sudo su - on monster and then ssh to aladdin to get on)
cd /apps/named/var/named/forward
Put "." after any fqdn's otherwise bind will append another domain to it
p4 -u brbills edit netflix.com
vi netflix.com
Update your records i.e..,
gslbtesat.netflix.com. IN NS gslbdns.netflix.com.
gslbdns IN A 208.75.79.9
gslbdns IN A 208.75.76.9
update the serial number at the top i.e.., 2009082100
(the 00 is for multiple times per day so if you
changed the file again today you would call it 2009082101 and so on.
p4 -u brbills submit netflix.com
/apps/named/named.sh restart
grep -A 4 'zone netflix.com/IN' /var/log/messages
Look for the updated serial number
Use a public dns server to resolve the host name.
Internal servers do not see the external records.
[root@aladdin]/apps/named/var/named/forward 1012> nslookup
> server 151.197.0.38
Default server: 151.197.0.38
Address: 151.197.0.38#53
> gslbdns.netflix.com
Server: 151.197.0.38
Address: 151.197.0.38#53

Non-authoritative answer:
Name: gslbdns.netflix.com
Address: 208.75.79.9
Name: gslbdns.netflix.com
Address: 208.75.76.9
Here's a url for perforce to check your work:
http://perforce.netflix.com:8080/depot/ITOps/Apps/named/external/var/named/forward/?ac=83

  • Up2date

===============
////////// Top
===============
# up2date --show-groups

Update packages in a group

# up2date -u "@<group name>"

Install all the default packages by group

# up2date "@<group name>"

kbase article that translates yum commands into up2date
kbase.redhat.com
article id 2531

 

  • Find difference Between 2 Files
===============
////////// Top
===============

I had to restore hundreds of huge movie files at Netflix using Netbackup.
In order for me to know what files were restored versus which ones were
yet to be restored I had to compare what was in the restore folder to what
was on the original list. I didn't want to duplicate my efforts and attempt
to restore files that were already restored. Using the "diff" command to me
is too hard to look at the output. I searched and found the following solution:

Before the first attempt of restoring the huge list of movie files
I cat the list and redirect it to a file:
brbills@lglt-brbills ~/beer
cat orig-list > original

After doing a 75-100 movie file restore:
brbills@lglt-brbills ~/beer
$ ls > now
Now I redirect the output of what hasn't been backed up to a file called diff:
brbills@lglt-brbills ~/beer
$ grep -vf now original > diff

Then I count how many files I have left to restore:
brbills@lglt-brbills ~/beer
$ cat diff |wc -l
850
Comments
Search
Only registered users can write comments!

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

Last Updated on Friday, 30 October 2009 15:26
 

Founder MJ12Net

Founder MJ12Net.org

Brian Bills
Founder MJ12Net
System Admin

Stumble Us

Valid XHTML & CSS | Template Design ah-68 | Copyright © 2009 by Firma