Friday, June 25, 2021

AWS Identity and Access Management (IAM)

AWS Identity and Access Management (IAM)


IAM User:

Newly created IAM User has no permissions associated with it.


IAM Policy:

IAM Policy allows us to change the permission on resources like EC2, S3, etc.


IAM Group:

IAM Group is a collection of users. We can assign IAM policy to IAM Group.


IAM Roles:

IAM Roles is a temporary access to some resource. We do not assign roles. Users, application or services can assume IAM Roles. 

Once a roles is assumed all previous permissions granted through groups and policies are not valid for the total duration of IAM Role is assumed.


MFA is extra layer of security provided in IAM


Monday, June 21, 2021

AWS Network ACL and Security Groups

ACLs perform stateless packet filtering (Always check packets)

Account's Default ACL: Allow all In and out traffic

Customer ACL: Only allow what is defined rest is deny

-------------------------------------------------------------------------

Security Groups perform stateful packet filtering (Remember previous decision for the packet)

By Default 

Deny all In

Allow all out


-------------------------------------------------------------------------






Thursday, June 10, 2021

Crontab

 # Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

Monday, June 7, 2021

AWS Cloud Practitioner Essentials Notes

-----------------
1. Compute in Cloud
-----------------

Compute on AWS
https://aws.amazon.com/products/compute/

Interactive map of the AWS Global Infrastructure
https://aws.amazon.com/about-aws/global-infrastructure/regions_az/

Tools to Build on AWS
https://aws.amazon.com/tools/

How Amazon VPC works
https://docs.aws.amazon.com/vpc/latest/userguide/how-it-works.html


-----------------
4. Storage and Database
-----------------

Cloud Storage on AWS
https://aws.amazon.com/products/storage/
AWS Database Migration Service
https://aws.amazon.com/dms/

AWS Management & Governance Blog
https://aws.amazon.com/blogs/mt/

Whitepaper: AWS Governance at Scale
https://docs.aws.amazon.com/whitepapers/latest/aws-governance-at-scale/aws-governance-at-scale.html


-----------------
7. Pricing and Support
-----------------

AWS Pricing
https://aws.amazon.com/pricing/

AWS Knowledge Center
https://aws.amazon.com/premiumsupport/knowledge-center/


-----------------
8. Migration and Innovation
-----------------

Migration & Transfer on AWS
https://aws.amazon.com/products/migration-and-transfer/

A Process for Mass Migrations to the Cloud
https://aws.amazon.com/blogs/enterprise-strategy/214-2/

AWS Cloud Enterprise Strategy Blog
https://aws.amazon.com/blogs/enterprise-strategy/

AWS Architecture Blog
https://aws.amazon.com/blogs/architecture/


-----------------
10. AWS Certified Cloud Practitioner Basics
-----------------
Overview of Amazon Web Services
https://d1.awsstatic.com/whitepapers/aws-overview.pdf


Tuesday, June 30, 2020

pscp - ssh_init: Network error: Cannot assign requested address

Playing around with pscp and encounted with an error

ssh_init: Network error: Cannot assign requested address

it looks like pscp is using port 0 by default and mentioning the port allowed copying the file.

C:\temp>pscp myfie.txt oracle@10.10.10.11:/home/test/
ssh_init: Network error: Cannot assign requested address
C:\temp>
C:\temp>pscp -P 22 myfie.txt oracle@10.10.10.11:/home/test/
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's ssh-ed25519 key fingerprint is:
ssh-ed25519 255 45:35:11:23:5d:10:e2:e3:60:6a:c9:06:bb:74:ad:34
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n) yes
oracle@10.10.10.11's password:
myfie.txt                 | 0 kB |   0.0 kB/s | ETA: 00:00:00 | 100%
C:\temp>

Thursday, January 30, 2020

Extending the partition on my AWS EC2 instance

It's been a while that I was using 8G of space for my little ec2 instance. Today my dad called that his application stopped working and when i logged in I have noticed that the space on EC2 was full. At first instance I have cleared some space and then I thought that it is a time to add more space to the machine.

Adding space was not tough. But there are a few steps. Altough the documentation is clear on AWS but for my reference below was done.

1. Log on to the AWS console and increased teh size to 20G.
2. df -h still showing 8G (Magic will not happen we need to do some work)

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            210M     0  210M   0% /dev
tmpfs            48M  612K   48M   2% /run
/dev/xvda1      7.8G  5.8G  1.6G  80% /
tmpfs           240M     0  240M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           240M     0  240M   0% /sys/fs/cgroup
tmpfs            48M     0   48M   0% /run/user/1000

3. Run lsblk to see how the disks are attached and what are the partitions

$ lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  20G  0 disk 
└─xvda1 202:1    0   8G  0 part /
$

I need to make xvda1 20G

4. Grow partition using 

$ sudo growpart /dev/xvda 1
CHANGED: partition=1 start=16065 old: size=16761118 end=16777183 new: size=41926942,end=41943007

It grew partition number 1 which is under min to it's full size

5. Note that it is still showing 8G under df -h 

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            210M     0  210M   0% /dev
tmpfs            48M  612K   48M   2% /run
/dev/xvda1      7.8G  5.8G  1.6G  80% /
tmpfs           240M     0  240M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           240M     0  240M   0% /sys/fs/cgroup
tmpfs            48M     0   48M   0% /run/user/1000
$

6. Just resize the filesystem on partition 

$ sudo resize2fs /dev/xvda1
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/xvda1 is now 5240867 (4k) blocks long.
$

7. Issue the df -h command and see the size is updated.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            210M     0  210M   0% /dev
tmpfs            48M  612K   48M   2% /run
/dev/xvda1       20G  5.8G   13G  32% /
tmpfs           240M     0  240M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           240M     0  240M   0% /sys/fs/cgroup
tmpfs            48M     0   48M   0% /run/user/1000
$


Now I will start paying more money to AWS and have less outages :-) . When you are expanding the partition you can expand it to your need rather that expanding it to full and use the space for something else if you like.

Now my dad will be happy for long time and I do not have to worry regarding sapce for some time.








Wednesday, January 8, 2020

ORA-3206 signalled during: alter tablespace MYTS add datafile

Getting an error while trying to add a datafile to the tablespace.

ORA-3206 signalled during: alter tablespace MYTS add datafile

SQL> alter tablespace MYTS add datafile '/data/db1/oradata/mydb/myts_02.dbf' size 100M autoextend on maxsize 65536M;
alter tablespace MYTS add datafile '/data/db1/oradata/mydb/myts_02.dbf' size 100M autoextend on maxsize 65536M
*
ERROR at line 1:
ORA-03206: maximum file size of (4194304) blocks in AUTOEXTEND clause is out of range


SQL>



Notice that I am trying to add a datafile with 64G size. This is because my db_block_size = 16384


SQL> show parameter db_block_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_size                        integer     16384
SQL>


If you look under
https://docs.oracle.com/cd/E11882_01/server.112/e40402/limits002.htm#REFRN0042

Smallfile (traditional) Tablespaces

Number of blocks

A smallfile tablespace is a traditional Oracle tablespace, which can contain 1022 datafiles or tempfiles, each of which can contain up to approximately 4 million (222) blocks.

222 = 4194304

If you look at the Oracle doc (Doc ID 804733.1)  then it is 4194303

which means that the value should be 
65535.98M

and command will look something like

alter tablespace MYTS add datafile '/data/db1/oradata/mydb/myts_02.dbf' size 100M autoextend on maxsize 65535.98M;


The work around is let oracle determine it and run command below without maxsize value.

SQL> alter tablespace MYTS add datafile '/data/db1/oradata/mydb/myts_02.dbf' size 100M autoextend on;

Tablespace altered.

SQL>











Monday, December 2, 2019

Understanding vm.nr_hugepages, vm.hugetlb_shm_group, kernel.shmall, kernel.shmmax, kernel.shmmni

Understanding vm.nr_hugepages, vm.hugetlb_shm_group, kernel.shmall, kernel.shmmax, kernel.shmmni

Setting up new database server and want to make sure that all the OS limits are set properly. It require little bit of calculation to be done. There are confusing bits what to divide by page size and what to divide by huge page size.

Hoping that below explanation should help in the understanding and setting them correctly. 



Getting Current values for all the variables
cat /etc/sysctl.conf | egrep '(shm|huge)' | sort


Hugepage size used on the machine
grep -i "Hugepagesize" /proc/meminfo



vm.nr_hugepages       = Number of hugepages available for a Unix Group. Make sure they are more than kernel.shmall.
Note: Make sure that the HugePages are many enough to cover all your database SGAs


vm.hugetlb_shm_group  = Group ID of the Unix group which can use the hugepages defined under vm.nr_hugepages

kernel.shmall         = Total number of pages available for all databases to place their SGAs.
Note: it is number of pages and not number of hugepages  (Command is $getconf PAGE_SIZE )
Note: it is number of pages. It is not the size.
Note: pga_aggregate_target is not part of this. pga_aggregate_target is taken from OS RAM.

kernel.shmmax         = SHMMAX is the maximum size of a single shared memory segment set in bytes.
Ideally, we would like SGA_TARGET to fit in one shared memory segment at startup by having
                        SGA_TARGET < SHMMAX
If SGA_TARGET > SHMMAX , then Oracle will try to use contiguous multi-segment to use to fit the SGA_TARGET.
If it is not able to do so, then it will use non-contiguous multi-segment allocation and in this
                        Oracle has to grab the free memory segments fragmented between used spaces.
Note: It has nothing to do with the total SGA for all databases. The database will start even if this value 
                        is smaller than SGA

kernel.shmmni         = It can vary for different OS.
Default use 4096



General Notes:
Make sure that the RAM and HugePages have enough space to cover all your database SGAs
Make sure the total SGA is less than the installed RAM and re-calculate HugePages.
Make sure that the HugePages are enough to cover all your database SGAs



Real world problem:
My server has 90G RAM. I will run 2 DBs on this server.

DB01 Requirements
-----------------
SGA = 12G
PGA = 4G


DB02 Requirements
-----------------
SGA = 7G
PGA = 10G


How can I setup the follwoing parameters?
vm.nr_hugepages, vm.hugetlb_shm_group, kernel.shmall, kernel.shmmax


Solution:
Value for kernel.shmmni

Setting the value to 4096 as that is recommended for redhat version I am using. 
kernel.shmmni = 4096



Calcualte kernel.shmall
Find Total SGA required which is 12 + 7 = 19G. It will be used to calculate kernel.shmall (Remember this value is numer of pages).

Page side we are using is 4k. So we will need 19G / 4k = Total number of pages required to hold SGA of both databases.

In this case it will be (19 * 1024 * 1024) / 4 = 4980736 pages

We can set kernel.shmall = 4980736    (Note: this is minimum value, you should add little more if you want to add more database later on. 
If you want to create another DB then there will be a need to change this parameter and restart of the server will be required. ) 



Calcualte kernel.shmmax
SHMMAX is the maximum size of a single shared memory segment set in bytes.
The biggest SGA out of two databases is 12G.
In this case it will be 12 * 1024 * 1024 = 12582912

kernel.shmmax = 12582912



Calcualte vm.nr_hugepages
Looking at shmall in our case we have allocated 19G so we have to calculate number of pages required to fit in for 19G. 
In our gase the huge page size is 2048k
In this case it will be (19 * 1024 * 1024) / 2048 = 9728

But 9728 may not fit evenly on 19G so I will allocate 512 more hugepages for this to happen smoohtly. Hence end result for the parameter will be 9728 + 512 = 10240

vm.nr_hugepages = 10240



Calcualte vm.hugetlb_shm_group
This is the group ID of the oracle user. Just issue the id oracle on shell prompt and you will get the GID. 

$ id oracle





Monday, May 20, 2019

Plant watering system using Raspberry PI

Tried using Raspberry PI to water plants while we are on holidays.

Raspberry PI setup with temperature sensor to water once a day when temp is over certain threshold.

Plants with a source of water
Raspberry PI setup for watering
Whole Setup



Thursday, May 9, 2019

Increase the size of /boot on centos

I have noticed that my /boot on one of my test machine is nearly full and I can not patch the machine any more and getting 

Total                                                                                                                                                                                                                           9.0 MB/s |  95 MB  00:00:10   
Running transaction check
Running transaction test


Transaction check error:
  installing package kernel-3.10.0-957.12.1.el7.x86_64 needs 23MB on the /boot filesystem

Error Summary
-------------
Disk Requirements:
  At least 23MB more space needed on the /boot filesystem.

#

This is a virtual box machine and I did the below to fix it.

Shut the machine down and added a new 4G disk to it.
startup
create new partition using

# fdisk /dev/sdb
n
p
rest as default

Select (default p): p
Partition number (1-4, default 1):
First sector (2048-8388607, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-8388607, default 8388607):
Using default value 8388607
Partition 1 of type Linux and of size 4 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#


Format the drive to ext4 file system

mkfs.ext4 /dev/sdb


Copy existing contents from /boot to this new drive

mkdir -p /tmp/sdb1
mount /dev/sdb1 /tmp/sdb1
cp -a /boot/* /tmp/sdb1/


Get the UUID of the drive

# blkid /dev/sdb1
/dev/sdb1: UUID="6ae400b9-ff66-4ed0-a550-77eaf29e8d7f" TYPE="ext4"
#


un mount the drive

# umount /tmp/sdb1/


Modify /etc/fstab and add UUID of new drive.



un mount /boot and mount is back so that new drive is mounted as /boot

# umount /boot
# mount /boot


# df -h
/dev/sdb1                  3.9G  194M  3.5G   6% /boot


Re- install GRUB and update configurations


[root@localhost ~]# grub2-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
[root@localhost ~]#
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-957.10.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.10.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.5.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.5.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-afcc54177a674be69136d59c73eb35bf
Found initrd image: /boot/initramfs-0-rescue-afcc54177a674be69136d59c73eb35bf.img
done
[root@localhost ~]#




























Saturday, April 27, 2019

Recover database after loss of control file

I lost the control file and when trying to start the database I am getting the error below:

SQL> startup
ORACLE instance started.

Total System Global Area  838860800 bytes
Fixed Size                  8798312 bytes
Variable Size             339742616 bytes
Database Buffers          486539264 bytes
Redo Buffers                3780608 bytes
ORA-00205: error in identifying control file, check alert log for more info


SQL> 



You can see that the error is there in alert log as well.

2019-04-27T07:29:30.006425-04:00
ALTER DATABASE   MOUNT
2019-04-27T07:29:30.781317-04:00
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/orcl12c/control01.ctl'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
ORA-205 signalled during: ALTER DATABASE   MOUNT...
2019-04-27T07:29:30.932158-04:00
Errors in file /u01/app/oracle/diag/rdbms/orcl12c/orcl12c/trace/orcl12c_m000_12917.trc:
ORA-00202: control file: '/u01/app/oracle/oradata/orcl12c/control01.ctl'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2019-04-27T07:29:32.069723-04:00
Checker run found 1 new persistent data failures


Solution: copying the second controlfile over original location and calling it control01.ctl and starting database fixed the issue.

location of the second control file is in the alert log.

  control_files            = "/u01/app/oracle/oradata/orcl12c/control01.ctl"
  control_files            = "/u01/app/oracle/fast_recovery_area/orcl12c/control02.ctl"



$ cp /u01/app/oracle/fast_recovery_area/orcl12c/control02.ctl /u01/app/oracle/oradata/orcl12c/control01.ctl

SQL> startup
ORACLE instance started.

Total System Global Area  838860800 bytes
Fixed Size                  8798312 bytes
Variable Size             339742616 bytes
Database Buffers          486539264 bytes
Redo Buffers                3780608 bytes
Database mounted.
Database opened.
SQL> 


Tuesday, March 12, 2019

The program cannot open the required dialog box because it cannot determine whether the computer named "BLABLA" is joined to a domain. Close this message, and try again.

I am connected to the sql server database from my machine using SQL Management Studio and wanted to add a user with Windows Authentication, but as soon as I click on Search button the session is taking some time and finally reporting back with an error as below:

The error message is "The program cannot open the required dialog box because it cannot determine whether the computer "BLABLA" named is joined to a domain. Close this message, and try again."

There is a workaround for this issue and a fix.

Workaround can be done from your client SQL Server management studio, but for fix you need to access sql server and make change in firewall.

Workaround:
Use the command like to create the user from SQL Server Management Studio and the example is as below:

create login "MYDOMAIN\test_user" from windows;
go

After this you should be able to refresh the Login view and grant required permissions to user.


Fix:
SQL Server Management Studio requires port 445 inbound to perform this search. So add that port to inbound rules and enable the rule to get it fixed.


Other Checks Done:
I have checked that the server is joined to domain and that can be done from cmd or from server properties

echo %userdomain%



Tuesday, February 26, 2019

Remove all old xauth entries

Simply log on to server and issue command below:

xauth list | cut -f1 -d\  | xargs -i xauth remove {}

Wednesday, January 23, 2019

Medical Records

I like to solve problems and one of the problem that I encountered is that if you are sick and seeing a doctor then you need to have few of your details handy like recent temperatures, medications taken, blood pressure and blood glucose readings.

The doctor would like to have a look that how each has been over a period of time.

Even sometime you would like to keep a track of these things for your own records.

I have Android phone and to fix this issue I have created and Android application which store this kind of information.

Now I can create profiles for all of my family member and keep their information different and if I am seeing a doctor then I just get their profile out and show it to doctor. It is much convenient and hoping that you like it as well.

Below is the Google Play store link from where you can download it:

https://play.google.com/store/apps/details?id=com.appowl247.fever

I will really like your feedback, please feel free to comment or provide feedback in Google Play.

Wednesday, January 16, 2019

Friday, January 11, 2019

FATAL: OCI listening thread exited. Failed to get IP address of host.

I am getting an error in the connection log when I am trying to connect to RAC database server


BLABLA(devel): sqlplus user/password@MY_TNS_NAME 

SQL*Plus: Release 11.2.0.2.0 Production on Fri Jan 11 14:11:21 2019

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

FATAL: OCI listening thread exited. Failed to get IP address of host.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics, Real Application Testing and Unified Auditing options

SQL>


As the name suggests sqlplus is not able to determine the IP address of local machine and showing this error.

It looks like it is a warning and can be fixed very easily by adding the hostname and the IP address in the /etc/hosts file.

Once it is done then I tried connecting and it is fixed.

BLABLA(devel): sqlplus user/password@MY_TNS_NAME    

SQL*Plus: Release 11.2.0.2.0 Production on Fri Jan 11 14:13:19 2019

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics, Real Application Testing and Unified Auditing options

SQL> 

Wednesday, December 5, 2018

ORA-02153: invalid VALUES password string

I am trying to alter an oracle user with the values clause rather than supplying the password in plain text but I am getting the error.

ORA-02153: invalid VALUES password string


SQL> alter user harvey identified by values 'S:AE24159F69EAD93A06E2D274D4C3E493EEE134CBCAA88CE869AEE7A40AC4;T:2E3AC72D182037E1EEC8D07FC1AAA7315940BF742217A635DBE4A58BF3E56B524E593BF9D30BD6B3CD73C3B56
  2  A781A00DD56D35E1E2C531DA702D4B6BF9A4D6C21597BA18C11BAFED7D9B9627A179DB5;337BCAD956B180F8';
alter user harvey identified by values 'S:AE24159F69EAD93A06E2D274D4C3E493EEE134CBCAA88CE869AEE7A40AC4;T:2E3AC72D182037E1EEC8D07FC1AAA7315940BF742217A635DBE4A58BF3E56B524E593BF9D30BD6B3CD73C3B56
*
ERROR at line 1:
ORA-02153: invalid VALUES password string


SQL>


I could not get my head around what is this, but it looks like it is something to do with the values string.

I have noticed that when I run the get_ddl for user it returned the hash of password in multiple lines and I was copying and pasting it and hence getting the error.

In order to fix this I have to get that value in one line and then it works

SQL> alter user harvey identified by values 'S:AE24159F69EAD93A06E2D274D4C3E493EEE134CBCAA88CE869AEE7A40AC4;T:2E3AC72D182037E1EEC8D07FC1AAA7315940BF742217A635DBE4A58BF3E56B524E593BF9D30BD6B3CD73C3B56A781A00DD56D35E1E2C531DA702D4B6BF9A4D6C21597BA18C11BAFED7D9B9627A179DB5;337BCAD956B180F8';

User altered.

SQL>

Done deal :-) 


Monday, December 3, 2018

Getting error while trying to run "Login-AzureRmAccount" from powershell

I am getting the error below while trying to login to azure using the power shell

PS C:\WINDOWS\system32> Login-AzureRmAccount
Login-AzureRmAccount : The term 'Login-AzureRmAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


PS C:\WINDOWS\system32>


In order to fix this I have done the installation of required module and it has started working fine.

PS C:\WINDOWS\system32> Install-Module -Name AzureRM -AllowClobber

PS C:\WINDOWS\system32>


But then I started getting another error:

PS C:\WINDOWS\system32> Login-AzureRmAccount
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.profile'.
At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule


PS C:\WINDOWS\system32>

Then another one :-( 

PS C:\WINDOWS\system32> Import-Module AzureRM.profile
Import-Module : File C:\Program Files\WindowsPowerShell\Modules\AzureRM.profile\5.8.2\AzureRM.Profile.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies
at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Import-Module AzureRM.profile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand

PS C:\WINDOWS\system32>

The I had to install the module 

PS C:\WINDOWS\system32> Install-Module -Name AzureRM.profile

PS C:\WINDOWS\system32>

Finally noticed that the execution policy is set to Restricted and it should be Unrestricted.


PS C:\WINDOWS\system32> Get-ExecutionPolicy
Restricted

PS C:\WINDOWS\system32> set-executionpolicy Unrestricted

PS C:\WINDOWS\system32>


PS C:\WINDOWS\system32> Get-ExecutionPolicy
Unrestricted

PS C:\WINDOWS\system32>

and there we go the azure login script is working now.


PS C:\WINDOWS\system32> Login-AzureRmAccount

Account                   SubscriptionName TenantId                             Environment
-------                   ---------------- --------                             -----------
XFtxxxxxxxx@xxxxxxxxxx.com Azuxxxx       00000000-0000-0000-0000-000000000000 AzureCloud



PS C:\WINDOWS\system32>


ORA-39181: Only partial table data may be exported due to fine grain access control on "OWNER"."TABLE_NAME"

Received an error while performing the export of an oracle database using System user.

ORA-39181: Only partial table data may be exported due to fine grain access control on "OWNER"."TABLE_NAME"

As the errors points that this is the issue with the fine grain access on the table. User surprisingly user system need exemption and can be done by

 GRANT EXEMPT ACCESS POLICY to System;

Next time you perform the export using system it should be all good.

Thursday, October 18, 2018

Role is disabled for users when operation is done through plsql

Getting error like ORA-00942 or ORA-01933 or ORA-01031 and ORA-06512 or  PLS-00201 and ORA-06550 or ORA-28111 or ORA-01031: insufficient privileges or PLS-00201: identifier 'x' must be declared


If there is a user which has got some permission to do the following through the role


select a table, select a view, create a table, create a view, create a trigger


and the above operations are done using calling a plsql procedure then the operation will only work if the direct grants are done for the user running plsql block.


The reason is that when a plsql block is executed then only direct grants on that user are in use and grant done through the role will not work as the role will not kick in.


Example is as show below:



SQL> create user harv identified by abc123 default tablespace USERS temporary tablespace temp;

User created.

SQL> grant create session to harv;

Grant succeeded.

SQL> grant resource to harv;

Grant succeeded.

SQL> conn harv/abc123
Connected.
SQL> create or replace procedure harv.temp is
  2     var1 varchar2(4000);
  3  BEGIN
  4     var1:='create table harv.tab(
  5            id number)';
  6     EXECUTE IMMEDIATE var1;
  7  end temp;
  8  /

Procedure created.

SQL> exec harv.temp
BEGIN harv.temp; END;

*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "harv.TEMP", line 6
ORA-06512: at line 1


SQL> conn / as sysdba
Connected.
SQL>

SQL> grant create table to harv;

Grant succeeded.

SQL>

SQL> conn harv/abc123
Connected.
SQL> exec harv.temp

PL/SQL procedure successfully completed.


SQL>