Monday, April 4, 2016

SHUTTING DOWN, SUSPENDING, AND HIBERNATING THE SYSTEM

source: - https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Power.html

8.4. SHUTTING DOWN, SUSPENDING, AND HIBERNATING THE SYSTEM

In Red Hat Enterprise Linux 7, the systemctl utility replaces a number of power management commands used in previous versions of the Red Hat Enterprise Linux system. The commands listed in Table 8.8, “Comparison of Power Management Commands with systemctl” are still available in the system for compatibility reasons, but it is advised that you use systemctl when possible.
Table 8.8. Comparison of Power Management Commands with systemctl
Old CommandNew CommandDescription
haltsystemctl haltHalts the system.
poweroffsystemctl poweroffPowers off the system.
rebootsystemctl rebootRestarts the system.
pm-suspendsystemctl suspendSuspends the system.
pm-hibernatesystemctl hibernateHibernates the system.
pm-suspend-hybridsystemctl hybrid-sleepHibernates and suspends the system.

8.4.1. Shutting Down the System

The systemctl utility provides commands for shutting down the system, however the traditional shutdown command is also supported. Although the shutdown command will call the systemctl utility to perform the shutdown, it has an advantage in that it also supports a time argument. This is particularly useful for scheduled maintenance and to allow more time for users to react to the warning that a system shutdown has been scheduled. The option to cancel the shutdown can also be an advantage.

⁠Using systemctl Commands

To shut down the system and power off the machine, type the following at a shell prompt as root:
systemctl poweroff
To shut down and halt the system without powering off the machine, run the following command as root:
systemctl halt
By default, running either of these commands causes systemd to send an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run the selected command with the --no-wall command line option, for example:
systemctl --no-wall poweroff

⁠Using the shutdown Command

To shut down the system and power off the machine at a certain time, use a command in the following format as root:
shutdown --poweroff hh:mm
Where hh:mm is the time in 24 hour clock format. The /run/nologin file is created 5 minutes before system shutdown to prevent new logins. When a time argument is used, an optional message, the wall message, can be appended to the command.
To shut down and halt the system after a delay, without powering off the machine, use a command in the following format as root:
shutdown --halt +m
Where +m is the delay time in minutes. The now keyword is an alias for +0.
A pending shutdown can be canceled by the root user as follows:
shutdown -c
See the shutdown(8) manual page for further command options.

8.4.2. Restarting the System

To restart the system, run the following command as root:
systemctl reboot
By default, this command causes systemd to send an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run this command with the --no-wall command line option:
systemctl --no-wall reboot

8.4.3. Suspending the System

To suspend the system, type the following at a shell prompt as root:
systemctl suspend
This command saves the system state in RAM and with the exception of the RAM module, powers off most of the devices in the machine. When you turn the machine back on, the system then restores its state from RAM without having to boot again. Because the system state is saved in RAM and not on the hard disk, restoring the system from suspend mode is significantly faster than restoring it from hibernation, but as a consequence, a suspended system state is also vulnerable to power outages.
For information on how to hibernate the system, see Section 8.4.4, “Hibernating the System”.

8.4.4. Hibernating the System

To hibernate the system, type the following at a shell prompt as root:
systemctl hibernate
This command saves the system state on the hard disk drive and powers off the machine. When you turn the machine back on, the system then restores its state from the saved data without having to boot again. Because the system state is saved on the hard disk and not in RAM, the machine does not have to maintain electrical power to the RAM module, but as a consequence, restoring the system from hibernation is significantly slower than restoring it from suspend mode.
To hibernate and suspend the system, run the following command as root:
systemctl hybrid-sleep

Solaris:- break LDOM to ok prompt or reboot

How to send break on LDOM to go to OK prompt or to reboot the hung system.

1. Login to your control domain and list your LDOMs
# ldm list

2. Login to hung ldom
# telnet localhost 5000

press enter and you may get hung state where cursor is just sitting no where.

Press CTRL + ]

you will be at telnet prompt.

at the prompt type ~? to get the help menu.

 ~^B -> Send break
 ~. -> exit from the console to control domain prompt
 ~w -> Force write access on console
 ~n -> console next
 ~p -> console previous
 ~? -> get help


2. To break, type send break at the telnet prompt. You will see following three options
c)ontinue, s)ync, r)eset?

s)ync option will generate core and takes a while to reboot the system
r)reset will reboo the system, if auto-boot set to true otherwise server will be at {ok} prompt.

Note: on t-series servers such as T3, T4, T5 servers, you can send break from SP.

Sunday, April 3, 2016

RHEL - yum history to roll back an update in Red Hat Enterprise Linux 6 , 7

How to use yum history to roll back an update in Red Hat Enterprise Linux 6 , 7?

 SOLUTION VERIFIED - Updated  - 

Environment

  • Red Hat Enterprise Linux 6 , 7
  • yum

Issue

  • How to roll back an update using yum in Red Hat Enterprise Linux-6, 7?
  • How to use yum history?
  • Information on best practice to enable easy backout of yum patching

Resolution

Note: Downgrading a system to minor version (ex: RHEL6.1 to RHEL6.0) is not recommended as this might leave the system in broken state where libgcc and other libraries won't rollback as expected. Use the history option for small update rollbacks.
Note: Rollback of selinux, selinux-policy-*, kernel, glibc (dependencies of glibc such as gcc) packages to older version is not supported.
If you decide to proceed with rollback, rather then reinstall, here are the instructions:
  • Red Hat Enterprise Linux 6 includes the yum history module which helps to rollback any updates done with the yum command. With this command, you can choose an update yum issued and remove those selected packages. The following is an example while installing the screen package:
[root@localhost ~]# yum install screen
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
rhel-6-server-rpms                                                                                                                             | 2.4 kB     00:00     
rhel-ha-for-rhel-6-server-rpms                                                                                                                 | 2.4 kB     00:00     
rhel-lb-for-rhel-6-server-rpms                                                                                                                 | 2.0 kB     00:00     
rhel-rs-for-rhel-6-server-rpms                                                                                                                 | 2.4 kB     00:00     
rhel-scalefs-for-rhel-6-server-rpms                                                                                                            |  951 B     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package screen.i686 0:4.0.3-16.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================================
 Package                            Arch                             Version                                     Repository                                      Size
======================================================================================================================================================================
Installing:
 screen                             i686                             4.0.3-16.el6                                rhel-6-server-rpms                             484 k

Transaction Summary
======================================================================================================================================================================
Install       1 Package(s)                                                                                                                                            

Total download size: 484 k                                                                                                                                            
Installed size: 484 k                                                                                                                                                 
Is this ok [y/N]: y                                                                                                                                                   
Downloading Packages:                                                                                                                                                 
screen-4.0.3-16.el6.i686.rpm                                                                                                                   | 484 kB     00:08     
Running rpm_check_debug                                                                                                                                               
Running Transaction Test                                                                                                                                              
Transaction Test Succeeded                                                                                                                                            
Running Transaction
  Installing : screen-4.0.3-16.el6.i686                                                                                                                           1/1 
rhel-6-server-rpms/productid                                                                                                                   | 1.7 kB     00:00     
rhel-ha-for-rhel-6-server-rpms/productid                                                                                                       | 1.7 kB     00:00     
rhel-lb-for-rhel-6-server-rpms/productid                                                                                                       | 1.7 kB     00:00     
rhel-rs-for-rhel-6-server-rpms/productid                                                                                                       | 1.7 kB     00:00     
duration: 319(ms)
Installed products updated.

Installed:
  screen.i686 0:4.0.3-16.el6                                                                                                                                          

Complete!
[root@localhost ~]# yum history
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     8 | root <root>              | 2011-10-03 14:40 | Install        |    1   
     7 | root <root>              | 2011-09-21 04:24 | Install        |    1 ##
     6 | root <root>              | 2011-09-21 04:23 | Install        |    1 ##
     5 | root <root>              | 2011-09-16 13:35 | Install        |    1   
     4 | root <root>              | 2011-09-16 13:33 | Erase          |    1   
     3 | root <root>              | 2011-09-14 14:36 | Install        |    1   
     2 | root <root>              | 2011-09-12 15:48 | I, U           |   80   
     1 | System <unset>           | 2011-09-12 14:57 | Install        | 1025  
[root@localhost ~]# yum history undo 8
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
rhel-6-server-rpms                                                                                                                             | 2.4 kB     00:00     
rhel-ha-for-rhel-6-server-rpms                                                                                                                 | 2.4 kB     00:00     
rhel-lb-for-rhel-6-server-rpms                                                                                                                 | 2.0 kB     00:00     
rhel-rs-for-rhel-6-server-rpms                                                                                                                 | 2.4 kB     00:00     
rhel-scalefs-for-rhel-6-server-rpms                                                                                                            |  951 B     00:00     
Undoing transaction 8, from Mon Oct  3 14:40:01 2011
    Install screen-4.0.3-16.el6.i686
Resolving Dependencies
--> Running transaction check
---> Package screen.i686 0:4.0.3-16.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================================
 Package                            Arch                             Version                                    Repository                                       Size
======================================================================================================================================================================
Removing:
 screen                             i686                             4.0.3-16.el6                               @rhel-6-server-rpms                             783 k

Transaction Summary
======================================================================================================================================================================
Remove        1 Package(s)

Installed size: 783 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : screen-4.0.3-16.el6.i686                                                                                                                           1/1 
duration: 320(ms)
Installed products updated.

Removed:
  screen.i686 0:4.0.3-16.el6                                                                                                                                          

Complete!

Source: https://access.redhat.com/solutions/64069

Thursday, March 31, 2016

Solaris10 - link aggregation



Prerequisite task:-
On Control domain, record the following information.

1. Get the virtual switch information.
# ldm list-services | more
VCC
VSW
    NAME             LDOM             MAC               NET-DEV   ID   DEVICE     LINKPROP   DEFAULT-VLAN-ID PVID VID                  MTU   MODE   INTER-VNET-LINK
    primary-vsw0     primary          00:14:4f:fa:33:81 aggr1     0    switch@0              1               1                         1500         on
    primary-vsw1     primary          00:14:4f:f8:c7:39 aggr2     1    switch@1              1               1                         1500         on


2. Get interface binding info for each domain.
# ldm list-bindings | more
VSW
    NAME             MAC               NET-DEV   ID   DEVICE     LINKPROP   DEFAULT-VLAN-ID PVID VID                  MTU   MODE   INTER-VNET-LINK
    primary-vsw0     00:14:4f:fa:33:81 aggr1     0    switch@0              1               1                         1500         on
        PEER                        MAC               PVID VID                  MTU   LINKPROP   INTERVNETLINK
        vnet1@mmerp-mw-v06           00:14:4f:fa:53:68 1                         1500
        vnet2@mmerp-mw-v07           00:14:4f:f9:cb:06 1                         1500
        vnet3@mmerp-mw-v08           00:14:4f:fb:36:ea 1                         1500
    NAME             MAC               NET-DEV   ID   DEVICE     LINKPROP   DEFAULT-VLAN-ID PVID VID                  MTU   MODE   INTER-VNET-LINK
    primary-vsw1     00:14:4f:f8:c7:39 aggr2     1    switch@1              1               1                         1500         on
        PEER                        MAC               PVID VID                  MTU   LINKPROP   INTERVNETLINK
        vnet1@mmerp-db-v06           00:14:4f:f9:57:32 1                         1500
        vnet2@mmerp-db-v07           00:14:4f:f9:f7:11 1                         1500
        vnet3@mmerp-db-v08           00:14:4f:f9:2a:74 1                         1500


3. Get the aggregation info.
# dladm  show-aggr
key: 1 (0x0001) policy: L4      address: 0:21:28:f1:de:29 (auto)
           device       address                 speed           duplex  link    state
           igb1         0:21:28:f1:de:29          1000  Mbps    full    up      attached
key: 2 (0x0002) policy: L4      address: 0:21:28:f1:de:2b (auto)
           device       address                 speed           duplex  link    state
           igb3         0:21:28:f1:de:2b          1000  Mbps    full    up      attached

Now, perform the following tasks.

1. Login to each server. luacticate newBE and init 0 the servers.
# luactivate newBE; init 0
2. Login to control domain and stop all LDOMs.
# ldm stop myldm
# ldm list - verify
3. Activate BE on control domain and reboot
# luactivate newBE; init 6
4. Once server comes up, verify patch level.
# uname -a
5. Get interface binding info for each LDOM.
# ldm list-services | grep -i vsw
# ldm list-bindings | more


VSW
    NAME             MAC               NET-DEV   ID   DEVICE     LINKPROP   DEFA
ULT-VLAN-ID PVID VID                  MTU   MODE   INTER-VNET-LINK
primary-vswaggr1  aggr1 switch@1
        vnet1@mmerp-db-v12
 vnet1@mmerp-mw-v11
 vnet1@pkds-mw-v13
 vnet1@pkds-mw-v12
 vnet1@trpn-mw-v08
 vnet1@depr-mw-v09
 vnet1@pkds-mw-v15
 vnet1@depr-mw-v08
 vnet1@mmerp-mw-v15


VSW
NAME             MAC               NET-DEV   ID   DEVICE      LINKPROP 
primary-vsw0     00:14:4f:fa:33:81 aggr1     0    switch@0              1
        vnet1@mmerp-mw-v06
        vnet2@mmerp-mw-v07
        vnet3@mmerp-mw-v08
primary-vsw1     00:14:4f:f8:c7:39 aggr2     1    switch@1              1
        vnet1@mmerp-db-v06
        vnet2@mmerp-db-v07
        vnet3@mmerp-db-v08

6. Remove existing VNETs from all LDOMs
# ldm remove-vnet vnet0 <myldom>
7. Remove the vsw info from LDOM configuration
# ldm remove-vsw primary-vsw0
# ldm remove-vsw primary-vsw1
# ldm remove-vswitch primary-vsw1
8. Remove all existing link aggregations
# dladm  show-aggr
# dladm show-link
aggr1           type: non-vlan  mtu: 1500       aggregation: key 1
aggr2           type: non-vlan  mtu: 1500       aggregation: key 2
Note the value after key on the output above.
# dladm delete-aggr 1
# dladm delete-aggr 2

9. Create new virtual switch using these two interfaces below.
igb1 -> primary-vsw0
igb2 -> primary-vsw1
# ldm add-vsw net-dev=igb1 inter-vnet-link=off linkprop=phys-state primary-vsw0 primary
# ldm add-vsw net-dev=igb2 inter-vnet-link=off linkprop=phys-state primary-vsw1 primary

Now, assign the vnet to the LDOM. To spread between LDOM, half of the LDOM will be on vsw0 and half on vsw1 as primary interface and secondary interface.


pkds-mw-v12  (vnet0:  primary-vsw0    vnet1: primary-vsw1)  --done
pkds-mw-v13  (vnet0:  primary-vsw0    vnet1: primary-vsw1)
pkds-mw-v15  (vnet0:  primary-vsw0    vnet1: primary-vsw1)
mmerp-mw-v15  (vnet0:  primary-vsw0    vnet1: primary-vsw1)
pkds-mw-v13      active     -t----  5003    8     32G       12%   12%  1m
pkds-mw-v15      active     -t----  5000    8     8G        12%   12%  25s
mmerp-mw-v15      active     -t----  5005    16    16G      6.3%  6.3%  14s
# ldm add-vnet linkprop=phys-state vnet0 primary-vsw0 pkds-mw-v13
# ldm add-vnet linkprop=phys-state vnet1 primary-vsw1 pkds-mw-v13
# ldm add-vnet linkprop=phys-state vnet0 primary-vsw0 pkds-mw-v15
# ldm add-vnet linkprop=phys-state vnet1 primary-vsw1 pkds-mw-v15
# ldm add-vnet linkprop=phys-state vnet0 primary-vsw0 mmerp-mw-v15
# ldm add-vnet linkprop=phys-state vnet1 primary-vsw1 mmerp-mw-v15


mmerp-mw-v11  (vnet0:  primary-vsw1    vnet1: primary-vsw0)  -- done  -- not working
trpn-mw-v08  (vnet0:  primary-vsw1    vnet1: primary-vsw0)  - worked
mmerp-db-v12  (vnet0:  primary-vsw1    vnet1: primary-vsw0)   -- card -reader., working ..
depr-mw-v08  (vnet0:  primary-vsw1    vnet1: primary-vsw0)
depr-mw-v09       (vnet0:  primary-vsw1    vnet1: primary-vsw0)
# ldm add-vnet linkprop=phys-state vnet0 primary-vsw1 mmerp-db-v12
# ldm add-vnet linkprop=phys-state vnet1 primary-vsw0 mmerp-db-v12
# ldm add-vnet linkprop=phys-state vnet0 primary-vsw1 depr-mw-v08
# ldm add-vnet linkprop=phys-state vnet1 primary-vsw0 depr-mw-v08
# ldm add-vnet linkprop=phys-state vnet0 primary-vsw1 depr-mw-v09
# ldm add-vnet linkprop=phys-state vnet1 primary-vsw0 depr-mw-v09
# ldm start mmerp-db-v12
LDom mmerp-db-v12 started

primary-vsw0
 vnet1@mmerp-mw-v06
        vnet2@mmerp-mw-v07
        vnet3@mmerp-mw-v08
# ldm add-vnet linkprop=phys-state vnet0 primary-vsw0 <ldm>
# ldm add-vnet linkprop=phys-state vnet1 primary-vsw1 <ldm>

primary-vsw1
        vnet1@mmerp-db-v06
        vnet2@mmerp-db-v07
        vnet3@mmerp-db-v08
# ldm add-vnet linkprop=phys-state vnet0 primary-vsw1 <ldm>
# ldm add-vnet linkprop=phys-state vnet1 primary-vsw0 <ldm>

10. Once interface is assigned to the LDOM, reboot your LDOM
# ldm start <LDOM>
# telnet 0 <port>
{ok} boot -s
11. On single user mode, modify the interface info
# vi /etc/hostname.interface0
hostname  netmask + broadcast + group ipmp up
# vi /etc/hostname.interface1
group ipmp up
12. Boot your system.
# press CTRL + D or init 6

13. Once server comes up, verify the patch level
# uname -a
14. Verify the multipathing info
# if_mpadm -d interface
# ifconfig -r interface
-d -> Detach or off-line the interface
-r -> Reattach



mmerp-db-v06     netmask + broadcast + group ipmp up
group ipmp up

Thursday, March 24, 2016

RHEL - playing with files and dir

[jay@sama test]$ echo today is `date +%w`
today is 5
[jay@sama test]$ echo today is `date +%A`
today is Friday
[jay@sama test]$ touch {file1 file2, file3,file4}.log
[jay@sama test]$ ls -ltr
total 16
-rw-r--r--. 1 jay testing 15751 Mar 11 17:38 myetc.txt
-rw-r--r--. 1 jay testing     0 Mar 11 17:54 {file1
-rw-r--r--. 1 jay testing     0 Mar 11 17:54 file3,file4}.log
-rw-r--r--. 1 jay testing     0 Mar 11 17:54 file2,
[jay@sama test]$ echo {file1 file2, file3,file4}.log
{file1 file2, file3,file4}.log
[jay@sama test]$ echo {file1_file2,file3,file4}.log
file1_file2.log file3.log file4.log
[jay@sama test]$ rm {file1 file2, file3,file4}.log
[jay@sama test]$ ls -ltr
total 16
-rw-r--r--. 1 jay testing 15751 Mar 11 17:38 myetc.txt
[jay@sama test]$ touch {file1_file2,file3,file4}.log
[jay@sama test]$ ls -ltr
total 16
-rw-r--r--. 1 jay testing 15751 Mar 11 17:38 myetc.txt
-rw-r--r--. 1 jay testing     0 Mar 11 17:56 file4.log
-rw-r--r--. 1 jay testing     0 Mar 11 17:56 file3.log
-rw-r--r--. 1 jay testing     0 Mar 11 17:56 file1_file2.log
[jay@sama test]$ rm {file1_file2,file3,file4}.log
[jay@sama test]$ ls -ltr
total 16
-rw-r--r--. 1 jay testing 15751 Mar 11 17:38 myetc.txt
[jay@sama test]$ echo file{1..3}.log
file1.log file2.log file3.log
[jay@sama test]$ echo file{1..5}.log
file1.log file2.log file3.log file4.log file5.log
[jay@sama test]$ echo file{a..g)(1..6)
-bash: syntax error near unexpected token `)'
[jay@sama test]$ echo file{a..g}{1..6}
filea1 filea2 filea3 filea4 filea5 filea6 fileb1 fileb2 fileb3 fileb4 fileb5 fileb6 filec1 filec2 filec3 filec4 filec5 filec6 filed1 filed2 filed3 filed4 filed5 filed6 filee1 filee2 filee3 filee4 filee5 filee6 filef1 filef2 filef3 filef4 filef5 filef6 fileg1 fileg2 fileg3 fileg4 fileg5 fileg6
[jay@sama test]$

[jay@sama test]$ echo file{a,b}{1,2}.txt
filea1.txt filea2.txt fileb1.txt fileb2.txt
[jay@sama test]$



[jay@sama test]$ echo file{a,b}{1,2}.txt
filea1.txt filea2.txt fileb1.txt fileb2.txt

[jay@sama test]$  echo file{x{1,3},y,z}.txt
filex1.txt filex3.txt filey.txt filez.txt
[jay@sama test]$

Saturday, March 5, 2016

SYSTEMD

$ man systemctl
$ systemctl --help
$ systemctl --help | grep -i <KEYWORD>

RHEL:- nfs direct and indirect mapping - autofs

PreReq:- Make sure to install nfs server/client on your system.

on server export the share

# cat /etc/exports
/share *(rw,fsid=0,insecure,no_root_squash,sync,no_subtree_check)

Restart nfs service
# systemctl start nfs-server.service

on client

using direct map

# cat /etc/auto.master
/- /etc/auto.direct

# cat /etc/auto.direct
/opt/share -fstype=nfs nfsserver:/share

Note: You define absolute path in direct map

using indirect map

# cat /etc/auto.master
/opt /etc/auto.local

# cat /etc/auto.local
share  -fstype=nfs nfsserver:/share

Note: you define relative path on in-direct map