Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Monday, 18 July 2011

Partitioning Tools - Virtual Partition Manager

• Partitioning Tools - Virtual Partition Manager
• Aix - Partitioning Tools - Virtual Partition Manager.



The Virtual Partition Manager is a feature of i5/OS that allows you to create and manage one i5/OS logical partition and up to four Linux logical partitions on a single IBM System i5 or eServer i5 server. You can use the Virtual Partition Manager to partition any IBM System i5 or eServer i5 model that does not require a Hardware Management Console (HMC), such as a model 595.

Partitioning Tools - Integrated Virtualisation Manager

• Partitioning Tools - Integrated Virtualisation Manager
• Aix - Partitioning Tools - Integrated Virtualisation Manager

The Integrated Virtualization Manager is a browser-based system management interface for the Virtual I/O Server. The Integrated Virtualization Manager allows you to create and manage AIX and Linux logical partitions on a single IBM System p server. On Open Power servers, the Integrated Virtualization Manager supports only Linux logical partitions.

Logical Partitioning - Virtual Processor Assignment

• Logical Partitioning - Virtual Processor Assignment
• Aix - Logical Partitioning - Virtual Processor Assignment

If you create a partition profile that is set to use shared processors, the HMC calculates a minimum, maximum, and desired number of virtual processors for
the partition profile. The calculation is based upon the minimum, maximum, and desired number of processing units that you specify for the partition profile. By default, the virtual processor settings are calculated as follows:

• The default minimum number of virtual processors is the minimum number of processing units (rounded up to the next whole number). For example, if the minimum number of processing units is 0.8, the default minimum number of virtual processors is 1.

• The default desired number of virtual processors is the desired number of processing units (rounded up to the next whole number). For example, if the desired number of processing units is 2.8, the default desired number of virtual processors is 3.

• The default maximum number of virtual processors is the maximum number of processing units rounded up to the next whole number and multiplied by two. For example, if the maximum number of processing units is 3.2, the default maximum number of virtual processors is 8 (4 times 2).

When you activate the logical partition using the partition profile on the HMC, the logical partition is assigned the desired number of virtual processors. You can then use dynamic logical partitioning to change the number of virtual processors to any number between the minimum and maximum values, so long as the number of virtual processors is greater than the number of processing units that are assigned to the logical partition. Before changing the default settings, performance modeling should be performed.

For example, you create a partition profile on the HMC with the following processor unit settings.
• Minimum processing units 1.25
• Desired processing units 3.80
• Maximum processing units 5.00

The default virtual processor settings for this partition profile on the HMC are as follows.
• Minimum virtual processors 2
• Desired virtual processors 4
• Maximum virtual processors 10


When you activate the logical partition using this partition profile on the HMC, the operating system sees four processors, because the logical partition is activated with the desired value of four virtual processors. Each of these virtual processors has 0.95 processing units supporting the work assigned to the processor. After the logical partition is activated, you can use dynamic logical partitioning to change the number of virtual processors on the logical partition to any number between 2 and 10, so long as the number of virtual processors is greater than the number of processing units that are assigned to the logical partition. If you increase the number of virtual processors, bear in mind that you will have less processing power supporting the work assigned to each processor.

Logical Partitioning - System Profile

Logical Partitioning - System Profile
Aix - Logical Partitioning - System Profile


• A system profile is an ordered list of partition profiles that is used by the Hardware Management Console (HMC) to start the logical partitions on a managed system in a specific configuration.
• When you activate the system profile, the managed system attempts to activate each partition profile in the system profile in the order specified. A system profile helps you activate or change the managed system from one complete set of logical partition configurations to another.
• It is possible for you to create a system profile whose partition profiles specify more resources than are available on the managed system. You can use the HMC to validate the system profile against the currently available system resources and against the total system resources. Validating your system profile ensures that your I/O devices and processing resources are not overcommitted and it increases the likelihood that the system profile can be activated. The validation process estimates the amount of memory needed to activate all of the partition profiles in the system profile. It is possible that a system profile can pass validation and yet not have enough memory to be activated.

Logical Partitioning - Running integrated clusters

• Logical Partitioning - Running integrated clusters
• Aix - Logical Partitioning - Running integrated clusters

Using high-availability application software, your partitioned server can run as an integrated cluster. You can use an integrated cluster to protect your server from most unscheduled failures within a partition.

Logical Partitioning - Partitioning Tools

• Logical Partitioning - Partitioning Tools
Aix - Logical Partitioning - Partitioning Tools

ou must use tools to partition your servers. The tool that you use to partition each server depends upon the server model and the operating systems and
features that you want to use on the server.

• Hardware Management Console
• Integrated Virtualisation Manager
• Virtual Partition Manag

Logical Partitioning - Partition Profile

• Logical Partitioning - Partition Profile
• Aix - Logical Partitioning - Partition Profile

A partition profile is a record on the Hardware Management Console (HMC) that
specifies a possible configuration for a logical partition. When you activate a
logical partition using a partition profile, the managed system attempts to start
the logical partition using the configuration information in the partition profile.
A partition profile specifies the desired system resources for the logical partition
and the minimum and maximum amounts of system resources that the logical
partition can have. The system resources specified within a partition profile
includes processors, memory, and I/O resources.

Each logical partition on a managed system that is managed by an HMC has at
least one partition profile. If desired, you can create additional partition profiles
with different resource specifications for your logical partition. If you create
multiple partition profiles, you can designate any partition profile on the logical
partition to be the default partition profile. The HMC activates the default profile if
you do not select a specific partition profile to be activated. Only one partition
profile can be active at one time. To activate another partition profile for a logical
partition, you must shut down the logical partition before you activate the other
partition profile.

A partition profile is identified by partition ID and profile name. Partition IDs are
whole numbers used to identify each logical partition that you create on a
managed system, and profile names identify the partition profiles that you create
for each logical partition.

Logical Partitioning - Merging production and test environments

• Logical Partitioning - Merging production and test environments
• Aix - Logical Partitioning - Merging production and test environments

Partitioning enables separate partitions to be allocated for production and test servers, eliminating the need to purchase additional hardware and software.When testing has been completed, the resources allocated to the test partition can be returned to the production partition or elsewhere as required. As new projects are developed, they can be built and tested on the same hardware on which they will eventually be deployed.

Logical Partitioning - Memory and Processor Resource Assignment

• Logical Partitioning - Memory and Processor Resource Assignment
• Aix - Logical Partitioning - Memory and Processor Resource Assignment
• When you create a partition profile for a logical partition, you set up the desired,minimum, and maximum amounts of memory and processor resources that you want for the logical partition. (Where applicable, this also applies to 5250 CPW.)The desired value is the resource amount that the logical partition gets if you do not over commit the resource on the managed system. If the desired amount of resources is available when you activate the partition profile, then the logical partition starts with the desired amount of resources. However, if the desired amount of resources is not available when you activate the partition profile, then the resources on your managed system are over committed. In that case, if the amount of resources that are available on the managed system is equal to or greater than the minimum amount of resources in the partition profile, then the logical partition starts with the available amount of resources. If the minimum amount of resources is not met, then the logical partition does not start.

Logical Partitioning - Maintaining Independent Servers

• Logical Partitioning - Maintaining Independent Servers
• Aix - Logical Partitioning - Maintaining Independent Servers

Logical isolation of software can be achieved by dedicating a portion of the resources (disk storage unit, processors, memory, and I/O devices) to a partition Software’s which might not run well together on a single machine, can be isolated and run efficiently in separate partitions.Logical partitions also have some hardware fault tolerance.

Logical Partitioning - I/O device assignment

Logical Partitioning - I/O device assignment
Aix - Logical Partitioning - I/O device assignment

• I/O devices are assigned to partition profiles on a slot-by-slot basis. Most I/O devices can be assigned to a partition profile on the HMC as required or as desired.
• If an I/O device is assigned to a partition profile as required, then the partition profile cannot be successfully activated if the I/O device is unavailable or is in use by another logical partition. Also, after the logical partition starts, you cannot use dynamic logical partitioning to remove the required I/O device from the running logical partition or move the required I/O device to another logical partition. This setting is suitable for devices that are required for the continuous operation of the logical partition (such as disk drives).
• If an I/O device is assigned to a partition profile as desired, then the partition profile can be successfully activated if the I/O device is unavailable or is in use by another logical partition. The desired I/O device can also be reconfigured in the operating system or system software and removed from the running logical partition or moved to another logical partition using dynamic logical partitioning. This setting is suitable for devices that you want to share among
multiple logical partitions (such as optical drives or tape drives). You can change the required or desired setting within any partition profile for any I/O device at any time. Changes to the required or desired setting for an I/O device take effect immediately, even if the logical partition is running. For example, you want to move a tape device from one running logical partition to
another, and the I/O device is required in the active partition profile for the source logical partition. You can access the active partition profile for the source logical partition, set the tape device to be desired, and then reconfigure and move the tape device to the other logical partition without having to restart either logical partition.

Logical Partitioning - Creating a mixed production and test environment

Logical Partitioning - Creating a mixed production and test environment
Aix - Logical Partitioning - Creating a mixed production and test environment


We can create a combined production and test environment on the same server. The production partition can run your main business applications, and the test partition is used to test software. A failure in a test partition, while not necessarily planned, will not disrupt normal business operations.

Logical Partioning - How resources are shared

Logical Partioning - How resources are shared
Following are the ways in which resources are shared

Micro-Partitioning feature allows processor resources to be shared automatically among logical partitions that use the shared processor pool. The shared processor pool includes all processors on the server that are not dedicated to specific logical partitions. Each logical partition that uses the shared processor pool is assigned a specific amount of processor power from the shared processor pool. If the logical partition needs more processor power than its assigned amount, the logical partition is set by default to use the unused processor power in the shared processor pool. The amount of processor power that the logical partition can use is limited only by the virtual processor settings of the logical partition and the amount.

Limitations of Logical partitioning

Limitations of Logical partitioning
AIX - Limitations of Logical partitioning


•Processor and memory failures might result in the failure of the entire server with all of its logical partitions. (The failure of a single I/O device affects only the logical partition to which the I/O device belongs.)
• There are many concepts that we must understand to implement logical partitions successfully on server.
• Administering a consolidated system might be more difficult in some ways than administering multiple smaller systems, particularly if the resources in the consolidated system are used at a level close to their capacity. Sharing resources.

AIX - Introduction to Logical Partitioning

AIX - Introduction to Logical Partitioning
1. What is logical partitioning?

Logical partitioning is the ability to make a server run as if it were two or more independent servers. When you logically partition a server, you divide the resources on the server into subsets called logical partitions or LPAR We can install different operating system on each logical partition, and each logical partition runs as an independent logical server with independent operating system and the resources that you have allocated to the logical partition. Processors, memory, and input/output devices are examples of resources that you can assign to logical partitions. Following are the Operating systems which can be installed on each independent Logical partition.

AIX,

i5/OS,

Linux operating systems and Virtual I/O Server.

All the Logical partitions partitioned from a single server share a few system attributes, such as the system serial number, system model, and processor feature code. All other system attributes on each Logical partition can vary from one logical partition to another.

AIX - Dynamic logical partitioning

AIX - Dynamic logical partitioning
Dynamic logical partitioning feature allow resources to be moved to, from, and between running logical partitions manually without shutting down or restarting the logical partitions. This allows us to share devices that logical partitions use occasionally. For example, if the logical partitions on your server use an optical drive occasionally, you can assign a single optical drive to multiple logical partitions as a desired device. The optical drive would belong to only one logical partition at a time, but you can use dynamic logical partitioning to move the optical drive between logical partitions as needed. On servers that are managed using the Integrated Virtualization Manager, dynamic logical partitioning is supported only for the management partition. Dynamic logical partitioning is not supported on servers that are managed using the Virtual Partition Manager.

AIX - Advantages of Logical Partitioning

AIX - Advantages of Logical Partitioning
The following are benefits of logical partitioning on a server:

2.1 Consolidating servers

A logically partitioned server reduces the number of servers that are needed in an enterprise. We can consolidate many servers into a single logically partitioned system. This eliminates the use of additional equipment & expenses.

2.2 Sharing resources

The ability to share resources among many logical partitions allows us to increase resource utilization on the server and to move the server resources to where they are needed. We can easily move the hardware resources from one logical partition to another logical partitioning whenever we need.

AIX - LPAR / DLPAR

• AIX - LPAR / DLPAR


We can configure LPAR and DLPAR in P690 Servers,

LPAR (Logical partitions)

In single server we can install multiple operating systems, like AIX 5.1, AIX 5.2, AIX 5.3, Susi Linux, AIX 4.3, and using LPAR concept

The above Os are installing in single server, before that we have to partition the hardware resources, like processors and memory, Harddisk,

Using HMC (Hardware Management Console) we can partition and operate the LPAR servers

If you have one P690 server with 16 CPU’s and 16GB Ram, in this server we can make 16 partitions,

Now each partitions has 1 CPU and 1GB Ram,

If one particular Os assigned for 500 users that time we have to assign additional hardware resources to that partition, online we can assign the hardware resources using HMC. No need to reboot the server, this concept called DLPAR (dynamic Logical Partition)

Like this we can create the LPAR / DLPAR

HMC - it is a desktop pc (Linux OS) connected with P690 server through Communication (com port) cable or RJ45 Ethernet cat cable

Using HMC we can Create, Delete, and Change the Logical Partitions

This LPAR server has hypervisor Controller, all the information’s stored in this hypervisor, and it is used to maintain the server

Accessing methods:

1. wsm (Web based system management , using this concept we can access the LPAR servers from windows desktops)
2. ssh (Secured shell, using this concept we can access the LPAR servers through telnet)

To configure the HMC, do the following steps:

HMC
To configure the HMC, do the following steps:

1. Turn on the HMC by pressing the power button.

2. Wait for the HMC to automatically select the default language and locale preference.

3. Accept the HMC license agreements. If you decline the HMC license agreements, you cannot complete the HMC configuration.

4. Click Log on and launch the Hardware Management Console web application.

5. Log in to the HMC:

ID: hscroot

Password: abc123

The Guided Setup wizard opens.

6. Click OK on the Guided Setup entry window.

7. Complete the steps in the Guided Setup wizard. Click Yes to continue and complete the steps in the Connectivity and Call-Home Servers wizard.

8. On the Summary window, click Finish.

9. If you have not connected the Ethernet crossover cable to your managed system, do so now and power on the managed server.

10. In the HMC navigation area, click Service Management.

11. In the contents area, click Authorize User. The Authorize User window opens.

12. Enter your IBM® ID in the field and click OK.

Creating LPAR using SSH

Get the configuration data from existing LPAR

If you already have LPARs created you can use this command to get their configuration which can be reused as template:

lssyscfg -r prof -m SERVERNAME --filter "lpar_ids=X, profile_names=normal"

Create new LPAR using command line

Here is an example, for more information see '''man mksyscfg'''

mksyscfg -r lpar -m MACHINE -i name=LPARNAME, profile_name=normal, lpar_env=aixlinux, shared_proc_pool_util_auth=1, min_mem=512, desired_mem=2048, max_mem=4096, proc_mode=shared, min_proc_units=0.2, desired_proc_units=0.5, max_proc_units=2.0, min_procs=1, desired_procs=2, max_procs=2, sharing_mode=uncap, uncap_weight=128,boot_mode=norm, conn_monitoring=1, shared_proc_pool_util_auth=1

Create more LPARs using configuration file

If you want to create more LPARS at once you can use a configuration file and provide it as input for mksyscfg.

Here is an example for 3 LPARs, each definition starting at new line:

name=LPAR1,profile_name=normal,lpar_env=aixlinux,all_resources=0,min_mem=1024,desired_mem=9216,max_mem=9216,proc_mode=shared,min_proc_units=0.3,desired_proc_units=1.0,max_proc_units=3.0,min_procs=1,desired_procs=3,max_procs=3,sharing_mode=uncap,uncap_weight=128,lpar_io_pool_ids=none,max_virtual_slots=10,"virtual_scsi_adapters=6/client/4/vio1a/11/1,7/client/9/vio2a/11/1","virtual_eth_adapters=4/0/3//0/1,5/0/4//0/1",boot_mode=norm,conn_monitoring=1,auto_start=0,power_ctrl_lpar_ids=none,work_group_id=none,shared_proc_pool_util_auth=1
name=LPAR2,profile_name=normal,lpar_env=aixlinux,all_resources=0,min_mem=1024,desired_mem=9216,max_mem=9216,proc_mode=shared,min_proc_units=0.3,desired_proc_units=1.0,max_proc_units=3.0,min_procs=1,desired_procs=3,max_procs=3,sharing_mode=uncap,uncap_weight=128,lpar_io_pool_ids=none,max_virtual_slots=10,"virtual_scsi_adapters=6/client/4/vio1a/12/1,7/client/9/vio2a/12/1","virtual_eth_adapters=4/0/3//0/1,5/0/4//0/1",boot_mode=norm,conn_monitoring=1,auto_start=0,power_ctrl_lpar_ids=none,work_group_id=none,shared_proc_pool_util_auth=1
name=LPAR3,profile_name=normal,lpar_env=aixlinux,all_resources=0,min_mem=1024,desired_mem=15360,max_mem=15360,proc_mode=shared,min_proc_units=0.4,desired_proc_units=1.0,max_proc_units=4.0,min_procs=1,desired_procs=4,max_procs=4,sharing_mode=uncap,uncap_weight=128,lpar_io_pool_ids=none,max_virtual_slots=10,"virtual_scsi_adapters=6/client/4/vio1a/13/1,7/client/9/vio2a/13/1","virtual_eth_adapters=4/0/3//0/1,5/0/4//0/1",boot_mode=norm,conn_monitoring=1,auto_start=0,power_ctrl_lpar_ids=none,work_group_id=none,shared_proc_pool_util_auth=1

Copy this file to HMC and run:
mksyscfg -r lpar -m SERVERNAME -f /tmp/profiles.txt

To check the HMC version
lshmc -V

Eg:
Release: 3
Version: 2.5
HMC Build level 20031020.1

To check the HMC vital product data information
lshmc -v

Eg:
Vital Product Data Information:
*FC ????????
*VC 20.0
*N2 Mon Aug 20 13:12:39 BST 2007
*FC ????????
*DS pSeries Hardware Management Console
*TM eserver xSeries 335 -[7315CR2]-
*SE 651BABA
*MN IBM
*PN Unknow
*SZ 1055932416
*OS Linux 2.4.20-19.7
*NA 10.35.0.135
*FC ????????
*DS Platform Firmware
*RM R3V2.5

To check the HMC network configurations:
lshmc -n

To List last 2 days console log details
lssvcevents -t console -d 2

HMC Hints:
Power 4 HMC Commands


To view partition state:
get_partition_state

To pop a hung partiton into the debugger (aka 'soft reset'):
reset_partition -m -p -t soft

To force a reboot of a hung system (aka 'hard reset'):
reset_partition -m -p -t hard

To start a partition:
start_partition -p -f -m

To get a listing of boot profiles:
query_profile_names -m -p

Power 5 HMC Commands

To see system state for a system or the partitions on a system:
lssyscfg -r sys -m
lssyscfg -r lpar -m

To just see names and state:
lssyscfg -r lpar -m -F name,state --header

To power on an lpar with a profile:
chsysstate -m -o on -r lpar -n -f
i.e. for example:
chsysstate -m alpha -o on -r lpar -n alpha-lp1 -f default

To power on a whole machine (CEC):
chsysstate -m alpha -o on -r sys

Etc. chsysstate, lssyscfg and other commands have good explanations if they're run without arguments.

Issuing a 'soft reset', to push a hung machine into KDB/XMON, is not obvious. The magic incantation is:
chsysstate -r lpar -m -n -o dumprestart

To issue a 'hard reset', to turn off a partition, no matter what:
chsysstate -r lpar -m -n -o shutdown --immed --restart

To add one virtual CPU: (note these use -p instead of -n for the partition name)
chhwres -r proc -m -p -o a --procs 1

To add one-tenth of a cpu processing entitlement:
chhwres -r proc -m -p --procunits 0.1

HMC AND LPAR

HMC AND LPAR
HMC device is required to perform LPAR , DLPAR and CUOD configuration and management.
A single HMC can manage 48 i5 systems and 254 LPARs
In a partition there is a maximum no. of 64 virtual processors.
A mix of dedicated and shared processors within the same partition is not supported.
Sharing a pool of virtualized processors is known as Micro Partitioning technology
The maximum no.of physical processors on p5 is 64.
In Micro partition technology the minimum capacity is 1/10 processing units.
Virtual Ethernet enables inter partition communication without a dedicated physical network adapter.
The virtual IO server owns the real resources that are shared with other clients.
Shared Ethernet adapter is a new service that acts as a layer 2 network switch to route network traffic from a virtual Ethernet to a real network adapter.
On p5 – 595 Max no.of processors- 64, Max Memory Size – 2TB, Dedicated processor partitions-64, Shared processor partitions- 254.
HMC model for p5 – 595 is 7310-C04 or 7310-CR3
HMC Functions: LPAR, DLPAR, Capacity on demand without reboot, Inventory and microcode management, Remote power control.
254 partitions supported by one HMC.
A Partition Profile is used to allocate resources such as processing units, memory and IO cards to a partition. Several partition profiles may be created for the same partition.
System profile is a collection of partition profiles. A partition profile cannot be added to a system profile if the partition resources are already committed to another partition profile.
To change from one system profile to another, all the running partitions must be shutdown.
To find the current firmware level: lscfg –vp |grep –p ‘Platform Firmware:’
Simultaneous multi threading : The instructions from the OS are loaded simultaneously into the processor and executed.
DLPAR : DLPAR allows us to add, move or remove processors, memory and IO resources to, from or between active partitions manually without having to restart or shutdown the partition.
Unused processing units available in shared processor pool.
Dedicated processors are whole processors that are assigned to a single partition. The minimum no. of dedicated processors you must assign is one processor.
When a partition with dedicated processors is powered down, their processors will be available to the shared processor pool. This capability is enabled by “Allow idle processors to be shared”.
Idle processors from active partitions with dedicated processors can be used by any uncapped partition that requires additional processing units to complete its jobs.
Shared processor minimum processing unit is 0.1
Capped : The processor usage never exceeds the assigned processing capacity.
Uncapped : Processing capacity may be exceeded when the shared processor pool has spare processing units.
Weight is a number range between 0-255. If there are 3 processors available in the shared processor pool , partition A has an uncapped weight of 80 and B has 160. The LPAR A will receive 1 processing unit and B receive 2 processing units.
Minimum Memory is the minimum amount of memory which needed by the logical partition to start.
Desired memory is the requested amount of memory for the partition. The partition will receive an amount of memory between minimum and desired. Desired memory is the amount of memory which LPAR needs to have when the lpar is powered on. If the managed system does not have the desired amount of memory but only has lesser memory , those uncommitted memory resources will be assigned to the LPAR when the LPAR is activated.
You cant increase the memory more than maximum value.
Installed memory is the total no. of memory units that are installed on the managed system
Creating a new LPAR :
Server and Partition à Server Management à right click partitionsà Createà logical partition
Give partition ID(Numeric between 1 and 254) and name (max 31 characters)
Give partition type (AIX or linux, i5/OS, VIO)
Select work load management group NO
Give profile name
Specify the Min, Desired and Max memory
Select the dedicated/shared processors
If you select dedicated then give min,desired and max processors
If you select the shared give min,desired and max processing units and click advanced
And click the radio button(capped/uncapped) and give the virtual processors(min,max,desired)
If you select the uncapped give the weight also.
Allocate physical IO resources : Select the IO and click the add as required/add as desired.
IO resources can be configured as required or desired. A required resource is needed for the partition to start when the profile is activated. Desired resources are assigned to the partition if they are available when the profile is activated.
And select the console, location code
To create another profile Right click the partition à createà profileà give profile id.
Change default profile : Right click the partition àchange default profileà choose profile.
Restart options :
DUMP : Initiate a main storage or system memory dump on the logical partition and restart the logical partition when complete.
Immediate : as quickly as possible , without notifying the logical partition.
DUMP Retry : Retry a main storage or system memory dump on the logical partition and restart the logical partition when complete.
Shutdown options :
Delayed : Shutdown the logical partition by starting the delayed power off sequence.
Immediate : as quickly as possible , without notifying the logical partition.
DLPAR:
DLPAR can be performed against the following types :
Physical Adapters
Processors
Memory
VIO Adapters
Right click the partition à Dynamic Logical Partitioningà Physical adapter resourcesà add/move/remove
Licensed Internal Code Updates: To install licensed internal code fixes on your managed systems for a current release click “change licensed internal code for the current release”
To upgrade licensed internal code fixes on your managed systems for a current release click “upgrade licensed internal code for the current release”
HMC Security: Servers and Clients communicate over the secure sockets layer(SSL). Which provides server authentication, data encryption and data integration.
HMC Serial number lshmc -v
To format the DVD-RAM media
The following steps show how to format the DVD-RAM disk:
1. Place a DVD-RAM disk in to the HMC DVD drive.
2. In the HMC Navigation area,under your managed system, click Licensed Internal Code
Maintenance.
3. Then click HMC Code Update.
4. In the right-hand window, click Format Removable Media.
5. Then select the Format DVD radio button.
6. Select Backup/restore.
7. Then click the Format button.
The DVD-RAM disk should be formatted in a few seconds, after which you will receive a
“Format DVD has been successfully completed – ACT0001F” message.
Back up to formatted DVD media
Use the following steps to back up the CCD to the formatted DVD media:
1. In the HMC Navigation area, click Licensed Internal Code Maintenance.
2. Then click the HMC Code Update.
3. In the right-hand window, click Back up Critical Console Data.
4. Select the Back up to DVD on local system radio button and click the Next button.
5. Enter some valid text in the description window and click OK.

Monday, 4 July 2011

USEFUL HACMP COMMANDS

USEFUL HACMP COMMANDS

clstat - show cluster state and substate; needs clinfo.

cldump - SNMP-based tool to show cluster state

cldisp - similar to cldump, perl script to show cluster state.

cltopinfo - list the local view of the cluster topology.

clshowsrv -a - list the local view of the cluster subsystems.

clfindres (-s) - locate the resource groups and display status.

clRGinfo -v - locate the resource groups and display status.

clcycle - rotate some of the log files.

cl_ping - a cluster ping program with more arguments.

clrsh - cluster rsh program that take cluster node names as argument.

clgetactivenodes - which nodes are active?

get_local_nodename - what is the name of the local node?

clconfig - check the HACMP ODM.

clRGmove - online/offline or move resource groups.

cldare - sync/fix the cluster.

cllsgrp - list the resource groups.

clsnapshotinfo - create a large snapshot of the hacmp configuration.

cllscf - list the network configuration of an hacmp cluster.


clshowres - show the resource group configuration.

cllsif - show network interface information.

cllsres - show short resource group information.

lssrc -ls clstrmgrES - list the cluster manager state.

lssrc -ls topsvcs - show heartbeat information.

cllsnode - list a node centric overview of the hacmp configuration.

TESTING HACMP: HA FAILOVER SCENARIOS

TESTING HACMP: HA FAILOVER SCENARIOS

1. Graceful

For graceful failover, you can run “smitty clstop” then select graceful option. This will not change

anything except stopping the cluster on that node.

Note: If you stop the cluster, check the status using lssrc –g cluster, sometimes clstrmgrES daemon will

take long time to stop, DO NOT KILL THIS DAEMON.It will stop automatically after a while.

You can do this on both the nodes

2. Takeover



For takeover, run “smitty clstop” with takeover option, this will stop the cluster on that node and the

standby node will take over the pakage

You can do this on both the nodes

3. Soft Pakckage Failover

Run smitty cm_hacmp_resource_group_and_application_management_menu >>>Move a

Resource Group to Another Node >>>>select the package name and node name

>>>enter

This will move the package from that node to the node that you have selected in the above menu. This

method will give lot of troubles in HA 4.5 whereas it runs good on HA 5.2 unless we have any apps

startup issues.

You can do this on both the nodes

4. Failover Network Adapter(s):

For this type of testing , run “ifconfig enx down” , then package IP will failover to primary adapter. You

can not even see any outage or anything.

We can manually (ifconfig enx up) bring it back to original adapter , but better to reboot the server to

bring the package back to the original node

5. Hardware Failure (crash):

This is a standard type of testing; run the command “reboot –q” then the node will godown without

stopping any apps and come up immediately. The package will failover to the standby node with in 2

min os downtime (Even tough HA failover is fast, some apps will take long time to start

STEPS TO CONFIGURE HACMP:

STEPS TO CONFIGURE HACMP:

1. Install the nodes, make sure the redundancy is maintained for power supplies, n/w and

fiber n/ws. Then Install AIX on the nodes.

2. Install all the HACMP filesets except HAview and HATivoli.

Install all the RSCT filesets from the AIX base CD.

Make sure that the AIX, HACMP patches and server code are at the latest level (ideally

recommended).

4. Check for fileset bos.clvm to be present on both the nodes. This is required to make the

VGs enhanced concurrent capable.

5. V.IMP: Reboot both the nodes after installing the HACMP filesets.

6. Configure shared storage on both the nodes. Also in case of a disk heartbeat, assign a

1GB shared storage LUN on both nodes.

7. Create the required VGs only on the first node. The VGs can be either normal VGs or

Enhanced concurrent VGs. Assign particular major number to each VGs while creating

the VGs. Record the major no. information.

To check the Majar no. use the command:

ls –lrt /dev grep

Mount automatically at system restart should be set to NO.


8. Varyon the VGs that was just created.

9. V.IMP: Create log LV on each VG first before creating any new LV. Give a unique

name to logLV.

Destroy the content of logLV by: logform /dev/loglvname

Repeat this step for all VGs that were created.

10. Create all the necessary LVs on each VG.

11. Create all the necessary file systems on each LV created…..you can create mount pts

as per the requirement of the customer,

Mount automatically at system restart should be set to NO.

12. umount all the filesystems and varyoff all the VGs.

13. chvg –an All VGs will be set to do not mount automatically at

System restart.

14. Go to node 2 and run cfgmgr –v to import the shared volumes.

15. Import all the VGs on node 2

use smitty importvg import with the same major number as assigned on node

16. Run chvg –an for all VGs on node 2.

17. V.IMP: Identify the boot1, boot2, service ip and persistent ip for both the nodes and make the entry

in the /etc/hosts.

18. Define cluster name.

19. Define the cluster nodes. #smitty hacmp -> Extended Configuration -> Extended topology

configuration -> Configure an HACMP node - > Add a node to an HACMP cluster Define both the

nodes on after the other.


20. Discover HACMP config: This will import for both nodes all the node info, boot ips,

service ips from the /etc/hosts

smitty hacmp -> Extended configurations -> Discover hacmp related information

Step21 Adding Communication interface

Add HACMP communication interfaces. (Ether interfaces.)

smitty hacmp -> Extended Configuration -> Extended Topology Configuration ->

Configure HACMP networks -> Add a network to the HACMP cluster.

Select ether and Press enter.

Then select diskhb and Press enter. Diskhb is your non-tcpip heartbeat.

step 22 Adding device for Disk Heart Beat

Include the interfaces/devices in the ether n/w and diskhb already defined.

smitty hacmp -> Extended Configuration -> Extended Topology Configuration ->

Configure HACMP communication interfaces/devices -> Add communication Interfaces/devices.

step23 Adding boot IP & Disk heart beat information

Include all the four boot ips (2 for each nodes) in this ether interface already defined.Then include the

disk for heartbeat on both the nodes in the diskhb already defined

step 24 Adding persistent IP

Add the persistent IPs:




smitty hacmp -> Extended Configuration -> Extended Topology Configuration ->

Configure HACMP persistent nodes IP label/Addresses

step 25 Adding Persistent IP labels

Add a persistent ip label for both nodes.

step 26 Defining IP labels

Define the service IP labels for both nodes.

smitty hacmp -> Extended Configuration -> Extended Resource Configuration ->

HACMP extended resource configuration -> Configure HACMP service IP label

step 27 Adding Resource Group

Add Resource Groups:

smitty hacmp -> Extended Configuration -> Extended Resource Configuration ->

HACMP extended resource group configuration

Continue similarly for all the resource groups.

The node selected first while defining the resource group will be the primary owner of

that resource group. The node after that is secondary node.




Make sure you set primary node correctly for each resource group. Also set the failover/fallback policies

as per the requirement of the setup

step 28 Setting attributes of Resource group

Set attributes of the resource groups already defined:

Here you have to actually assign the resources to the resource groups.

smitty hacmp -> Extended Configuration -> Extended Resource Configuration ->

HACMP extended resource group configuration

step 29 Adding IP label & RG owned by Node

Add the service IP label for the owner node and also the VGs owned by the owner node

Of this resource group.

step 30 & 31 Synchronize & start Cluster

Synchronize the cluster:

This will sync the info from one node to second node.

Smitty cl_sync

That’s it. Now you are ready to start the cluster.

Smitty clstart


You can start the cluster together on both nodes or start individually on each node.

You can start the cluster together on both nodes or start individually on each node.

Step 32 & 33 Check for cluster Stabilize & VG varied on

Wait for the cluster to stabilize. You can check when the cluster is up by following

commands

a. netstat –i

b. ifconfig –a : look-out for service ip. It will show on each node if the cluster is up.

Check whether the VGs under cluster’s RGs are varied-ON and the filesystems in the

VGs are mounted after the cluster start.

Here test1vg and test2vg are VGs which are varied-ON when the cluster is started and

Filesystems /test2 and /test3 are mounted when the cluster starts.

/test2 and /test3 are in test2vg which is part of the RG which is owned by this node.

32. Perform all the tests such as resource take-over, node failure, n/w failure and verify

the cluster before releasing the system to the customer.

Specifying the default gateway on a specific interface



When you're using HACMP, you usually have multiple network adapters installed and thus multiple

network interface to handle with. If AIX configured the default gateway on a wrong interface (like on

your management interface instead of the boot interface), you might want to change this, so network

traffic isn't sent over the management interface. Here's how you can do this:

First, stop HACMP or do a take-over of the resource groups to another node; this will avoid any

problems with applications when you start fiddling with the network configuration.

Then open up a virtual terminal window to the host on your HMC. Otherwise you would loose the

connection, as soon as you drop the current default gateway.

Now you need to determine where your current default gateway is configured. You can do this by

typing: lsattr -El inet0 and netstat -nr. The lsattr command will show you the current default gateway

route and the netstat command will show you the interface it is configured on. You can also check the

ODM: odmget -q"attribute=route" CuAt.

Now, delete the default gateway like this:

lsattr -El inet0 | awk '$2 ~ /hopcount/ { print $2 }' | read GW

chdev -l inet0 -a delroute=${GW}

If you would now use the route command to specifiy the default gateway on a specific interface, like

this:

route add 0 [ip address of default gateway: xxx.xxx.xxx.254] -if enX

You will have a working entry for the default gateway. But... the route command does not change

anything in the ODM. As soon as your system reboots; the default gateway is gone again. Not a good

idea.

A better solution is to use the chdev command:



chdev -l inet0 -a addroute=net,-hopcount,0,,0,[ip address of default gateway]

This will set the default gateway to the first interface available.

To specify the interface use:

chdev -l inet0 -a addroute=net,-hopcount,0,if,enX,,0,[ip address of default gateway]

Substitute the correct interface for enX in the command above.

If you previously used the route add command, and after that you use chdev to enter the default

gateway, then this will fail. You have to delete it first by using route delete 0, and then give the chdev

command.

Afterwards, check with lsattr -El inet0 and odmget -q"attribute=route" CuAt if the new default gateway

is properly configured. And ofcourse, try to ping the IP address of the default gateway and some outside

address. Now reboot your system and check if the default gateway remains configured on the correct

interface. And startup HACMP again!

HACMP V5.X DISK HEARTBEAT DEVICE CONFIGURATION

HACMP V5.X DISK HEARTBEAT DEVICE CONFIGURATION

Introduction

This document is intended to supplement existing documentation on how to configure, test, and

monitor a disk heartbeat device and network in HACMP/ES V 5.x. This feature is new in V5.1, and it

provides another alternative for non-ip based heartbeats. The intent of this document is to provide stepby-

step directions as they are currently sketchy in the HACMP v5.1 pubs. This will hopefully clarify

several misconceptions that have been brought to my attention.

This example consists of a two-node cluster (nodes GT40 & SL55) with shared ESS vpath devices. If

more than two nodes exist in your cluster, you will need N number or non-ip heartbeat networks.

Where N represents the number of nodes in the cluster. (i.e. three node cluster requires 3 non-ip

heartbeat networks). This creates a heartbeat ring.

It’s worth noting that one should not confuse concurrent volume groups with concurrent resource

groups. And note, there is a difference between concurrent volume groups and enhanced concurrent

volume groups. A concurrent resource group is one which may be active on more than one node at a

type. A concurrent volume group also shares the characteristic that it may be active on more than one

node at a time. This is also true for an enhanced concurrent VG; however, in a non-concurrent resource

group, the enhanced concurrent VG, while it may be active and not have a SCSI reserve residing on the

disk, it’s data is only normally accessed by one system at a time.

Pre-Reqs

In this document, it is assumed that the shared storage devices are already made available and

configured to AIX, and that the proper levels of RSCT and HACMP are already installed. Since utilizing

enhanced-concurrent volume groups, it is also necessary to make sure that bos.clvm.enh is installed.

This is not normally installed as part of a HACMP installation via the installp command.

Disk Heartbeat Details

This provides the ability to use existing shared disks, regardless of disk type, to provide a serial network

like heartbeat path. A benefit of this is that one need not dedicate the integrated serial ports for HACMP

heartbeats (if supported on the subject systems) or purchase an 8-port asynchronous adapter.

This feature utilizes a special area on the disk previously reserved for “Concurrent Capable” volume

groups (traditionally only for SSA disks). Since AIX 5.2 dropped support for the SSA concurrent volume



groups, this fit makes it available for use. This also means that the disk chosen for serial heartbeat can

be part of a data volume group. (Note Performance Concerns below)

The disk heart beating code went into the 2.2.1.30 version of RSCT. Some recommended APARs bring

that to 2.2.1.31. If you've got that level installed, and HACMP 5.1, you can use disk heart beating. The

relevant file to look for is /usr/sbin/rsct/bin/hats_diskhb_nim. Though it is supported mainly through

RSCT, we recommend AIX 5.2 when utilizing disk heartbeat.

To use disk heartbeats, no node can issue a SCSI reserve for the disk. This is because both nodes using it

for heart beating must be able to read and write to that disk. It is sufficient that the disk be in an

enhanced concurrent volume group to meet this requirement. (It should also be possible to use a disk

that is in no volume group for disk heart beating. RSCT certainly won't care; but HACMP SMIT panels

may not be particularly helpful in setting this up.)

Now, in HACMP 5.1 with AIX 5.1, enhanced concurrent mode volume groups can be used only in

concurrent (or "online on all available nodes") resource groups. This means that disk heart beating is

useful only to people running concurrent configurations, or who can allocate such a volume group/disk

(which is certainly possible, though perhaps an expensive approach). In other words, at HACMP 5.1 and

AIX 5.1, typical HACMP clusters (with a server and idle standby) will require an additional concurrent

resource group with a disk in an enhanced concurrent VG dedicated for heartbeat use. At AIX 5.2, disk

heartbeats can exist on an enhanced concurrent VG that resides in a non-concurrent resource group. At

AIX 5.2, one may also use the fast disk takeover feature in non-concurrent resource groups with

enhanced concurrent volume groups. With HACMP 5.1 and AIX 5.2, enhanced concurrent mode volume

groups can be used in serial access configurations for fast disk takeover, along with disk heart beating.

(AIX 5.2 requires RSCT 2.3.1.0 or later) That is, the facility becomes usable to the average customer,

without committment of additional resource, since disk heart beating can occur on a volume group used

for ordinary filesystem and logical volume activity.

Performance Concerns with Disk Heart Beating

Most modern disks take somewhere around 15 milliseconds to service an IO request, which means that

they can't do much more than 60 seeks per second. The sectors used for disk heart beating are part of

the VGDA, which is at the outer edge of the disk, and may not be near the application data. This means

that every time a disk heart beat is done, a seek will have to be done. Disk heart beating will typically



(with the default parameters) require four (4) seeks per second. That is each of two nodes will write to

the disk and read from the disk once/second, for a total of 4 IOPS. So, if possible, a disk should be

selected as a heart beat path that does not normally do more than about 50 seeks per second. The

filemon tool can be used to monitor the seek activity on a disk.

In cases where a disk must be used for heart beating that already has a high seek rate, it may be

necessary to change the heart beat timing parameters to prevent long write delays from being seen as a

failure.

The above cautions as stated apply to JBOD configurations, and should be modified based on the

technology of the disk subsystem:

• If the disk used for heart beating is in a controller that provides large amounts of cache - such as the

ESS - the number of seeks per second can be much larger

• If the disk used for heart beating is part of a RAID set without a caching front end controller, the disk

may be able to support fewer seeks, due to the extra activity required by RAID operations

Pros & Cons of using Disk Heart Beating

Pros:

1. No additional hardware needed.

2. Easier to span greater distances.

3. No loss in usable storage space and can use existing data volume groups.

4. Uses enhanced concurrent vgs which also allows for fast-disk takeover.

Cons:

1. Must be aware of the devices diskhb uses and administer devices properly*

2. Lose the forced down option of stopping cluster services because of enhanced concurrent vg usage.

*I have had a customer delete all their disk definitions and run cfgmgr again to clean up number holes in

their device definition list. When they did, obviously , the device names did not come back in the same


order as they were before. So the diskhb device assigned to HACMP, was no longer valid as a different

device was configured using the old device name and it was not part of an enhanced concurrent vg.

Hence diskhb no longer worked, and since the customer did not monitor their cluster either, they were

unaware that the diskhb no longer worked.

Configuring Disk Heartbeat

As mentioned previously, disk heartbeat utilizes enhanced-concurrent volume groups. If starting with a

new configuration of disks, you will want to create enhanced-concurrent volume groups, either

manually, or by utilizing C-SPOC. My example shows using C-SPOC which is the best practice to use here.

If you plan to use an existing volume group for disk heartbeats that is not enhanced concurrent, then

you will have to convert them to such using the chvg command. We recommend that the VG be active

on only one node, and that the application not be running when making this change run chvg –C vgname

to change the VG to enhanced concurrent mode. Vary it off, then run importvg –L vgname on the other

node to make it aware that the vg is now enhanced concurrent capable. If using this method, you can

skip to the “Creating Disk Heartbeat Devices and Network” section of this document.

Disk and VG Preparation

To be able to use C-SPOC successfully, it is required that some basic IP based topology already exists,

and that the storage devices have their PVIDs in both system’s ODMs. This can be verified by running

lspv on each system. If a PVID does not exist on each system, it is necessary to run chdev -l -a pv=yes on

each system. This will allow C-SPOC to match up the device(s) as known shared storage devices.

In this example, vpath0 on GT40 is the same virtual disk as vpath3 on SL55.

Use C-SPOC to create an Enhanced Concurrent volume group. In the following example, since vpath

devices are being used, the following smit screen paths were used.

Go to HACMP Concurrent Logical Volume smitty cl_admin Create a Concurrent Volume Group with

Data Concurrent Volume Groups Management Path Devices and press Enter



Choose the appropriate nodes, and then choose the appropriate shared storage devices based on pvids

(vpath0 and vpath3 in this example). Choose a name for the VG , desired PP size, make sure that

Enhanced Concurrent Mode is set to true and press Enter. (enhconcvg in this example). This will create

the shared enhanced-concurrent vg needed for our disk heartbeat. .

It’s a good idea to verify via lspv once this has completed to make sure the device and vg is show

appropriately as follows:

GT40#/ lspv

vpath0 000a7f5af78e0cf4 enhconcvg

SL55#/lspv

vpath3 000a7f5af78e0cf4 enhconcvg

Creating Disk Heartbeat Devices and Network

There are two different ways to do this. Since we have already created the enhanced concurrent vg, we

can use the discovery method (1) and let HA find it for us. Or we can do this manually via the Predefined

devices method (2). Following is an example of each.

1) Creating via Discover Method: (See Note)

Extended Enter smitty hacmp Press Discover HACMP-related Information from Configured

Nodes Configuration Enter

This will run automatically and create a clip_config file that contains the information it has discovered.

Once completed, go back to the Extended Configuration menu and chose:


Extended Topology Add Communication Configure HACMP Communication

Interfaces/Devices Configuration Add Discovered Communication Interface and Interfaces/Devices

Choose appropriate devices (ex. vpath0 and Communication Devices Devices vpath3)

Select Point-to-Point Pair of Discovered Communication Devices to Add

Move cursor to desired item and press F7. Use arrow keys to scroll.

ONE OR MORE items can be selected.

Press Enter AFTER making all selections.

# Node Device Device Path Pvid

> nodeGT40 vpath0 /dev/vpath0 000a7f5af78

> nodeSL55 vpath3 /dev/vpath3 000a7f5af78

Note: Base HA 5.1 appears to have a problem when using the Discovered Devices this method. If you get

this error: "ERROR: Invalid node name 000a7f5af78e0cf4".

Then you will need apar IY51594. Otherwise you will have to create via the Pre-Defined Devices method.

Once corrected, this section will be completed

2) Creating via Pre-Defined Devices Method

When using this method, it is necessary to create a diskhb network first, then assign the disk-node pair

devices to the network. Create the diskhb network as follows:

Extended Topology Extended Configuration smitty hacmp Add a Network to the HACMP cluster

Configure HACMP Networks Configuration Enter desired network name (ex. disknet1)—press choose

diskhb Enter


Extended Topology Extended Configuration smitty hacmp Add Configure HACMP Communication

Interfaces/Devices Configuration Add Pre-Defined Communication Interfaces and Communication

Interfaces/Devices Devices

Choose your diskhb Network Name Communication Devices

Add a Communication Device

Type or select values in entry fields.

Press Enter AFTER making all desired changes.

[Entry Fields]

* Device Name [GT40_hboverdisk]

* Network Type diskhb

* Network Name disknet1

* Device Path [/dev/vpath0]

* Node Name [GT40]

For Device Name, that is a unique name you can chose. It will show up in your topology under this

name, much like serial heartbeat and ttys have in the past.

For the Device Path, you want to put in /dev/. Then choose the corresponding node for this device and

device name (ex. GT40). Then press Enter.


You will repeat this process for the other node (ex. SL55) and the other device (vpath3). This will

complete both devices for the diskhb network.

Testing Disk Heartbeat Connectivity

Once the device and network definitions have been created, it is a good idea to test it and make sure

communications is working properly. If the volume group is varied on in normal mode on one of the

nodes, the test will probably not work.

/usr/sbin/rsct/bin/dhb_read is used to test the validity of a diskhb connection. The usage of dhb_read is

as follows:

dhb_read -p devicename //dump diskhb sector contents

dhb_read -p devicename -r //receive data over diskhb network

dhb_read -p devicename -t //transmit data over diskhb network

To test that disknet1, in the example configuration, can communicate from nodeB(ex. SL55) to nodeA

(ex. GT40), you would run the following commands:

On nodeA, enter:

dhb_read -p rvpath0 -r

On nodeB, enter:


dhb_read -p rvpath3 -t

Note: That the device name is raw device as designated with the “r” proceeding the device name.

If the link from nodeB to nodeA is operational, both nodes will display:

Link operating normally.

You can run this again and swap which node transmits and which one receives. To make the network

active, it is necessary to sync up the cluster. Since the volume group has not been added to the resource

group, we will sync up once instead of twice.

Add Shared Disk as a Shared Resource

In most cases you would have your diskhb device on a shared data vg. It is necessary to add that vg into

your resource group and synchronize the cluster.

Extended Extended Configuration smitty hacmp Resource Configuration >

Change/Show Extended Resource Group Configuration and press Enter. Resources and Attributes for a

Resource Group

Choose the appropriate resource group, enter the new vg (enhconcvg) into the volume group list and

press Enter.


Return to the top of the Extended Configuration menu and synchronize the cluster.

Monitor Disk Heartbeat

Once the cluster is up and running, you can monitor the activity of the disk (actually all) heartbeats via

lssrc -ls topsvcs. An example of the output follows:

Subsystem Group PID Status

topsvcs topsvcs 32108 active

Network Name Indx Defd Mbrs St Adapter ID Group ID

disknet1 [ 3] 2 2 S 255.255.10.0 255.255.10.1

disknet1 [ 3] rvpath3 0x86cd1b02 0x86cd1b4f

HB Interval = 2 secs. Sensitivity = 4 missed beats

Missed HBs: Total: 0 Current group: 0

Packets sent : 229 ICMP 0 Errors: 0 No mbuf: 0

Packets received: 217 ICMP 0 Dropped: 0

NIM's PID: 28724

Be aware that there is a grace period for heartbeats to start processing. This is normally around 60

seconds. So if you run this command quickly after starting the cluster, you may not see anything at all

until heartbeat processing is started after the grace period time has elapsed.

HACMP LOG FILES

HACMP LOG FILES

/usr/sbin/cluster/etc/rhosts --- to accept incoming communication from clcomdES (cluster

communucation enahanced security)

/usr/es/sbin/cluster/etc/rhosts

Note: If there is an unresolvable label in the /usr/es/sbin/cluster/etc/rhosts file,

then all clcomdES connections from remote nodes will be denied.

cluster manager clstrmgrES

cluster lock Daemon (clockdES)

cluster multi peer extension communication daemon (clsmuxpdES)

The clcomdES is used for cluster configuration operations such as cluster synchronisation

cluster management (C-SPoC) * Dynamic re-configuration DARE configuration. (DARE ) operation.

For clcomdES there should be atleast 20 MB free space in /var file system.

/var/hacmp/clcomd/clcomd.log --it requires 2 MB

/var/hacmp/clcomd/clcomdiag.log --it requires 18MB

Additional 1 MB required for

/var/hacmp/odmcache directory

clverfify.log also present in /var directory

/var/hacmp/clverify/current//* contains log for mcurrent execution of clverify

/var/hacmp/clverify/pass//* contains logs from the last passed verification
/var/hacmp/clverify/pass.prev//* contains log from the second last passed verification

HACMP CAN BE CONFIGURED IN 3 WAYS.

HACMP CAN BE CONFIGURED IN 3 WAYS.


1. Rotating

2. Cascading

3. Mutual Failover

The cascading and rotating resource groups are the “classic”, pre-HA 5.1 types. The new “custom” type

of resource group has been introduced in HA 5.1 onwards.

Cascading resource group:

Upon node failure, a cascading resource group falls over to the available node with the next priority in

the node priority list.

Upon node reintegration into the cluster, a cascading resource group falls back to its home node by

default.

Cascading without fallback

Thisoption, this means whenever a primary node fails, the package will failover to the next available

node in the list and when the primary node comes online then the package will not fallback

automatically. We need to move package to its home node at a convenient time.

Rotating resource group:

This is almost similar to Cascading without fallback, whenever package failover to the standby nodes it

will never fallback to the primary node automatically, we need to move it manually at our convenience.



Mutual takeover:

Mutual takeover option, which means both the nodes in this type are active-active mode. Whenever fail

over happens the package on the failed node will move to the other active node and will run with

already existing package. Once the failed node comes online we can move the package manually to that

node.

HACMP INFORMATION THROUGH COMMAND LINE

HACMP INFORMATION THROUGH COMMAND LINE
SET THE PATH FIRST TO RUN CLUSTER COMMANDS PEACEFULLY ( WITHOUT THINKING ABOUT THEIR PATHS)

# cd /usr/es/sbin/cluster

# export PATH=$PATH:$(pwd)

# cd utilities
# set -o vi
# export PATH=$PATH:$(pwd)
# cd ..
# cd sbin
# export PATH=$PATH:$(pwd)

# cd etc
# export PATH=$PATH:$(pwd)
#


INFO ABOUT VG

# cl_lsvg
cws: mksysvg
cws: sharevg
cws: shvg
pci: sharevg
pci: shvg
#
GETTING INFORMATION ABOUT RESOURCE GROUPS
SMALL INFO

# clRGinfo
-----------------------------------------------------------------------------
Group Name Type State Location
-----------------------------------------------------------------------------
ravirg non-concurrent OFFLINE pci
ONLINE cws

DETAILED INFO
# clshowres

Resource Group Name ravirg
Participating Node Name(s) pci cws
Startup Policy Online On Home Node Only
Fallover Policy Fallover To Next Priority Node In The List
Fallback Policy Fallback To Higher Priority Node In The List
Site Relationship ignore
Node Priority
Service IP Label pci_svc
Filesystems ALL
Filesystems Consistency Check fsck
Filesystems Recovery Method sequential
Filesystems/Directories to be exported
Filesystems to be NFS mounted
Network For NFS Mount
Volume Groups shvg sharevg
Concurrent Volume Groups
Use forced varyon for volume groups, if necessaryfalse
Disks
GMD Replicated Resources
PPRC Replicated Resources
ERCMF Replicated Resources
SVC PPRC Replicated Resources
AIX Connections Services
AIX Fast Connect Services
Shared Tape Resources
Application Servers
Highly Available Communication Links
Primary Workload Manager Class
Secondary Workload Manager Class
Delayed Fallback Timer
Miscellaneous Data
Automatically Import Volume Groups false
Inactive Takeover
SSA Disk Fencing false
Filesystems mounted before IP configured false


Run Time Parameters:

Node Name pci
Debug Level high
Format for hacmp.out Standard

Node Name cws
Debug Level high
Format for hacmp.out Standard
# clRGinfo
-----------------------------------------------------------------------------
Group Name Type State Location
-----------------------------------------------------------------------------
ravirg non-concurrent OFFLINE pci
ONLINE cws



GETTING INFORMATION ABOUT THE DISKS IN RESOURCE GROUP

# cllsdisk -g ravirg

000ac13302f48c19
000ac13311b97dc2
00fad1d4388d422c
#
GETTING INFORMATION ON THE FILE SYSTEMS IN RESOURCE GROUP

# cllsfs -g ravirg
/ravifs
/tstfs
#
GETTING INFORMATION ABOUT DISKS IN RESOURCE GROUP VG

# /usr/es/sbin/cluster/cspoc/cl_lsrgvgdisks
#Volume Group hdisk PVID Cluster Node
#---------------------------------------------------------------------
shvg hdisk3 000ac13302f48c19 cws ravirg
sharevg hdisk4 000ac13311b97dc2 cws ravirg
sharevg hdisk5 00fad1d4388d422c cws ravirg
#

COMPLETE CLUSTER INFORMATION

# /usr/es/sbin/cluster/utilities/cllscf
Cluster Name: ravicl
Cluster Connection Authentication Mode: Standard
Cluster Message Authentication Mode: None
Cluster Message Encryption: None
Use Persistent Labels for Communication: No
There were 1 networks defined: net_ether_01
There are 2 nodes in this cluster

NODE cws:
This node has 1 service IP label(s):

Service IP Label pci_svc:
IP address: 10.0.10.1
Hardware Address:
Network: net_ether_01
Attribute: public
Aliased Address?: Enable

Service IP Label pci_svc has 2 communication interfaces.
(Alternate Service) Communication Interface 1: cws_std
IP Address: 10.0.20.2
Network: net_ether_01
Attribute: public

Alias address for heartbeat:
(Alternate Service) Communication Interface 2: cws
IP Address: 10.0.0.2
Network: net_ether_01
Attribute: public

Alias address for heartbeat:
Service IP Label pci_svc has no communication interfaces for recovery.


NODE pci:
This node has 1 service IP label(s):

Service IP Label pci_svc:
IP address: 10.0.10.1
Hardware Address:
Network: net_ether_01
Attribute: public
Aliased Address?: Enable

Service IP Label pci_svc has 2 communication interfaces.
(Alternate Service) Communication Interface 1: pci_std
IP Address: 10.0.20.1
Network: net_ether_01
Attribute: public

Alias address for heartbeat:
(Alternate Service) Communication Interface 2: pci_std1
IP Address: 193.9.200.224
Network: net_ether_01
Attribute: public

Alias address for heartbeat:
Service IP Label pci_svc has no communication interfaces for recovery.




Breakdown of network connections:

Connections to network net_ether_01
Node cws is connected to network net_ether_01 by these interfaces:
cws_std
cws
pci_svc

Node pci is connected to network net_ether_01 by these interfaces:
pci_std
pci_std1
pci_svc

#
DETAIL INFORMATION ABOUT VG IN CLUSTER
# /usr/es/sbin/cluster/utilities/cllsvgdata
hdisk0:000ac133608d9e98:rootvg:10:0:active:0
hdisk1:000ac13382115287:rootvg:10:0:active:0
hdisk2:000ac13302f48c19:shvg:50:0:inactive:0
hdisk3:000ac13311b97dc2:sharevg:49:0:inactive:0
hdisk4:00fad1d4388d422c:sharevg:49:0:inactive:0
FREEMAJORS:45..48,51...

GETTING COMPLETE TOPOLOGY INFORMATION

# cltopinfo
Cluster Name: ravicl
Cluster Connection Authentication Mode: Standard
Cluster Message Authentication Mode: None
Cluster Message Encryption: None
Use Persistent Labels for Communication: No
There are 2 node(s) and 1 network(s) defined
NODE cws:
Network net_ether_01
pci_svc 10.0.10.1
cws_std 10.0.20.2
cws 10.0.0.2
NODE pci:
Network net_ether_01
pci_svc 10.0.10.1
pci_std 10.0.20.1
pci_std1 193.9.200.224

Resource Group ravirg
Startup Policy Online On Home Node Only
Fallover Policy Fallover To Next Priority Node In The List
Fallback Policy Fallback To Higher Priority Node In The List
Participating Nodes pci cws
Service IP Label pci_svc
#

HACMP QUICK REFERENCE AND INTERVIEW PREPERATION

HACMP QUICK REFERENCE AND INTERVIEW PREPERATION

DOCUMENT CREATED BY SANDEEP TANTI




TABLE OF CONTENTS

TABLE OF CONTENTS .................................................................................................................................... 1

HACMP BASICS ............................................................................................................................................. 2

USEFUL HACMP COMMANDS ....................................................................................................................... 3

STEPS TO CONFIGURE HACMP: ..................................................................................................................... 4

TESTING HACMP: HA FAILOVER SCENARIOS ............................................................................................... 11

HACMP V5.X DISK HEARTBEAT DEVICE CONFIGURATION .......................................................................... 13

Monitor Disk Heartbeat .............................................................................................................................. 22

HACMP LOG FILES ...................................................................................................................................... 23

C program-6

1. /* Write a C program to read a string and check whether it is *
* a palindrome or not (without using library functions). Output *
* the given string along with suitable message */

#include
#include

main()
{
char string[25], revString[25]={'\0'};
int i,length = 0, flag = 0;

clrscr();
fflush(stdin);

printf("Enter a string\n");
gets(string);

for (i=0; string[i] != '\0'; i++) /*keep going through each */
{ /*character of the string */
length++; /*till its end */
}
for (i=length-1; i >= 0 ; i--)
{
revString[length-i-1] = string[i];
}
/*Compare the input string and its reverse. If both are equal
then the input string is palindrome. Otherwise it is
not a palindrome */

for (i=0; i < length ; i++) { if (revString[i] == string[i]) flag = 1; else flag = 0; } if (flag == 1) printf ("%s is a palindrome\n", string); else printf("%s is not a palindrome\n", string); } /*End of main()*/ /*---------------------------------------------------- Output RUN 1 Enter a string madam madam is a palindrome RUN 2 Enter a string Madam Madam is not a palindrome RUN 3 Enter a string good good is not a palindrome ----------------------------------------------------------*/ ********************************************************************************* 2. /* Write a C program to read two strings and concatenate them * * (without using library functions). Output the concatenated * * string along with the given string */ #include
#include
main()
{
char string1[20], string2[20];
int i,j,pos;

strset(string1, '\0'); /*set all occurrences in two strings to NULL*/
strset(string2,'\0');

printf("Enter the first string :");
gets(string1);
fflush(stdin);
printf("Enter the second string:");
gets(string2);

printf("First string = %s\n", string1);
printf("Second string = %s\n", string2);

/*To concate the second stribg to the end of the string
travserse the first to its end and attach the second string*/
for (i=0; string1[i] != '\0'; i++)
{
; /*null statement: simply trvsering the string1*/
}

pos = i;
for (i=pos,j=0; string2[j]!='\0'; i++)
{
string1[i] = string2[j++];
}
string1[i]='\0'; /*set the last character of string1 to NULL*/

printf("Concatenated string = %s\n", string1);
}
/*---------------------------------------
Output
Enter the first string :CD-
Enter the second string:ROM
First string = CD-
Second string = ROM
Concatenated string = CD-ROM
----------------------------------------*/

*********************************************************************

3. /* Write a C program to read an English sentence and replace*
* lowercase characters by uppercase and vice-versa. Output *
* the given sentence as well as the case covrted sentence on*
* two different lines. */

#include
#include
#include

main()
{
char sentence[100];
int count, ch, i;
clrscr();
printf("Enter a sentence\n");
for(i=0; (sentence[i] = getchar())!='\n'; i++)
{
;
}
sentence[i]='\0';
count = i; /*shows the number of chars accepted in a sentence*/

printf("The given sentence is : %s",sentence);
printf("\nCase changed sentence is: ");
for(i=0; i < count; i++) { ch = islower(sentence[i]) ? toupper(sentence[i]) : tolower(sentence[i]); putchar(ch); } } /*End of main()*/ /*------------------------------ Output Enter a sentence Mera Bharat Mahan The given sentence is : Mera Bhaaat Mahan Case changed sentence is: mERA bHARAT mAHAN ------------------------------------------------*/ ****************************************************************** 4. /* Write a C program read a sentence and count the number of * * number of vowels and consonants in the given sentence. * * Output the results on two lines with suitable headings */ #include
main()
{
char sentence[80];
int i, vowels=0, consonants=0, special = 0;
clrscr();
printf("Enter a sentence\n");
gets(sentence);

for(i=0; sentence[i] != '\0'; i++)
{
if((sentence[i] == 'a'||sentence[i] == 'e'||sentence[i] == 'i'||
sentence[i] == 'o'||sentence[i] == 'u') ||(sentence[i] == 'A'||
sentence[i] == 'E'||sentence[i] == 'I'|| sentence[i] == 'O'||
sentence[i] == 'U'))
{
vowels = vowels + 1;
}
else
{
consonants = consonants + 1;
}
if (sentence[i] =='\t' ||sentence[i] =='\0' || sentence[i] ==' ')
{
special = special + 1;
}
}
consonants = consonants - special;
printf("No. of vowels in %s = %d\n", sentence, vowels);
printf("No. of consonants in %s = %d\n", sentence, consonants);
}
/*------------------------
Output
Enter a sentence
Good Morning
No. of vowels in Good Morning = 4
No. of consonants in Good Morning = 7
-----------------------------------------*/



***************************************************************************

5. /* Write a C program to read N names, store them in the form *
* of an array and sort them in alphabetical order. Output the*
* give names and the sorted names in two columns side by side*
* wih suitable heading */

#include
#include

main()
{
char name[10][8], Tname[10][8], temp[8];
int i, j, N;

clrscr();

printf("Enter the value of N\n");
scanf("%d", &N);

printf("Enter %d names\n", N);
for(i=0; i< N ; i++) { scanf("%s",name[i]); strcpy (Tname[i], name[i]); } for(i=0; i < N-1 ; i++) { for(j=i+1; j< N; j++) { if(strcmpi(name[i],name[j]) > 0)
{
strcpy(temp,name[i]);
strcpy(name[i],name[j]);
strcpy(name[j],temp);
}
}
}
printf("\n----------------------------------------\n");
printf("Input Names\tSorted names\n");
printf("----------------------------------------\n");
for(i=0; i< N ; i++)
{
printf("%s\t\t%s\n",Tname[i], name[i]);
}
printf("----------------------------------------\n");
} /* End of main() */
/*--------------------------------
Output
Enter the value of N
3
Enter 3 names
Monica
Laxmi
Anand

----------------------------------------
Input Names Sorted names
----------------------------------------
Monica Anand
Laxmi Laxmi
Anand Monica
----------------------------------------
---------------------------------------- */

C program-5

1. /* Write a C program to input real numbers and find the *
* mean, variance and standard deviation */

#include
#include
#define MAXSIZE 10
main()
{
float x[MAXSIZE];
int i, n;
float avrg, var, SD, sum=0, sum1=0;

clrscr();

printf("Enter the value of N\n");
scanf("%d", &n);

printf("Enter %d real numbers\n",n);
for(i=0; i
#define MAX 4

main()
{
int a[MAX], i, l1,l2, s, temp;
clrscr();

printf("Enter %d integer numbers\n", MAX);
for (i=0; i < MAX; i++) { scanf("%d", &a[i]); } printf("Input interger are\n"); for (i=0; i < MAX; i++) { printf("%5d", a[i]); } printf("\n"); l1 = a[0]; /*assume first element of array is the first largest*/ l2 = a[1]; /*assume first element of array is the second largest*/ if (l1 < l2) { temp = l1; l1 = l2; l2 = temp; } for (i=2;i<4;i++) { if (a[i] >= l1)
{
l2 = l1;
l1 = a[i];
}
else if(a[i] > l2)
{
l2= a[i];
}
}
printf("\n%d is the first largest\n", l1);
printf("%d is the second largest\n", l2);
printf("\nAverage of %d and %d = %d\n", l1,l2, (l1+l2)/2);
}
/*-----------------------------------
Output
RUN 1
Enter 4 integer numbers
45
33
21
10
Input interger are
45 33 21 10

45 is the first largest
33 is the second largest

Average of 45 and 33 = 39

RUN 2
Enter 4 integer numbers
12
90
54
67
Input interger are
12 90 54 67

90 is the first largest
67 is the second largest

Average of 90 and 67 = 78

RUN 3
Enter 4 integer numbers
100
200
300
400
Input interger are
100 200 300 400

400 is the first largest
300 is the second largest

Average of 400 and 300 = 350

------------------------------------*/

**************************************************************************


3. /* Write a C program to evaluate the given polynomial *
* P(x)=AnXn + An-1Xn-1 + An-2Xn-2+... +A1X + A0, by *
* reading its coefficents into an array. [Hint:Rewrite *
* the polynomial as *
* P(x) = a0 + x(a1+x(a2+x(a3+x(a4+x(...x(an-1+xan)))) *
* and evalate the function starting from the inner loop]*/
#include
#define MAXSIZE 10
main()
{
int a[MAXSIZE];
int i, N,power;
float x, polySum;

clrscr();
printf("Enter the order of the polynomial\n");
scanf("%d", &N);

printf("Enter the value of x\n");
scanf("%f", &x);
/*Read the coefficients into an array*/
printf("Enter %d coefficients\n",N+1);
for (i=0;i <= N;i++) { scanf("%d",&a[i]); } polySum = a[0]; for (i=1;i<= N;i++) { polySum = polySum * x + a[i]; } power = N; /*power--;*/ printf("Given polynomial is:\n"); for (i=0;i<= N;i++) { if (power < 0) { break; } /* printing proper polynomial function*/ if (a[i] > 0)
printf(" + ");
else if (a[i] < 0) printf(" - "); else printf (" "); printf("%dx^%d ",abs(a[i]),power--); } printf("\nSum of the polynomial = %6.2f\n",polySum); } /*------------------ Output RUN 1 Enter the order of the polynomial 2 Enter the value of x 2 Enter 3 coefficients 3 2 6 Given polynomial is: + 3x^2 + 2x^1 + 6x^0 Sum of the polynomial = 22.00 RUN 2 Enter the order of the polynomial 4 Enter the value of x 1 Enter 5 coefficients 3 -5 6 8 -9 Given polynomial is: + 3x^4 - 5x^3 + 6x^2 + 8x^1 - 9x^0 Sum of the polynomial = 3.00 --------------------*/ ********************************************************************* 4. /* Write a C program to read two matrices A (MxN) and B(MxN)* * and perform addition OR subtraction of A and B. Find the * * trace of the resultant matrix. Output the given matrix, * * their sum or Differences and the trace. */ #include

main()
{
int A[10][10], B[10][10], sumat[10][10], diffmat[10][10];
int i, j, M,N, option;
void trace (int arr[][10], int M, int N);
clrscr();
printf("Enter the order of the matrice A and B\n");
scanf("%d %d", &M, &N);

printf("Enter the elements of matrix A\n");
for(i=0; i

main()
{
int i,j,M,N;
int A[10][10], B[10][10];
int transpose(int A[][10], int r, int c); /*Function prototype*/
clrscr();

printf("Enter the order of matrix A\n");
scanf("%d %d", &M, &N);
printf("Enter the elements of matrix\n");
for(i=0;i {
for(j=0;j {
scanf("%d",&A[i][j]);
}
}
printf("Matrix A is\n");
for(i=0;i {
for(j=0;j {
printf("%3d",A[i][j]);
}
printf("\n");
}
/* Finding Transpose of matrix*/
for(i=0;i {
for(j=0;j {
B[i][j] = A[j][i];
}
}

printf("Its Transpose is\n");
for(i=0;i {
for(j=0;j {
printf("%3d",B[i][j]);
}
printf("\n");
}

} /*End of main()*/
/*---------------------------------------
Output
Enter the order of matrix A
3 3
Enter the elements of matrix
1
2
3
4
5
6
7
8
9
MatrixxA is
1 2 3
4 5 6
7 8 9
Its Transpose is
1 4 7
2 5 8
3 6 9
-----------------------------*/




C Program-4

1. /* Write a C program to find the sum of odd numbers and *
* sum of even numbers from 1 to N. Output the computed *
* sums on two different lines with suitable headings */

#include

main()
{
int i, N, oddSum = 0, evenSum = 0;
clrscr();

printf("Enter the value of N\n");
scanf ("%d", &N);

for (i=1; i <=N; i++) { if (i % 2 == 0) evenSum = evenSum + i; else oddSum = oddSum + i; } printf ("Sum of all odd numbers = %d\n", oddSum); printf ("Sum of all even numbers = %d\n", evenSum); } /*----------------------------- Output RUN1 Enter the value of N 10 Sum of all odd numbers = 25 Sum of all even numbers = 30 RUN2 Enter the value of N 50 Sum of all odd numbers = 625 Sum of all even numbers = 650 ------------------------------*/ ***************************************************************** 2. /* Write a C program to reverse a given integer number and check * * whether it is a palindrome. Output the given numbers with suitable* * message */ #include
main()
{
int num, rev = 0, found = 0, temp, digit;
clrscr();
printf("Enter an integer\n");
scanf("%d", &num);

temp = num;
while(num > 0)
{
digit = num % 10;
rev = rev * 10 + digit;
num /= 10;
}
printf("Given number is = %d\n", temp);
printf("Its reverse is = %d\n", rev);

if(temp == rev )
printf("Number is a palindrome\n");
else
printf("Number is not a palindrome\n");
}
/*------------------------
Output
RUN 1
Enter an integer
12321
Given number is = 12321
Its reverse is = 12321
Number is a palindrome

RUN 2
Enter an integer
3456
Given number is = 3456
Its reverse is = 6543
Number is not a palindrome
-----------------------------------*/

****************************************************************

3. /* Write a C program to find the value of sin(x) using the series *
* up to the given accuracy (without using user defined function) *
* Also print sin(x) using library function. */

#include
#include
#include

main()
{
float acc, term, den, x, sinx=0, sinval;
int i, n, x1;
clrscr();

printf("Enter the value of x (in degrees)\n");
scanf("%f",&x);
x1 = x;
/* Degrees to radians*/
x = x*(3.142/180.0);
sinval = sin(x);

printf("Enter the accuary for the result\n");
scanf("%f", &acc);
term = x;
sinx = term;
n = 1;

do
{
den = 2*n*(2*n+1);
term = -term * x * x / den;
sinx = sinx + term;
n = n + 1;
} while(acc <= fabs(sinval - sinx)); printf("Sum of the sine series = %f\n", sinx); printf("Using Library function sin(%d) = %f\n", x1,sin(x)); } /*End of main() */ /*------------------------------ Output Enter the value of x (in degrees) 30 Enter the accuary for the result 0.000001 Sum of the sine series = 0.500059 Using Library function sin(30) = 0.500059 RUN 2 Enter the value of x (in degrees) 45 Enter the accuary for the result 0.0001 Sum of the sine series = 0.707215 Using Library function sin(45) = 0.707179 ---------------------------------------------*/ ******************************************************************************** 4. /* Write a C program to find the value of cos(x) using the series * * up to the given accuracy (without using user defined function) * * Also print cos(x) using library function. */ #include
#include
#include

main()
{
float acc, term, den, x, cosx=0, cosval;
int i, n, x1;
clrscr();

printf("Enter the value of x (in degrees)\n");
scanf("%f",&x);
x1 = x;
/* Degrees to radians*/
x = x*(3.142/180.0);
cosval = cos(x);

printf("Enter the accuary for the result\n");
scanf("%f", &acc);
term = 1;
cosx = term;
n = 1;

do
{
den = 2*n*(2*n-1);
term = -term * x * x / den;
cosx = cosx + term;
n = n + 1;
} while(acc <= fabs(cosval - cosx)); printf("Sum of the cosine series = %f\n", cosx); printf("Using Library function cos(%d) = %f\n", x1,cos(x)); } /*End of main() */ /*------------------------------ Output Enter the value of x (in degrees) 30 Enter the accuary for the result 0.000001 Sum of the cosine series = 0.865991 Using Library function cos(30) = 0.865991 RUN 2 Enter the value of x (in degrees) 45 Enter the accuary for the result 0.0001 Sum of the cosine series = 0.707031 Using Library function cos(45) = 0.707035 ---------------------------------------------*/ **************************************************************************** 5. /* Write a C program to check whether a given number is prime or not * * and output the given number with suitable message */ #include
#include
main()
{
int num, j, flag;
clrscr();

printf("Enter a number\n");
scanf("%d", &num);
if ( num <= 1)
{
printf("%d is not a prime numbers\n", num);
exit(1);
}

flag = 0;
for ( j=2; j<= num/2; j++)
{
if( ( num % j ) == 0)
{
flag = 1;
break;
}
}
if(flag == 0)
printf("%d is a prime number\n",num);
else
printf("%d is not a prime number\n", num);
}
/*------------------------
Output
RUN 1
Enter a number
34
34 is not a prime number

RUN 2
Enter a number
29
29 is a prime number
-----------------------------*/