Friday, March 23, 2018

ORA-10631: SHRINK clause should not be specified for this object

Trying to shrink space on a table and getting the error message

ORA-10631: SHRINK clause should not be specified for this object

Issue: The table has got a functional based index.

Solution:

Get the DDL for the index.
Remove the index 
Perform the shrink operation
re-create the index

Under standing /etc/resolv.conf

When your request from local machine has to go out and you need to find the IP address or domain name of a remote computer then you need some help from DNS.

In order to reach out to your preferred DNS Server one need to setup /etc/resolv.conf properly.

At minimum you can have at least values for two variables

search
nameserver


search: Is the list of the domains which the location machine can search to get the answer.
nameserver: Is the IP address of the DNS Server in those domain. There can be maximum of 3 nameservers and it is setup in (/usr/include/resolv.h)  with value
# define MAXNS                  3       /* max # name servers we'll track */

Let's test it. My setting is

My computer is on a domain and then on my computer I have virtualbox network setup of machines

My Domain:                   appowl247.com
My Virtualbox Domain: example.com
DNS on exmaple.com:   192.168.2.150
Two DNS on appowl274.com : xxx.xxx.x.xxx and yyy.yyy.yy.yy

Setting on my DNS for example.com

[root@dns ~]# cat /etc/resolv.conf
# Generated by NetworkManager
domain appowl247.com
search appowl247.com example.com
nameserver xxx.xxx.x.xxx
nameserver yyy.yyy.yy.yy
[root@dns ~]#

Test:
I will try to resolve the name for
wa01.example.com
google.com
hdhillon.appowl247.com



Scenario 1:

Let's create the /etc/resolv.conf file with appowl247.com and example.com

[root@wa01 ~]# cat /etc/resolv.conf
search example.com appowl247.com

nameserver 192.168.2.150

nameserver xxx.xxx.x.xxx
nameserver yyy.yyy.yy.yy

[root@wa01 ~]#


Below nslookup will work for example.com , appowl247.com and internet.

[root@wa01 ~]# nslookup wa01.example.com
Server:         192.168.2.150nslookup google.com

Address:        192.168.2.150#53

Name:   wa01.example.com
Address: 192.168.2.11

[root@wa01 ~]# nslookup google.com
nslookup hdhillon
Server:         xxx.xxx.x.xxx
Address:        xxx.xxx.x.xxx#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.25.46

[root@wa01 ~]# nslookup hdhillon
Server:         xxx.xxx.x.xxx
Address:        xxx.xxx.x.xxx#53

Name:   hdhillon.appowl247.com
Address: 10.11.12.105

[root@wa01 ~]#


Scenario 2:

[root@wa01 ~]# cat /etc/resolv.conf
search example.com appowl247.com
nameserver 192.168.2.150

[root@wa01 ~]#

nslookup is not able to find the IP address of appowl247.com as well as internet

[root@wa01 ~]# nslookup wa01.example.com
Server:         192.168.2.150
Address:        192.168.2.150#53

Name:   wa01.example.com
Address: 192.168.2.11

[root@wa01 ~]# nslookup google.com
nslookup hdhillon
;; connection timed out; trying next origin
;; connection timed out; no servers could be reached

[root@wa01 ~]# nslookup hdhillon
;; connection timed out; trying next origin
;; connection timed out; no servers could be reached

[root@wa01 ~]#


Scenario 3:

[root@wa01 ~]# cat /etc/resolv.conf

search example.com 

nameserver 192.168.2.150

nameserver xxx.xxx.x.xxx
nameserver yyy.yyy.yy.yy

[root@wa01 ~]# 

nslookup is not able to find the IP address of my machine on appowl247.com

[root@wa01 ~]# nslookup wa01.example.com
Server:         192.168.2.150
Address:        192.168.2.150#53

Name:   wa01.example.com
Address: 192.168.2.11

[root@wa01 ~]# nslookup google.com
nslookup hdhillon
Server:         xxx.xxx.x.xxx
Address:        xxx.xxx.x.xxx#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.25.46

[root@wa01 ~]# nslookup hdhillon
Server:         xxx.xxx.x.xxx
Address:        xxx.xxx.x.xxx#53

** server can't find hdhillon: NXDOMAIN

[root@wa01 ~]# 


Scenario 4:

[root@wa01 ~]# chattr +i /etc/resolv.conf
[root@wa01 ~]# cat /etc/resolv.conf
# Harvey additions
search example.com

nameserver 192.168.2.150

nameserver xxx.xxx.x.xxx
nameserver yyy.yyy.yy.yy

[root@wa01 ~]#

nslookup will not be able to locate the IP for machine on appowl247.com

[root@wa01 ~]# nslookup wa01.example.com
Server:         192.168.2.150
Address:        192.168.2.150#53

Name:   wa01.example.com
Address: 192.168.2.11

[root@wa01 ~]# nslookup google.com
nslookup hdhillon
Server:         xxx.xxx.x.xxx
Address:        xxx.xxx.x.xxx#53

Non-authoritative answer:
Name:   google.com
Address: 216.58.200.110

[root@wa01 ~]# nslookup hdhillon
Server:         xxx.xxx.x.xxx
Address:        xxx.xxx.x.xxx#53

** server can't find hdhillon: NXDOMAIN

[root@wa01 ~]#


Findings:

It is very important to consider adding all the domains you wish to search for to look at the DNS.

If domain name is missing under search then you will get an error like:
** server can't find <what ever>: NXDOMAIN


In case domain is present but the IP address of DNS is missing under nameserver then you will get
[root@wa01 ~]# nslookup google.com
;; connection timed out; trying next origin
;; connection timed out; no servers could be reached


In case domain is missing and but the IP address of DNS is present under nameserver then you will get
** server can't find <Something>: NXDOMAIN




Friday, March 16, 2018

ORA-01156: recovery or flashback in progress may need access to files

Trying to create the standby log file on DR database and getting the error:

ORA-01156: recovery or flashback in progress may need access to files

As the message suggest that recovery is in progress so shutdown the database and start up in mount mode

srvctl stop database -d dev1alsd 

srvctl start database -d dev1alsd -o mount

Now issue the command

ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 SIZE 100M; 

Database altered.

SQL>

It worked. Stop and start the database again.

srvctl stop database -d dev1alsd 

srvctl start database -d dev1alsd




Tuesday, March 6, 2018

Minecraft error while loading shared libraries: libGLESv2.so

I am trying run mincraft from my raspberry pi zero and getting the error below:

har@raspberrypi:~/minecraft_base/mcpi$ ./minecraft-pi
./minecraft-pi: error while loading shared libraries: libGLESv2.so: cannot open shared object file: No such file or directory
har@raspberrypi:~/minecraft_base/mcpi$ 

I made sure that OS is up to date but still there error persists. The issue was resolved by doing the raspberry pi firmware upgrade


har@raspberrypi:~$ sudo rpi-update
[sudo] password for har
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13403  100 13403    0     0   6458      0  0:00:02  0:00:02 --:--:--  6481
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Backing up firmware
 *** Backing up modules 4.9.59+
#############################################################
WARNING: This update bumps to rpi-4.14.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=197689
##############################################################
Would you like to proceed? (y/N)

 *** Downloading specific firmware revision (this will take a few minutes)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168    0   168    0     0    119      0 --:--:--  0:00:01 --:--:--   119
100 55.3M  100 55.3M    0     0   788k      0  0:01:11  0:01:11 --:--:-- 1055k
 *** Updating firmware
 *** Updating kernel modules
 *** depmod 4.14.24-v7+
 *** depmod 4.14.24+
 *** Updating VideoCore libraries
 *** Using HardFP libraries
 *** Updating SDK
 *** Running ldconfig
 *** Storing current firmware revision
 *** Deleting downloaded files
 *** Syncing changes to disk
 *** If no errors appeared, your firmware was successfully updated to 2659c9e87b574b3b05eacef80961c404ed0f0ce3
 *** A reboot is needed to activate the new firmware
har@raspberrypi:~$ 
har@raspberrypi:~$ 

After the reboot I was able to run mincraft but getting the blank screen. that is something I need to work on.

har@raspberrypi:~/minecraft_base/mcpi$ ./minecraft-pi 

What should I install to get my utility in UNIX

I am trying to access xclock and getting error that is is not found !!! I want to know that what should I install so that I can get this utility

[root@wa01 ~]# xclock
-bash: xclock: command not found
[root@wa01 ~]# 

Simplest way is run the command below and it will give you name of application which has this util


# yum whatprovides xclock


[root@wa01 ~]# yum whatprovides xclock
Loaded plugins: refresh-packagekit, ulninfo
xorg-x11-apps-7.7-6.el6.x86_64 : X.Org X11 applications
Repo        : public_ol6_latest
Matched from:
Other       : xclock



xorg-x11-apps-7.6-6.el6.x86_64 : X.Org X11 applications
Repo        : public_ol6_latest
Matched from:
Other       : xclock



xorg-x11-apps-7.4-10.el6.x86_64 : X.Org X11 applications
Repo        : public_ol6_latest
Matched from:
Other       : xclock



[root@wa01 ~]# 


The installation will be done as

[root@wa01 ~]# yum install xorg-x11-apps

After the install, now utility is avaialble

[root@wa01 ~]# which xclock
/usr/bin/xclock
[root@wa01 ~]# 




Monday, March 5, 2018

What is AWS ec2 pem file and how does it work

If you want to connect to a server without entering password then you can follow this post.

We have three servers

wa01.example.com          IP : 192.168.1.11
syd01.example.com         IP : 192.168.1.12
per01.example.com         IP : 192.168.1.13

Problem: We want to log in to syd01.example.com without entering the password.

Steps: 
1. Generated keys public and private on wa01.example.com
2. Use ssh-copy-id to create the authorized_keys on syd01.example.com
3. ssh from wa01.example.com to syd01.example.com


Action:


Generate the key pair on wa01.example.com

[harvarinder@wa01 .ssh]$ ssh-keygen -t rsa -b 2048 -v
Generating public/private rsa key pair.
Enter file in which to save the key (/home/harvarinder/.ssh/id_rsa): harvey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in harvey.
Your public key has been saved in harvey.pub.
The key fingerprint is:
9c:e5:d0:7d:73:98:20:10:a8:f7:fd:92:d8:9d:15:f5 harvarinder@wa01.example.com
The key's randomart image is:
+--[ RSA 2048]----+
|       .oo. .    |
|      .  . o . o.|
|     .  . o . =.o|
|    . .. =   ..oE|
|     . .S..    . |
|        . .   .  |
|         o + o   |
|        . + +    |
|           .     |
+-----------------+
[harvarinder@wa01 .ssh]$

Please note that it will generate two files one harvey and second harvey.pub

[harvarinder@wa01 .ssh]$ ls -lah
total 20K
drwx------.  2 harvarinder harvarinder 4.0K Mar  5 13:55 .
drwx------. 26 harvarinder harvarinder 4.0K Mar  5 13:46 ..
-rw-------.  1 harvarinder harvarinder 1.7K Mar  5 13:55 harvey
-rw-r--r--.  1 harvarinder harvarinder  410 Mar  5 13:55 harvey.pub
harvey.pub is the public key and other is the private key.
Copy the public key which has .pub in its name across to syd01.example.com

[harvarinder@wa01 .ssh]$ ssh-copy-id -i harvey.pub harvarinder@192.168.1.12
The authenticity of host '192.168.1.12 (192.168.1.12)' can't be established.
RSA key fingerprint is 97:87:aa:97:55:1b:9d:81:f5:18:0a:cf:6a:6c:c6:db.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.12' (RSA) to the list of known hosts.
harvarinder@192.168.1.12's password:
Now try logging into the machine, with "ssh 'harvarinder@192.168.1.12'", and check in:
  .ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[harvarinder@wa01 .ssh]$


Please note that if you log in to syd01.example.com and look under .ssh folder of harvarinder user then you should be able to see a file called authorized_keys. Above steps will create this file if it is not present and add the public key in it else it will append the key in the file.

This is to ensure that any one key who's generate a public key in this file should be able to make the ssh connection using this user.

Below is the snip of the file
[harvarinder@syd01 .ssh]$ cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4kp92dtMkT1n1dNTO6nEuZRubT......vCDwdeqDMuBEfzJoBQ== harvarinder@wa01.example.com


From here on ssh to syd01.example.com without password.

[harvarinder@wa01 .ssh]$ ssh -i harvey harvarinder@192.168.1.12
Last login: Mon Mar  5 13:56:02 2018 from 192.168.1.11
[harvarinder@syd01 ~]$

Extending this test

lets copy the harvey file to per01.example.com and see if we can log in from there as well.


[harvarinder@wa01 .ssh]$ scp -p harvey 192.168.1.13:.ssh
The authenticity of host '192.168.1.13 (192.168.1.13)' can't be established.
RSA key fingerprint is 97:87:aa:97:55:1b:9d:81:f5:18:0a:cf:6a:6c:c6:db.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.13' (RSA) to the list of known hosts.
harvarinder@192.168.1.13's password:
harvey                                                                                                                                                                                                                        100% 1675     1.6KB/s   00:00 
[harvarinder@wa01 .ssh]$

Now let's ssh from per01.example.com to syd01.example.com using private key harvey
[harvarinder@per01 .ssh]$ pwd
/home/harvarinder/.ssh
[harvarinder@per01 .ssh]$ ls -l
total 4
-rw-------. 1 harvarinder harvarinder 1675 Mar  5 13:57 harvey
[harvarinder@per01 .ssh]$
[harvarinder@per01 .ssh]$
[harvarinder@per01 .ssh]$ ssh -i harvey harvarinder@192.168.1.12
The authenticity of host '192.168.1.12 (192.168.1.12)' can't be established.
RSA key fingerprint is 97:87:aa:97:55:1b:9d:81:f5:18:0a:cf:6a:6c:c6:db.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.12' (RSA) to the list of known hosts.
Last login: Mon Mar  5 13:57:39 2018 from 192.168.1.11
[harvarinder@syd01 ~]$
[harvarinder@syd01 ~]$


Lets do a final trick of renaming the file to something else and see what happens, I am renaming it on per01.example.com

[harvarinder@per01 .ssh]$ mv harvey harvey.pem
[harvarinder@per01 .ssh]$ ssh -i harvey.pem harvarinder@192.168.1.12
Last login: Mon Mar  5 14:19:53 2018 from 192.168.1.13
[harvarinder@syd01 ~]$
[harvarinder@syd01 ~]$
[harvarinder@per01 .ssh]$ mv harvey.pem harvey.dhillon
[harvarinder@per01 .ssh]$
[harvarinder@per01 .ssh]$
[harvarinder@per01 .ssh]$ ssh -i harvey.dhillon harvarinder@192.168.1.12
Last login: Mon Mar  5 14:23:12 2018 from 192.168.1.13
[harvarinder@syd01 ~]$

Interesting isn't it .


Result:

If we have a key pair (public and private keys) then we can copy the public keys in the authorized_keys of the server where we want to connect. Please note that if we want to connect to remote machine as username called bing then authorized_keys file should be under .ssh folder under bing user. If you want to connect as oracle user then authorized_keys should be under .ssh folder under oracle user.

Then connect from any machine which has ssh client using the private key using that user and have fun. Did I say anything about AWS ec2 pem file ?


Rename unix hostname

Want to rename the hostname of a unix host.

Current name:     wagga01.example1111.com
New Name:         wagga01.example.com

Make sure that the HOSTNAME entry under /etc/sysconfig/network is updated to new name and reboot the machine and it is done.

Steps are below:


[root@wagga01 ~]# cat /etc/hosts
10.0.2.15       wagga01.example1111.com wagga01 # Added by NetworkManager
127.0.0.1       localhost.localdomain   localhost
::1     wagga01.example1111.com wagga01 localhost6.localdomain6 localhost6
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wagga01.example1111.com
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# hostname
wagga01.example1111.com
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# cat  /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wagga01.example.com
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# hostname
wagga01.example1111.com
[root@wagga01 ~]#

[root@wagga01 ~]# shutdown -r now

[root@wagga01 ~]# hostname
wagga01.example.com
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# cat /etc/hosts
10.0.2.15       wagga01.example.com     wagga01 # Added by NetworkManager
127.0.0.1       localhost.localdomain   localhost
::1     wagga01.example.com     wagga01 localhost6.localdomain6 localhost6
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wagga01.example.com
[root@wagga01 ~]#

In case you are on centos or redhat then there is an easy way that is

# hostnamectl set-hostname wagga01.example.com

Then reboot:

# shutdown -r now




Saturday, March 3, 2018

Installed oracle linux 6 but unable to get the update

Installed oracle linux 6 but I am not able to get the updates and getting message


[root@ordb01 ~]# yum update
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with ULN.
ULN support will be disabled.
Setting up Update Process
No Packages marked for Update
[root@ordb01 ~]#


Solution is

# cd /etc/yum.repos.d
# wget http://yum.oracle.com/public-yum-ol6.repo

make sure that enabled=1 under ol6_latest

Now we can install the updates without any issue.

# yum update

BINGO!!!

Friday, March 2, 2018

Running multiple websites on one apache using virtual host

cp -p /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.conf
mkdir -p /var/www/html/example

cat /etc/apache2/sites-available/example.conf

<VirtualHost *:80>
<Directory "/var/www/html/example">
    AllowOverride All
</Directory>

        ServerAdmin example@example.com
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/html/example

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


cp -p /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/secondexample.conf
mkdir -p /var/www/html/secondexample

cat/etc/apache2/sites-available/secondexample.conf

<VirtualHost *:80>
<Directory "/var/www/html/secondexample">
    AllowOverride All
</Directory>

        ServerAdmin secondexample@secondexample.com
        ServerName secondexample.com
        ServerAlias www.secondexample.com
        DocumentRoot /var/www/html/secondexample

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


sudo a2ensite example.conf
sudo a2ensite secondexample.conf


sudo service apache2 restart


now both awesomesite and example with work from same apache as long as thier files are under correct document directory

Get wordpress running from different location without changing much in code.

In my instance the website was under /var/www/html and my apache2.conf says <Directory /var/www>

My .htaccess file under /var/www/html/ is and that is standard.


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


Lets say we want to keep all urls the samebut want to keep the file under /var/www/html/mywordpress/
To achive this do the following

mkdir /var/www/html/mywordpress/
make sure all the permissions are correct.

mv /var/www/html/* /var/www/html/mywordpress/
mv /var/www/html/mywordpress/.htaccess /var/www/html/mywordpress/.htaccess.old

vi /var/www/html/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/mywordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mywordpress/$1
RewriteRule ^(/)?$ mywordpress/index.php [L]
</IfModule>

# END WordPress


restart the apache

sudo apachectl restart


Done!!!