Re: [CentOS] Bash scripting - Remotely ran commands break while loop

2012-02-01 Thread Peter Blajev
On Wed, Feb 1, 2012 at 7:13 PM, Stephen Harris  wrote:

> On Wed, Feb 01, 2012 at 07:03:33PM -0800, Peter Blajev wrote:
> > On Wed, Feb 1, 2012 at 2:53 PM, Stephen Harris  wrote:
> >
> > > On Wed, Feb 01, 2012 at 01:07:31PM -0800, Peter Blajev wrote:
> > > > echo " server2
> > > > server2" | \
> > > > while read confLine; do
> > > >  echo "--> $confLine"
> > > >  ssh peter@$confLine ls
> > > >  echo "--> END $confLine"
> > > > done
>
> > > > Any idea what would cause the ssh command to break the while loop?
> > >
> > > "ssh" is reading from stdin and passing the data over to the remote
> > > machine.  You can test this with
> > >  ssh peter@$confLine 'read x ; echo we got $x'
> > >
> > > To stop it doing this, use the "-n" flag
> > >  ssh -n peter@$confLine ls
> >
> > Unfortunately I can't always use the (-n) option. If I wan't to send data
> > through the pipe then the (-n) won't work. For example (on top of my
> head):
> >   mysqldump dB | ssh peter@remoteServer "mysql dB"
>
> In this situation, ssh will read from the pipe and not from the "echo"
> statement and so it won't break your while loop.
>
> The thing you need to understand is how redirection works.
>  echo foo | while read
>  do
>   ...
>  done
>
> Everything from the "while" to the "done" will have stdin configured to
> read from the pipe (the output of "echo").   Here's an example:
>  % echo "a
>  b
>  c
>  d" | while read a
>  do
>echo We have $a
>read b
>echo And $b
>  done
>  We have a
>  And b
>  We have c
>  And d
>
> You can see that the "read" statement inside the loop is reading from
> the pipe and so draining input.
>
> An "ssh" on its own, in this situation, would drain _all_ the input.
> The "-n" flag tells ssh to not do this.  But, equally, when you do
>  sqldump | ssh
> then you've told ssh to take input from the output of sqldump, and so it's
> no longer reading the from outer loop.
>
> Instead of "ssh -n" you could do "ssh < /dev/null" or "echo | ssh" or
> other options, and get the same sort of effect; you're setting up the
> stdin to ssh to be from somewhere _other_ than your main echo.


Wow. Great lesson. Thank you Stephen.
It makes more sense now.

I'll save this email for sure.

--
Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Bash scripting - Remotely ran commands break while loop

2012-02-01 Thread Peter Blajev
On Wed, Feb 1, 2012 at 2:53 PM, Stephen Harris  wrote:

> On Wed, Feb 01, 2012 at 01:07:31PM -0800, Peter Blajev wrote:
> > echo " server2
> > server2" | \
> > while read confLine; do
> >  echo "--> $confLine"
> >  ssh peter@$confLine ls
> >  echo "--> END $confLine"
> > done
>
> > The "for" loop in the script above will run twice but the "while" loop
> > below it will run only once.
>
> > Any idea what would cause the ssh command to break the while loop?
>
> "ssh" is reading from stdin and passing the data over to the remote
> machine.  You can test this with
>  ssh peter@$confLine 'read x ; echo we got $x'
>
> To stop it doing this, use the "-n" flag
>  ssh -n peter@$confLine ls


This is it. Right on Stephen. Thank you very much. I can't believe I've
gone so long without knowing it.

This works for me. I still don't have full understanding of it but I'll do
some more reading.

Unfortunately I can't always use the (-n) option. If I wan't to send data
through the pipe then the (-n) won't work. For example (on top of my head):
  mysqldump dB | ssh peter@remoteServer "mysql dB"

In my script I ended up using "ssh -n" when I want to work on the output of
remotely ran command and "ssh" without (-n) when I want to send data over
ssh to a remote command.

This so far is not breaking the while loop and it seems to be working but
it makes me nervous.

Any note will be appreciated.

Thanks again.

--
Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] Bash scripting - Remotely ran commands break while loop

2012-02-01 Thread Peter Blajev
I have two CentOS5 systems server1 and server2. There is user peter on
server1 who can ssh to server2 using public ssh keys and no password is
needed.

What I noticed is that running remote ssh commands in bash script breaks
while loops.

==
#!/bin/sh
for i in server2 server2; do
 echo "--> Start"
 ssh peter@$i ls
 echo "--> END"
done

echo " server2
server2" | \
while read confLine; do
 echo "--> $confLine"
 ssh peter@$confLine ls
 echo "--> END $confLine"
done


The "for" loop in the script above will run twice but the "while" loop
below it will run only once.

This is very simple to test and I've tried it on different systems
including CentOS6 and OpenSolaris with the same result.

Any idea what would cause the ssh command to break the while loop?

Thanks
Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] problems with OpenVPN 2.1.4 on Centos 5.5

2011-01-20 Thread Peter Blajev
Boris,

Are you using bash?

Try this:
/bin/bash
. ./vars

--
Peter

On 01/20/2011 08:28 AM, Boris Epstein wrote:
> Hello listmates,
>
> I've got this Centos 5.5 box which I am trying to configure as an
> OpenVPN server. Now 2.1.4 seems to have added pkcs11 support and that
> stops me from creating the CA and other necessary files:
>
>
> [root@gw5fl 2.0]# . ./vars
> bash: /usr/share/doc/openvpn-2.1.4/easy-rsa/2.0/whichopensslcnf:
> Permission denied
> NOTE: If you run ./clean-all, I will be doing a rm -rf on
> /usr/share/doc/openvpn-2.1.4/easy-rsa/2.0/keys
> [root@gw5fl 2.0]# ./clean-all
> [root@gw5fl 2.0]# ./build-ca
>Please edit the vars script to reflect your configuration,
>then source it with "source ./vars".
>Next, to start with a fresh PKI configuration and to delete any
>previous certificates and keys, run "./clean-all".
>Finally, you can run this tool (pkitool) to build certificates/keys.
> [root@gw5fl 2.0]#
>
> Now, the tool I seem to need (from the "vars" file):
>
> export PKCS11TOOL="pkcs11-tool"
>
> does not seem to be there and I am not sure how to install it as I
> couldn't find it.
>
> So, any perspective on what this mess is all about and how to get out
> of it would be much appreciated.
>
> Thanks.
>
> Boris.
> ___
> CentOS mailing list
> CentOS@centos.org
> http://lists.centos.org/mailman/listinfo/centos
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] Kernel panic due to vg00 not found while not using LVM at all

2010-04-09 Thread Peter Blajev
Hi,

I have a system running CentOS4.8.

Last month I installed the latest updates including kernel 2.6.9-89.0.23 
and rebooted the system. It has been running for almost a month.

Last night I updated the system again which updated only a few packages:
openssl, tzdata, curl,vixie-cron and logrotate.

No new kernel or anything out of ordinary. The reboot after the update 
stopped with kernel panic:


Loading dm-snapshot.ko module
Making device-mapper control node
Scanning logical volumes
   Reading all physical volumes. This may take a while...
Activating logical volumes
Volume group vg00 not found
ERROR: /bin/lvm exited abnormaly!
Creating root device

After that it's trying to mount root and it fails with kernel panic.

This system is using disk partitions. It's not using LVM.

I can boot in rescue mode and "chmod /mnt/sysimage". All partitons are 
there and mountable. No fsck errors. I checked /boot/grub/grub.conf and 
it looks fine to me. The time stamp was from last month when I did the 
first update. Also there are no new files in /boot since the update from 
last month.

Why is it looking for logical volumes? Any idea?

Thanks
Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Dependency problems with Yum update

2010-03-10 Thread Peter Blajev
Todd,

Run "yum clean all" first and then try your yum command again.

--
Peter

Todd Cary wrote:
> I am spoiled with Yum: never have had a dependency problem until today.  
> Can this be resolved:
> 
> ---> Downloading header for compat-openldap to pack into transaction set.
> compat-openldap-2.3.27_2. 100% |=|  30 kB00:00
> ---> Package compat-openldap.i386 0:2.3.27_2.2.29-4.el4.centos set to be 
> updated
> --> Running transaction check
> --> Processing Dependency: libmysqlclient.so.14(libmysqlclient_14) for 
> package: dovecot
> --> Processing Dependency: libmysqlclient.so.14 for package: perl-DBD-MySQL
> --> Processing Dependency: libmysqlclient.so.14 for package: mod_auth_mysql
> --> Processing Dependency: libmysqlclient_r.so.14 for package: MySQL-python
> --> Processing Dependency: libmysqlclient_r.so.14(libmysqlclient_14) for 
> package: MySQL-python
> --> Processing Dependency: libmysqlclient.so.14 for package: dovecot
> --> Finished Dependency Resolution
> Error: Missing Dependency: libmysqlclient_r.so.14 is needed by package 
> MySQL-python
> Error: Missing Dependency: libmysqlclient.so.14(libmysqlclient_14) is 
> needed by package dovecot
> Error: Missing Dependency: libmysqlclient.so.14 is needed by package dovecot
> Error: Missing Dependency: libmysqlclient.so.14 is needed by package 
> perl-DBD-MySQL
> Error: Missing Dependency: libmysqlclient.so.14 is needed by package 
> mod_auth_mysql
> Error: Missing Dependency: libmysqlclient_r.so.14(libmysqlclient_14) is 
> needed by package MySQL-python
> 
> Many thanks from a Linux user that knows just enough to keep it running...
> 
> Todd
> 
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] How to force iscsi to see the new LUN size

2010-01-19 Thread Peter Blajev
Pasi Kärkkäinen wrote:
> On Fri, Jan 15, 2010 at 05:34:47PM -0800, Peter Blajev wrote:
>> Hi,
>>
>> I increased the size of one of the LUNs and on CentOS 5.4 if I restart 
>> iscsi (`service iscsi restart`) I'll see the the new size but this will 
>> disconnect all other LUNs.
>>
>> I'm hoping that there is isciadm or some other command that will force 
>> iscsi to rediscover the LUNs but I can't seem to be able to come up with 
>> one.
>>
>> Resize2fs says that there is nothing to be done. I'm not using LVM.
>>
>> Any ideas?
>>
> 
> Try: iscsiadm -m node -R
> It should work with CentOS 5.3 and newer.
> 
> Also you might be interested of this:
> http://pasik.reaktio.net/rhel5-online-iscsi-resize-test.txt
> 
> -- Pasi
> 
> ___
> CentOS mailing list
> CentOS@centos.org
> http://lists.centos.org/mailman/listinfo/centos

Thank you to all that replied.

I studied and followed the document Pasi provided:
http://pasik.reaktio.net/rhel5-online-iscsi-resize-test.txt

Great step-by-step instructions, right on the point. It worked for me.

Thanks again.

--
Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] How to force iscsi to see the new LUN size

2010-01-15 Thread Peter Blajev
Hi,

I increased the size of one of the LUNs and on CentOS 5.4 if I restart 
iscsi (`service iscsi restart`) I'll see the the new size but this will 
disconnect all other LUNs.

I'm hoping that there is isciadm or some other command that will force 
iscsi to rediscover the LUNs but I can't seem to be able to come up with 
one.

Resize2fs says that there is nothing to be done. I'm not using LVM.

Any ideas?

Thanks
Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] Re: Disk partitions and LVM limits - SUMMARY

2008-02-13 Thread Peter Blajev
Thank you all for the help.
I'm writing this summary message because of people requests. I haven't tried 
all of this. I just collected it and organized it.

You've got a big storage. Now what?
The short answer is: "Just connect it. It should work."

I'll play safe by saying that the following applies to <10TB storage. Some 
people reported file systems of 80TB.

Things to watch out for:
  - Make sure the driver you are using or the storage itself don't restrict 
you from making big partitions or file systems.
  - fdisk creates partitions up to 2.1TB in size. Use "parted" instead.
  - RHEL5 supports up to 8TB ext3 file system. To create bigger then 8TB use 
option "-F" and 4K blocks.

Your options are:
  - If the storage is connected to a RAID controller you can use the 
controller to create smaller logical partitions. Then combine them with LVM.

 - If you really want to partition the drive use parted.
   While partitioning if you run into this message:
===
sdb: very big device. try to use READ CAPACITY(16).
SCSI device sdb: 10248519680 512-byte hdwr sectors (5247242 MB)
sdb: Write Protect is off
===
you can just ignore it. It's informational (based on a few people 
replies).
If you don't like parted you can still use fdisk to create a few 2TB 
partitions and then use LVM.

  - Use LVM on the raw device. Don't partition.
This is what I did and it worked for me.
Make sure you wipe out the MBR first:
dd if=/dev/zero of=/dev/sdX bs=512 count=63
  (count=1 should work too but 63 won't hurt either)

Create the pv, vg and lv:
  pvcreate /dev/sdX
  vgcreate  /dev/sdX
  lvcreate -L  -n  -v vg_name

Now you have to create the file systems. Some people recommend XFS.
If you try to create bigger then 8TB ext3 file system make sure you use
option "-F" and 4K blocks:
 mkfs -t ext3 -F -b 4096 /dev/vg00/lvol01

For more information:
  http://www.centos.org/product.html
  http://kbase.redhat.com/faq/FAQ_103_11461.shtm
  The email thread "Disk partitions and LVM limits" in CentOS, RedHat and
 RedHat-Sysadmin mailing lists.

Thank you
Peter

> Hi,
>
> I've got a DAS DELL MD1000 with a bunch of SATA drives in RAID 5
> configuration with total space of 5.4TB. This box is attached to a
> CentOS5 system (kernel 2.6.18-53.1.6.el5).
>
> Any idea how to make this space usable?
> Is there a limit how big a partition can be? What is the work around?
> Is there a limit how big a file system ca be?
>
> I've tried to partition it but no matter how bug partition I create
> fdisk spits out these messages on the console:
> ---
> sdb: very big device. try to use READ CAPACITY(16).
> SCSI device sdb: 10248519680 512-byte hdwr sectors (5247242 MB)
> sdb: Write Protect is off
> ---
>
> I decided to not partition the drive and use LVM but the physical volume
> stopped at 2TB.
>
> So, right now I can't use LVM because of this 2TB limit and I'm not sure
> if I partition the drive how good these partitions are because of the
> the message from fdisk.
>
> Any help or idea is highly appreciated.
>
> Thank you
> Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Disk partitions and LVM limits

2008-02-08 Thread Peter Blajev
> Undo the LVM config, wipe out any MBR or disklabels on the drive,
> then pvcreate the raw disk (/dev/sdb) it should be able to handle
> the whole 5.4TB.

I tried this but I'll try again tonight just in case I missed something the 
first time.

I didn't check what pvcreate did but vgcreate after that gave me 2TB volume 
group. Googling around it looks like there is 2TB limit and there should be 
some kernel parameters to tweak but I still can't get a clear answer.

Thanks
Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] Disk partitions and LVM limits

2008-02-08 Thread Peter Blajev
Hi,

I've got a DAS DELL MD1000 with a bunch of SATA drives in RAID 5 configuration 
with total space of 5.4TB. This box is attached to a CentOS5 system (kernel 
2.6.18-53.1.6.el5).

Any idea how to make this space usable?
Is there a limit how big a partition can be? What is the work around?
Is there a limit how big a file system ca be?

I've tried to partition it but no matter how bug partition I create fdisk 
spits out these messages on the console:
---
sdb: very big device. try to use READ CAPACITY(16).
SCSI device sdb: 10248519680 512-byte hdwr sectors (5247242 MB)
sdb: Write Protect is off
---

I decided to not partition the drive and use LVM but the physical volume 
stopped at 2TB.

So, right now I can't use LVM because of this 2TB limit and I'm not sure if I 
partition the drive how good these partitions are because of the the message 
from fdisk.

Any help or idea is highly appreciated.

Thank you
Peter



-- 
Peter Blajev
Systems Administrator
Computer Science and Engineering Department
University of California, San Diego
Office: EBU3B 1214
Phone: (858) 534-2532
E-mail: [EMAIL PROTECTED]
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] Shearing file systems on the network

2008-01-24 Thread Peter Blajev
I have 4 systems and each one of them has a partition I'd like to be remotely 
accessible on the other 3 systems.

In other words System1 has Partition1. Systems 2,3,4 should be able to 
remotely mount Partition1 from System1. Also System2 has Partition2. Then 
systems 1,3,4 should be able to remotely mount Partition2 from System2 and so 
on.

I tried NFS and it works but only in the ideal world. If one of the systems 
goes down the whole NFS cross-mounting makes the other systems somewhat 
unstable. It's a known issue and I believe you guys are aware of it but I 
just had to see it myself.

What would you recommend? What is the best practice for doing that?

Unfortunately SAN and NAS are not really an option due to some financial 
restructions. I'm thinking SMB...? Would that work?

Thank you
Peter
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos