Wednesday, August 13, 2008

How to change date and time on Linux using hand and NTP

I will write about two methods to change the time in Linux.
1. By hand. This setting may be be accurate as lots of clocks tend to drift over time.
2. Using NTP (Network Time Protocol). With this settings, you can get accurate time from a network time server.

1.By hand.
In order to see the current time and date settings issue,
[root@racnode-2 ~]# date
Thu Aug 14 17:49:04 BDT 2008
So current time is month 8 day 17, year 2008, time 17:49:04.

Now to change only time to 11:51.30 issue,
[root@racnode-2 ~]# date 08141151.30
Thu Aug 14 11:51:30 BDT 2008
Now issue date,
[root@racnode-2 ~]# date
Thu Aug 14 11:51:32 BDT 2008

Note that setting date in this way will not cause the date to remain after a reboot. The date command sets the Linux system clock which is separate from the hardware clock.
We can check linux hardware clock by,
[root@racnode-2 ~]# hwclock
Thu 14 Aug 2008 05:57:01 PM BDT -0.788181 seconds

To make date setting persistent update the hardware clock with the date from the Linux system clock.
[root@racnode-2 ~]# /sbin/hwclock --systohc
If you are using universal time then use,
hwclock --utc --systohc

An alternative way is if you want to set the hardware(BIOS) clock so the system will keep the time when it reboots using,

clock -w
or
setclock
after changing date and time by date command.

To set date and time we can also use,
# date -s "2 OCT 2008 8:00:00"

If you wanted to change the year as well, for example to change year to 2007 of 30th April time 11:16pm you could type
#date 043023162007

To change only the time to 10:10 am you also can use,
#date -s 10:10

2.Using NTP (Network Time Protocol).
This is simple process. Just adding the time server to /etc/ntp.conf and to /etc/ntp/step-tickers Here I use time server as 192.168.1.91.
#vi /etc/ntp.conf
server 192.168.1.91
#vi /etc/ntp/step-tickers
192.168.1.91
Then of course make sure that ntp will start at boot time by,
chkconfig --level 2345 ntpd on
chkconfig --list ntpd


And let's start the service now by,
service ntpd start

It will display output as
ntpd: Synchronizing with time server: [ OK ]
Starting ntpd: [ OK ]
Related Documents
http://arjudba.blogspot.com/2008/08/how-to-change-hostname-in-linux.html

Configure Network for oracle RAC installation

1)Determine public node names, private node names, and virtual node names for each node in the cluster.
For the public node name, use the primary host name of each node.
In my environment my one node name is racnode-1 and another node name is racnode-2. So I determine the public, private and virtual node name for node racnode-1 as racnode-1, racnode-1-priv and racnode-1-vip accordingly.

Similarly on racnode-2 as racnode-2, racnode-2-priv and racnode-2-vip accordingly.

2)Identify the interface names and associated IP addresses.

On racnode-1,
#/sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:76:B0:46:7D
inet addr:192.168.1.91 Bcast:192.168.15.255 Mask:255.255.240.0
inet6 addr: fe80::216:76ff:feb0:467d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:96114 errors:0 dropped:0 overruns:0 frame:0
TX packets:1769 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7704446 (7.3 MiB) TX bytes:215309 (210.2 KiB)

eth1 Link encap:Ethernet HWaddr 00:11:3B:0A:42:DC
inet addr:192.168.150.30 Bcast:192.168.150.255 Mask:255.255.255.0
inet6 addr: fe80::211:3bff:fe0a:42dc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:27116 errors:0 dropped:0 overruns:0 frame:0
TX packets:48666 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7171014 (6.8 MiB) TX bytes:4353054 (4.1 MiB)
Interrupt:58 Base address:0xa000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1201 errors:0 dropped:0 overruns:0 frame:0
TX packets:1201 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3069384 (2.9 MiB) TX bytes:3069384 (2.9 MiB)

On racnode-2,

[root@racnode-2 ~]# /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:76:B2:EB:27
inet addr:192.168.1.92 Bcast:192.168.15.255 Mask:255.255.240.0
inet6 addr: fe80::216:76ff:feb2:eb27/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:104567 errors:0 dropped:0 overruns:0 frame:0
TX packets:1424 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8546472 (8.1 MiB) TX bytes:197747 (193.1 KiB)
Interrupt:169 Base address:0x6200

eth1 Link encap:Ethernet HWaddr 00:11:95:1F:02:09
inet addr:192.168.150.20 Bcast:192.168.150.255 Mask:255.255.255.0
inet6 addr: fe80::211:95ff:fe1f:209/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:27495 errors:0 dropped:0 overruns:0 frame:0
TX packets:50130 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6697016 (6.3 MiB) TX bytes:4488642 (4.2 MiB)
Interrupt:177 Base address:0x8100

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1203 errors:0 dropped:0 overruns:0 frame:0
TX packets:1203 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2857788 (2.7 MiB) TX bytes:2857788 (2.7 MiB)

Here I will use network interface eth0 for the public network and eth1 is for the private network. So, on racnode-1 IP address on public network will be 192.168.1.91 and IP address on private network will be 192.168.150.30. Similarly on racnode-2 IP address on public network will be 192.168.1.92 and IP address on private network is 192.168.150.20

3)On each node in the cluster, determine a third IP address that will serve as a virtual IP address which must not use currently in the network and its subnet must be same as on public network. I determine virtual IP address for racnode-1 as 192.168.1.95 and on racnode-2 as 192.168.1.96

4)After completing the network configuration, the IP address and network interface configuration should be as follows,
Node(Hostname) Node Name Type IP Address
racnode-1 racnode-1 public 192.168.1.91
racnode-1 racnode-1-vip virtual 192.168.1.95
racnode-1 racnode-1-priv private 192.168.150.30
racnode-2 racnode-2 public 192.168.1.92
racnode-2 racnode-2-vip virtual 192.168.1.96
racnode-2 racnode-2-priv private 192.168.150.20


5)In all nodes modify /etc/hosts file so that they contain the host IP addresses, virtual IP addresses, and private network IP addresses from both nodes in the cluster, as follows,
[root@racnode-2 ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.1.91 racnode-1
192.168.1.95 racnode-1-vip
192.168.150.30 racnode-1-priv

192.168.1.92 racnode-2
192.168.1.96 racnode-2-vip
192.168.150.20 racnode-2-priv


6)Verify the network configuration by using the ping command to test the connection.
ping -c 3 racnode-2
ping -c 3 racnode-2-vip
ping -c 3 racnode-2-priv

ping -c 3 racnode-1
ping -c 3 racnode-1-vip
ping -c 3 racnode-1-priv


Note that in this stage ping to the virtual ip address will fail until after Oracle Clusterware is installed and running. But ping to your private and public network address should work.

How to change the hostname in Linux

There are several ways by which we can change the hostname in linux. The process may vary based on distribution of linux.

To see your system current host name use,
# hostname
# cat /bin/hostname


On debian system you can use,
# uname -n
To see the fully qualified domain name if you have use,
#hostname –fqd

Temporary Change hostname
To change the hostname temporary issue,
#hostname new_name which will change your current hostname to the new_name. You will most probably need to exit the current shell in order to see the change in your shell prompt. However changes in this way is not persistent because if the system reboot it will show the hostname values from a particular field.

Permanently change hostname of Debian Linux
To change the hostname of debian linux distribution edit the file /etc/hostname as debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh

So, to change it in debian issue,
#vi /etc/hostname
and put a new entry there.

After changing to make it active run the script /etc/init.d/hostname.sh
# /etc/init.d/hostname.sh

Use sysctl to change the hostname both in RHL and debian
This process can be used both debian and red hat linux distribution. In this process use sysctl to change the variable kernel.hostname.

To read the current hostname issue,
#sysctl kernel.hostname

To change the current hostname to new_name issue,

#sysctl kernel.hostname=new_name

Change the hostname permanently in RHL Linux
This system is avilable for RHL distribution. Not apply for debian distribution. In this system change the network configuration file /etc/sysconfig/network in RHL.
Edit the /etc/sysconfig/network and change the hostname parameter to the new_name.
#vi /etc/sysconfig/network
HOSTNAME=new-host-name

Restart the network which relied on the hostname. You can perform reboot here.
# service network restart
Or,
#/etc/sysconfig/network-scripts/ifcfg-eth0

You may need to restart your console.
#init 3
#init 5


Related Documents
Vi Command in Unix.
Terminate Process on UNIX
umask and permission in unix.
How to change/configure IP Address on Linux/ Fedora /Ubuntu
Copy files between Unix and Windows with rcp
Screen -A very useful unix tool to work with remote system
Different ways to take Screenshot on Linux
Memory Usage of Solaris Operating System

Pre-Installation RAC environement setup check with CVU

Checking the Network Setup with CVU
To verify node connectivity among all nodes in your cluster use following syntax as an oracle user,
/mount_point/crs/Disk1/cluvfy/runcluvfy.sh comp nodecon -n node_list [-verbose]

If you have two nodes node1 and node2 and your mountpoint is /dev/cdrom then enter following command.
/dev/cdrom/crs/Disk1/cluvfy/runcluvfy.sh comp nodecon -n node1,node2 -verbose

Checking the Hardware and Operating System Setup with CV
As an oracle user use the following command syntax to start Cluster Verification Utility (CVU) stage verification to check hardware and OS setup:

/mountpoint/crs/Disk1/cluvfy/runcluvfy.sh stage –post hwos –n node_list [-verbose]
If you have two nodes node1 and node2 and your mountpoint is /dev/cdrom then enter following command,
/dev/cdrom/crs/Disk1/cluvfy/runcluvfy.sh stage –post hwos –n node1,node2

Checking the Operating System Requirements Setup with CVU
To check if your system meets the operating system requirement pre-installation tasks use the following syntax,
/mountpoint/crs/Disk1/cluvfy/runcluvfy.sh comp sys -n node_list -p {crs|database}
-osdba osdba_group -orainv orainv_group -verbose


If you have two nodes node1 and node2 and your mountpoint is /dev/cdrom with the OSDBA dba and Oracle inventory group oinstall then enter following command,
/dev/cdrom/crs/Disk1/cluvfy/runcluvfy.sh comp sys -n node1,node2 -p crs -osdba crs -orainv oinstall

How to Avoid mozilla firefox to hang to load webpage

In my system mozilla firefox browser often hangs initially while loaded serveral tabbed web page. In fact on my debian version linux the program is iceweasol. If the tabbed browser load is higher or if there is many tabbed webpage then while initially loading the webpage mozilla get stuck and I can't work with it. Though I kill by using kill -9 everytime and try to load again it hangs. It is really cumbersome work.

The extra work if you run program as root and the later pid of process is not 1 then while killing process as root at exists as root user and goes as normal user. So again I have to logon as root and have to run firefox. But if later process id is 1 then it remains as a root user.

Like,
debian:/home/Arju# kill -9 4502 4495
Arju@debian:~$ ----It switches to normal user

debian:/home/Arju# kill -9 4447 1
debian:/home/Arju# -----As later process id is 1 so does not exit root user.

In order to avoid the problem while loading your mozilla firefox browser with multiple tabbed page just click some tabs and select the stop button. Now firefox will load the other page. And after loading successfully other pages you can reload pages that you stopped.

Related Documents
Terminate Process on UNIX

How to configure(modify,see) Kernel Parameters in Linux

Kernel Parameters, Recommended Values to install Oracle and Associated Files
1)semmsl semmns semopm semmni: Corresponding recommended values to install oracle are 250 32000 100 128 or over and associated the default settings of these kernel parameter are in file /proc/sys/kernel/sem

2)shmmax:
Recommended value to install oracle is the half the size of physical memory (in bytes) or over. The default setting of this kernel parameter is in /proc/sys/kernel/shmmax

3)shmmni:
Recommended value to install oracle is 4096 or over. The default setting of this kernel parameter is in /proc/sys/kernel/shmmni

4)shmall: Recommended value to install oracle is 2097152 or over. The default setting of this kernel parameter is in /proc/sys/kernel/shmall

5)ip_local_port_range: Recommended value to install oracle is Minimum: 1024 and Maximum: 65000 or over. The default setting of this kernel parameter is in /proc/sys/net/ipv4/ip_local_port_range

6)rmem_default: Recommended value to install oracle is 1048576 or over. The default setting of this kernel parameter is in /proc/sys/net/core/rmem_default

7)rmem_max:
Recommended value to install oracle is 1048576 or over. The default setting of this kernel parameter is in /proc/sys/net/core/rmem_max

8)wmem_default: Recommended value to install oracle is 262144 or over. The default setting of this kernel parameter is in /proc/sys/net/core/wmem_default

9)wmem_max: Recommended value to install oracle is 262144 or over. The default setting of this kernel parameter is in /proc/sys/net/core/wmem_max

How to see the current value of the kernel parameters

1)semmsl, semmns, semopm, and semmni: # /sbin/sysctl -a | grep sem

2)shmall, shmmax, and shmmni: # /sbin/sysctl -a | grep shm

3)ip_local_port_range: # /sbin/sysctl -a | grep ip_local_port_range

4)rmem_default, rmem_max, wmem_default, and wmem_max: # /sbin/sysctl -a | grep net.core


How to modify the Kernel Parameter in Linux
1)Modifying /etc/sysctl.conf startup file.
With any text editor you can edit /etc/sysctl.conf file and then either put of change the entry like,
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=262144
net.core.wmem_max=262144


Or to change a certain parameter like kernel.shmmax you can insert it in the /etc/sysctl.conf like,
# echo "kernel.shmmax=2147483632" >> /etc/sysctl.conf

Note that settings in /etc/sysctl.conf is persistent but not immediate affect. That is whenever your system will restart then it will in effect. In order the affect the setting of the value immediately use,
/sbin/sysctl -p -On Red Hat Linux system.

On SUSE linux to set persistently use
# /sbin/chkconfig boot.sysctl on

2)Modifying /proc file system.
If you wanted to dynamically alter the value of SHMMAX without rebooting the machine, you can make this change directly to the /proc file system. This command can be made permanent by putting it into the /etc/rc.local startup file:
Like,
debian:/home/Arju# echo "6553" > /proc/sys/fs/file-max

3) Using sysctl command


With sysctl command you can also change the value of SHMMAX:

# sysctl -w kernel.shmmax=2147483228

Configure server to install Oracle RAC

Configuring Operating System Users and Groups in All Nodes
On windows you don't need to create separate user to install oracle or don't need to create groups. OUI automatically do it. However on unix you must create the following operating system groups are required if you are installing Oracle RAC for the first time.

•The OSDBA group (typically, dba) -This is the OS user who has SYSDBA privilege.

•The Oracle Inventory group (typically, oinstall) -This group owns all Oracle software installed on the system.

The following operating system users are required

•A user that owns the Oracle software (typically, oracle).

•An unprivileged user (for example, the nobody user on Linux systems).

Create the required groups and users
Do this steps on all nodes of your cluster.
As a root user,

/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
useradd -u 200 -g oinstall -G dba -d /home/oracle -r oracle

Change the password by,
passwd oracle

Verify the user by,
id oracle

Note that in this example in stead of using node1 use your original node name and instead of using node2 use your original node name.

Configuring SSH on All Cluster Nodes
When installing Oracle RAC on UNIX and Linux platforms, the software is installed on one node, and OUI uses secure communication to copy the software binary files to the other cluster nodes. OUI uses the Secure Shell (SSH) for the communication.

So you must have configured SSH on all nodes.

•To configure SSH, you must first create Rivest-Shamir-Adleman (RSA) keys and Digital Signature Algorithm (DSA) keys on each cluster node. After you have created the private and public keys, you copy the keys from all cluster node members into an authorized keys file that is identical on each node.

Generating RSA and DSA Keys
1)Log on as oracle user.

2)See whether .ssh directory exist or not. If does not exist then create one.
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh


3)Create the RSA-type public and private encryption keys by,
/usr/bin/ssh-keygen -t rsa
This command creates the public key in the /home/oracle/.ssh/id_rsa.pub file and the private key in the /home/oracle/.ssh/id_rsa file.

4)Create the DSA type public and private keys.
/usr/bin/ssh-keygen -t dsa
This command creates the public key in the /home/oracle/.ssh/id_dsa.pub file and the private key in the /home/oracle/.ssh/id_dsa file.

5)Repeat step 1 through 4 in all the nodes.

Adding the Keys to an Authorized Key File
1)Go to .ssh directory
$ cd ~/.ssh

2)Add the RSA and DSA keys to the authorized_keys files.
$ cat id_rsa.pub >>authorized_keys
$ cat id_dsa.pub >>authorized_keys


3)Using SCP copy the authorized_keys file to the oracle user .ssh directory on a remote node.
scp authorized_keys node2:/home/oracle/.ssh/

4)Using SSH, log in to the node where you copied the authorized_keys file, using the passphrase you created. Then change to the .ssh directory, and using the cat command, add the RSA and DSA keys for the second node to authorized_keys file.
ssh node2
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
cd ~/.ssh
cat id_rsa.pub >> authorized_keys
cat id_dsa.pub >> authorized_keys


5)If you have more than 2 nodes in your cluster, repeat step 3 and step 4 for each node you intend to add to your cluster. Copy the most recently updated authorized_keys file to the next node, then add the public keys for that node to the authorized_keys file.

6)After updating the authorized_keys file on all nodes, use SCP to copy the complete authorized_keys file from the last node to be updated to all the other cluster nodes, overwriting the existing version on the other nodes. For example,
scp authorized_keys node1:/home/oracle/.ssh/

Configure SSH User Equivalency on Cluster Member Nodes
1)Log on as a oracle user.

2)Start the SSH agent and load the SSH keys into memory.
$ exec /usr/bin/ssh-agent $SHELL
$ /usr/bin/ssh-add


3)Complete the SSH configuration by using the ssh command to retrieve the date on each node in the cluster.
$ ssh node1 date
$ ssh node2 date


Related Documents