In this article, I will change hostname in RAC (both the nodes in my RAC environment). But you can follow these steps and apply the same in the standalone database to change hostname in Linux. Currently, hostname for the both nodes is localhost.
Please find the below details that I will set to change hostname in rac for both nodes. If you are doing this in the standalone database then ignore the below table.
NODE1 | NODE2 | |
Public IP | 192.168.56.11 | 192.168.56.12 |
Private IP | 192.168.10.1 | 192.168.10.2 |
VIP | 192.168.56.21 | 192.168.56.22 |
SCAN | 192.168.56.50 | 192.168.56.50 |
Now we have to update below four files below in both nodes with the VI editor to change hostname in Linux system:
1)/etc/hosts 2)/etc/sysconfig/network 3)/etc/sysctl.conf 4)/etc/hostname
Table of Contents
1.Update the below details in the /etc/hosts file of both nodes. This file is used to resolve domain names locally before querying DNS.
NODE1 AND NODE2: cat /etc/hosts #PUBLIC IP 192.168.56.11 node1 192.168.56.12 node2 #PRIVATE IP 192.168.10.1 nodep1 192.168.10.2 nodep2 #VIRTUAL IP 192.168.56.21 nodevip1 192.168.56.22 nodevip2 #SCAN 192.168.56.55 cluster12-scan
2. Update the /etc/sysconfig/network file with the hostname. This file is used for proper system identification and network functionality.
NODE1: [root@localhost ~]# cat /etc/sysconfig/network # Created by anaconda # oracle-database-preinstall-19c : Add NOZEROCONF=yes NOZEROCONF=yes hostname=node1 NODE2: [root@localhost ~]# cat /etc/sysconfig/network # Created by anaconda # oracle-database-preinstall-19c : Add NOZEROCONF=yes NOZEROCONF=yes hostname=node2
3. Update the file /etc/sysctl.conf with kernel hostname. This file is used to set the hostname of the system at the kernel level.
NODE1: [root@localhost ~]# cat /etc/sysctl.conf # sysctl settings are defined through files in # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/. # Vendors settings live in /usr/lib/sysctl.d/. # To override a whole file, create a new file with the same in # /etc/sysctl.d/ and put new settings there. To override # only specific settings, add a file with a lexically later # name in /etc/sysctl.d/ and put new settings there. # For more information, see sysctl.conf(5) and sysctl.d(5). kernel.hostname=node1 NODE2: [root@localhost ~]# cat /etc/sysctl.conf # sysctl settings are defined through files in # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/. # Vendors settings live in /usr/lib/sysctl.d/. # To override a whole file, create a new file with the same in # /etc/sysctl.d/ and put new settings there. To override # only specific settings, add a file with a lexically later # name in /etc/sysctl.d/ and put new settings there. # For more information, see sysctl.conf(5) and sysctl.d(5). kernel.hostname=node2
4. Update /etc/hostname file. This file is used to persistently set the hostname across reboots.
NODE1: [root@localhost ~]# cat /etc/hostname node1 NODE2: [root@localhost ~]# cat /etc/hostname node2
5. Open a new terminal window to reflect the changes and login to node1 and node2. Once logged in ping the public and private IP addresses to check if it is reachable.
NODE1:
[root@node1 ~]# ping -c 3 node2 PING node2 (192.168.56.12) 56(84) bytes of data. 64 bytes from node2 (192.168.56.12): icmp_seq=1 ttl=64 time=0.778 ms 64 bytes from node2 (192.168.56.12): icmp_seq=2 ttl=64 time=0.698 ms 64 bytes from node2 (192.168.56.12): icmp_seq=3 ttl=64 time=0.932 ms --- node2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 0.698/0.802/0.932/0.102 ms [root@node1 ~]# ping -c 3 nodep2 PING nodep2 (192.168.10.2) 56(84) bytes of data. 64 bytes from nodep2 (192.168.10.2): icmp_seq=1 ttl=64 time=1.61 ms 64 bytes from nodep2 (192.168.10.2): icmp_seq=2 ttl=64 time=0.875 ms 64 bytes from nodep2 (192.168.10.2): icmp_seq=3 ttl=64 time=0.838 ms --- nodep2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 0.838/1.109/1.616/0.360 ms
NODE2:
[root@node2 ~]# ping -c 3 node1 PING node1 (192.168.56.11) 56(84) bytes of data. 64 bytes from node1 (192.168.56.11): icmp_seq=1 ttl=64 time=1.11 ms 64 bytes from node1 (192.168.56.11): icmp_seq=2 ttl=64 time=1.09 ms 64 bytes from node1 (192.168.56.11): icmp_seq=3 ttl=64 time=0.675 ms --- node1 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2004ms rtt min/avg/max/mdev = 0.675/0.961/1.112/0.204 ms [root@node2 ~]# ping -c 3 nodep1 PING nodep1 (192.168.10.1) 56(84) bytes of data. 64 bytes from nodep1 (192.168.10.1): icmp_seq=1 ttl=64 time=1.43 ms 64 bytes from nodep1 (192.168.10.1): icmp_seq=2 ttl=64 time=0.737 ms 64 bytes from nodep1 (192.168.10.1): icmp_seq=3 ttl=64 time=1.10 ms --- nodep1 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2005ms rtt min/avg/max/mdev = 0.737/1.090/1.433/0.284 ms
Hope this article helped you to change hostname in RAC as well as change hostname in linux system. If you want to know the network configuration for Oracle RAC in VirtualBox then you can follow my other article RAC node1 network configuration and RAC node2 network configuration.
Pingback: How to delete files older than 7 days in Linux :