CRONTAB:
The cron daemon, which translates to Chronological Data Event Monitor,
is a program that schedules jobs to run automatically at a specific time
and date. The /etc/inittab file contains all the AIX startup programs,
including the cron daemon. The init process in AIX starts the cron
daemon, or cron, from the inittab file during the initialization process
of the operating system.
You can submit jobs, or events, to cron by doing one of the following:
Use the at and batch facilities to submit jobs for one-time execution.
Use the crontab files to execute jobs at regularly scheduled intervals (hourly, daily, weekly, and so on).
By default, cron can concurrently run 100 events of equal importance.
The /usr/adm/cron/queuedefs file allows you to change this schedule.
c.200j10n120w
| | | |
| | | wait period (in seconds)
| | nice value
| jobs
cron
At regularly scheduled intervals, cron looks for and reads the crontab
files that are located in the directory /var/spool/cron/crontabs.
These files contain jobs submitted by users. For example, the file
/var/spool/cron/crontabs/john contains John's jobs that are scheduled to
be run by cron
The cron daemon reads the files in the /var/spool/cron/crontabs
directory. The files in this directory are named for the individual
users.
When changes are made to the files in the crontabs directory, the cron daemon must be notified to reread the files
/var/adm/cron/log cron daemon creates a log of its activities
/var/adm/cron/cron.deny Any user can use cron except those listed in this file
/var/adm/cron/cron.allow Only users listed in this file can use cron (root user included)
crontab -l Lists the contents of your current crontab file
crontab -e Edits your current crontab file (when the file saved, the cron daemon is automatically refreshed.)
crontab -r Removes your crontab file from the crontab directory
crontab -v check crontab submission time
crontab mycronfile submit your crontab file to /var/spool/cron/crontabs directory
crontab file format:
minute hour day_of_month month weekday command
0-59 0-23 1-31 1-12 0-6 Sun-Sat shell command
* * * * * /bin/script.sh schedule a job to run every minute
0 1 15 * * /fullbackup 1 am on the 15th of every month
0 0 * * 1-5 /usr/sbin/backup start the backup command at midnight, Mo - Fr
0,15,30,45 6-17 * * 1-5 /home/script1 execute script1 every 15 minutes between 6AM and 5PM, Mo - Fr
0 1 1 * * /tmp -name 'TRACE*' -mtime +270 -exec rm {} \\; >/dev/null 2>&1 it will delete files older than 9 months
(\\; <-- double "\" needed because to interpret ";" correctly)
----------------------------
AT:
at submits a job for cron to run at a specific time in the future
(at -f /home/root/bb_at -t 2007122503)
echo "<command>" | at now this starts in the background (and you can log off)
at now +2 mins
banner hello > /dev/pts/0
<ctrl-d> (at now + 1 minute,at 5 pm Friday )
/var/adm/cron/at.deny allows any users except those listed in this file to use the at command.
/var/adm/cron/at.allow allows only those users listed in this file to use the at command (including root).
at -l Lists at jobs
atq [user] Views other user's jobs (Only root can use this command.)
at -r Cancels an at job
atrm job Cancels an at job by job number
atrm user Cancels an at job by the user (root can use it for any user; users can cancel their jobs.)
atrm Cancels all at jobs belonging to the user invoking the atrm command
batch submits a job to be run in the background when the processor load is low
Friday, September 20, 2013
CPU PROCESSES
Physical - Virtual - Logical CPU:
Physical Processors are cores in the machine. Virtual Processors are assigned to an LPAR manually when LPAR is created. Logical Processors are created automatically by AIX, depending on the SMT setting.
------------------------
Simultaneous Multi-Threading (SMT)
SMT is that feature of a Power Processor, when multiple hardware threads can run on one physical processor at the same time (a processor appears as 2 or 4 logical CPU). Within a CPU (core/cpu/processor are the same thing) there are multiple execution units. For example: floating point arithmetic unit, load and store execution units... A single thread would use only 1 or 2 of those units at any point in time. So most of the executional units within a core will not be utilized. With the ability of multi-threading 2 (or 4) threads could be running in a core at same time. One of them will use the floating processor while the other doing load and store ...(If there are collisions, one of them would be delayed but it happens no too often.)
How threads will be dispatched to multiple cores:
First thread will be dispatched to the primary hw thread of a physical cpu. If we have another CPU then next thread will be dispatched there (to avoid collision)
IMPORTANT:
- Prior AIX6 TL4: if only a single hw thread was busy, processor reported as 100% utilized (this is an error because all the secondary threads were not utlized)
- AIX6 TL4 and later: potential capacity of unused hw threads are from TL4 reported as idle time for the processor (it measures the capacity of the unused hw threads.)
------------------------
SMT behaviour and intelligent SMT threads:
AIX default behaviour is to use all the VPs for maximun performance. If workload grows it will use up all VPs (CPU cores) quickly, but AIX first uses SMT thread 1 on all CPU cores before allocating work to the 2nd, 3rd and 4th SMT threads.
SMT threads can be seen as Logical CPUs on AIX. If SMT=4 then 1 VP shows up as 4 Logical CPU. From Power7 there is a thing called "intelligent SMT threads". If there are not enough processes to run on all SMT threads (official mode is SMT=4) it will be dynamically switched to 2 or 1.
mpstat or topas -L is showing it:
At the column "lpa" the sign "-" will show turned off SMT threads
# mpstat 2
cpu min maj mpc int cs ics rq mig lpa sysc us sy wa id pc %ec lcs
0 0 0 0 265 35 24 2 0 100 64 100 0 0 0 0.63 31.7 99
1 0 0 0 12 12 0 0 0 100 9 0 0 0 100 0.12 6.1 22
2 0 0 0 9 0 0 0 0 - 0 0 0 0 100 0.12 6.1 20 <--this SMT thread is turned off
3 0 0 0 9 0 0 0 0 - 0 0 0 0 100 0.12 6.1 19 <--this SMT thread is turned off
4 0 0 0 100 12 8 1 0 100 0 100 0 0 0 0.64 31.8 99
5 0 0 0 19 59 0 0 0 100 9 0 0 0 100 0.12 6.1 69
6 0 0 0 9 0 0 0 0 - 0 0 0 0 100 0.12 6.1 9 <--this SMT thread is turned off
7 0 0 0 9 0 0 0 0 - 0 0 0 0 100 0.12 6.1 9 <--this SMT thread is turned off
ALL 0 0 0 432 118 32 3 0 0 82 63 0 0 37 2.00 999.8 346
--------------------------------------------------------------------------------
------------------------
Context Switch:
It is inherent in any multiprocessing operating system. Different appl. threads are sharing a CPU. Every time 1 thread is leaving a CPU and a new thread is dispatched to the CPU, a context switch occurs. The environment of the leaving one has to be saved and new environment ha to be reestablished for the new process. High context switch rates can cause many work (overhead) for the CPU, which can be a problem.
------------------------
PROCESS:
You use commands to tell the operating system what task you want it to perform. When commands are entered, they are recognized by a command interpreter (also known as a shell), and the task is processed.
A program or command that is actually running on the computer is referred to as a process.
The commom types of processes:
Foreground processes
Processes that require a user to start them or to interact with. Programs and commands run as foreground processes by default.
Background processes
Processes that are run independently of a user. To run a process in the background, type the name of the command with the appropriate parameters and flags, followed by an ampersand (&). When a process is running in the background, you can perform additional tasks by entering other commands at the command prompt. Most processes direct their output to standard output (stdout), even when they run in the background. Because the output from a background process can interfere with your other work on the system, it is usually good practice to redirect the output of a background process to a file.
Daemon processes
Daemons are processes that run unattended. They are constantly in the background and are available at all times. Daemons are started usually when the system starts, and they run until the system stops. A daemon process typically performs system services. For example qdaemon (provides access to system resources such as printers) and sendmail are daemons.
Zombie processes
A zombie process is a dead process that is no longer executing but is still recognized in the process table (in other words, it has a PID number). Zombie processe have been killed or have exited and continue to exist in the process table until the parent process dies or the system is shut down and restarted. Zombie processes display as <defunct> when listed by the ps command. The only way to remove zombies is to reboot the system.
Thread
Each process is made up of one or more kernel threads. A thread is a single sequential flow of control. Rather than duplicating the environment of a parent process, as done via fork, all threads within a process use the same address space and can communicate with each other through variables.
------------------------------
Process priority
A priority is a number assigned to a thread. The kernel maintains a priority value (0-255). A smaller priority value indicates a more important thread. Real time thread priorities are lower than 40.
Nice value
A nice value is a priority adjustment factor added to the base user priority of 40 (for non-fixed priority threads). The nice value is used by the system to calculate the current priority of a running process. The first process in the system (init) has a nice value of 20, and therefore an effective priority of 60. (PRI heading in the below output) A foreground process has a nice value of 20 (24 for a background process).
ps -el shows process priorities
ps -ekl shows process priorities including kernel processes
ps -kmo THREAD shows processes with their threads priorities
root@aix31: / # ps -el <--shows the nice values under the NI heading (-- means it is running with fixed prio.
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
200003 A 0 1 0 0 60 20 7037000 784 - 0:39 init
200103 A 0 311326 352456 0 24 -- 81d8400 4676 - 1:15 xmtopas
The nice value can be set at process creation time by using the nice command. If the process already created the renice command is used.
(ksh will add automatically 4 to the default nice value (20) if a process is started in the background (&))
The nice value can be ranged from 0 to 39, with 39 being the lowest priority.
nice -10 <command> add 10 to current nice value (lower priority)
nice --10 <command> subtract 10 from current nice value (higher priority)
The renice value can be -20 to 20. (1-20: lowers the priority, 0:sets to the base scheduling priority, -20 to -1:highers the priority)
renice 10 -p <pid> add 10 to the default nice value (20) (lower priority)
renice -n 10 -p <pid> add 10 to current nice value (lower priority)
renice -10 -p <pid> subtract 10 from the default nice value (20) (higher priority)
renice -n -10 -p <pid> subtract 10 from current nice value (higher priority)
(-n: incerment is added to the current nice value, not default)
---------------------------
CPU infos:
lscfg | grep proc shows how many (virtual) processors we have (lsdev -Cc processor, shows also how many virt. proc we have)
bindprocessor -q shows how many logical (SMT) processors we have
lsattr -El procX shows the processor settings
pmcycles -m shows the processors speed (if smt is enabled it will show for all the logical processors)
smtctl it will show how many processor we have (if smt is turned on or not)
---------------------------
Process handling:
Ctrl-C or Ctrl-Backspace cancels a foreground process
ps lists processes (by default lists only processes started from the current terminal)
-e every process runnning on the system
-f full listing (username, PPID...)
-L <pid> lists all processes which PPID is <pid>
-u <user> lists all processes running under <user>
-T lists the tree of a given process (shows the children of a given process)
ps -elmo THREAD lists processes and its threads (shows pids and the threads (tid) which belong to a given process)
proctree <pid> displays the process tree of the specified process
kill <pid> notification to the process to terminate (it is using the default, 15, signal)
kill -9 <pid> kills the process without notification
kill -1 <pid> restarts the process (rereads the config files as well) (HUP - hangup)
(when a background process is running and you log off a hangup signal is sent)
kill -2 <pid> interrupt signal (same as ctrl+c)
kill -l lists all the signals supported by kill (cat /usr/include/sys/signal.h will show as well, with details)
ls -R / > ls.out & starts ls in the background (standard output is ls.out)
nohup ls -R / > ls.out & nohup allows a background process to continue after logging off the system
(if output isn't redirected, it will create nohup.out)
echo "<command>" | at now this also starts in the background (and you can log off)
jobs lists which processes are running in the background
nohup alt_disk_copy -d hdisk1 -B & can't be hanged up and in backgound (kill command can stop it)
Restarting a stopped foreground process (jobs command):
1. Ctrl-Z stops a foreground process, its PID is still in the process table (it goes to background)
2. jobs this will list stopped processes
[1] + Stopped (SIGTSTP) ./myscript <--you will see a line like this (here #1 is the job id)
3. fg %1 put given job into foregeound (bg %1 puts into background)
Restarting a stopped foreground process (ps -ef <pid>):
1.Ctrl-Z stops a foreground process, its PID is still in the process table (it goes to background)
2.ps -ef | grep <PROC.NAME> find the process ID (PID)
3.fg <PID> restarts that stopped proces (it will go to foreground)
Removing a background process:
1.find / -type f > output & run the find command in the background
2.ps lists the PID numbers
3.kill <PID> cancel the process
------------------------------
The operating system allows you to manipulate the input and output (I/O) of data to and from your system. For example you can specify to read input entered on the keyboard (standard input) or to read input from a file. Or you can specify to write output data to the screen (standard output) or to write it to a file.
When a command begins running, it usually expects that the following files are already open: standard input, standard output and standard error. A number, called a file descriptor, is associated with each of these files:
0 represents standard input (stdin)
1 represents standard output (stdout)
2 represents standard error (stderr)
The redirection symbols and their meanings:
< redirects input (stdin) (< filename is added to the end of the command)
> redirects output (stdout) (> filename is added to the end of the command)
>> appends output
<< inline input (see pg. 574)
2> redirects output (stderr)
1>&2 redirects stdout to stderr
2>&1 redirects stderr to stdout
mail denise < letter1 sends the file letter1 to user denise with the mail command
echo $PATH > path1 saves the value of the PATH variable on the file path1
cat file2 >> file1 append file2 to file1 (the cat commands can concatenate not only display files)
ls -l file1 2> list1 save the stderr to file list1 (if file1 does not exist)
ls *.dat *.txt > files.out 2> files.err (files.out: stdout, file.err: stderr)
command > output 2>&1 saves all the output (stdout and stderr) in one single file
Physical Processors are cores in the machine. Virtual Processors are assigned to an LPAR manually when LPAR is created. Logical Processors are created automatically by AIX, depending on the SMT setting.
------------------------
Simultaneous Multi-Threading (SMT)
SMT is that feature of a Power Processor, when multiple hardware threads can run on one physical processor at the same time (a processor appears as 2 or 4 logical CPU). Within a CPU (core/cpu/processor are the same thing) there are multiple execution units. For example: floating point arithmetic unit, load and store execution units... A single thread would use only 1 or 2 of those units at any point in time. So most of the executional units within a core will not be utilized. With the ability of multi-threading 2 (or 4) threads could be running in a core at same time. One of them will use the floating processor while the other doing load and store ...(If there are collisions, one of them would be delayed but it happens no too often.)
How threads will be dispatched to multiple cores:
First thread will be dispatched to the primary hw thread of a physical cpu. If we have another CPU then next thread will be dispatched there (to avoid collision)
IMPORTANT:
- Prior AIX6 TL4: if only a single hw thread was busy, processor reported as 100% utilized (this is an error because all the secondary threads were not utlized)
- AIX6 TL4 and later: potential capacity of unused hw threads are from TL4 reported as idle time for the processor (it measures the capacity of the unused hw threads.)
------------------------
SMT behaviour and intelligent SMT threads:
AIX default behaviour is to use all the VPs for maximun performance. If workload grows it will use up all VPs (CPU cores) quickly, but AIX first uses SMT thread 1 on all CPU cores before allocating work to the 2nd, 3rd and 4th SMT threads.
SMT threads can be seen as Logical CPUs on AIX. If SMT=4 then 1 VP shows up as 4 Logical CPU. From Power7 there is a thing called "intelligent SMT threads". If there are not enough processes to run on all SMT threads (official mode is SMT=4) it will be dynamically switched to 2 or 1.
mpstat or topas -L is showing it:
At the column "lpa" the sign "-" will show turned off SMT threads
# mpstat 2
cpu min maj mpc int cs ics rq mig lpa sysc us sy wa id pc %ec lcs
0 0 0 0 265 35 24 2 0 100 64 100 0 0 0 0.63 31.7 99
1 0 0 0 12 12 0 0 0 100 9 0 0 0 100 0.12 6.1 22
2 0 0 0 9 0 0 0 0 - 0 0 0 0 100 0.12 6.1 20 <--this SMT thread is turned off
3 0 0 0 9 0 0 0 0 - 0 0 0 0 100 0.12 6.1 19 <--this SMT thread is turned off
4 0 0 0 100 12 8 1 0 100 0 100 0 0 0 0.64 31.8 99
5 0 0 0 19 59 0 0 0 100 9 0 0 0 100 0.12 6.1 69
6 0 0 0 9 0 0 0 0 - 0 0 0 0 100 0.12 6.1 9 <--this SMT thread is turned off
7 0 0 0 9 0 0 0 0 - 0 0 0 0 100 0.12 6.1 9 <--this SMT thread is turned off
ALL 0 0 0 432 118 32 3 0 0 82 63 0 0 37 2.00 999.8 346
--------------------------------------------------------------------------------
------------------------
Context Switch:
It is inherent in any multiprocessing operating system. Different appl. threads are sharing a CPU. Every time 1 thread is leaving a CPU and a new thread is dispatched to the CPU, a context switch occurs. The environment of the leaving one has to be saved and new environment ha to be reestablished for the new process. High context switch rates can cause many work (overhead) for the CPU, which can be a problem.
------------------------
PROCESS:
You use commands to tell the operating system what task you want it to perform. When commands are entered, they are recognized by a command interpreter (also known as a shell), and the task is processed.
A program or command that is actually running on the computer is referred to as a process.
The commom types of processes:
Foreground processes
Processes that require a user to start them or to interact with. Programs and commands run as foreground processes by default.
Background processes
Processes that are run independently of a user. To run a process in the background, type the name of the command with the appropriate parameters and flags, followed by an ampersand (&). When a process is running in the background, you can perform additional tasks by entering other commands at the command prompt. Most processes direct their output to standard output (stdout), even when they run in the background. Because the output from a background process can interfere with your other work on the system, it is usually good practice to redirect the output of a background process to a file.
Daemon processes
Daemons are processes that run unattended. They are constantly in the background and are available at all times. Daemons are started usually when the system starts, and they run until the system stops. A daemon process typically performs system services. For example qdaemon (provides access to system resources such as printers) and sendmail are daemons.
Zombie processes
A zombie process is a dead process that is no longer executing but is still recognized in the process table (in other words, it has a PID number). Zombie processe have been killed or have exited and continue to exist in the process table until the parent process dies or the system is shut down and restarted. Zombie processes display as <defunct> when listed by the ps command. The only way to remove zombies is to reboot the system.
Thread
Each process is made up of one or more kernel threads. A thread is a single sequential flow of control. Rather than duplicating the environment of a parent process, as done via fork, all threads within a process use the same address space and can communicate with each other through variables.
------------------------------
Process priority
A priority is a number assigned to a thread. The kernel maintains a priority value (0-255). A smaller priority value indicates a more important thread. Real time thread priorities are lower than 40.
Nice value
A nice value is a priority adjustment factor added to the base user priority of 40 (for non-fixed priority threads). The nice value is used by the system to calculate the current priority of a running process. The first process in the system (init) has a nice value of 20, and therefore an effective priority of 60. (PRI heading in the below output) A foreground process has a nice value of 20 (24 for a background process).
ps -el shows process priorities
ps -ekl shows process priorities including kernel processes
ps -kmo THREAD shows processes with their threads priorities
root@aix31: / # ps -el <--shows the nice values under the NI heading (-- means it is running with fixed prio.
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
200003 A 0 1 0 0 60 20 7037000 784 - 0:39 init
200103 A 0 311326 352456 0 24 -- 81d8400 4676 - 1:15 xmtopas
The nice value can be set at process creation time by using the nice command. If the process already created the renice command is used.
(ksh will add automatically 4 to the default nice value (20) if a process is started in the background (&))
The nice value can be ranged from 0 to 39, with 39 being the lowest priority.
nice -10 <command> add 10 to current nice value (lower priority)
nice --10 <command> subtract 10 from current nice value (higher priority)
The renice value can be -20 to 20. (1-20: lowers the priority, 0:sets to the base scheduling priority, -20 to -1:highers the priority)
renice 10 -p <pid> add 10 to the default nice value (20) (lower priority)
renice -n 10 -p <pid> add 10 to current nice value (lower priority)
renice -10 -p <pid> subtract 10 from the default nice value (20) (higher priority)
renice -n -10 -p <pid> subtract 10 from current nice value (higher priority)
(-n: incerment is added to the current nice value, not default)
---------------------------
CPU infos:
lscfg | grep proc shows how many (virtual) processors we have (lsdev -Cc processor, shows also how many virt. proc we have)
bindprocessor -q shows how many logical (SMT) processors we have
lsattr -El procX shows the processor settings
pmcycles -m shows the processors speed (if smt is enabled it will show for all the logical processors)
smtctl it will show how many processor we have (if smt is turned on or not)
---------------------------
Process handling:
Ctrl-C or Ctrl-Backspace cancels a foreground process
ps lists processes (by default lists only processes started from the current terminal)
-e every process runnning on the system
-f full listing (username, PPID...)
-L <pid> lists all processes which PPID is <pid>
-u <user> lists all processes running under <user>
-T lists the tree of a given process (shows the children of a given process)
ps -elmo THREAD lists processes and its threads (shows pids and the threads (tid) which belong to a given process)
proctree <pid> displays the process tree of the specified process
kill <pid> notification to the process to terminate (it is using the default, 15, signal)
kill -9 <pid> kills the process without notification
kill -1 <pid> restarts the process (rereads the config files as well) (HUP - hangup)
(when a background process is running and you log off a hangup signal is sent)
kill -2 <pid> interrupt signal (same as ctrl+c)
kill -l lists all the signals supported by kill (cat /usr/include/sys/signal.h will show as well, with details)
ls -R / > ls.out & starts ls in the background (standard output is ls.out)
nohup ls -R / > ls.out & nohup allows a background process to continue after logging off the system
(if output isn't redirected, it will create nohup.out)
echo "<command>" | at now this also starts in the background (and you can log off)
jobs lists which processes are running in the background
nohup alt_disk_copy -d hdisk1 -B & can't be hanged up and in backgound (kill command can stop it)
Restarting a stopped foreground process (jobs command):
1. Ctrl-Z stops a foreground process, its PID is still in the process table (it goes to background)
2. jobs this will list stopped processes
[1] + Stopped (SIGTSTP) ./myscript <--you will see a line like this (here #1 is the job id)
3. fg %1 put given job into foregeound (bg %1 puts into background)
Restarting a stopped foreground process (ps -ef <pid>):
1.Ctrl-Z stops a foreground process, its PID is still in the process table (it goes to background)
2.ps -ef | grep <PROC.NAME> find the process ID (PID)
3.fg <PID> restarts that stopped proces (it will go to foreground)
Removing a background process:
1.find / -type f > output & run the find command in the background
2.ps lists the PID numbers
3.kill <PID> cancel the process
------------------------------
The operating system allows you to manipulate the input and output (I/O) of data to and from your system. For example you can specify to read input entered on the keyboard (standard input) or to read input from a file. Or you can specify to write output data to the screen (standard output) or to write it to a file.
When a command begins running, it usually expects that the following files are already open: standard input, standard output and standard error. A number, called a file descriptor, is associated with each of these files:
0 represents standard input (stdin)
1 represents standard output (stdout)
2 represents standard error (stderr)
The redirection symbols and their meanings:
< redirects input (stdin) (< filename is added to the end of the command)
> redirects output (stdout) (> filename is added to the end of the command)
>> appends output
<< inline input (see pg. 574)
2> redirects output (stderr)
1>&2 redirects stdout to stderr
2>&1 redirects stderr to stdout
mail denise < letter1 sends the file letter1 to user denise with the mail command
echo $PATH > path1 saves the value of the PATH variable on the file path1
cat file2 >> file1 append file2 to file1 (the cat commands can concatenate not only display files)
ls -l file1 2> list1 save the stderr to file list1 (if file1 does not exist)
ls *.dat *.txt > files.out 2> files.err (files.out: stdout, file.err: stderr)
command > output 2>&1 saves all the output (stdout and stderr) in one single file
Commands
Commands
CUT:
lspv | cut -c 6-7 lists the hdisks numbers (cuts the 6th and 7tn character (disk nubers))
dlnkmgr view -drv | grep -w 00000 | awk '{print $4}' | cut -d . -f 3
--------------------------------------------------------------------------------
EXPR: integer arithmetic
\* multiplication (\ is needed to tell * is not a special character)
/ division
% remainder
+ addition
- substraction
expr \( 6 + 4 \) / 2 5
--------------------------------------------------------------------------------
FIND: recursively searches the directory tree
find / -xdev -type f -name "cor*" -size +10000c -exec ls -l {} \;
/ where to find
-xdev looks only in the given fs
-type f what type to look for (f: file, d: direcory)
-name "cor*" name to look for
-size +10000c search for the given size (+10000c : greater than 10000 character (larger then 10kbyte))
-size +2 search for greater than 1kbyte (bloxk size is 512 byte, that's why +2 is given)
-exec ls -l {} \; what command to execute
({}: it represents each findings and \; is needed at the end of line)
e.g. find /home -xdev -name "*.old" -exec rm {} \;
-mtime -1 file modifocation date is less then 1 day (+1 means older than 1 day)
find . -name '*.ksh' -ok rm {} \; this will ask if the command (rm) should be executed or not (much safer if find is not perfect)
find /etc/rc.d -ls it lists the files and dirs in the given dir
find /tmp/bb -exec awk '/func/ {print FILENAME}' {} \; it will check in /tmp/bb if any files contains the word "func" and list those
--------------------------------------------------------------------------------
GREP: (Global Regular Expression Parser) The grep command searches for the pattern.
grep -i ignore case (small letter or capital)
grep -c displays only a count of matching lines
grep -n shows line number at the beginning of the matching line
grep -v invert the sense of matching, to select non-matching lines
grep -w selects only whole words
grep -l lists the name of the files (once) which contain matching line (grep -l paging00 *)
ps -ef | egrep 'ssh|aix' select lines with ssh and aix
errpt -a|grep -A1 'NAME' selects lines with NAME and shows 1 line after that (A: after, B: before)
--------------------------------------------------------------------------------
HEAD, TAIL:
head filename displays first 10 lines of the file
head -50 filename displays first 50 lines
tail filename displays last 10 lines of the file
tail -50 filename displays last 50 lines
tail +15 filename displays the file starting from the 15th line
tail -f filename used when we are monitoring the file (interactively shows how the file is changing)
--------------------------------------------------------------------------------
LSOF:
NETWORK
-n no host name resolution
-P not converts port numbers to port names
lsof -i show all network connections
lsof -i| grep LISTEN shows what ports are waiting for connections
lsof -i | grep ESTABLISHED shows current active connections
lsof -i tcp list only TCP connections (works with udp as well)
lsof -i :<port> shows all connections of a given port (lsof -i :22 or lsof -i :ssh)
lsof -i @<host> shows connections to a specific host (lsof -i @192.168.1.5)
lsof -i protocol:@ip:port this is the syntax for network findings (protocol: tcp or udp, @ip: any ip address, port: a port number)
lsof -a -u <user> -i shows all network activity of a user (-a combines -u and -i)
USER, FILES, PROCESSES
lsof -u <user> shows what is open for a user (lsof -u oracle)
lsof <file> shows what is using a file (lsof /var/adm/syslog.log)
lsof <directory> shows what pids are using the filesystem (directory) (it can be good if we cannot umount)
lsof +D <directory> shows which file is open by which process in a directory (lsof +D /usr)
(+D will show recurcively the open files, otherwise only device name would be shown)
lsof -N list all NFS files
lsof -c <command> shows files and network connections a command is using (lsof -c ssh)
lsof -p <pid> shows what a proccess ID has open (lsof -p 335545)
-----------------------------
HOW TO FIND WHAT FILES ARE OPENED BY A PID
1.
root@aix20: /root # lsof -p 319660
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ovcd 319660 root 32r VREG 10,5 12153 69705 /usr (/dev/hd2)
(it will show the filesystem and the indode number (69705))
2.
root@aix20: /root # find /usr -inum 69705
/usr/lpp/VV/msg/en_US/sec.cm.client.cat
--------------------------------------------------------------------------------
METACHARACTERS, VARIABLES:
GREP SHELL
single character . ?
multicharacter .* *
character range [x-z] [x-z]
begins a line ^ N/A
ends a line $ N/A
variable N/A $
HOME home directory
$PS1 prompt symbol
set displays the values of all shell variables
--------------------------------------------------------------------------------
RPM:
rpm -qa shows what rpm packages are installed
rpm -ql <package name> shows where the files are installed (rpm -qlp .. shows the absolut paths???)
rpm -q --filesbypkg cdrecord list all the files on installed rpm package
rpm -qf /usr/bin/lynx query a file to find the source rpm package
rpm -qi <package name> list information on an installed rpm package
rpm -qR <package name> list all dependencies on any rpm package
rpm -ivh httpd-2.2.8.aix5.1.rpm install the rpm package
rpm -ivh --force *.rpm
rpm -ivh --force --nodeps <package name> does not check dependency (same can be done with "rpm -Uvh..." for upgrade)
rpm -e <package name> removes the rpm package
rpm -Va shows which files are missing from the RPM database
rpm -Vv <package name> verifies a package
rpm --rebuilddb compress and rebuild the RPM database
/usr/sbin/updtvpkg enables the rpm command to recognize that the libraries have been installed
In some cases you might get an error about failed dependencies when you install RPMs on AIX (for example, error: failed dependencies: libX11.a(shr4.o) is needed by tk-8.3.3-1). Most likely the error occurs because the rpm command does not recognize the shared library. If the error occurs, check to see if the X11 libraries are installed in the directory /usr/lpp/X11/lib. If they are not installed, use the AIX product media to install them. After you have installed the libraries, run the above command (updtvpkg). The command enables the rpm command to recognize that the libraries have been installed.
--------------------------------------------------------------------------------
RSYNC:
Much like cp, rsync copies files from a source to a destination. Unlike cp, the source and destination of an rsync operation can be local or remote. rsync can resume a transfer after interruption; it transfers only those portions of a file that differ between source and destination; and rsync can perform entire or incremental backups.
By default, rsync uses Secure Shell (SSH) as its transport mechanism; you can reuse your machine aliases and public keys with rsync
rsync -av /tmp/bb_rs30 /tmp/bb it will copy the directory (/tmp/bb_rs30) and its contents under /tmp/bb
rsync -av /tmp/bb_rs30/ /tmp/bb it will copy the contents of the named directory but not the directory itself (check / at the end)
-v option enables verbose messages
-a option (stands for archive), is a shorthand for -rlptgoD:
recurse, copy symbolic links as symbolic links, preserve permissions, preserve file times,
preserve group, preserve owner, and preserve devices and special files, respectively
rsync -n -av /tmp/bb_rs30/ /tmp/bb -n: previews what will happen but does not move a single byte (it is good for testing)
rsync -av /tmp/bb_rs30/ aix2:/tmp/bb_rs20 it will copy the contents of the given dir to the other host
(assuming the same login name on the remote machine)
--------------------------------------------------------------------------------
SORT:
cat /etc/passwd | sort -t: -n +2
-t: gives the delimeter character (here :, deafult is the space)
-n numerical order
+2 sort by the 3rd column
-r reverse order
df -m | sort -n +3 | egrep '9.%|100%' sorts by the 4th column (%) of the filesstems, which are 90-100% full
cat animals | sort +0.1 sort the file animals by the second character of the first word
ls -lR |sort -nk 5|tail -20 sorts the 20 largest file
lspv | sort -k1.6n list hdisk in numerical order (lspv|sort -tk +1 -n <--it is the same (delimiter is "k")
lspv | sort -k1,1.5 -k1.6n list hdisks then vpaths in numeric order
--------------------------------------------------------------------------------
TAR:
tar -cvf /tmp/file.tar . saves where we are to the given path (-c: create, -v: verbose, -f: file)
tar -cvf conf.tar conf creates conf.tar of the dir conf
tar -xvf /tmp/file.tar extracts the tar file (-x: extract)
tar -xvf -C /home/bb /tmp/file.tar it will extract the tar file to /home/bb
tar -tvf /tmp/file.tar list (verify) the content of a tar file
tar -cf - * | gzip -9 > vmi.tar.gz makes tar and zip wehere we are
tar cvf - openssh5.8p1 | gzip -c > openssh5.8p1.tgz creates tgz in one command
tar: 0511-197 DirectorServer: Cannot write data extracted with the tar command:
A file cannot be larger than the value set by ulimit.
I changed these ulimit settings after that it was OK (dont't forget to logout and login again)
root@bb_lpar: /bb # chuser fsize=-1 fsize_hard=-1 root
root@bb_lpar: /bb # chuser data=-1 data_hard=-1 root
--------------------------------------------------------------------------------
TRUSS:
truss <command> it will show what system calls a command makes
truss -c -p <pid> it will trace a process (-c: counts the system calls rather than displaying them, -p: pid)
truss -d -p <pid> -o
truss -t open lsps -a shows whatis needed for the given command (here lsps -a)
--------------------------------------------------------------------------------
XARGS:
lspv|awk '{print$1}'|xargs it will list the elements in a line separated with space
cat list | xargs -t rm will rm all the files which are in the file list
ls | xargs -t -I {} mv {} {}.old it will rename to .old all the file in the current dir
-t it echoes the constructed command (trace mode) (it is optional)
-I {} insert each line of the ls to that place where the {} symbol appear
lsdev -Cc disk | xargs -n1 rmdev -dl removes all the listed disks
-n1 1 element will be passed each time to xargs (if n2 then the command will be created with 2 elements)
--------------------------------------------------------------------------------
ZIPPING:
gzip-V shows gzip version
gzip file1 zip
gzip -d file1.gz unzip
gzip -9 filename will zip (and remove the file automatically)
gunzip filename unzipping it
gzip -c file > file.gz it creates a zip file but leave the original file as well
> filename after that original file can be emptied
compress file1 the original file will be deleted and a new compressed file will be created with a .Z at the end
zcat file1.Z displays the compressed files (without uncompression)
uncomress file1.Z uncompressing a file (the compressed one will be deleted)
if you receive this:
gunzip SysDir6_2.tar.gz
gunzip: SysDir6_2.tar: File too large
this is because gzip 1.2.4 (or lower gzip versions) need a patch to accept large files, workaround for this problem:
gzip -d -c SysDir6_2.tar.gz| tar xvf -
--------------------------------------------------------------------------------
OTHER:
file <filename> shows the type of a file
diff file1 file2 compares only text files
cmp file1 file2 compares all types of files
dircmp dir1 dir2 compares directories
time cp file1 /home show the time to accomplish the command (godd for performance analysis)
ps $$ shows which shell is in use
echo $SHELL shows the current shell
printenv view environmental variables
cat -vet file shows tabs, enters... as viewable characters
-v displays non-printing characters as visible characters
-t displays tab as ^I
-e displays enter as $
!!! sh -xv <command...> for troubleshooting, if a command fails, you can see where exactly it failed in the command script!!!
(sh -xv exportvg rootvg)
dd if=/dev/zero of=/home/user/bb/4GB_file bs=1m count=4000 it creates a 4GB file
lmktemp <filename> <size_in_bytes> it creates a file with given size
alias dir='ls' creates an alias
unalias dir removes an alias
set - unset
df -g | awk '{sum = sum + $3} END {print sum}' it sums up the fs in gigabyte (by the 3rd column)
for i in `ls -l | grep old | awk '{print $9}'` ; do du -sk $i; done | awk '{sum = sum + $1} END {print sum}'
CUT:
lspv | cut -c 6-7 lists the hdisks numbers (cuts the 6th and 7tn character (disk nubers))
dlnkmgr view -drv | grep -w 00000 | awk '{print $4}' | cut -d . -f 3
--------------------------------------------------------------------------------
EXPR: integer arithmetic
\* multiplication (\ is needed to tell * is not a special character)
/ division
% remainder
+ addition
- substraction
expr \( 6 + 4 \) / 2 5
--------------------------------------------------------------------------------
FIND: recursively searches the directory tree
find / -xdev -type f -name "cor*" -size +10000c -exec ls -l {} \;
/ where to find
-xdev looks only in the given fs
-type f what type to look for (f: file, d: direcory)
-name "cor*" name to look for
-size +10000c search for the given size (+10000c : greater than 10000 character (larger then 10kbyte))
-size +2 search for greater than 1kbyte (bloxk size is 512 byte, that's why +2 is given)
-exec ls -l {} \; what command to execute
({}: it represents each findings and \; is needed at the end of line)
e.g. find /home -xdev -name "*.old" -exec rm {} \;
-mtime -1 file modifocation date is less then 1 day (+1 means older than 1 day)
find . -name '*.ksh' -ok rm {} \; this will ask if the command (rm) should be executed or not (much safer if find is not perfect)
find /etc/rc.d -ls it lists the files and dirs in the given dir
find /tmp/bb -exec awk '/func/ {print FILENAME}' {} \; it will check in /tmp/bb if any files contains the word "func" and list those
--------------------------------------------------------------------------------
GREP: (Global Regular Expression Parser) The grep command searches for the pattern.
grep -i ignore case (small letter or capital)
grep -c displays only a count of matching lines
grep -n shows line number at the beginning of the matching line
grep -v invert the sense of matching, to select non-matching lines
grep -w selects only whole words
grep -l lists the name of the files (once) which contain matching line (grep -l paging00 *)
ps -ef | egrep 'ssh|aix' select lines with ssh and aix
errpt -a|grep -A1 'NAME' selects lines with NAME and shows 1 line after that (A: after, B: before)
--------------------------------------------------------------------------------
HEAD, TAIL:
head filename displays first 10 lines of the file
head -50 filename displays first 50 lines
tail filename displays last 10 lines of the file
tail -50 filename displays last 50 lines
tail +15 filename displays the file starting from the 15th line
tail -f filename used when we are monitoring the file (interactively shows how the file is changing)
--------------------------------------------------------------------------------
LSOF:
NETWORK
-n no host name resolution
-P not converts port numbers to port names
lsof -i show all network connections
lsof -i| grep LISTEN shows what ports are waiting for connections
lsof -i | grep ESTABLISHED shows current active connections
lsof -i tcp list only TCP connections (works with udp as well)
lsof -i :<port> shows all connections of a given port (lsof -i :22 or lsof -i :ssh)
lsof -i @<host> shows connections to a specific host (lsof -i @192.168.1.5)
lsof -i protocol:@ip:port this is the syntax for network findings (protocol: tcp or udp, @ip: any ip address, port: a port number)
lsof -a -u <user> -i shows all network activity of a user (-a combines -u and -i)
USER, FILES, PROCESSES
lsof -u <user> shows what is open for a user (lsof -u oracle)
lsof <file> shows what is using a file (lsof /var/adm/syslog.log)
lsof <directory> shows what pids are using the filesystem (directory) (it can be good if we cannot umount)
lsof +D <directory> shows which file is open by which process in a directory (lsof +D /usr)
(+D will show recurcively the open files, otherwise only device name would be shown)
lsof -N list all NFS files
lsof -c <command> shows files and network connections a command is using (lsof -c ssh)
lsof -p <pid> shows what a proccess ID has open (lsof -p 335545)
-----------------------------
HOW TO FIND WHAT FILES ARE OPENED BY A PID
1.
root@aix20: /root # lsof -p 319660
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ovcd 319660 root 32r VREG 10,5 12153 69705 /usr (/dev/hd2)
(it will show the filesystem and the indode number (69705))
2.
root@aix20: /root # find /usr -inum 69705
/usr/lpp/VV/msg/en_US/sec.cm.client.cat
--------------------------------------------------------------------------------
METACHARACTERS, VARIABLES:
GREP SHELL
single character . ?
multicharacter .* *
character range [x-z] [x-z]
begins a line ^ N/A
ends a line $ N/A
variable N/A $
HOME home directory
$PS1 prompt symbol
set displays the values of all shell variables
--------------------------------------------------------------------------------
RPM:
rpm -qa shows what rpm packages are installed
rpm -ql <package name> shows where the files are installed (rpm -qlp .. shows the absolut paths???)
rpm -q --filesbypkg cdrecord list all the files on installed rpm package
rpm -qf /usr/bin/lynx query a file to find the source rpm package
rpm -qi <package name> list information on an installed rpm package
rpm -qR <package name> list all dependencies on any rpm package
rpm -ivh httpd-2.2.8.aix5.1.rpm install the rpm package
rpm -ivh --force *.rpm
rpm -ivh --force --nodeps <package name> does not check dependency (same can be done with "rpm -Uvh..." for upgrade)
rpm -e <package name> removes the rpm package
rpm -Va shows which files are missing from the RPM database
rpm -Vv <package name> verifies a package
rpm --rebuilddb compress and rebuild the RPM database
/usr/sbin/updtvpkg enables the rpm command to recognize that the libraries have been installed
In some cases you might get an error about failed dependencies when you install RPMs on AIX (for example, error: failed dependencies: libX11.a(shr4.o) is needed by tk-8.3.3-1). Most likely the error occurs because the rpm command does not recognize the shared library. If the error occurs, check to see if the X11 libraries are installed in the directory /usr/lpp/X11/lib. If they are not installed, use the AIX product media to install them. After you have installed the libraries, run the above command (updtvpkg). The command enables the rpm command to recognize that the libraries have been installed.
--------------------------------------------------------------------------------
RSYNC:
Much like cp, rsync copies files from a source to a destination. Unlike cp, the source and destination of an rsync operation can be local or remote. rsync can resume a transfer after interruption; it transfers only those portions of a file that differ between source and destination; and rsync can perform entire or incremental backups.
By default, rsync uses Secure Shell (SSH) as its transport mechanism; you can reuse your machine aliases and public keys with rsync
rsync -av /tmp/bb_rs30 /tmp/bb it will copy the directory (/tmp/bb_rs30) and its contents under /tmp/bb
rsync -av /tmp/bb_rs30/ /tmp/bb it will copy the contents of the named directory but not the directory itself (check / at the end)
-v option enables verbose messages
-a option (stands for archive), is a shorthand for -rlptgoD:
recurse, copy symbolic links as symbolic links, preserve permissions, preserve file times,
preserve group, preserve owner, and preserve devices and special files, respectively
rsync -n -av /tmp/bb_rs30/ /tmp/bb -n: previews what will happen but does not move a single byte (it is good for testing)
rsync -av /tmp/bb_rs30/ aix2:/tmp/bb_rs20 it will copy the contents of the given dir to the other host
(assuming the same login name on the remote machine)
--------------------------------------------------------------------------------
SORT:
cat /etc/passwd | sort -t: -n +2
-t: gives the delimeter character (here :, deafult is the space)
-n numerical order
+2 sort by the 3rd column
-r reverse order
df -m | sort -n +3 | egrep '9.%|100%' sorts by the 4th column (%) of the filesstems, which are 90-100% full
cat animals | sort +0.1 sort the file animals by the second character of the first word
ls -lR |sort -nk 5|tail -20 sorts the 20 largest file
lspv | sort -k1.6n list hdisk in numerical order (lspv|sort -tk +1 -n <--it is the same (delimiter is "k")
lspv | sort -k1,1.5 -k1.6n list hdisks then vpaths in numeric order
--------------------------------------------------------------------------------
TAR:
tar -cvf /tmp/file.tar . saves where we are to the given path (-c: create, -v: verbose, -f: file)
tar -cvf conf.tar conf creates conf.tar of the dir conf
tar -xvf /tmp/file.tar extracts the tar file (-x: extract)
tar -xvf -C /home/bb /tmp/file.tar it will extract the tar file to /home/bb
tar -tvf /tmp/file.tar list (verify) the content of a tar file
tar -cf - * | gzip -9 > vmi.tar.gz makes tar and zip wehere we are
tar cvf - openssh5.8p1 | gzip -c > openssh5.8p1.tgz creates tgz in one command
tar: 0511-197 DirectorServer: Cannot write data extracted with the tar command:
A file cannot be larger than the value set by ulimit.
I changed these ulimit settings after that it was OK (dont't forget to logout and login again)
root@bb_lpar: /bb # chuser fsize=-1 fsize_hard=-1 root
root@bb_lpar: /bb # chuser data=-1 data_hard=-1 root
--------------------------------------------------------------------------------
TRUSS:
truss <command> it will show what system calls a command makes
truss -c -p <pid> it will trace a process (-c: counts the system calls rather than displaying them, -p: pid)
truss -d -p <pid> -o
truss -t open lsps -a shows whatis needed for the given command (here lsps -a)
--------------------------------------------------------------------------------
XARGS:
lspv|awk '{print$1}'|xargs it will list the elements in a line separated with space
cat list | xargs -t rm will rm all the files which are in the file list
ls | xargs -t -I {} mv {} {}.old it will rename to .old all the file in the current dir
-t it echoes the constructed command (trace mode) (it is optional)
-I {} insert each line of the ls to that place where the {} symbol appear
lsdev -Cc disk | xargs -n1 rmdev -dl removes all the listed disks
-n1 1 element will be passed each time to xargs (if n2 then the command will be created with 2 elements)
--------------------------------------------------------------------------------
ZIPPING:
gzip-V shows gzip version
gzip file1 zip
gzip -d file1.gz unzip
gzip -9 filename will zip (and remove the file automatically)
gunzip filename unzipping it
gzip -c file > file.gz it creates a zip file but leave the original file as well
> filename after that original file can be emptied
compress file1 the original file will be deleted and a new compressed file will be created with a .Z at the end
zcat file1.Z displays the compressed files (without uncompression)
uncomress file1.Z uncompressing a file (the compressed one will be deleted)
if you receive this:
gunzip SysDir6_2.tar.gz
gunzip: SysDir6_2.tar: File too large
this is because gzip 1.2.4 (or lower gzip versions) need a patch to accept large files, workaround for this problem:
gzip -d -c SysDir6_2.tar.gz| tar xvf -
--------------------------------------------------------------------------------
OTHER:
file <filename> shows the type of a file
diff file1 file2 compares only text files
cmp file1 file2 compares all types of files
dircmp dir1 dir2 compares directories
time cp file1 /home show the time to accomplish the command (godd for performance analysis)
ps $$ shows which shell is in use
echo $SHELL shows the current shell
printenv view environmental variables
cat -vet file shows tabs, enters... as viewable characters
-v displays non-printing characters as visible characters
-t displays tab as ^I
-e displays enter as $
!!! sh -xv <command...> for troubleshooting, if a command fails, you can see where exactly it failed in the command script!!!
(sh -xv exportvg rootvg)
dd if=/dev/zero of=/home/user/bb/4GB_file bs=1m count=4000 it creates a 4GB file
lmktemp <filename> <size_in_bytes> it creates a file with given size
alias dir='ls' creates an alias
unalias dir removes an alias
set - unset
df -g | awk '{sum = sum + $3} END {print sum}' it sums up the fs in gigabyte (by the 3rd column)
for i in `ls -l | grep old | awk '{print $9}'` ; do du -sk $i; done | awk '{sum = sum + $1} END {print sum}'
Backup and Restore AiX
Backup - Restore
MKSYSB (for rootvg, OS):
(only for rootvg and only for mounted filesystems)
mksysb -i /testfs/mksysb.0725 creates an installable image of the rootvg (from NIM it can be restored)
The restorevgfiles and listvgbackup -r commands perform identical operations and should be considered interchangeable
listvgbackup -f /mnt/aix11.mksysb -r /etc/resolv.conf restores the file /etc/resolv.conf from the specified backup
------------------------------------------------
BACKUP - RESTORE (for filesystems):
find /bckfs -print | backup -i -f /dev/rmt0 backup all the files and subdirs
find: genereates a list of all the files
-i: files will be read from standard input
restore extracts files from archives created with the backup command.
JFS2 snapshot:
creates a point in time image, it is very quick and very small
------------------------------------------------
SAVEVG - RESTVG (for volume groups):
savevg -f /bckfs/backup.0725 bckvg backs up all files belonging to bckvg to the specified file
restvg -f /bckfs/backup.0725 restores the vg and all the files what have been saved with savevg
(it creates the vg, lv, fs...)
------------------------------------------------
TAPE:
tctl gives subcommand to tape (move forward/backward)
tcopy copies magnetic tapes
MKSYSB (for rootvg, OS):
(only for rootvg and only for mounted filesystems)
mksysb -i /testfs/mksysb.0725 creates an installable image of the rootvg (from NIM it can be restored)
The restorevgfiles and listvgbackup -r commands perform identical operations and should be considered interchangeable
listvgbackup -f /mnt/aix11.mksysb -r /etc/resolv.conf restores the file /etc/resolv.conf from the specified backup
------------------------------------------------
BACKUP - RESTORE (for filesystems):
find /bckfs -print | backup -i -f /dev/rmt0 backup all the files and subdirs
find: genereates a list of all the files
-i: files will be read from standard input
restore extracts files from archives created with the backup command.
JFS2 snapshot:
creates a point in time image, it is very quick and very small
------------------------------------------------
SAVEVG - RESTVG (for volume groups):
savevg -f /bckfs/backup.0725 bckvg backs up all files belonging to bckvg to the specified file
restvg -f /bckfs/backup.0725 restores the vg and all the files what have been saved with savevg
(it creates the vg, lv, fs...)
------------------------------------------------
TAPE:
tctl gives subcommand to tape (move forward/backward)
tcopy copies magnetic tapes
AIX history
AIX history:
IBM had 2 discrete Power Architecture hardware lines, based on different Operating Systems:
- OS/400, later i5/OS, more later IBM i
- AIX (on the same hardware it is possible to run Linux as well)
I. 1986-1990 (AS/400 - IBM RT):
In 1986 AIX Version 1 had been introduced for the IBM 6150 RT workstation, which was based on UNIX.
In 1987 for the other product line: OS/400 (later i5/OS and IBM i), the platform (hardware) AS/400 had been released.
II. 1990-1999 (RS/6000):
Among other variants, IBM later produced
AIX Version 3 (also known as AIX/6000), for their IBM POWER-based
RS/6000 platform. The RS/6000 family replaced the IBM RT computer
platform in February 1990, and was the first computer line to see the
use of IBM's POWER and PowerPC based microprocessors. Since 1990, AIX
has served as the primary operating system for the RS/6000 series.
AIX Version 4, introduced in 1994, added
symmetric multiprocessing with the introduction of the first RS/6000
SMP servers and continued to evolve through the 1990s, culminating with
AIX 4.3.3 in 1999. RS/6000 was renamed eServer pSeries in October 2000.
III. 2000-2004 (eServer pseries):
IBM eServer was a family of computer
servers from IBM Corporation. Announced in the year 2000, it combined
the various IBM server brands (AS/400, RS/6000...) under one brand.
The various sub-brands were at the same time rebranded from:
- IBM AS/400 to IBM eServer iSeries, i for Integrated.
- IBM RS/6000 to IBM eServer pSeries, p for POWER
...
They merged to use essentially the same
hardware platform in 2001/2002 with the introduction of the POWER4
processor. After that, there was little difference between both the "p"
and the "i" hardware; the only differences were in the software and
services offerings. AIX 5.2 was introduced in October 2002.
IV. 2004-2008 (IBM system i and p):
In 2005 announced a new brand, 'IBM System' as an umbrella for all IBM server and storage brands:
- IBM eServer iSeries became IBM System i
- IBM eServer pSeries became IBM System p
...
With the introduction of the POWER5
processor in 2004, even the product numbering was synchronized. The
System i5 570 was virtually identical to the System p5 570. AIX 5.3 was
intoduced in August of 2004. In May 2007 IBM launched its POWER6 and AIX
6.1 in November 2007.
V. 2008-2010 (Power Systems):
In April of 2008, IBM officially merged
the two lines of servers and workstations under the same name, Power
Systems, with identical hardware and a choice of operating systems,
software and service contracts.
Power Systems is the name of IBM's
unified Power Architecture-based server line, merging both System i and
System p server platforms, and running either IBM i (formerly i5/OS and
OS/400), AIX or Linux operating systems. Power Systems was announced
April 2, 2008.
POWER8 is under development at this date.
VOLUME GROUP
VOLUME GROUP
When you install a system, the first volume group (VG) is created. It is called the rootvg. Your rootvg volume group is a base set of logical volumes required to start the system. It includes paging space, the journal log, boot data, and dump storage, each on its own separate logical volume.
A normal VG is limited to 32512 physical partitions. (32 physical volumes, each with 1016 partitions)
you can change it with: chvg -t4 bbvg (the factor is 4, which means: maximum partitions:4064 (instead of 1016), max disks:8 (instead of 32))
How do I know if my volume group is normal, big, or scalable?
Run the lsvg command on the volume group and look at the value for MAX PVs. The value is 32 for normal, 128 for big, and 1024 for scalable volume group.
VG type Maximum PVs Maximum LVs Maximum PPs per VG Maximum PP size
Normal VG 32 256 32,512 (1016 * 32) 1 GB
Big VG 128 512 130,048 (1016 * 128) 1 GB
Scalable VG 1024 4096 2,097,152 128 GB
If a physical volume is part of a volume group, it contains 2 additional reserved areas. One area contains both the VGSA and the VGDA, and this area is started from the first 128 reserved sectors (blocks) on the disk. The other area is at the end of the disk, and is reserved as a relocation pool for bad blocks.
VGDA (Volume Group Descriptor Area)
It is an area on the hard disk (PV) that contains information about the entire volume group. There is at least one VGDA per physical volume, one or two copies per disk. It contains physical volume list (PVIDs), logical volume list (LVIDs), physical partition map (maps lps to pps)
# lqueryvg -tAp hdisk0 <--look into the VGDA (-A:all info, -t: tagged, without it only numbers)
Max LVs: 256
PP Size: 27 <--exponent of 2:2 to 7=128MB
Free PPs: 698
LV count: 11
PV count: 2
Total VGDAs: 3
Conc Allowed: 0
MAX PPs per PV 2032
MAX PVs: 16
Quorum (disk): 0
Quorum (dd): 0
Auto Varyon ?: 1
Conc Autovaryo 0
Varied on Conc 0
Logical: 00cebffe00004c000000010363f50ac5.1 hd5 1 <--1: count of mirror copies (00cebff...c5 is the VGID)
00cebffe00004c000000010363f50ac5.2 hd6 1
00cebffe00004c000000010363f50ac5.3 hd8 1
...
Physical: 00cebffe63f500ee 2 0 <--2:VGDA count 0:code for its state (active, missing, removed)
00cebffe63f50314 1 0 (The sum of VGDA count should be the same as the Total VGDAs)
Total PPs: 1092
LTG size: 128
...
Max PPs: 32512
-----------------------
VGSA (Volume Group Status Area)
The VGSAs are always present, but used with mirroring only. Needed to track the state of mirror copies, that means whether synchronized or stale. Per-disk stucure, but twice on each disk.
Quorum
Non-rootvg volume groups can be taken offline and brought online by a process called varying on and varying off a volume group. The system checks the availability of all VGDAs for a particular volume group to determine if a volume group is going to be varied on or off.
When attempting to vary on a volume group, the system checks for a quorum of the VGDA to be available. A quorum is equal to 51 percent or more of the VGDAs available. If it can find a quorum, the VG will be varied on; if not, it will not make the volume group available.
Turning off the quorum does not allow a varyonvg without a quorum, it just prevents the closing of an active vg when losing its quorum. (so forced varyon may needed: varyonvg -f VGname)
After turning it off (chvg -Qn VGname) it is in effect immediately.
LTG
LTG is the maximum transfer size of a logical volume (volume group?).
At 5.3 and 6.1 AIX dynamically sets LTG size (calculated at each volume group activation).
LTG size can be changed with: varyonvg -M<LTG size>
(The chvg -L has no effect on volume groups created on 5.3 or later (it was used on 5.2)
To display the LTG size of a disk: /usr/sbin/lquerypv -M <hdisk#>
lsvg lists the volume groups that are on the system
lsvg -o lists all volume groups that are varied on
lsvg -o | lsvg -ip lists pvs of online vgs
lsvg rootvg gives details about the vg (lsvg -L <vgname>, will doe not wait for the lock release (useful during mirroring))
lsvg -l rootvg info about all logical volumes that are part of a vg
lsvg -M rootvg lists all PV, LV, PP deatils of a vg (PVname:PPnum LVname: LPnum :Copynum)
lsvg -p rootvg display all physical volumes that are part of the volume group
lsvg -n <hdisk> shows vg infos, but it is read from the VGDA on the specified disk (it is useful to compare it with different disks)
mkvg -s 2 -y testvg hdisk13 creates a volume group
-s specify the physical partition size
-y indicate the name of the new vg
chvg changes the characteristics of a volume group
chvg -u <vgname> unlocks the volume group (if a command core dumping, or the system crashed and vg is left in locked state)
(Many LVM commands place a lock into the ODM to prevent other commands working on the same time.)
extendvg rootvg hdisk7 adds hdisk7 to rootvg (-f forces it: extendvg -f ...)
reducevg rootvg hdisk7 tries to delete hdisk7 (the vg must be varied on) (reducevg -f ... :force it)
(it will fail if the vg contains open logical volumes)
reducevg datavg <pvid> reducevg command can use pvid as well (it is useful, if disk already removed from ODM, but VGDA still exist)
syncvg synchronizes stale physical partitions (varyonvg better, becaue first it reestablis reservation then sync in backg.)
varyonvg rootvg makes the vg available (-f force a vg to be online if it does not have the quorum of available disks)
(varyonvg acts as a self-repair program for VGDAs, it does a syncvg as well)
varyoffvg rootvg deactivate a volume group
mirrorvg -S P01vg hdisk1 mirroring rootvg to hdisk1 (checking: lsvg P01vg | grep STALE) (-S: background sync)
(mirrorvg -m rootvg hdisk1 <--m makes an exact copy, pp mapping will be identical, it is advised this way)
unmirrorvg testvg1 hdisk0 hdisk1 remove mirrors on the vg from the specified disks
exportvg avg removes the VGs definition out of the ODM and /etc/filesystems (for ODM problems after importvg will fix it)
importvg -y avg hdisk8 makes the previously exported vg known to the system (hdisk8, is any disk belongs to the vg)
reorgvg rearranges physical partitions within the vg to conform with the placement policy (outer edge...) for the lv.
(For this 1 free pp is needed, and the relocatable flag for lvs must be set to 'y': chlv -r...)
getlvodm -j <hdisk> get the vgid for the hdisk from the odm
getlvodm -t <vgid> get the vg name for the vgid from the odm
getlvodm -v <vgname> get the vgid for the vg name from the odm
getlvodm -p <hdisk> get the pvid for the hdisk from the odm
getlvodm -g <pvid> get the hdisk for the pvid from the odm
lqueryvg -tcAp <hdisk> get all the vgid and pvid information for the vg from the vgda (directly from the disk)
(you can compare the disk with odm: getlvodm <-> lqueryvg)
synclvodm <vgname> synchronizes or rebuilds the lvcb, the device configuration database, and the vgdas on the physical volumes
redefinevg it helps regain the basic ODM informations if those are corrupted (redefinevg -d hdisk0 rootvg)
readvgda hdisk40 shows details from the disk
Physical Volume states (and quorum):
lsvg -p VGName <--shows pv states (not devices states!)
active <--during varyonvg disk can be accessed
missing <--during varyonvg disk can not be accessed + quorum is available
(after disk repair varyonvg VGName will put in active state)
removed <--no disk access during varyonvg + quorum is not available --> you issue varyonvg -f VGName
(after force varyonvg in the above case, PV state will be removed, and it won't be used for quorum)
(to put back in active state, first we have to tell the system the failure is over:)
(chpv -va hdiskX, this defines the disk as active, and after that varyonvg will synchronize)
---------------------------------------
Mirroring rootvg (i.e after disk replacement):
1. disk replaced -> cfgmgr <--it will find the new disk (i.e. hdisk1)
2. extendvg rootvg hdisk1 <--sometimes extendvg -f rootvg...
(3. chvg -Qn rootvg) <--only if quorum setting has not yet been disabled, because this needs a restart
4. mirrorvg -s rootvg <--add mirror for rootvg (-s: synchronization will not be done)
5. syncvg -v rootvg <--synchronize the new copy (lsvg rootvg | grep STALE)
6. bosboot -a <--we changed the system so create boot image (-a: create complete boot image and device)
(hd5 is mirrorred, no need to do it for each disk. ie. bosboot -ad hdisk0)
7. bootlist -m normal hdisk0 hdisk1 <--set normal bootlist
8. bootlist -m service hdisk0 hdisk1 <--set bootlist when we want to boot into service mode
(9. shutdown -Fr) <--this is needed if quorum has been disabled
10.bootinfo -b <--shows the disk which was used for boot
---------------------------------------
Export/Import:
1. node A: umount all fs -> varyoffvg myvg
2. node A: exportvg myvg <--ODM cleared
3. node B: importvg -y myvg hdisk3 <-- -y: vgname, if omitted a new vg will be created (if needed varyonvg -> mount fs)
if fs already exists:
1. umount the old one and mount the imported one with this: mount -o log=/dev/loglv01 -V jfs2 /dev/lv24 /home/michael
(these details have to added in the mount command, and these can be retreived from LVCB: getlvcb lv24 -At)
2. vi /etc/filesystems, create a second stanza for the imported filesystems with a new mountpoint.
---------------------------------------
VG problems with ODM:
if varyoff possible:
1. write down VGs name, major number, a disk
2. exportvg VGname
3. importvg -V MajorNum -y VGname hdiskX
if varyoff not possible:
1. write down VGs name, major number, a disk
2. export the vg by the backdoor, using: odmdelete
3. re-import vg (may produce warnings, but works)
(it is not necessary to umount fs or stop processes)
---------------------------------------
Changing factor value (chvg -t) of a VG:
A normal or a big vg has the following limitations after creation:
MAX PPs per VG = MAX PVs * MAX PPS per PV)
Normal Big
MAX PPs per VG: 32512 130048
MAX PPs per PV: 1016 1016
MAX PVs: 32 128
If we want to extend the vg with a disk, which is so large that we would have more than 1016 PPs on that disk, we will receive:
root@bb_lpar: / # extendvg bbvg hdisk4
0516-1162 extendvg: Warning, The Physical Partition Size of 4 requires the
creation of 1024 partitions for hdisk4. The limitation for volume group
bbvg is 1016 physical partitions per physical volume. Use chvg command
with -t option to attempt to change the maximum Physical Partitions per
Physical volume for this volume group.
If we change the factor value of the VG, then extendvg will be possible:
root@bb_lpar: / # chvg -t 2 bbvg
0516-1164 chvg: Volume group bbvg changed. With given characteristics bbvg
can include up to 16 physical volumes with 2032 physical partitions each.
Calculation:
Normal VG: 32/factor = new value of MAX PVs
Big VG: 128/factor= new value of MAX PVs
-t PPs per PV MAX PV (Normal) MAX PV (Big)
1 1016 32 128
2 2032 16 64
3 3048 10 42
4 4064 8 32
5 5080 6 25
...
"chvg -t" can be used online either increasing or decreasing the value of the factor.
---------------------------------------
Changing Normal VG to Big VG:
If you reached the MAX PV limit of a Normal VG and playing with the factor (chvg -t) is not possible anymore you can convert it to Big VG.
It is an online activity, but there must be free PPs on each physical volume, because VGDA will be expanded on all disks:
root@bb_lpar: / # lsvg -p bbvg
bbvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 511 2 02..00..00..00..00
hdisk3 active 511 23 00..00..00..00..23
hdisk4 active 1023 0 00..00..00..00..00
root@bb_lpar: / # chvg -B bbvg
0516-1214 chvg: Not enough free physical partitions exist on hdisk4 for the
expansion of the volume group descriptor area. Migrate/reorganize to free up
2 partitions and run chvg again.
In this case we have to migrate 2 PPs from hdisk4 to hdsik3 (so 2 PPs will be freed up on hdisk4):
root@bb_lpar: / # lspv -M hdisk4
hdisk4:1 bblv:920
hdisk4:2 bblv:921
hdisk4:3 bblv:922
hdisk4:4 bblv:923
hdisk4:5 bblv:924
...
root@bb_lpar: / # lspv -M hdisk3
hdisk3:484 bblv:3040
hdisk3:485 bblv:3041
hdisk3:486 bblv:3042
hdisk3:487 bblv:1
hdisk3:488 bblv:2
hdisk3:489-511
root@bb_lpar: / # migratelp bblv/920 hdisk3/489
root@bb_lpar: / # migratelp bblv/921 hdisk3/490
root@bb_lpar: / # lsvg -p bbvg
bbvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 511 2 02..00..00..00..00
hdisk3 active 511 21 00..00..00..00..21
hdisk4 active 1023 2 02..00..00..00..00
If we try again changing to Big VG, now it is successful:
root@bb_lpar: / # chvg -B bbvg
0516-1216 chvg: Physical partitions are being migrated for volume group
descriptor area expansion. Please wait.
0516-1164 chvg: Volume group bbvg2 changed. With given characteristics bbvg2
can include up to 128 physical volumes with 1016 physical partitions each.
If you check again, freed up PPs has been used:
root@bb_lpar: / # lsvg -p bbvg
bbvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 509 0 00..00..00..00..00
hdisk3 active 509 17 00..00..00..00..17
hdisk4 active 1021 0 00..00..00..00..00
---------------------------------------
Changing Normal (or Big) VG to Scalable VG:
If you reached the MAX PV limit of a Normal or a Big VG and playing with the factor (chvg -t) is not possible anymore you can convert that VG to Scalable VG. A Scalable VG allows a maximum of 1024 PVs and 4096 LVs and a very big advantage that the maximum number of PPs applies to the entire VG and is no longer defined on a per disk basis.
!!!Converting to Scalable VG is an offline activity (varyoffvg), and there must be free PPs on each physical volume, because VGDA will be expanded on all disks.
root@bb_lpar: / # chvg -G bbvg
0516-1707 chvg: The volume group must be varied off during conversion to
scalable volume group format.
root@bb_lpar: / # varyoffvg bbvg
root@bb_lpar: / # chvg -G bbvg
0516-1214 chvg: Not enough free physical partitions exist on hdisk2 for the
expansion of the volume group descriptor area. Migrate/reorganize to free up
18 partitions and run chvg again.
After migrating some lps to free up required PPs (in this case it was 18), then changing to Scalable VG is successful:
root@bb_lpar: / # chvg -G bbvg
0516-1224 chvg: WARNING, once this operation is completed, volume group bbvg
cannot be imported into AIX 5.2 or lower versions. Continue (y/n) ?
...
0516-1712 chvg: Volume group bbvg changed. bbvg can include up to 1024 physical volumes with 2097152 total physical partitions in the volume group.
---------------------------------------
0516-008 varyonvg: LVM system call returned an unknown error code (2).
solution: export LDR_CNTRL=MAXDATA=0x80000000@DSA (check /etc/environment if LDR_CNTRL has a value, which is causing the trouble)
---------------------------------------
If VG cannot be created:
root@aix21c: / # mkvg -y tvg hdisk29
0516-1376 mkvg: Physical volume contains a VERITAS volume group.
0516-1397 mkvg: The physical volume hdisk29, will not be added to
the volume group.
0516-862 mkvg: Unable to create volume group.
root@aixc: / # chpv -C hdisk29 <--clears owning volume manager from a disk, after this mkvg was successful
---------------------------------------
root@aix1: /root # importvg -L testvg -n hdiskpower12
0516-022 : Illegal parameter or structure value.
0516-780 importvg: Unable to import volume group from hdiskpower12.
For me the solution was:
there was no pvid on the disk, after adding it (chdev -l hdiskpower12 -a pv=yes) it was OK
---------------------------------------
Reorgvg log files, and how it is working:
reorgvg activity is logged in lvmcfg:
root@bb_lpar: / # alog -ot lvmcfg | tail -3
[S 17039512 6750244 10/23/11-12:39:05:781 reorgvg.sh 580] reorgvg bbvg bb1lv
[S 7405650 17039512 10/23/11-12:39:06:689 migfix.c 168] migfix /tmp/.workdir.9699494.17039512_1/freemap17039512 /tmp/.workdir.9699494.17039512_1/migrate17039512 /tmp/.workdir.9699494.17039512_1/lvm_moves17039512
[E 17039512 47:320 reorgvg.sh 23] reorgvg: exited with rc=0
Field of these lines:
S - Start, E - End; PID, PPID; TIMESTAMP
At E (end) line shows how long reorgvg was running (in second:milliseconds):
47:320 = 47s 320ms
for a long running reorgvg, you can see it's status:
1. check the working dir of reorgvg
root@aixdb2: /root # alog -ot lvmcfg | tail -3 | grep workdir
[S 5226546 5288122 10/22/11-13:55:11:001 migfix.c 165] migfix /tmp/.workdir.4935912.5288122_1/freemap5288122 /tmp/.workdir.4935912.5288122_1/migrate5288122 /tmp/.workdir.4935912.5288122_1/lvm_moves5288122
2. check lvm_moves file in that dir (we will need the path of this file):
root@aixdb2: /root # ls -l /tmp/.workdir.4935912.5288122_1 | grep lvm_moves
-rw------- 1 root system 1341300 Oct 22 13:55 lvm_moves5288122
(it contains all the lp migartions, and reorgvg goes through on this file, line by line)
3. check the process of reorgvg:
root@aixdb2: /root # ps -ef | grep reorgvg
root 5288122 5013742 0 13:52:16 pts/2 0:12 /bin/ksh /usr/sbin/reorgvg P_NAVISvg p_datlv
root@aixdb2: /root # ps -fT 5288122
CMD
/bin/ksh /usr/sbin/reorgvg P_NAVISvg p_datlv
|\--lmigratepp -g 00c0ad0200004c000000012ce4ad7285 -p 00c80ef201f81fa6 -n 1183 -P 00c0ad021d62f017 -N 1565
\--awk -F: {print "-p "$1" -n "$2" -P "$3" -N "$4 }
(lmigratepp shows: -g VGid -p SourcePVid -n SourcePPnumber -P DestinationPVid -N DestinationPPnumber)
lmigratepp shows the actual PP which is migrated at this moment
(if you ask few seconds later it will show the next PP which is migrated, and it uses the lvm_moves file)
4. check the line number of the PP which is being migrated at this moment:
(now the ps command in step 3 is extended with the content of the lvm_moves file)
root@aixdb2: /root # grep -n `ps -fT 5288122|grep migr|awk '{print $12":"$14}'` /tmp/.workdir.4935912.5288122_1/lvm_moves5288122
17943:00c0ad021d66f58b:205:00c0ad021d612cda:1259
17944:00c80ef24b619875:486:00c0ad021d66f58b:205
you can compare the above line numbers (17943, 17944) to how many lines lvm_moves file has.
root@aixdb2: /root # cat /tmp/.workdir.4935912.5288122_1/lvm_moves5288122 | wc -l
31536
It shows that from 31536 lp migrations we are at this moment at 17943.
---------------------------------------
0516-304 : Unable to find device id 00080e82dfb5a427 in the Device
Configuration Database.
If a disk has been deleted (rmdev) somehow, but from the vg it was not removed:
root@bb_lpar: / # lsvg -p newvg
newvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 31 20 06..00..02..06..06
0516-304 : Unable to find device id 00080e82dfb5a427 in the Device
Configuration Database.
00080e82dfb5a427 removed 31 31 07..06..06..06..06
VGDA still shows the missing disk is part of the vg:
root@bb_lpar: / # lqueryvg -tAp hdisk2
...
Physical: 00080e82dfab25bc 2 0
00080e82dfb5a427 0 4
VGDA should be updated (on hdisk2) but it is possible only, if the PVID is used with reducevg:
root@bb_lpar: / # reducevg newvg 00080e82dfb5a427
---------------------------------------
If you run into not being able to access an hdiskpowerX disk, you may need to reset the reservation bit on it:
root@aix21: / # lqueryvg -tAp hdiskpower13
0516-024 lqueryvg: Unable to open physical volume.
Either PV was not configured or could not be opened. Run diagnostics.
root@aix21: / # lsvg -p sapvg
PTAsapvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdiskpower12 active 811 0 00..00..00..00..00
hdiskpower13 missing 811 0 00..00..00..00..00
hdiskpower14 active 811 0 00..00..00..00..00
root@aix21: / # bootinfo -s hdiskpower13
0
Possible solution could be emcpowerreset:
root@aix21: / # /usr/lpp/EMC/Symmetrix/bin/emcpowerreset fscsi0 hdiskpower13
(after this varyonvg will bring back the disk into active state)
When you install a system, the first volume group (VG) is created. It is called the rootvg. Your rootvg volume group is a base set of logical volumes required to start the system. It includes paging space, the journal log, boot data, and dump storage, each on its own separate logical volume.
A normal VG is limited to 32512 physical partitions. (32 physical volumes, each with 1016 partitions)
you can change it with: chvg -t4 bbvg (the factor is 4, which means: maximum partitions:4064 (instead of 1016), max disks:8 (instead of 32))
How do I know if my volume group is normal, big, or scalable?
Run the lsvg command on the volume group and look at the value for MAX PVs. The value is 32 for normal, 128 for big, and 1024 for scalable volume group.
VG type Maximum PVs Maximum LVs Maximum PPs per VG Maximum PP size
Normal VG 32 256 32,512 (1016 * 32) 1 GB
Big VG 128 512 130,048 (1016 * 128) 1 GB
Scalable VG 1024 4096 2,097,152 128 GB
If a physical volume is part of a volume group, it contains 2 additional reserved areas. One area contains both the VGSA and the VGDA, and this area is started from the first 128 reserved sectors (blocks) on the disk. The other area is at the end of the disk, and is reserved as a relocation pool for bad blocks.
VGDA (Volume Group Descriptor Area)
It is an area on the hard disk (PV) that contains information about the entire volume group. There is at least one VGDA per physical volume, one or two copies per disk. It contains physical volume list (PVIDs), logical volume list (LVIDs), physical partition map (maps lps to pps)
# lqueryvg -tAp hdisk0 <--look into the VGDA (-A:all info, -t: tagged, without it only numbers)
Max LVs: 256
PP Size: 27 <--exponent of 2:2 to 7=128MB
Free PPs: 698
LV count: 11
PV count: 2
Total VGDAs: 3
Conc Allowed: 0
MAX PPs per PV 2032
MAX PVs: 16
Quorum (disk): 0
Quorum (dd): 0
Auto Varyon ?: 1
Conc Autovaryo 0
Varied on Conc 0
Logical: 00cebffe00004c000000010363f50ac5.1 hd5 1 <--1: count of mirror copies (00cebff...c5 is the VGID)
00cebffe00004c000000010363f50ac5.2 hd6 1
00cebffe00004c000000010363f50ac5.3 hd8 1
...
Physical: 00cebffe63f500ee 2 0 <--2:VGDA count 0:code for its state (active, missing, removed)
00cebffe63f50314 1 0 (The sum of VGDA count should be the same as the Total VGDAs)
Total PPs: 1092
LTG size: 128
...
Max PPs: 32512
-----------------------
VGSA (Volume Group Status Area)
The VGSAs are always present, but used with mirroring only. Needed to track the state of mirror copies, that means whether synchronized or stale. Per-disk stucure, but twice on each disk.
Quorum
Non-rootvg volume groups can be taken offline and brought online by a process called varying on and varying off a volume group. The system checks the availability of all VGDAs for a particular volume group to determine if a volume group is going to be varied on or off.
When attempting to vary on a volume group, the system checks for a quorum of the VGDA to be available. A quorum is equal to 51 percent or more of the VGDAs available. If it can find a quorum, the VG will be varied on; if not, it will not make the volume group available.
Turning off the quorum does not allow a varyonvg without a quorum, it just prevents the closing of an active vg when losing its quorum. (so forced varyon may needed: varyonvg -f VGname)
After turning it off (chvg -Qn VGname) it is in effect immediately.
LTG
LTG is the maximum transfer size of a logical volume (volume group?).
At 5.3 and 6.1 AIX dynamically sets LTG size (calculated at each volume group activation).
LTG size can be changed with: varyonvg -M<LTG size>
(The chvg -L has no effect on volume groups created on 5.3 or later (it was used on 5.2)
To display the LTG size of a disk: /usr/sbin/lquerypv -M <hdisk#>
lsvg lists the volume groups that are on the system
lsvg -o lists all volume groups that are varied on
lsvg -o | lsvg -ip lists pvs of online vgs
lsvg rootvg gives details about the vg (lsvg -L <vgname>, will doe not wait for the lock release (useful during mirroring))
lsvg -l rootvg info about all logical volumes that are part of a vg
lsvg -M rootvg lists all PV, LV, PP deatils of a vg (PVname:PPnum LVname: LPnum :Copynum)
lsvg -p rootvg display all physical volumes that are part of the volume group
lsvg -n <hdisk> shows vg infos, but it is read from the VGDA on the specified disk (it is useful to compare it with different disks)
mkvg -s 2 -y testvg hdisk13 creates a volume group
-s specify the physical partition size
-y indicate the name of the new vg
chvg changes the characteristics of a volume group
chvg -u <vgname> unlocks the volume group (if a command core dumping, or the system crashed and vg is left in locked state)
(Many LVM commands place a lock into the ODM to prevent other commands working on the same time.)
extendvg rootvg hdisk7 adds hdisk7 to rootvg (-f forces it: extendvg -f ...)
reducevg rootvg hdisk7 tries to delete hdisk7 (the vg must be varied on) (reducevg -f ... :force it)
(it will fail if the vg contains open logical volumes)
reducevg datavg <pvid> reducevg command can use pvid as well (it is useful, if disk already removed from ODM, but VGDA still exist)
syncvg synchronizes stale physical partitions (varyonvg better, becaue first it reestablis reservation then sync in backg.)
varyonvg rootvg makes the vg available (-f force a vg to be online if it does not have the quorum of available disks)
(varyonvg acts as a self-repair program for VGDAs, it does a syncvg as well)
varyoffvg rootvg deactivate a volume group
mirrorvg -S P01vg hdisk1 mirroring rootvg to hdisk1 (checking: lsvg P01vg | grep STALE) (-S: background sync)
(mirrorvg -m rootvg hdisk1 <--m makes an exact copy, pp mapping will be identical, it is advised this way)
unmirrorvg testvg1 hdisk0 hdisk1 remove mirrors on the vg from the specified disks
exportvg avg removes the VGs definition out of the ODM and /etc/filesystems (for ODM problems after importvg will fix it)
importvg -y avg hdisk8 makes the previously exported vg known to the system (hdisk8, is any disk belongs to the vg)
reorgvg rearranges physical partitions within the vg to conform with the placement policy (outer edge...) for the lv.
(For this 1 free pp is needed, and the relocatable flag for lvs must be set to 'y': chlv -r...)
getlvodm -j <hdisk> get the vgid for the hdisk from the odm
getlvodm -t <vgid> get the vg name for the vgid from the odm
getlvodm -v <vgname> get the vgid for the vg name from the odm
getlvodm -p <hdisk> get the pvid for the hdisk from the odm
getlvodm -g <pvid> get the hdisk for the pvid from the odm
lqueryvg -tcAp <hdisk> get all the vgid and pvid information for the vg from the vgda (directly from the disk)
(you can compare the disk with odm: getlvodm <-> lqueryvg)
synclvodm <vgname> synchronizes or rebuilds the lvcb, the device configuration database, and the vgdas on the physical volumes
redefinevg it helps regain the basic ODM informations if those are corrupted (redefinevg -d hdisk0 rootvg)
readvgda hdisk40 shows details from the disk
Physical Volume states (and quorum):
lsvg -p VGName <--shows pv states (not devices states!)
active <--during varyonvg disk can be accessed
missing <--during varyonvg disk can not be accessed + quorum is available
(after disk repair varyonvg VGName will put in active state)
removed <--no disk access during varyonvg + quorum is not available --> you issue varyonvg -f VGName
(after force varyonvg in the above case, PV state will be removed, and it won't be used for quorum)
(to put back in active state, first we have to tell the system the failure is over:)
(chpv -va hdiskX, this defines the disk as active, and after that varyonvg will synchronize)
---------------------------------------
Mirroring rootvg (i.e after disk replacement):
1. disk replaced -> cfgmgr <--it will find the new disk (i.e. hdisk1)
2. extendvg rootvg hdisk1 <--sometimes extendvg -f rootvg...
(3. chvg -Qn rootvg) <--only if quorum setting has not yet been disabled, because this needs a restart
4. mirrorvg -s rootvg <--add mirror for rootvg (-s: synchronization will not be done)
5. syncvg -v rootvg <--synchronize the new copy (lsvg rootvg | grep STALE)
6. bosboot -a <--we changed the system so create boot image (-a: create complete boot image and device)
(hd5 is mirrorred, no need to do it for each disk. ie. bosboot -ad hdisk0)
7. bootlist -m normal hdisk0 hdisk1 <--set normal bootlist
8. bootlist -m service hdisk0 hdisk1 <--set bootlist when we want to boot into service mode
(9. shutdown -Fr) <--this is needed if quorum has been disabled
10.bootinfo -b <--shows the disk which was used for boot
---------------------------------------
Export/Import:
1. node A: umount all fs -> varyoffvg myvg
2. node A: exportvg myvg <--ODM cleared
3. node B: importvg -y myvg hdisk3 <-- -y: vgname, if omitted a new vg will be created (if needed varyonvg -> mount fs)
if fs already exists:
1. umount the old one and mount the imported one with this: mount -o log=/dev/loglv01 -V jfs2 /dev/lv24 /home/michael
(these details have to added in the mount command, and these can be retreived from LVCB: getlvcb lv24 -At)
2. vi /etc/filesystems, create a second stanza for the imported filesystems with a new mountpoint.
---------------------------------------
VG problems with ODM:
if varyoff possible:
1. write down VGs name, major number, a disk
2. exportvg VGname
3. importvg -V MajorNum -y VGname hdiskX
if varyoff not possible:
1. write down VGs name, major number, a disk
2. export the vg by the backdoor, using: odmdelete
3. re-import vg (may produce warnings, but works)
(it is not necessary to umount fs or stop processes)
---------------------------------------
Changing factor value (chvg -t) of a VG:
A normal or a big vg has the following limitations after creation:
MAX PPs per VG = MAX PVs * MAX PPS per PV)
Normal Big
MAX PPs per VG: 32512 130048
MAX PPs per PV: 1016 1016
MAX PVs: 32 128
If we want to extend the vg with a disk, which is so large that we would have more than 1016 PPs on that disk, we will receive:
root@bb_lpar: / # extendvg bbvg hdisk4
0516-1162 extendvg: Warning, The Physical Partition Size of 4 requires the
creation of 1024 partitions for hdisk4. The limitation for volume group
bbvg is 1016 physical partitions per physical volume. Use chvg command
with -t option to attempt to change the maximum Physical Partitions per
Physical volume for this volume group.
If we change the factor value of the VG, then extendvg will be possible:
root@bb_lpar: / # chvg -t 2 bbvg
0516-1164 chvg: Volume group bbvg changed. With given characteristics bbvg
can include up to 16 physical volumes with 2032 physical partitions each.
Calculation:
Normal VG: 32/factor = new value of MAX PVs
Big VG: 128/factor= new value of MAX PVs
-t PPs per PV MAX PV (Normal) MAX PV (Big)
1 1016 32 128
2 2032 16 64
3 3048 10 42
4 4064 8 32
5 5080 6 25
...
"chvg -t" can be used online either increasing or decreasing the value of the factor.
---------------------------------------
Changing Normal VG to Big VG:
If you reached the MAX PV limit of a Normal VG and playing with the factor (chvg -t) is not possible anymore you can convert it to Big VG.
It is an online activity, but there must be free PPs on each physical volume, because VGDA will be expanded on all disks:
root@bb_lpar: / # lsvg -p bbvg
bbvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 511 2 02..00..00..00..00
hdisk3 active 511 23 00..00..00..00..23
hdisk4 active 1023 0 00..00..00..00..00
root@bb_lpar: / # chvg -B bbvg
0516-1214 chvg: Not enough free physical partitions exist on hdisk4 for the
expansion of the volume group descriptor area. Migrate/reorganize to free up
2 partitions and run chvg again.
In this case we have to migrate 2 PPs from hdisk4 to hdsik3 (so 2 PPs will be freed up on hdisk4):
root@bb_lpar: / # lspv -M hdisk4
hdisk4:1 bblv:920
hdisk4:2 bblv:921
hdisk4:3 bblv:922
hdisk4:4 bblv:923
hdisk4:5 bblv:924
...
root@bb_lpar: / # lspv -M hdisk3
hdisk3:484 bblv:3040
hdisk3:485 bblv:3041
hdisk3:486 bblv:3042
hdisk3:487 bblv:1
hdisk3:488 bblv:2
hdisk3:489-511
root@bb_lpar: / # migratelp bblv/920 hdisk3/489
root@bb_lpar: / # migratelp bblv/921 hdisk3/490
root@bb_lpar: / # lsvg -p bbvg
bbvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 511 2 02..00..00..00..00
hdisk3 active 511 21 00..00..00..00..21
hdisk4 active 1023 2 02..00..00..00..00
If we try again changing to Big VG, now it is successful:
root@bb_lpar: / # chvg -B bbvg
0516-1216 chvg: Physical partitions are being migrated for volume group
descriptor area expansion. Please wait.
0516-1164 chvg: Volume group bbvg2 changed. With given characteristics bbvg2
can include up to 128 physical volumes with 1016 physical partitions each.
If you check again, freed up PPs has been used:
root@bb_lpar: / # lsvg -p bbvg
bbvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 509 0 00..00..00..00..00
hdisk3 active 509 17 00..00..00..00..17
hdisk4 active 1021 0 00..00..00..00..00
---------------------------------------
Changing Normal (or Big) VG to Scalable VG:
If you reached the MAX PV limit of a Normal or a Big VG and playing with the factor (chvg -t) is not possible anymore you can convert that VG to Scalable VG. A Scalable VG allows a maximum of 1024 PVs and 4096 LVs and a very big advantage that the maximum number of PPs applies to the entire VG and is no longer defined on a per disk basis.
!!!Converting to Scalable VG is an offline activity (varyoffvg), and there must be free PPs on each physical volume, because VGDA will be expanded on all disks.
root@bb_lpar: / # chvg -G bbvg
0516-1707 chvg: The volume group must be varied off during conversion to
scalable volume group format.
root@bb_lpar: / # varyoffvg bbvg
root@bb_lpar: / # chvg -G bbvg
0516-1214 chvg: Not enough free physical partitions exist on hdisk2 for the
expansion of the volume group descriptor area. Migrate/reorganize to free up
18 partitions and run chvg again.
After migrating some lps to free up required PPs (in this case it was 18), then changing to Scalable VG is successful:
root@bb_lpar: / # chvg -G bbvg
0516-1224 chvg: WARNING, once this operation is completed, volume group bbvg
cannot be imported into AIX 5.2 or lower versions. Continue (y/n) ?
...
0516-1712 chvg: Volume group bbvg changed. bbvg can include up to 1024 physical volumes with 2097152 total physical partitions in the volume group.
---------------------------------------
0516-008 varyonvg: LVM system call returned an unknown error code (2).
solution: export LDR_CNTRL=MAXDATA=0x80000000@DSA (check /etc/environment if LDR_CNTRL has a value, which is causing the trouble)
---------------------------------------
If VG cannot be created:
root@aix21c: / # mkvg -y tvg hdisk29
0516-1376 mkvg: Physical volume contains a VERITAS volume group.
0516-1397 mkvg: The physical volume hdisk29, will not be added to
the volume group.
0516-862 mkvg: Unable to create volume group.
root@aixc: / # chpv -C hdisk29 <--clears owning volume manager from a disk, after this mkvg was successful
---------------------------------------
root@aix1: /root # importvg -L testvg -n hdiskpower12
0516-022 : Illegal parameter or structure value.
0516-780 importvg: Unable to import volume group from hdiskpower12.
For me the solution was:
there was no pvid on the disk, after adding it (chdev -l hdiskpower12 -a pv=yes) it was OK
---------------------------------------
Reorgvg log files, and how it is working:
reorgvg activity is logged in lvmcfg:
root@bb_lpar: / # alog -ot lvmcfg | tail -3
[S 17039512 6750244 10/23/11-12:39:05:781 reorgvg.sh 580] reorgvg bbvg bb1lv
[S 7405650 17039512 10/23/11-12:39:06:689 migfix.c 168] migfix /tmp/.workdir.9699494.17039512_1/freemap17039512 /tmp/.workdir.9699494.17039512_1/migrate17039512 /tmp/.workdir.9699494.17039512_1/lvm_moves17039512
[E 17039512 47:320 reorgvg.sh 23] reorgvg: exited with rc=0
Field of these lines:
S - Start, E - End; PID, PPID; TIMESTAMP
At E (end) line shows how long reorgvg was running (in second:milliseconds):
47:320 = 47s 320ms
for a long running reorgvg, you can see it's status:
1. check the working dir of reorgvg
root@aixdb2: /root # alog -ot lvmcfg | tail -3 | grep workdir
[S 5226546 5288122 10/22/11-13:55:11:001 migfix.c 165] migfix /tmp/.workdir.4935912.5288122_1/freemap5288122 /tmp/.workdir.4935912.5288122_1/migrate5288122 /tmp/.workdir.4935912.5288122_1/lvm_moves5288122
2. check lvm_moves file in that dir (we will need the path of this file):
root@aixdb2: /root # ls -l /tmp/.workdir.4935912.5288122_1 | grep lvm_moves
-rw------- 1 root system 1341300 Oct 22 13:55 lvm_moves5288122
(it contains all the lp migartions, and reorgvg goes through on this file, line by line)
3. check the process of reorgvg:
root@aixdb2: /root # ps -ef | grep reorgvg
root 5288122 5013742 0 13:52:16 pts/2 0:12 /bin/ksh /usr/sbin/reorgvg P_NAVISvg p_datlv
root@aixdb2: /root # ps -fT 5288122
CMD
/bin/ksh /usr/sbin/reorgvg P_NAVISvg p_datlv
|\--lmigratepp -g 00c0ad0200004c000000012ce4ad7285 -p 00c80ef201f81fa6 -n 1183 -P 00c0ad021d62f017 -N 1565
\--awk -F: {print "-p "$1" -n "$2" -P "$3" -N "$4 }
(lmigratepp shows: -g VGid -p SourcePVid -n SourcePPnumber -P DestinationPVid -N DestinationPPnumber)
lmigratepp shows the actual PP which is migrated at this moment
(if you ask few seconds later it will show the next PP which is migrated, and it uses the lvm_moves file)
4. check the line number of the PP which is being migrated at this moment:
(now the ps command in step 3 is extended with the content of the lvm_moves file)
root@aixdb2: /root # grep -n `ps -fT 5288122|grep migr|awk '{print $12":"$14}'` /tmp/.workdir.4935912.5288122_1/lvm_moves5288122
17943:00c0ad021d66f58b:205:00c0ad021d612cda:1259
17944:00c80ef24b619875:486:00c0ad021d66f58b:205
you can compare the above line numbers (17943, 17944) to how many lines lvm_moves file has.
root@aixdb2: /root # cat /tmp/.workdir.4935912.5288122_1/lvm_moves5288122 | wc -l
31536
It shows that from 31536 lp migrations we are at this moment at 17943.
---------------------------------------
0516-304 : Unable to find device id 00080e82dfb5a427 in the Device
Configuration Database.
If a disk has been deleted (rmdev) somehow, but from the vg it was not removed:
root@bb_lpar: / # lsvg -p newvg
newvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 31 20 06..00..02..06..06
0516-304 : Unable to find device id 00080e82dfb5a427 in the Device
Configuration Database.
00080e82dfb5a427 removed 31 31 07..06..06..06..06
VGDA still shows the missing disk is part of the vg:
root@bb_lpar: / # lqueryvg -tAp hdisk2
...
Physical: 00080e82dfab25bc 2 0
00080e82dfb5a427 0 4
VGDA should be updated (on hdisk2) but it is possible only, if the PVID is used with reducevg:
root@bb_lpar: / # reducevg newvg 00080e82dfb5a427
---------------------------------------
If you run into not being able to access an hdiskpowerX disk, you may need to reset the reservation bit on it:
root@aix21: / # lqueryvg -tAp hdiskpower13
0516-024 lqueryvg: Unable to open physical volume.
Either PV was not configured or could not be opened. Run diagnostics.
root@aix21: / # lsvg -p sapvg
PTAsapvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdiskpower12 active 811 0 00..00..00..00..00
hdiskpower13 missing 811 0 00..00..00..00..00
hdiskpower14 active 811 0 00..00..00..00..00
root@aix21: / # bootinfo -s hdiskpower13
0
Possible solution could be emcpowerreset:
root@aix21: / # /usr/lpp/EMC/Symmetrix/bin/emcpowerreset fscsi0 hdiskpower13
(after this varyonvg will bring back the disk into active state)
Subscribe to:
Posts (Atom)