One discussion in toolbox.com give me the idea to write this article. The subject was full root (/) filesystem and how to extend it. Most of the participants do not believe this is possible, but i will demonstrate how to do it. My demonstration is based on Oracle Solaris 10 Generic_142910-17 i386.
1. What is my OS
# showrev
Hostname: sun02
Hostid: 10b69b13
Release: 5.10
Kernel architecture: i86pc
Application architecture: i386
Hardware provider:
Domain:
Kernel version: SunOS 5.10 Generic_142910-17
2. Check the map of harddisk
# prtvtoc /dev/dsk/c1t0d0s2
* /dev/dsk/c1t0d0s2 partition map
<snip>
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 2 00 16065 2104515 2120579 /
1 4 00 2570400 6297480 8867879 /usr
2 5 00 0 33495525 33495524
3 3 01 11309760 1060290 12370049
8 1 01 0 16065 16064
As you can see I have some unallocated cylinders after each partition (/. /usr and swap) and this is done on time of installation for the reason of demonstration.
3. Check the exact sizes of filesystems
# df -k / /usr
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s0 1019856 377425 581240 40% /
/dev/dsk/c1t0d0s1 3100362 2251708 786647 75% /usr
# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c1t0d0s3 30,3 8 1060280 1060280
4. Create two control files, filled with random bytes for control of the integrity of filesystems
# dd if=/dev/urandom of=/checkfileroot bs=1024 count=10240
10240+0 records in
10240+0 records out
# dd if=/dev/urandom of=/usr/checkfileusr bs=1024 count=10240
10240+0 records in
10240+0 records out
5. And get checksums ot the files
# digest -a sha1 /checkfileroot /usr/checkfileusr
(/checkfileroot) = c5ee33c68b147c58e6190a99a647a9baf35581a8
(/usr/checkfileusr) = 77bb739b734ab01a43578479ec4a3abe92e6c4bd
6. Extend slice 0, 1 and 3 with some amount of cylinders
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t0d0 <DEFAULT cyl 2085 alt 2 hd 255 sec 63>
/pci@0,0/pci1000,30@10/sd@0,0
Specify disk (enter its number): 0
selecting c1t0d0
[disk formatted]
Warning: Current Disk has mounted partitions.
/dev/dsk/c1t0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c1t0d0s1 is currently mounted on /usr. Please see umount(1M).
/dev/dsk/c1t0d0s3 is currently used by swap. Please see swap(1M).
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
fdisk - run the fdisk program
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
format> p
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
!<cmd> - execute <cmd>, then return
quit
partition> 0
Part Tag Flag Cylinders Size Blocks
0 root wm 1 - 131 1.00GB (131/0/0) 2104515
Enter partition id tag[root]:
Enter partition permission flags[wm]:
Enter new starting cyl[1]:
Enter partition size[2104515b, 131c, 131e, 1027.60mb, 1.00gb]: 140c
partition> 1
Part Tag Flag Cylinders Size Blocks
1 usr wm 160 - 551 3.00GB (392/0/0) 6297480
Enter partition id tag[usr]:
Enter partition permission flags[wm]:
Enter new starting cyl[160]:
Enter partition size[6297480b, 392c, 551e, 3074.94mb, 3.00gb]: 400c
partition> 3
Part Tag Flag Cylinders Size Blocks
3 swap wu 704 - 769 517.72MB (66/0/0) 1060290
Enter partition id tag[swap]:
Enter partition permission flags[wu]:
Enter new starting cyl[704]:
Enter partition size[1060290b, 66c, 769e, 517.72mb, 0.51gb]: 80c
partition> la
Ready to label disk, continue? y
partition> q
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
fdisk - run the fdisk program
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
format> q
7. And the moment of true, extend root (/) filesystem
# growfs -M / /dev/rdsk/c1t0d0s0
Warning: 5748 sector(s) in last cylinder unallocated
/dev/rdsk/c1t0d0s0: 2249100 sectors in 367 cylinders of 48 tracks, 128 sectors
1098.2MB in 23 cyl groups (16 c/g, 48.00MB/g, 11648 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
1279648, 1378080, 1476512, 1574944, 1673376, 1771808, 1870240, 1968672,
2067104, 2165536
8. Then grow /usr
# growfs -M /usr /dev/rdsk/c1t0d0s1
Warning: 624 sector(s) in last cylinder unallocated
/dev/rdsk/c1t0d0s1: 6426000 sectors in 1046 cylinders of 48 tracks, 128 sectors
3137.7MB in 66 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
5512224, 5610656, 5709088, 5807520, 5905952, 6004384, 6102816, 6201248,
6291488, 6389920
9. And swap
# swap -d /dev/dsk/c1t0d0s3
/dev/dsk/c1t0d0s3 was dump device --
invoking dumpadm(1M) -d swap to select new dump device
dumpadm: no swap devices are available
# swap -a /dev/dsk/c1t0d0s3
operating system crash dump was previously disabled --
invoking dumpadm(1M) -d swap to select new dump device
# dumpadm -d swap
Dump content: kernel pages
Dump device: /dev/dsk/c1t0d0s3 (swap)
Savecore directory: /var/crash/sun02
Savecore enabled: yes
Save compressed: on
For the swap I just delete and add it again. And update dump device, this is important. Of course it is not always possible just to delete virtual memory on production, but its possible to play with creation of new swap device, delete old, add old and delete new. This can take long time on production system, but its relatively safe operation
10. So, let check again the sizes of filesystems
# df -k / /usr
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s0 1090677 387745 641741 38% /
/dev/dsk/c1t0d0s1 3163878 2262020 839851 73% /usr
# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c1t0d0s3 30,3 8 1285192 1285192
As you can see they are bigger that few minutes a go
11. But what is the situation with control files
# digest -a sha1 /checkfileroot /usr/checkfileusr
(/checkfileroot) = c5ee33c68b147c58e6190a99a647a9baf35581a8
(/usr/checkfileusr) = 77bb739b734ab01a43578479ec4a3abe92e6c4bd
As you can see they are the same
12. Et voila, we successfully extend our filesystems on the fly. By the way in official Oracle Solaris documentations you can see this
--------------
LIMITATIONS
Only UFS file systems (either mounted or unmounted) can be expanded using the growfs command. Once a file system is expanded, it cannot be decreased in size. The following conditions prevent you from expanding file systems: When acct is activated and the accounting file is on the target device. When C2 security is activated and the logging file is on the target file system. When there is a local swap file in the target file system. When the file system is root (/), /usr, or swap.
Showing posts with label solaris. Show all posts
Showing posts with label solaris. Show all posts
Beyond the limits - environment (cont 2)
Comment from Paul for the article make me rerun the tests in different conditions: I update the memory of both machines to 1024 MB and use scripts (see below)
[root@centos ~]# cat z1.sh
TEMPVAR=A
for i in {1..1000};
do
TEMPVAR=${TEMPVAR}$TEMPVAR;
a=$(echo 2^$i|bc)
b=${#TEMPVAR}
if [ $a -ne $b ]
then echo KO - $a, $b
else echo $a
fi
done
[root@centos ~]# cat z1.1.sh
TEMPVAR=A
for i in {1..1000};
do
TEMPVAR=${TEMPVAR}$TEMPVAR;
a=$(echo 2^$i+1|bc)
b=$(echo $TEMPVAR|wc -c)
if [ $a -ne $b ]
then echo KO - $a, $b
else echo $a
fi
done
Solaris
On Solaris independently of the amout of memory and the way of get length of environment variable the result is same:
bash-3.00# vmstat 1 2
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr cd f0 s0 -- in sy cs us sy id
0 0 0 1075080 616428 152 3085 0 0 0 0 204 10 -0 3 0 309 3345 1511 14 19 67
1 0 0 1407772 753456 18 50 0 0 0 0 0 0 0 0 0 304 324 142 0 1 99
It seems 32MB is internal limitation in bash (or OS) in Solaris
bash-3.00# ./z1.sh
2
4
<snip>
8388608
16777216
33554432
./z1.sh: fork: Not enough space
./z1.sh: line 7: [: -ne: unary operator expected
./z1.sh: fork: Not enough space
bash-3.00# ./z1.1.sh
3
5
<snip>
16777217
33554433
./z1.1.sh: fork: Not enough space
./z1.1.sh: fork: Not enough space
KO - ,
./z1.1.sh: fork: Not enough space
And the execution times follow the common sense
bash-3.00# time ./z1.sh
2
4
<snip>
16777216
33554432
real 0m9.670s
user 0m6.454s
sys 0m3.014s
bash-3.00# time ./z1.1.sh
3
5
<snip>
16777217
33554433
real 0m13.709s
user 0m8.040s
sys 0m5.352s
Linux
But on linux
[root@centos ~]# vmstat 1 2
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 10416 1016704 252 4072 75 804 318 828 1008 77 19 44 32 4 0
0 0 10416 1016704 252 4096 0 0 0 0 1015 14 0 1 99 0 0
my method of count permit me to reach bigger length
[root@centos ~]# ./z1.sh
2
4
<snip>
67108864
134217728
./z1.sh: xmalloc: cannot allocate 536870913 bytes (0 bytes allocated)
[root@centos ~]# ./z1.1.sh
3
5
<snip>
134217729
268435457
./z1.1.sh: xmalloc: cannot allocate 1073741825 bytes (0 bytes allocated)
KO - 536870913, 0
./z1.1.sh: xmalloc: cannot allocate 1073741825 bytes (0 bytes allocated)
and need less execution time (with limit to 2^26)
[root@centos ~]# time ./z1.sh
2
4
<snip>
33554432
67108864
real 1m58.730s
user 0m33.084s
sys 1m27.562s
[root@centos ~]# time ./z1.1.sh
3
5
<snip>
33554433
67108865
real 1m36.457s
user 0m50.206s
sys 0m47.815s
Final conclusion: this need further investigations :)
[root@centos ~]# cat z1.sh
TEMPVAR=A
for i in {1..1000};
do
TEMPVAR=${TEMPVAR}$TEMPVAR;
a=$(echo 2^$i|bc)
b=${#TEMPVAR}
if [ $a -ne $b ]
then echo KO - $a, $b
else echo $a
fi
done
[root@centos ~]# cat z1.1.sh
TEMPVAR=A
for i in {1..1000};
do
TEMPVAR=${TEMPVAR}$TEMPVAR;
a=$(echo 2^$i+1|bc)
b=$(echo $TEMPVAR|wc -c)
if [ $a -ne $b ]
then echo KO - $a, $b
else echo $a
fi
done
Solaris
On Solaris independently of the amout of memory and the way of get length of environment variable the result is same:
bash-3.00# vmstat 1 2
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr cd f0 s0 -- in sy cs us sy id
0 0 0 1075080 616428 152 3085 0 0 0 0 204 10 -0 3 0 309 3345 1511 14 19 67
1 0 0 1407772 753456 18 50 0 0 0 0 0 0 0 0 0 304 324 142 0 1 99
It seems 32MB is internal limitation in bash (or OS) in Solaris
bash-3.00# ./z1.sh
2
4
<snip>
8388608
16777216
33554432
./z1.sh: fork: Not enough space
./z1.sh: line 7: [: -ne: unary operator expected
./z1.sh: fork: Not enough space
bash-3.00# ./z1.1.sh
3
5
<snip>
16777217
33554433
./z1.1.sh: fork: Not enough space
./z1.1.sh: fork: Not enough space
KO - ,
./z1.1.sh: fork: Not enough space
And the execution times follow the common sense
bash-3.00# time ./z1.sh
2
4
<snip>
16777216
33554432
real 0m9.670s
user 0m6.454s
sys 0m3.014s
bash-3.00# time ./z1.1.sh
3
5
<snip>
16777217
33554433
real 0m13.709s
user 0m8.040s
sys 0m5.352s
Linux
But on linux
[root@centos ~]# vmstat 1 2
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 10416 1016704 252 4072 75 804 318 828 1008 77 19 44 32 4 0
0 0 10416 1016704 252 4096 0 0 0 0 1015 14 0 1 99 0 0
my method of count permit me to reach bigger length
[root@centos ~]# ./z1.sh
2
4
<snip>
67108864
134217728
./z1.sh: xmalloc: cannot allocate 536870913 bytes (0 bytes allocated)
[root@centos ~]# ./z1.1.sh
3
5
<snip>
134217729
268435457
./z1.1.sh: xmalloc: cannot allocate 1073741825 bytes (0 bytes allocated)
KO - 536870913, 0
./z1.1.sh: xmalloc: cannot allocate 1073741825 bytes (0 bytes allocated)
and need less execution time (with limit to 2^26)
[root@centos ~]# time ./z1.sh
2
4
<snip>
33554432
67108864
real 1m58.730s
user 0m33.084s
sys 1m27.562s
[root@centos ~]# time ./z1.1.sh
3
5
<snip>
33554433
67108865
real 1m36.457s
user 0m50.206s
sys 0m47.815s
Final conclusion: this need further investigations :)
Beyond the limits - environment (cont)
4. Accessable command line argument
Now I will try to see how many are acceptable command line arguments from system utils like pgrep, pkill and similar. For this puspose I will use dummy C program which do nothing
#include <stdio.h>
int main(int argc, char *argv[])
{
while(1){};
}
And will generate sequence of random numbers to be fure will have ho false results
for i in {1..256}; do dd if=/dev/urandom bs=1 count=64|md5sum|awk '{printf $1" "}'>>random_arg;done
[root@centos ~]# cat random_arg
d4a798eea8f9b9b5c9751aa8a785b465 da735316b9d27af062c28a0e3655a1f5 43c45dcd136e53d01662a5f9cfa943d9 fd5d2445ebf54a969cd6dff7e8cb3c09
<snip>
1187d29932b7d5827080684f16205330 92398e4719194f13a1a79064c5a69d05 e1cd425a036f77cc6fb6f3002d00bada a0c6d3b48c5e8146b2fe0b5f74383b9c
Let try with shorter arguments
4.1. Linux
Compile the program
[root@centos ~]# cc z4.c
And execute it
[root@centos ~]# ./a.out `cat random_arg `&
[1] 5094
Lets check what I can see with ps
[[root@centos ~]# ps -efl|grep a.out
0 R root 5094 2174 99 85 0 - 403 - 06:13 pts/0 00:00:35 ./a.out d4a798eea8f9b9b5c9751aa8a785b465 da735316b9d27af062c28a0e3655a1f5 43c45dcd136e53d01662a5f9cfa943d9 fd5d2445ebf54a969cd6dff7e8cb3c09 73e522501878712898d1c47342b9bd66
<snip>
f566402f18f3ebe15453d3a74fc1c534 f87fe9ab1f5f85238ce01ca5d62d57e1 d05d9d3b9cb608d8a177434a4cda5c69 43e80e6069a763a0da17abdba8a06b30 d79a21984d368e4b574e4690a749c7af f5c9eddc01dd1a98bdb7ecbd5eba87a7 249a93f99bb66ff2361f722d1de2b
0 R root 5101 2174 0 78 0 - 1001 - 06:13 pts/0 00:00:00 grep a.out
OK, but let see if i can find all the arguments with ps:
CNT=1
for i in `cat random_arg `;
do
if [ `ps -efl|grep $i|grep -v grep|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
and exec
[root@centos ~]# ./z3.sh
OK 1
OK 2
<snip>
OK 123
249a93f99bb66ff2361f722d1de2b8ff
f2793da3d8bbab2c7b972c4ff2dc7176
60bc35ea120dc372a5b14a02acc2182a
<snip>
So I can see only 123 arguments. Hm, this a big number, but no so much
Lets try with pgrep
CNT=1
for i in `cat random_arg `;
do
if [ `pgrep -f $i|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
[root@centos ~]# ./z4.sh
OK 1
<snip>
OK 123
249a93f99bb66ff2361f722d1de2b8ff
f2793da3d8bbab2c7b972c4ff2dc7176
60bc35ea120dc372a5b14a02acc2182a
<snip>
The same result. So i can see beyond parameter number 123. And sample chech if this depend of number of variables in environment
[root@centos ~]# env|wc -l
20
[root@centos ~]# export BB=1
[root@centos ~]# env|wc -l
21
[root@centos ~]# ./z4.sh
OK 1
<snip>
OK 123
249a93f99bb66ff2361f722d1de2b8ff
f2793da3d8bbab2c7b972c4ff2dc7176
60bc35ea120dc372a5b14a02acc2182a
<snip>
It seems do not depend and this is internal limitation
4.2. Solaris
Compile the program
bash-3.00# /usr/sfw/bin/gcc z3.c
and generate random numbers
for i in {1..256}; do dd if=/dev/urandom bs=1 count=64|digest -a md5|awk '{printf $1" "}'>>random_arg;done
bash-3.00# cat random_arg
40e4b176f31e662ae95ac93e995cf4a4 f1e1c978a8007aa88bfffd675af2d56b 6b06061f1e4a76e3ced152855f7f5047 89e3f7ee6744078726a58ba3fe85092a
d1659b7259bf383888e93caee7e26282 637ff2c7ad50c5f2018f7a865d646667 35bcc0568f9b8b8902fdc4f73fbadb49 34ce610edd36d834c08115de0c8e4568
<snip>
And execute it
bash-3.00# ./a.out `cat random_arg `&
[1] 1536
Lets check what I can see with ps
bash-3.00# ps -efl|grep a.out
0 S root 1539 749 0 40 20 ? 347 ? 07:40:11 pts/1 0:00 grep a.out
0 R root 1536 749 70 89 20 ? 336 07:39:46 pts/1 0:26 ./a.out 40e4b176f31e662ae95ac93e995
OK, but let see if i can find all the arguments with ps:
CNT=1
for i in `cat random_arg `;
do
if [ `ps -efl|grep $i|grep -v grep|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
and exec
bash-3.00# ./z3.sh
OK 1
OK 2
6b06061f1e4a76e3ced152855f7f5047
89e3f7ee6744078726a58ba3fe85092a
d1659b7259bf383888e93caee7e26282
<snip>
As you can see Solaris show me only two arguments with SYSV ps, but let me try with pargs
bash-3.00# pargs 1536
1536: ./a.out 40e4b176f31e662ae95ac93e995cf4a4 f1e1c978a8007aa88bfffd675af2d56b 6b060
argv[0]: ./a.out
argv[1]: 40e4b176f31e662ae95ac93e995cf4a4
argv[2]: f1e1c978a8007aa88bfffd675af2d56b
<snip>
argv[256]: 85fa98d8bf33f2b0507ec9714472d17f
OK, thats good, but I should know the PID :)
Lets try with pgrep
CNT=1
for i in `cat random_arg `;
do
if [ `pgrep -f $i|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
bash-3.00# ./z4.sh
OK 1
OK 2
6b06061f1e4a76e3ced152855f7f5047
89e3f7ee6744078726a58ba3fe85092a
d1659b7259bf383888e93caee7e26282
<snip>
Ha, I can see only two arguments, this is too small for me
And sample check if this depend of number of variables in environment
bash-3.00# env|wc -l
14
bash-3.00# export BB=1
bash-3.00# env|wc -l
15
bash-3.00# ./z4.sh
OK 1
OK 2
6b06061f1e4a76e3ced152855f7f5047
89e3f7ee6744078726a58ba3fe85092a
d1659b7259bf383888e93caee7e26282
<snip>
It seems do not depend and this is internal limitation
Let see what will happen with shorter arguments
bash-3.00# ./a.out 111 222 333 444 555 666 777 888 999&
[1] 2346
bash-3.00# cat z4.sh
CNT=1
for i in 111 222 333 444 555 666 777 888 999;
do
if [ `pgrep -f $i|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
bash-3.00# ./z4.sh
OK 1
OK 2
OK 3
OK 4
OK 5
OK 6
OK 7
OK 8
OK 9
O, all seems OK, but why i cant reach more deeper in argument list. Let keep this question open :)
Now I will try to see how many are acceptable command line arguments from system utils like pgrep, pkill and similar. For this puspose I will use dummy C program which do nothing
#include <stdio.h>
int main(int argc, char *argv[])
{
while(1){};
}
And will generate sequence of random numbers to be fure will have ho false results
for i in {1..256}; do dd if=/dev/urandom bs=1 count=64|md5sum|awk '{printf $1" "}'>>random_arg;done
[root@centos ~]# cat random_arg
d4a798eea8f9b9b5c9751aa8a785b465 da735316b9d27af062c28a0e3655a1f5 43c45dcd136e53d01662a5f9cfa943d9 fd5d2445ebf54a969cd6dff7e8cb3c09
<snip>
1187d29932b7d5827080684f16205330 92398e4719194f13a1a79064c5a69d05 e1cd425a036f77cc6fb6f3002d00bada a0c6d3b48c5e8146b2fe0b5f74383b9c
Let try with shorter arguments
4.1. Linux
Compile the program
[root@centos ~]# cc z4.c
And execute it
[root@centos ~]# ./a.out `cat random_arg `&
[1] 5094
Lets check what I can see with ps
[[root@centos ~]# ps -efl|grep a.out
0 R root 5094 2174 99 85 0 - 403 - 06:13 pts/0 00:00:35 ./a.out d4a798eea8f9b9b5c9751aa8a785b465 da735316b9d27af062c28a0e3655a1f5 43c45dcd136e53d01662a5f9cfa943d9 fd5d2445ebf54a969cd6dff7e8cb3c09 73e522501878712898d1c47342b9bd66
<snip>
f566402f18f3ebe15453d3a74fc1c534 f87fe9ab1f5f85238ce01ca5d62d57e1 d05d9d3b9cb608d8a177434a4cda5c69 43e80e6069a763a0da17abdba8a06b30 d79a21984d368e4b574e4690a749c7af f5c9eddc01dd1a98bdb7ecbd5eba87a7 249a93f99bb66ff2361f722d1de2b
0 R root 5101 2174 0 78 0 - 1001 - 06:13 pts/0 00:00:00 grep a.out
OK, but let see if i can find all the arguments with ps:
CNT=1
for i in `cat random_arg `;
do
if [ `ps -efl|grep $i|grep -v grep|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
and exec
[root@centos ~]# ./z3.sh
OK 1
OK 2
<snip>
OK 123
249a93f99bb66ff2361f722d1de2b8ff
f2793da3d8bbab2c7b972c4ff2dc7176
60bc35ea120dc372a5b14a02acc2182a
<snip>
So I can see only 123 arguments. Hm, this a big number, but no so much
Lets try with pgrep
CNT=1
for i in `cat random_arg `;
do
if [ `pgrep -f $i|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
[root@centos ~]# ./z4.sh
OK 1
<snip>
OK 123
249a93f99bb66ff2361f722d1de2b8ff
f2793da3d8bbab2c7b972c4ff2dc7176
60bc35ea120dc372a5b14a02acc2182a
<snip>
The same result. So i can see beyond parameter number 123. And sample chech if this depend of number of variables in environment
[root@centos ~]# env|wc -l
20
[root@centos ~]# export BB=1
[root@centos ~]# env|wc -l
21
[root@centos ~]# ./z4.sh
OK 1
<snip>
OK 123
249a93f99bb66ff2361f722d1de2b8ff
f2793da3d8bbab2c7b972c4ff2dc7176
60bc35ea120dc372a5b14a02acc2182a
<snip>
It seems do not depend and this is internal limitation
4.2. Solaris
Compile the program
bash-3.00# /usr/sfw/bin/gcc z3.c
and generate random numbers
for i in {1..256}; do dd if=/dev/urandom bs=1 count=64|digest -a md5|awk '{printf $1" "}'>>random_arg;done
bash-3.00# cat random_arg
40e4b176f31e662ae95ac93e995cf4a4 f1e1c978a8007aa88bfffd675af2d56b 6b06061f1e4a76e3ced152855f7f5047 89e3f7ee6744078726a58ba3fe85092a
d1659b7259bf383888e93caee7e26282 637ff2c7ad50c5f2018f7a865d646667 35bcc0568f9b8b8902fdc4f73fbadb49 34ce610edd36d834c08115de0c8e4568
<snip>
And execute it
bash-3.00# ./a.out `cat random_arg `&
[1] 1536
Lets check what I can see with ps
bash-3.00# ps -efl|grep a.out
0 S root 1539 749 0 40 20 ? 347 ? 07:40:11 pts/1 0:00 grep a.out
0 R root 1536 749 70 89 20 ? 336 07:39:46 pts/1 0:26 ./a.out 40e4b176f31e662ae95ac93e995
OK, but let see if i can find all the arguments with ps:
CNT=1
for i in `cat random_arg `;
do
if [ `ps -efl|grep $i|grep -v grep|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
and exec
bash-3.00# ./z3.sh
OK 1
OK 2
6b06061f1e4a76e3ced152855f7f5047
89e3f7ee6744078726a58ba3fe85092a
d1659b7259bf383888e93caee7e26282
<snip>
As you can see Solaris show me only two arguments with SYSV ps, but let me try with pargs
bash-3.00# pargs 1536
1536: ./a.out 40e4b176f31e662ae95ac93e995cf4a4 f1e1c978a8007aa88bfffd675af2d56b 6b060
argv[0]: ./a.out
argv[1]: 40e4b176f31e662ae95ac93e995cf4a4
argv[2]: f1e1c978a8007aa88bfffd675af2d56b
<snip>
argv[256]: 85fa98d8bf33f2b0507ec9714472d17f
OK, thats good, but I should know the PID :)
Lets try with pgrep
CNT=1
for i in `cat random_arg `;
do
if [ `pgrep -f $i|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
bash-3.00# ./z4.sh
OK 1
OK 2
6b06061f1e4a76e3ced152855f7f5047
89e3f7ee6744078726a58ba3fe85092a
d1659b7259bf383888e93caee7e26282
<snip>
Ha, I can see only two arguments, this is too small for me
And sample check if this depend of number of variables in environment
bash-3.00# env|wc -l
14
bash-3.00# export BB=1
bash-3.00# env|wc -l
15
bash-3.00# ./z4.sh
OK 1
OK 2
6b06061f1e4a76e3ced152855f7f5047
89e3f7ee6744078726a58ba3fe85092a
d1659b7259bf383888e93caee7e26282
<snip>
It seems do not depend and this is internal limitation
Let see what will happen with shorter arguments
bash-3.00# ./a.out 111 222 333 444 555 666 777 888 999&
[1] 2346
bash-3.00# cat z4.sh
CNT=1
for i in 111 222 333 444 555 666 777 888 999;
do
if [ `pgrep -f $i|wc -l` -eq 1 ]
then echo OK $CNT
else echo $i
fi
CNT=`echo $CNT + 1|bc`
done
bash-3.00# ./z4.sh
OK 1
OK 2
OK 3
OK 4
OK 5
OK 6
OK 7
OK 8
OK 9
O, all seems OK, but why i cant reach more deeper in argument list. Let keep this question open :)
Beyond the limits - environment
1. Prerequisites
My environmnet is based on Solaris 10 10 9/10 with 640 MB of memory and CentOS 5.5 2.6.18-194.26.1.el5 with 512 MB, standard installation both of them run in VMWare environmnet. For shell I use bash (as common)
bash-3.00# bash --version
GNU bash, version 3.00.16(1)-release (i386-pc-solaris2.10)
Copyright (C) 2004 Free Software Foundation, Inc.
[root@centos ~]# bash --version
GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
All the tests will be done with default settings of the OS and environment
2. Test the maximum length variable
the script i will use is sample:
TEMPVAR=A
for i in {1..10000};
do
TEMPVAR=${TEMPVAR}$TEMPVAR;
a=$(echo 2^$i+1|bc)
b=$(echo $TEMPVAR|wc -c)
if [ $a -ne $b ]
then echo KO - $a, $b
else echo $a
fi
done
2.1. And the execution in Linux
[root@centos ~]# ./z1.sh
3
5
<snip>
67108865
134217729
./z1.sh: xmalloc: cannot allocate 268435457 bytes (0 bytes allocated)
KO - 268435457, 0
[1]+ Stopped ./z1.sh
[root@centos ~]# vmstat 1 2
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 10716 229500 25160 228524 66 139 138 178 1011 151 18 18 61 3 0
0 0 10716 229500 25160 228524 0 0 0 0 1013 15 0 0 100 0 0
As you can see above I get error allocating memory beyond the size of free memory
2.2. Execution in Solaris
bash-3.00# ./z1.sh
3
5
<snip>
8388609
16777217
./z1.sh: fork: Not enough space
./z1.sh: line 7: [: 33554433: unary operator expected
33554433
./z1.sh: fork: Not enough space
bash-3.00# vmstat 1 2
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr cd f0 s0 -- in sy cs us sy id
0 0 0 856808 174100 50 1101 0 1 5 0 66 2 -0 3 0 336 801 308 9 7 84
0 0 0 749832 70472 3 43 0 0 0 0 0 27 0 0 0 326 300 185 1 9 90
The similar is situation in Solaris where i can allocate even less that half of free memory
Of course it is not very wise to use such variables, but who knows?
3. Number of commandline arguments
3.1. Sample C program
Next I will try to check what is the maximum of commandline arguments of one sample C program
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%d\n", argc);
}
and the shell script I will use is
TEMPVAR=A
for i in {1..1000}
do
TEMPVAR="$TEMPVAR $TEMPVAR"
a=$(./a.out $TEMPVAR)
echo $a
done
3.1.1 On Linux
[root@centos ~]# cc z2.c
[root@centos ~]# ./a.out 1
2
[root@centos ~]# ./a.out 1 2
3
[root@centos ~]# ./z2.sh
3
5
<snip>
524289
1048577
./z2.sh: line 5: ./a.out: Argument list too long
1m of arguments, that pretty much :)
3.1.2 Solaris
bash-3.00# /usr/sfw/bin/gcc z2.c
bash-3.00# ./a.out 1
2
bash-3.00# ./a.out 1 2
3
bash-3.00# ./z2.sh
3
5
<snip>
65537
131073
./z2.sh: line 5: ./a.out: Arg list too long
"Just" 128k, not so much as Linux, but anyway do someone will use so many for practical puspose?
3.2. Sample shell program
Next I will try to check what is the maximum of commandline arguments of one very sample shell program
echo $#
using this shell script
TEMPVAR=A
for i in {1..1000}
do
TEMPVAR="$TEMPVAR $TEMPVAR"
a=$(./z2test.sh $TEMPVAR)
echo $a
done
This time the results appear mich slower because of the invocation of subshell.
3.2.1 Linux
After 1 hour of waiting I stop the script, but before this I see in top
29827 root 25 0 47028 41m 476 R 99.9 8.3 2:38.86 bash
3.2.2. Solaris
The same (long waiting) happen in Solaris and after 128k i see in prstat
15100 root 72M 69M run 20 0 0:09:01 96% bash/1
As conclusion 128K is the maximum practicle limit of number command line arguments
My environmnet is based on Solaris 10 10 9/10 with 640 MB of memory and CentOS 5.5 2.6.18-194.26.1.el5 with 512 MB, standard installation both of them run in VMWare environmnet. For shell I use bash (as common)
bash-3.00# bash --version
GNU bash, version 3.00.16(1)-release (i386-pc-solaris2.10)
Copyright (C) 2004 Free Software Foundation, Inc.
[root@centos ~]# bash --version
GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
All the tests will be done with default settings of the OS and environment
2. Test the maximum length variable
the script i will use is sample:
TEMPVAR=A
for i in {1..10000};
do
TEMPVAR=${TEMPVAR}$TEMPVAR;
a=$(echo 2^$i+1|bc)
b=$(echo $TEMPVAR|wc -c)
if [ $a -ne $b ]
then echo KO - $a, $b
else echo $a
fi
done
2.1. And the execution in Linux
[root@centos ~]# ./z1.sh
3
5
<snip>
67108865
134217729
./z1.sh: xmalloc: cannot allocate 268435457 bytes (0 bytes allocated)
KO - 268435457, 0
[1]+ Stopped ./z1.sh
[root@centos ~]# vmstat 1 2
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 10716 229500 25160 228524 66 139 138 178 1011 151 18 18 61 3 0
0 0 10716 229500 25160 228524 0 0 0 0 1013 15 0 0 100 0 0
As you can see above I get error allocating memory beyond the size of free memory
2.2. Execution in Solaris
bash-3.00# ./z1.sh
3
5
<snip>
8388609
16777217
./z1.sh: fork: Not enough space
./z1.sh: line 7: [: 33554433: unary operator expected
33554433
./z1.sh: fork: Not enough space
bash-3.00# vmstat 1 2
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr cd f0 s0 -- in sy cs us sy id
0 0 0 856808 174100 50 1101 0 1 5 0 66 2 -0 3 0 336 801 308 9 7 84
0 0 0 749832 70472 3 43 0 0 0 0 0 27 0 0 0 326 300 185 1 9 90
The similar is situation in Solaris where i can allocate even less that half of free memory
Of course it is not very wise to use such variables, but who knows?
3. Number of commandline arguments
3.1. Sample C program
Next I will try to check what is the maximum of commandline arguments of one sample C program
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%d\n", argc);
}
and the shell script I will use is
TEMPVAR=A
for i in {1..1000}
do
TEMPVAR="$TEMPVAR $TEMPVAR"
a=$(./a.out $TEMPVAR)
echo $a
done
3.1.1 On Linux
[root@centos ~]# cc z2.c
[root@centos ~]# ./a.out 1
2
[root@centos ~]# ./a.out 1 2
3
[root@centos ~]# ./z2.sh
3
5
<snip>
524289
1048577
./z2.sh: line 5: ./a.out: Argument list too long
1m of arguments, that pretty much :)
3.1.2 Solaris
bash-3.00# /usr/sfw/bin/gcc z2.c
bash-3.00# ./a.out 1
2
bash-3.00# ./a.out 1 2
3
bash-3.00# ./z2.sh
3
5
<snip>
65537
131073
./z2.sh: line 5: ./a.out: Arg list too long
"Just" 128k, not so much as Linux, but anyway do someone will use so many for practical puspose?
3.2. Sample shell program
Next I will try to check what is the maximum of commandline arguments of one very sample shell program
echo $#
using this shell script
TEMPVAR=A
for i in {1..1000}
do
TEMPVAR="$TEMPVAR $TEMPVAR"
a=$(./z2test.sh $TEMPVAR)
echo $a
done
This time the results appear mich slower because of the invocation of subshell.
3.2.1 Linux
After 1 hour of waiting I stop the script, but before this I see in top
29827 root 25 0 47028 41m 476 R 99.9 8.3 2:38.86 bash
3.2.2. Solaris
The same (long waiting) happen in Solaris and after 128k i see in prstat
15100 root 72M 69M run 20 0 0:09:01 96% bash/1
As conclusion 128K is the maximum practicle limit of number command line arguments
Solaris x86 root filesystem mirroring
Preamble
This document is directed to give idea how to create mirroring of root filesystem in Solaris x86 with the help of Solaris Volume Manager. Here will be used already installed OS and all the work will be done without need of reinstall
Prerequisites
1. First we should be sure have two identical harddisks in the server
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 1563 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@7,1/ide@0/cmdk@0,0
1. c0d1 <DEFAULT cyl 1563 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@7,1/ide@0/cmdk@1,0
Specify disk (enter its number): ^C
2. Its need to create small slice for metadb information (usually slice 7) like:
partition> p
Current partition table (unnamed):
Total disk cylinders available: 1563 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 518 - 1562 8.01GB (1045/0/0) 16787925
1 swap wu 3 - 133 1.00GB (131/0/0) 2104515
2 backup wm 0 - 1562 11.97GB (1563/0/0) 25109595
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 134 - 135 15.69MB (2/0/0) 32130
8 boot wu 0 - 0 7.84MB (1/0/0) 16065
9 alternates wu 1 - 2 15.69MB (2/0/0) 32130
3. Next step is to create the same partitions on the second disk. To avoid human error it is much better to use some kind of automations:
prtvtoc /dev/rdsk/c0d0s2 > /tmp/c0d0s2.toc
fmthard -s /tmp/c0d0s2.toc /dev/rdsk/c0d1s2
4. Then we should identify the partitions need to be mirrored:
# egrep "ufs|swap" /etc/vfstab|grep "/dev/dsk"
/dev/dsk/c0d0s1 - - swap - no -
/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 / ufs 1 no -
LVM
1. Let’s create few copies of metadb on the partitions we create for this puspose:
# metadb -a -f -c 2 c0d0s7 c0d1s7
2. It’s time to put our disks where OS reside under management of SVM
# metainit -f d10 1 1 c0d0s0
d10: Concat/Stripe is setup
# metainit -f d11 1 1 c0d0s1
d11: Concat/Stripe is setup
# metainit d0 -m d10
d0: Mirror is setup
# metainit d1 -m d11
d1: Mirror is setup
# metaroot d0
3. Check newly created devices:
# ls -l /dev/md/rdsk
total 8
lrwxrwxrwx 1 root root 36 Aug 30 18:29 d0 -> ../../../devices/pseudo/md@0:0,0,raw
lrwxrwxrwx 1 root root 36 Aug 30 18:29 d1 -> ../../../devices/pseudo/md@0:0,1,raw
lrwxrwxrwx 1 root root 37 Aug 30 18:28 d10 -> ../../../devices/pseudo/md@0:0,10,raw
lrwxrwxrwx 1 root root 37 Aug 30 18:28 d11 -> ../../../devices/pseudo/md@0:0,11,raw
# ls -l /dev/md/dsk
total 8
lrwxrwxrwx 1 root root 36 Aug 30 18:29 d0 -> ../../../devices/pseudo/md@0:0,0,blk
lrwxrwxrwx 1 root root 36 Aug 30 18:29 d1 -> ../../../devices/pseudo/md@0:0,1,blk
lrwxrwxrwx 1 root root 37 Aug 30 18:28 d10 -> ../../../devices/pseudo/md@0:0,10,blk
lrwxrwxrwx 1 root root 37 Aug 30 18:28 d11 -> ../../../devices/pseudo/md@0:0,11,blk
4. Make appropriate changes in /etc/vfstab to get boot from mirror, not standard disks
# egrep "ufs|swap" /etc/vfstab|grep "/dev/md/dsk"
/dev/md/dsk/d1 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
5. The next step is to flush cache buffers and reboot
# sync;sync;sync
# init 6
6. It is time to put second disk under management of SVN
# metainit -f d20 1 1 c0d1s0
d20: Concat/Stripe is setup
# metainit -f d21 1 1 c0d1s1
d21: Concat/Stripe is setup
7. And to add them to created previously mirrors. Be aware process of synchronisation will continue in background and you can check the process
# metattach d0 d20
d0: submirror d20 is attached
# metattach d1 d21
d1: submirror d21 is attached
8. Check the process of building mirrors and wait till they finnish
# metastat
d1: Mirror
Submirror 0: d11
State: Okay
Submirror 1: d21
State: Resyncing
Resync in progress: 96 % done
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 2104515 blocks (1.0 GB)
d11: Submirror of d1
State: Okay
Size: 2104515 blocks (1.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s1 0 No Okay Yes
d21: Submirror of d1
State: Resyncing
Size: 2104515 blocks (1.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d1s1 0 No Okay Yes
d0: Mirror
Submirror 0: d10
State: Okay
Submirror 1: d20
State: Resyncing
Resync in progress: 13 % done
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 16787925 blocks (8.0 GB)
d10: Submirror of d0
State: Okay
Size: 16787925 blocks (8.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s0 0 No Okay Yes
d20: Submirror of d0
State: Resyncing
Size: 16787925 blocks (8.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d1s0 0 No Okay Yes
Device Relocation Information:
Device Reloc Device ID
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
Boot
1. Next step is to check if partition on second disk is active
# fdisk /dev/rdsk/c0d1p0
Total disk size is 1566 cylinders
Cylinder size is 16065 (512 byte) blocks
Cylinders
Partition Status Type Start End Length %
= = = =
1 Active Solaris2 1 1565 1565 100
2. And to add boot record to the second disk to make it bootable
# /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0d1s0
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 233 sectors starting at 50 (abs 16115)
3. Add new item in the boot menu (/boot/grub/menu.lst) to have alternative way to boot
title Alternate boot
root (hd1,0,a)
kernel /platform/i86pc/multiboot
module /platform/i86pc/boot_archive
4. Check if the new item is added to the boot menu
# bootadm list-menu
The location for the active GRUB menu is: /boot/grub/menu.lst
default 0
timeout 10
0 Solaris 10 5/08 s10x_u5wos_10 X86
1 Solaris failsafe
2 Alternate boot
5. That’s all, you have already mirrored root partition (plus swap)
Conclusion
In the document are not mentioned all the options and possibilities of SVM, but only short set, need to done the work. For further information, please consult official Oracle documentation.
Audit (Solaris) - something you have, something you do not know - part 1
Audit subsystem in Solaris is very powerful and can give you a lot of information. In this first article I will give you example how to play with audit for monitoring user actions
1. Check the user i want to monitor
# id test1
uid=200(test1) gid=1(other)
2. And the actions I want to record
# cat /etc/security/audit_class
#
.....
# File Format:
#
# mask:name:description
#
0x00000000:no:invalid class
...
0xffffffff:all:all classes (meta-class)
Of course in above file you will see much more classes and you can set to monitor and audit only part of them, but for this example I will use monitoring all
3. Set user and classes
# cat /etc/security/audit_user
#
...
# username:always:never
#
root:lo:no
test1:all:no
So here I will monitor everything and no exceptions
4. Run bsmconv because of first usage of audit
# /etc/security/bsmconv
This script is used to enable the Basic Security Module (BSM).
Shall we continue with the conversion now? [y/n] y
bsmconv: INFO: checking startup file.
bsmconv: INFO: turning on audit module.
bsmconv: INFO: initializing device allocation.
The Basic Security Module is ready.
If there were any errors, please fix them now.
Configure BSM by editing files located in /etc/security.
Reboot this system now to come up with BSM enabled.
5. And reboot
# init 6
updating /platform/i86pc/boot_archive
6. Login as test1 do some actions and exit
login as: test1
Password:
Last login: Sun Sep 26 10:13:00 2010 from 10.1.0.1
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$ pwd
/export/home/test1
$ ls
$ df -k .
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s7 248647 1042 222741 1% /export/home
$ /usr/sbin/mkfile 10m aa
$ ls -l
total 20496
-rw------- 1 test1 other 10485760 Sep 26 10:13 aa
$ exit
7. Check the audit file(s)
# cd /var/audit
# ls -l
total 128
-rw------- 1 root root 64370 Sep 26 10:16 20100926081119.20100926081640.sol01
8. Browse the content of this audit file
# praudit 20100926081119.20100926081640.sol01
...
header,134,2,execve(2),,sol01,2010-09-26 10:13:35.371 +02:00
path,/usr/sbin/mkfile
attribute,100555,root,bin,3,853,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,102,2,open(2) - read,fe,sol01,2010-09-26 10:13:35.371 +02:00
path,/var/ld/ld.config
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,failure: No such file or directory,-1
header,114,2,munmap(2),,sol01,2010-09-26 10:13:35.371 +02:00
argument,1,0xfef8e000,addr
argument,2,0x10000,len
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,168,2,memcntl(2),,sol01,2010-09-26 10:13:35.371 +02:00
argument,1,0xfee80000,base
argument,2,0x1e4b0,len
argument,3,0x4,cmd
argument,4,0x3,arg
argument,5,0x0,attr
argument,6,0x0,mask
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,114,2,munmap(2),,sol01,2010-09-26 10:13:35.372 +02:00
argument,1,0xfefb0000,addr
argument,2,0x8000,len
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,139,2,open(2) - read,write,creat,trunc,,sol01,2010-09-26 10:13:35.386 +02:00
path,/export/home/test1/aa
attribute,100600,test1,other,7,5,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,3
header,150,2,close(2),,sol01,2010-09-26 10:13:35.429 +02:00
argument,1,0x3,fd
path,/export/home/test1/aa
attribute,100600,test1,other,7,5,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
...
As you can see clear here is executed command mkfile and created file, named aa in to the home directory of the user. Of course in above example I use only few of the features in the audit subsystem of Solaris, but in next article will try to present more in deep the options
1. Check the user i want to monitor
# id test1
uid=200(test1) gid=1(other)
2. And the actions I want to record
# cat /etc/security/audit_class
#
.....
# File Format:
#
# mask:name:description
#
0x00000000:no:invalid class
...
0xffffffff:all:all classes (meta-class)
Of course in above file you will see much more classes and you can set to monitor and audit only part of them, but for this example I will use monitoring all
3. Set user and classes
# cat /etc/security/audit_user
#
...
# username:always:never
#
root:lo:no
test1:all:no
So here I will monitor everything and no exceptions
4. Run bsmconv because of first usage of audit
# /etc/security/bsmconv
This script is used to enable the Basic Security Module (BSM).
Shall we continue with the conversion now? [y/n] y
bsmconv: INFO: checking startup file.
bsmconv: INFO: turning on audit module.
bsmconv: INFO: initializing device allocation.
The Basic Security Module is ready.
If there were any errors, please fix them now.
Configure BSM by editing files located in /etc/security.
Reboot this system now to come up with BSM enabled.
5. And reboot
# init 6
updating /platform/i86pc/boot_archive
6. Login as test1 do some actions and exit
login as: test1
Password:
Last login: Sun Sep 26 10:13:00 2010 from 10.1.0.1
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$ pwd
/export/home/test1
$ ls
$ df -k .
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s7 248647 1042 222741 1% /export/home
$ /usr/sbin/mkfile 10m aa
$ ls -l
total 20496
-rw------- 1 test1 other 10485760 Sep 26 10:13 aa
$ exit
7. Check the audit file(s)
# cd /var/audit
# ls -l
total 128
-rw------- 1 root root 64370 Sep 26 10:16 20100926081119.20100926081640.sol01
8. Browse the content of this audit file
# praudit 20100926081119.20100926081640.sol01
...
header,134,2,execve(2),,sol01,2010-09-26 10:13:35.371 +02:00
path,/usr/sbin/mkfile
attribute,100555,root,bin,3,853,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,102,2,open(2) - read,fe,sol01,2010-09-26 10:13:35.371 +02:00
path,/var/ld/ld.config
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,failure: No such file or directory,-1
header,114,2,munmap(2),,sol01,2010-09-26 10:13:35.371 +02:00
argument,1,0xfef8e000,addr
argument,2,0x10000,len
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,168,2,memcntl(2),,sol01,2010-09-26 10:13:35.371 +02:00
argument,1,0xfee80000,base
argument,2,0x1e4b0,len
argument,3,0x4,cmd
argument,4,0x3,arg
argument,5,0x0,attr
argument,6,0x0,mask
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,114,2,munmap(2),,sol01,2010-09-26 10:13:35.372 +02:00
argument,1,0xfefb0000,addr
argument,2,0x8000,len
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,139,2,open(2) - read,write,creat,trunc,,sol01,2010-09-26 10:13:35.386 +02:00
path,/export/home/test1/aa
attribute,100600,test1,other,7,5,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,3
header,150,2,close(2),,sol01,2010-09-26 10:13:35.429 +02:00
argument,1,0x3,fd
path,/export/home/test1/aa
attribute,100600,test1,other,7,5,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
...
As you can see clear here is executed command mkfile and created file, named aa in to the home directory of the user. Of course in above example I use only few of the features in the audit subsystem of Solaris, but in next article will try to present more in deep the options
Play with Solaris project
In this short article I will demonstrate few options of project subsystem in Solaris.
1. Create sample project
# projadd -p 101 -c "my first project" -K "process.max-data-size=(priv,32m,deny)" test1
where 101 is the ID (numeric) of the project
"my first project" is just a comment
test1 is the name of the project
and "process.max-data-size=(priv,32m,deny)" describe attributes. In this example i limit memory data segment to 32 megabytes. The string "priv" is definition who can modify the value and string "deny" define the action when the value is reached.For more info see manual page of resource_controls(5)
2. Check the project
# projects -l
system
projid : 0
comment: ""
users : (none)
groups : (none)
attribs:
...
test1
projid : 101
comment: "my first project"
users : (none)
groups : (none)
attribs: process.max-data-size=(priv,33554432,deny)
3. Test if its work
For this purpose I will use one sample C program to allocate memory and exec it
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
and just in case check exit code :)
# echo $?
1
4. Modify the project to give more memory
projmod -p 101 -K "process.max-data-size=(priv,64m,deny)" test1
5. and check again
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
allocated 33554432 bytes
As you can see all work perfect and we can start using projects in our daily work
1. Create sample project
# projadd -p 101 -c "my first project" -K "process.max-data-size=(priv,32m,deny)" test1
where 101 is the ID (numeric) of the project
"my first project" is just a comment
test1 is the name of the project
and "process.max-data-size=(priv,32m,deny)" describe attributes. In this example i limit memory data segment to 32 megabytes. The string "priv" is definition who can modify the value and string "deny" define the action when the value is reached.For more info see manual page of resource_controls(5)
2. Check the project
# projects -l
system
projid : 0
comment: ""
users : (none)
groups : (none)
attribs:
...
test1
projid : 101
comment: "my first project"
users : (none)
groups : (none)
attribs: process.max-data-size=(priv,33554432,deny)
3. Test if its work
For this purpose I will use one sample C program to allocate memory and exec it
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
and just in case check exit code :)
# echo $?
1
4. Modify the project to give more memory
projmod -p 101 -K "process.max-data-size=(priv,64m,deny)" test1
5. and check again
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
allocated 33554432 bytes
As you can see all work perfect and we can start using projects in our daily work
Solaris x86 root filesystem mirroring
Preamble
This document is directed to give idea how to create mirroring of root filesystem in Solaris x86 with the help of Solaris Volume Manager. Here will be used already installed OS and all the work will be done without need of reinstall
Prerequisites
1. First we should be sure have two identical harddisks in the server
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 1563 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@7,1/ide@0/cmdk@0,0
1. c0d1 <DEFAULT cyl 1563 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@7,1/ide@0/cmdk@1,0
Specify disk (enter its number): ^C
2. Its need to create small slice for metadb information (usually slice 7) like:
partition> p
Current partition table (unnamed):
Total disk cylinders available: 1563 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 518 - 1562 8.01GB (1045/0/0) 16787925
1 swap wu 3 - 133 1.00GB (131/0/0) 2104515
2 backup wm 0 - 1562 11.97GB (1563/0/0) 25109595
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 134 - 135 15.69MB (2/0/0) 32130
8 boot wu 0 - 0 7.84MB (1/0/0) 16065
9 alternates wu 1 - 2 15.69MB (2/0/0) 32130
3. Next step is to create the same partitions on the second disk. To
avoid human error it is much better to use some kind of automations:
prtvtoc /dev/rdsk/c0d0s2 > /tmp/c0d0s2.toc
fmthard -s /tmp/c0d0s2.toc /dev/rdsk/c0d1s2
4. Then we should identify the partitions need to be mirrored:
# egrep "ufs|swap" /etc/vfstab|grep "/dev/dsk"
/dev/dsk/c0d0s1 - - swap - no -
/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 / ufs 1 no -
LVM
1. Let’s create few copies of metadb on the partitions we create for this puspose:
# metadb -a -f -c 2 c0d0s7 c0d1s7
2. It’s time to put our disks where OS reside under management of SVM
# metainit -f d10 1 1 c0d0s0 d10: Concat/Stripe is setup # metainit -f d11 1 1 c0d0s1 d11: Concat/Stripe is setup # metainit d0 -m d10 d0: Mirror is setup # metainit d1 -m d11 d1: Mirror is setup # metaroot d03. Check newly created devices:
# ls -l /dev/md/rdsk
total 8
lrwxrwxrwx 1 root root 36 Aug 30 18:29 d0 -> ../../../devices/pseudo/md@0:0,0,raw
lrwxrwxrwx 1 root root 36 Aug 30 18:29 d1 -> ../../../devices/pseudo/md@0:0,1,raw
lrwxrwxrwx 1 root root 37 Aug 30 18:28 d10 -> ../../../devices/pseudo/md@0:0,10,raw
lrwxrwxrwx 1 root root 37 Aug 30 18:28 d11 -> ../../../devices/pseudo/md@0:0,11,raw
# ls -l /dev/md/dsk
total 8
lrwxrwxrwx 1 root root 36 Aug 30 18:29 d0 -> ../../../devices/pseudo/md@0:0,0,blk
lrwxrwxrwx 1 root root 36 Aug 30 18:29 d1 -> ../../../devices/pseudo/md@0:0,1,blk
lrwxrwxrwx 1 root root 37 Aug 30 18:28 d10 -> ../../../devices/pseudo/md@0:0,10,blk
lrwxrwxrwx 1 root root 37 Aug 30 18:28 d11 -> ../../../devices/pseudo/md@0:0,11,blk
4. Make appropriate changes in /etc/vfstab to get boot from mirror, not standard disks
# egrep "ufs|swap" /etc/vfstab|grep "/dev/md/dsk"
/dev/md/dsk/d1 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
5. The next step is to flush cache buffers and reboot
# sync;sync;sync
# reboot
6. It is time to put second disk under management of SVN
# metainit -f d20 1 1 c0d1s0
d20: Concat/Stripe is setup
# metainit -f d21 1 1 c0d1s1
d21: Concat/Stripe is setup
7. And to add them to created previously mirrors. Be aware process of
synchronisation will continue in background and you can check the
process
# metattach d0 d20
d0: submirror d20 is attached
# metattach d1 d21
d1: submirror d21 is attached
8. Check the process of building mirrors and wait till they finnish
# metastat
d1: Mirror
Submirror 0: d11
State: Okay
Submirror 1: d21
State: Resyncing
Resync in progress: 96 % done
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 2104515 blocks (1.0 GB)
d11: Submirror of d1
State: Okay
Size: 2104515 blocks (1.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s1 0 No Okay Yes
d21: Submirror of d1
State: Resyncing
Size: 2104515 blocks (1.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d1s1 0 No Okay Yes
d0: Mirror
Submirror 0: d10
State: Okay
Submirror 1: d20
State: Resyncing
Resync in progress: 13 % done
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 16787925 blocks (8.0 GB)
d10: Submirror of d0
State: Okay
Size: 16787925 blocks (8.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s0 0 No Okay Yes
d20: Submirror of d0
State: Resyncing
Size: 16787925 blocks (8.0 GB)
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d1s0 0 No Okay Yes
Device Relocation Information:
Device Reloc Device ID
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
Boot
1. Next step is to check if partition on second disk is active
# fdisk /dev/rdsk/c0d1p0
Total disk size is 1566 cylinders
Cylinder size is 16065 (512 byte) blocks
Cylinders
Partition Status Type Start End Length %
========= ====== ============ ===== === ====== ===
1 Active Solaris2 1 1565 1565 100
SELECT ONE OF THE FOLLOWING:
1. Create a partition
2. Specify the active partition
3. Delete a partition
4. Change between Solaris and Solaris2 Partition IDs
5. Exit (update disk configuration and exit)
6. Cancel (exit without updating disk configuration)
Enter Selection: 5
2. And to add boot record to the second disk to make it bootable
# /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0d1s0
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 233 sectors starting at 50 (abs 16115)
3. Add new item in the boot menu (/boot/grub/menu.lst) to have alternative way to boot
title Alternate boot
root (hd1,0,a)
kernel /platform/i86pc/multiboot
module /platform/i86pc/boot_archive
4. Check if the new item is added to the boot menu
# bootadm list-menu
The location for the active GRUB menu is: /boot/grub/menu.lst
default 0
timeout 10
0 Solaris 10 5/08 s10x_u5wos_10 X86
1 Solaris failsafe
2 Alternate boot
5. That’s all, you have already mirrored root partition (plus swap)
Conclusion
In the document are not mentioned all the options and possibilities
of SVM, but only short set, need to done the work. For further
information, please consult official Oracle documentation.
Sample configuration of DHCP server on Solaris
Preamble
This document is intended to show how to create DHCP server on Solaris using only command line tools. Of course exist GUI tool, named dhcpmgr, located in /usr/sadm/admin/bin directory, but first usually system administrators prefer and do they work via command line and second graphical environment can be inappropriate in some situations because of security, bandwidth or other reasons.
Installation
1. For our installation we will assume our domain is example.com and default gateway is 10.0.1.1
2. First step is to configure server itself, defining directory where the files will be located, type of repository (can be text files, binary files or NIS+ repository), lease time and default gateway. IN this example will be used domain example.com, text files as repository and leased time 2 days
# dhcpconfig -D -p /var/dhcp -r SUNWfiles -d example.com -l 172000 -a 10.0.1.1
Created DHCP configuration file.
Created dhcptab.
Added "Locale" macro to dhcptab.
Added server macro to dhcptab - sol3.
DHCP server started.
3. Next we should create network from where the IP addresses will be leased.
# pntadm -C 10.0.1.0
4. Just in case let check the list of configured networks
# pntadm -L
10.0.1.0
5. Lets put in repository addresses from 10.0.1.64 to 10.0.1.79 to be managed by DHCP server
# for i in `echo "echo 10.0.1.{64..79}"|bash`; do pntadm -r SUNWfiles -p /var/dhcp -A $i 10.0.1.0; done
6. And check what the situation with addresses is.
# pntadm -P 10.0.1.0
Client ID Flags Client IP Server IP Lease Expiration Macro Comment
01000C2913E7E8 00 10.0.1.79 10.0.1.12 08/31/2008 UNKNOWN
00 00 10.0.1.78 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.77 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.76 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.75 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.74 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.73 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.72 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.71 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.70 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.69 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.68 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.67 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.66 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.65 10.0.1.12 Zero UNKNOWN
00 00 10.0.1.64 10.0.1.12 Zero UNKNOWN
7. For our surprise someone already lease 10.0.1.79, so our server work
Conclusion
In the document are not mentioned many of the options of the user
programs, but you can take a look in appropriate man pages, official SUN
documentation and related papers
Sample NIS implementation on Solaris
Preamble
This document is intended to give idea about sample implementation of NIS. In the document will be used commands and files as they are in Solaris 10. For your flavour of UNIX or Linux refer to the documentation.
Implementation
1. We should set in the beginning the domain name of our new NIS
domain. Here will be used domain name “example”, for your configuration,
consult your infrastructure manager and documentation. With command
domainname we can set the domain, but until next reboot, so better edit
file /etc/defaultdomain and put in to the file the name of your domain.
Be careful to set the same name as you enter in domainname command.
# domainname example
# domainname > /etc/defaultdomain
2. It’s very wise to define dedicated repository for NIS files
instead of using original files of the machine. This can help in case of
problems with NIS server and avoid potential risk, based on usage of
the same root password on all NIS clients. And in some circumstances
it’s good to have local users like sys, adm, mail, so we should exclude
them from passwd file. For this purpose we will set up directory, named
nisfiles and /etc look a fine container for the directory.
# mkdir /etc/nisfiles
3. Here is the example list of files to be copied in our NIS
repository:
auto_home auto_master bootparams ethers group hosts ipnodes netgroup
netmasks networks passwd protocols rpc services shadow user_attr
publickey timezone
4. Next step is to go in directory /var/yp and edit Makefile. Change the line DIR =/etc to be DIR =/etc/nisfiles and if need the line started with all: to define services will be served by NIS. The actual creation of map files can be done via command make or ypinit –m
# ypinit -m
In order for NIS to operate sucessfully, we have to construct a list of the
NIS servers. Please continue to add the names for YP servers in order of
preference, one per line. When you are done with the list, type a <control D>
or a return on a line by itself.
next host to add: sol1
next host to add: ^D
The current list of yp servers looks like this:
sol1
Is this correct? [y/n: y]
Installing the YP database will require that you answer a few questions.
Questions will all be asked at the beginning of the procedure.
Do you want this procedure to quit on non-fatal errors? [y/n: n]
OK, please remember to go back and redo manually whatever fails. If you
don't, some part of the system (perhaps the yp itself) won't work.
The yp domain directory is /var/yp/example
There will be no further questions. The remainder of the procedure should take
5 to 10 minutes.
Building /var/yp/example/ypservers...
Running /var/yp /Makefile...
updated passwd
updated group
updated hosts
updated ipnodes
updated networks
updated rpc
updated services
updated protocols
/var/yp/example/mail.aliases: 12 aliases, longest 10 bytes, 138 bytes total
/usr/lib/netsvc/yp/mkalias /var/yp/`domainname`/mail.aliases /var/yp/`domainname`/mail.byaddr;
updated aliases
updated publickey
updated netid
/usr/sbin/makedbm /etc/nisfiles/netmasks /var/yp/`domainname`/netmasks.byaddr;
updated netmasks
updated timezone
updated auto.master
updated auto.home
updated ageing
updated auth_attr
updated exec_attr
updated prof_attr
updated user_attr
updated audit_user
updated bootparams
updated ethers
updated netgroup
sol1 has been set up as a yp master server without any errors.
If there are running slave yp servers, run yppush now for any data bases
which have been changed. If there are no running slaves, run ypinit on
those hosts which are to be slave servers.
5. Edit /var/yp/securenets to add networks, to be served by server. Record should look like
255.255.255.0 10.0.1.0
6. It’s time to start (restart) our NIS server and check if it running
# svcadm restart nis/server
# svcs -av|grep nis
disabled - 7:25:29 - svc:/network/rpc/nisplus:default
disabled - 7:25:30 - svc:/system/patch-finish:delete
online - 8:16:53 96 svc:/network/nis/xfr:default
online - 8:16:54 97 svc:/network/nis/passwd:default
online - 8:16:54 99 svc:/network/nis/update:default
online - 8:31:58 102 svc:/network/nis/client:default
online - 8:36:49 103 svc:/network/nis/server:default
# ps -efl|grep yp
0 S daemon 149 1 0 40 20 ? 1075 ? 07:25:42 ? 0:00 /usr/lib/crypto/kcfd
0 S root 2404 1 0 40 20 ? 1289 ? 08:36:49 ? 0:00 /usr/lib/netsvc/yp/ypserv
0 S root 1429 1 0 40 20 ? 1302 ? 08:16:54 ? 0:00 /usr/lib/netsvc/yp/ypxfrd
0 S root 1443 1 0 40 20 ? 468 ? 08:16:54 ? 0:00 /usr/lib/netsvc/yp/rpc.ypupdated
0 S root 1436 1 0 40 20 ? 1288 ? 08:16:54 ? 0:00 /usr/lib/netsvc/yp/rpc.yppasswdd -m
0 S root 2390 1 0 40 20 ? 526 ? 08:31:58 ? 0:00 /usr/lib/netsvc/yp/ypbind
7. Then we should set your server as client. This is usual situation
and only in special circumstances you should set one machine only as NIS
server, but not client. When you configure other servers as clients do
not forget to set /etc/defaultdomain and nsswitch.conf files
# ypinit -c
In order for NIS to operate sucessfully, we have to construct a list of the
NIS servers. Please continue to add the names for YP servers in order of
preference, one per line. When you are done with the list, type a <control D>
or a return on a line by itself.
next host to add: sol1
next host to add: ^D
The current list of yp servers looks like this:
sol1
Is this correct? [y/n: y]
8. And now is time to check if everything works fine. There is in
/etc/nisfiles/hosts record for host m1, but not in /etc/inet/hosts:
# getent hosts m1
10.0.1.51 m1
# ypcat hosts
127.0.0.1 localhost
10.0.1.10 sol1 loghost
10.0.1.53 m3
10.0.1.52 m2
10.0.1.51 m1
Conclusion
Of course this short document do not cover all aspects and details of
NIS, so it is strictly recommended to read and understand the
documentation for your OS and special notes, related to NIS client and
server.
Quick guide for installation Glassfish on Solaris
Preamble
One of the tasks of UNIX/Linux administration is the installation of software. In this article we will discuss the installation of Glassfish - a Java application server from Oracle on the Solaris platform:-
Prerequisites
For the installation we will need Solaris OS installed and a JDK . For an example manual on how to install Solaris, see.
In this example we will use JDBC connection to an Oracle database. For
the Oracle client we could choose Instant Client or the full
Installation, because, in our case, we will only need ojdbc14.jar to be
in the Glassfish /lib directory. But I strictly recommend installing the
full Oracle client, (Administrator), because there are a lot of helpful
utilities such as sqlplus, tnsping which can help resolve oracle (and
other) connectivity problems there. Also recommended is to install its
own version of JDK (as described in the remarks here:
This will help you have a nonchangeable environment to run the
application server. However it will add some system administration
overhead. But it will increase the reliability of our environment.
Installation process
- Install Oracle client
(below we assume the installation base is in /opt/oracle and the installation of the client is in the directory: /opt/oracle/product/10.2.0/client_1 and the version of Oracle client is 10.2) - Create a user to run our application server:
useradd -d /opt/Glassfish -k /etc/skel -m Glassfish
Of course it is possible to run Glassfish as root, but for security reasons, the separation of duties and privileges is strictly recommended to run software under its own user. On the above command ignore the error, related to the length of the user name. - Download and extract JDK for example in /etc/Glassfish/java
- Download Glassfish software and put the archive in /opt
Do not forget to change ownership of the file and to remove it after installation - Set the environment variables for Glassfish user:
JAVA_HOME=/opt/Glassfish/java
ORACLE_BASE=/opt/oracle
ORACLE_HOME=${ORACLE_BASE}/product/10.2.0/client_1
ORACLE_SID=ORCL
LD_LIBRARY_PATH=${ORACLE_HOME}/lib:/lib:/usr/lib
CLASSPATH=${ORACLE_HOME}/jre:${ORACLE_HOME}/jlib:${ORACLE_HOME}/rdbms/jlib
ANT_HOME=/opt/Glassfish/lib/ant
PATH=${JAVA_HOME}/bin:${ANT_HOME}/bin:$PATH
export JAVA_HOME ORACLE_BASE ORACLE_HOME LD_LIBRARY_PATH CLASSPATH ANT_HOME PATH
- switch to Glassfish user
- run installation of Glassfish
java -Xmx256m -jar Glassfish-installer-v2-b58g.jar
(the name of Glassfish installation file is just an example, your may vary) - go to Glassfish home directory
- add executable mode to ant
chmod -R +x lib/ant/bin - run ant to accomplish configuration of Glassfish
lib/ant/bin/ant -f setup.xml
(if server will be in cluster instead of setup.xml use setup-cluster.xml) - Voila! You have installed the Glassfish Java application server
Prepare sample jumpstart server
Introduction
This guide is directed to create very sample JumpStart server for almost unattended installation of Solaris.
Steps
- Create directory where will be created image of CD or DVD for installation - /export/install
- Go to cdrom directory contain tools /cdrom/sol_10_606_x86/Solaris_10/Tools
- Run setup_install_server with parameter directory, created at point 1 - ./setup_install_server /export/install This process can take long time, but you can continue with the rest of process meanwhile
- Let's prepare file sysidcfg with answers of questions during installation for creating automatic installation
- Create directory for storing configuration files /export/config
- Create sysidcfg file, where netmask_value – usually this is netmask of the server i.e. Server and client are in the same network, gateway – just set the same default gateway as server (see above), for name_service set none. It's possible to define DNS, NIS, etc., but you can configure them later. For the timezone value, enter time zone for your location. Time zone files are located in directory tree below /usr/share/lib/zoneinfo. For me the zone is Europe/Sofia. Set locale value as you prefer. You can choose en_US.UTF-8 which is enough common for many purposes and do not interfere with not localized software. For the timeserver_IP value, enter the IP address of the system that will provide the time-of-day to the JumpStart client. This string (y5KqWP1EnT5Es) for root_password is hash of my password, you should set your
- Next step is to create rules and profile files for clients in the same directory
- Sample rules file looks like(see examples), where hostname is keyword, c1 is just name of client, and p1 is filename of profile, applied to this client. First dash mean no pre-installation script, second dash mean no post-installation script
- Create profile file, where install_type is actually type of installation :-), system_type is standalone (let's make thinks sample), partitioning is explicit to force repartitioning of disks, filesys describe filesystems to be created. In my case I use IDE harddisks, if you have SCSI, set in appropriate way. Cluster mean which cluster of packages to install. In my case - everything
- Add record in /etc/inet/hosts for client (same host name as in rules file)
- Add record in /etc/ethers in format (see ecamples)
- Copy utility for checking if profile and rules files are ok: cp /export/install/Solaris_10/Misc/jumpstart_sample/check /export/config
- run check utility: cd /export/config; ./check
- everything is OK continue, otherwise correct the error and start program again
- Run add_install_client (see examples), where -c is for place where rules and profile files reside, -p is for place where sysidcfg file next is hostname of client and at the end architecture of client
- After this export config directory: share -o ro /export/config
- For x86 installation you should create a grub floppy and edit GRUB menu to contain the following entry (see examples)
- After this reboot client machine with this floppy and voila – you have installed Solaris over the network :-)
Examples
sysidcfg file:network_interface=primary {protocol_ipv6=no
netmask=255.255.255.0
default_route=192.168.30.1}
security_policy=none
name_service=none
timezone=Europe/Sofia
system_locale=en_US.UTF-8
timeserver=192.168.30.1
root_password=y5KqWP1EnT5Es
sample profile file:
install_type initial_install
system_type standalone
partitioning explicit
filesys c0d0s0 free /
filesys c0d0s1 512 swap
cluster SUNWCXall
Grub entry:
title Solaris netinstall
rarp
kernel /I86PC.Solaris_10-1/multiboot kernel/unix -B install_media=192.168.30.2:/export/install
module /I86PC.Solaris_10-1/x86.miniroot
/etc/ethers in format:
MAC_ADDRESS hostname
Run add_install_client
./add_install_client -c t1:/export/config -p t1:/export/config t3 i86pc
Implement IPMP on Solaris
Preamble
This document is intended to give fast overview and sample way to implement IPMP on SUN Solaris. IPMP play very important role in SUN strategy to provide high availability in Solaris. Basic idea is to have IP address why “switch” between physical interfaces in case of fail of one of them
Prerequisites
1. To implement IPMP you need to have on the machine 2 NICs with unique MAC addresses2. NICs in IPMP group should have same media type (i.e. Ethernet or ATM for example)
3. NICs should be be connected to the same switch or hub. In case of switch check if they are in same VLAN (if configured)
4. Loaded ip module to the interface
# ifconfig e1000g2 modlist
0 arp
1 ip
2 e1000g
5. If you do not have it execute
# ifconfig e1000g2 modinsert ip
6. Working gateway for IPs used in IPMP group
Setup
1. set in /etc/hostname.e1000g2 and /etc/hostname.e1000g3 the
appropriate parameters for to attach interfaces to the group named test
and set additional IP address
# cat /etc/hostname.e1000g2
sun3-2-1 netmask + broadcast + failover group test up addif sun3-2 netmask + broadcast + -failover deprecated up
# cat /etc/hostname.e1000g3
sun3-2-2 netmask + broadcast + failover group test up
2. activate the interfaces
# ifconfig e1000g2 plumb
# ifconfig e1000g3 plumb
# ifconfig e1000g2 `cat /etc/hostname.e1000g2 `
Setting netmask of e1000g2 to 255.255.255.0
Created new logical interface e1000g2:1
Setting netmask of e1000g2:1 to 255.255.255.0
# ifconfig e1000g3 `cat /etc/hostname.e1000g3 `
Setting netmask of e1000g3 to 255.255.255.0
3. Check what's happen with interfaces and IPs
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
e1000g1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.1.88 netmask ffffff00 broadcast 192.168.1.255
ether 0:c:29:b2:8f:92
e1000g2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 12
inet 10.0.1.12 netmask ffffff00 broadcast 10.0.1.255
groupname test
ether 0:c:29:b2:8f:9c
e1000g2:1: flags=9040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4,NOFAILOVER> mtu 1500 index 12
inet 10.0.1.32 netmask ffffff00 broadcast 10.0.1.255
e1000g3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 10
inet 10.0.1.22 netmask ffffff00 broadcast 10.0.1.255
groupname test
ether 0:c:29:b2:8f:b0
Final notes
Of course the above example give just very brief explanation and
sample configuration. For more information take a look on the official Oracle documentations.
Subscribe to:
Posts (Atom)
Should I trust AI
Should I trust AI? So far no, sorry. I tested for the moment (May, 2025) most advanced model for programming and ask very simple question:...
-
There are some cases when you want to create compressed tar archive but you do not have enough disk space to keep original files and tar arc...
-
To build firewall under AIX is sample, but as each host based firewall should be done careful 1. Prerequisites To start firewall in AIX yo...
-
Should I trust AI? So far no, sorry. I tested for the moment (May, 2025) most advanced model for programming and ask very simple question:...