Saturday 15 October 2022

ValueError: cannot set a frame with no defined index and a scalar

This error message typically occurs when trying to assign a scalar value to a DataFrame without specifying the index or columns. Here's an example:

python
import pandas as pd df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) # This line will raise the ValueError df.loc[0] = 7
 

In this example, we have a DataFrame with two columns 'A' and 'B' and three rows. The df.loc[0] = 7 line is trying to set the first row of the DataFrame to the value 7. However, since we haven't specified which columns to update, Pandas is trying to set all columns to the scalar value 7, which isn't possible.

To fix this error, we need to specify which columns we want to update. For example:

python
df.loc[0, 'A'] = 7
 

This will set the value of the 'A' column in the first row to 7. Alternatively, we can specify the columns to update using a list:

python
df.loc[0, ['A', 'B']] = [7, 8]
 

This will set the values of both the 'A' and 'B' columns in the first row to 7 and 8, respectively.

Monday 3 October 2022

Linux basic commands

Here are some basic Linux commands along with their full forms and brief descriptions:

  1. ls (List): Lists files and directories in the current working directory. Example: ls -l (long format listing), ls -a (include hidden files), ls -h (human-readable sizes).
  2. cd (Change Directory): Changes the current working directory. Example: cd /path/to/directory.
  3. pwd (Print Working Directory): Displays the current working directory. Example: pwd.
  4. cp (Copy): Copies files and directories. Example: cp file.txt destination/.
    copy file with same  timestamp
    cp -p oldfile newfile
  5. mv (Move): Moves or renames files and directories. Example: mv file.txt new_location/, mv old_name.txt new_name.txt.
  6. rm (Remove): Deletes files and directories. Example: rm file.txt, rm -r directory/ (recursively delete a directory).
  7. mkdir (Make Directory): Creates a new directory. Example: mkdir new_directory.
  8. rmdir (Remove Directory): Deletes an empty directory. Example: rmdir empty_directory.
  9. cat (Concatenate): Displays the contents of a file. Example: cat file.txt.
  10. more or less: Pager commands to view text files page by page. Example: more file.txt, less file.txt.
  11. head and tail: Display the first or last part of a file. Example: head file.txt (displays the first few lines), tail file.txt (displays the last few lines).
  12. grep (Global Regular Expression Print): Searches for a pattern in a file or input. Example: grep "keyword" file.txt.
  13. find: Searches for files and directories based on different criteria. Example: find /path/to/search -name "filename".
  14. chmod (Change Mode): Modifies file permissions. Example: chmod +x script.sh (adds execute permission), chmod 644 file.txt (sets read-write permissions for owner, read-only for group and others).
  15. chown (Change Ownership): Changes the owner of a file or directory. Example: chown user:group file.txt.
  16. ps (Process Status): Displays information about currently running processes. 

Example: ps aux (lists all processes), ps -ef | grep process_name (search for a specific process).

  1. kill: Sends a signal to terminate a process. Example: kill PID (PID is the process ID).
  2. df (Disk Free): Shows disk space usage on file systems. Example: df -h ,df -g(displays sizes in human-readable format).
  3. free: Shows system memory usage. Example: free -h,free-g (displays sizes in human-readable format).
  4. top and htop: Displays real-time system resource usage and processes. Example: top, htop (htop is an improved version of top).
  5. ifconfig : Interface Configuration: Displays and configures network interfaces (deprecated on modern systems).
  6. ip - IP: A modern alternative to ifconfig for network configuration.
  7. ping : Sends an ICMP echo request to a host to check network connectivity.
  8. ssh - Secure Shell: Allows secure remote login to another machine over a network.
  9. scp - Secure Copy: Securely copies files between hosts over a network.
  10. tar - Tape Archive: Used to archive multiple files into a single tarball file.
  11. gzip - GNU Zip: Compresses files to reduce their size.
  12. unzip - Unzip: Extracts files from a zip archive.
  13. who - Who: Displays a list of currently logged-in users.
  14. history - History: Shows a list of previously executed commands.
     

 

Saturday 1 October 2022

Move a Database to an Oracle Home with a different patch level( 19.8 to 19.12) Using dbaascli in Exacs

This post covers detailed steps to move a database to an Oracle Home with a different patch level( 19.8 to 19.12) Using dbaascli in Exacs.

High Level Steps:
 --> Verify present db version and components list from registry
 --> Gather invalid objects details and try to compile
 --> Run Prechecks for db home move
 --> Move db to different oracle home with different patch level
 --> Verify db present version and components list from registry , Invalid objects
 
Verify Present db Version:
SQL> select INSTANCE_NAME,host_name,status,logins,version,VERSION_FULL,to_char(STARTUP_TIME,'DD/MM/YYYY HH24:MI:SS') "STARTUP_TIME" from gv$instance;
INSTANCE_NAME      HOST_NAME           STATUS       LOGINS     VERSION           VERSION_FULL      STARTUP_TIME
---------------- -------------------  ------------ ---------- ----------------- ----------------- -------------------
stgdb011           ociexacs-node1       OPEN         ALLOWED    19.0.0.0.0        19.8.0.0.0        22/08/2022 04:04:03
stgdb012           ociexacs-node2       OPEN         ALLOWED    19.0.0.0.0        19.8.0.0.0        22/08/2022 04:04:03

Verify installed components and component version:
SQL> select COMP_ID,COMP_NAME,VERSION,VERSION_FULL,STATUS from dba_registry;
COMP_ID         COMP_NAME                            VERSION         VERSION_FULL                   STATUS
-------------- ------------------------------------ ---------------- ------------------------------ --------
CATALOG         Oracle Database Catalog Views        19.0.0.0.0      19.8.0.0.0                     VALID
CATPROC         Oracle Database Packages and Types   19.0.0.0.0      19.8.0.0.0                     VALID
RAC             Oracle Real Application Clusters     19.0.0.0.0      19.8.0.0.0                     VALID
JAVAVM          JServer JAVA Virtual Machine         19.0.0.0.0      19.8.0.0.0                     VALID
XML             Oracle XDK                           19.0.0.0.0      19.8.0.0.0                     VALID
CATJAVA         Oracle Database Java Packages        19.0.0.0.0      19.8.0.0.0                     VALID
APS             OLAP Analytic Workspace              19.0.0.0.0      19.8.0.0.0                     VALID
XDB             Oracle XML Database                  19.0.0.0.0      19.8.0.0.0                     VALID
OWM             Oracle Workspace Manager             19.0.0.0.0      19.8.0.0.0                     VALID
CONTEXT         Oracle Text                          19.0.0.0.0      19.8.0.0.0                     VALID
ORDIM           Oracle Multimedia                    19.0.0.0.0      19.8.0.0.0                     VALID
SDO             Spatial                              19.0.0.0.0      19.8.0.0.0                     VALID
XOQ             Oracle OLAP API                      19.0.0.0.0      19.8.0.0.0                     VALID
OLS             Oracle Label Security                19.0.0.0.0      19.8.0.0.0                     VALID
DV              Oracle Database Vault                19.0.0.0.0      19.8.0.0.0                     VALID

15 rows selected.

Check Invalid objects:
SQL> select OWNER,OBJECT_NAME,OBJECT_TYPE from dba_objects where STATUS='INVALID';
no rows selected

Check installed DB Home details on Exacs nodes:
[root@ociexacs-node1 ~]# dbaascli system getDBHomes
DBAAS CLI version 22.3.1.1.0
Executing command system getDBHomes
Job id:
{
  "OraHome3" : {
    "id" : "",
    "homePath" : "/u02/app/oracle/product/19.0.0.0/dbhome_1",
    "homeName" : "OraHome3",
    "version" : "19.12.0.0.0",
    "createTime" : 1664597038000,
    "updateTime" : 1664597038000,
    "ohNodeLevelDetails" : {
      "ociexacs-node2" : {
        "nodeName" : "ociexacs-node2",
        "version" : "19.12.0.0.0"
      },
      "ociexacs-node1" : {
        "nodeName" : "ociexacs-node1",
        "version" : "19.12.0.0.0"
      }
    },
    "messages" : [ ]
  },
  "OraHome100" : {
    "id" : "",
    "homePath" : "/u02/app/oracle/product/19.0.0.0/dbhome_2",
    "homeName" : "OraHome100",
    "version" : "19.8.0.0.0",
    "createTime" : 1664596819000,
    "updateTime" : 1664596819000,
    "ohNodeLevelDetails" : {
      "ociexacs-node2" : {
        "nodeName" : "ociexacs-node2",
        "version" : "19.8.0.0.0"
      },
      "ociexacs-node1" : {
        "nodeName" : "ociexacs-node1",
        "version" : "19.8.0.0.0"
      }
    },
    "messages" : [ ]
  }
}
dbaascli execution completed

19.12 version already installed on Exacs nodes, if target version not installed follow steps in https://www.dbops-tech.com/2021/08/install-oracle-rdbms-on-oracle-cloud.html  to installed required db version.

Execute Pre-checks for db move:
[root@ociexacs-node1 ~]# dbaascli database move --dbname stgdb01 --ohome /u02/app/oracle/product/19.0.0.0/dbhome_1 --executePrereqs


DBAAS CLI version 22.3.1.1.0
Executing command database move --ohome /u02/app/oracle/product/19.0.0.0/dbhome_1 --executePrereqs
Job id: cf0a124f-6131-4a11-86af-767175292a27
Loading PILOT...
Session ID of the current execution is: 4
Log file location: /var/opt/oracle/log/stgdb01/database/move/pilot_2022-09-28_09-12-02-PM_90184
-----------------
Running initialization job
Completed initialization job
-----------------
Running validate_user_input job
Completed validate_user_input job
-----------------
Running validate_database job
Completed validate_database job
-----------------
Running validate_creg_file_existence job
Completed validate_creg_file_existence job
-----------------
Running validate_source_home job
Completed validate_source_home job
-----------------
Running validate_major_version job
Completed validate_major_version job
-----------------
Running validate_oracle_home_type job
Completed validate_oracle_home_type job
-----------------
Running check_target_source_home_not_same job
Completed check_target_source_home_not_same job
-----------------
Running validate_home_existence job
Completed validate_home_existence job
-----------------
Running validate_home_consistency job
Completed validate_home_consistency job
-----------------
Running validate_home_options job
Completed validate_home_options job
-----------------
Running validate_disk_space job
Completed validate_disk_space job
dbaascli execution completed
[root@ociexacs-node1 ~]#

Move db to different home using dbaascli:
[root@ociexacs-node1 ~]# dbaascli database move --dbname stgdb01 --ohome /u02/app/oracle/product/19.0.0.0/dbhome_1


DBAAS CLI version 22.3.1.1.0
Executing command database move --ohome /u02/app/oracle/product/19.0.0.0/dbhome_1
Job id: 5bd5403b-0bb4-4db3-8bee-aeca7eebf327
Loading PILOT...
Session ID of the current execution is: 5
Log file location: /var/opt/oracle/log/stgdb01/database/move/pilot_2022-09-28_09-17-09-PM_156886
-----------------
Running initialization job
Completed initialization job
-----------------
Running validate_user_input job
Completed validate_user_input job
-----------------
Running validate_database job
Completed validate_database job
-----------------
Running validate_creg_file_existence job
Completed validate_creg_file_existence job
-----------------
Running validate_source_home job
Completed validate_source_home job
-----------------
Running validate_major_version job
Completed validate_major_version job
-----------------
Running validate_oracle_home_type job
Completed validate_oracle_home_type job
-----------------
Running check_target_source_home_not_same job
Completed check_target_source_home_not_same job
-----------------
Running validate_home_existence job
Completed validate_home_existence job
-----------------
Running validate_home_consistency job
Completed validate_home_consistency job
-----------------
Running validate_home_options job
Completed validate_home_options job
-----------------
Running validate_disk_space job
Completed validate_disk_space job
-----------------
Running acquire_lock job
Completed acquire_lock job
-----------------
Running copy_config_files job
Completed copy_config_files job
-----------------
Running stop_database_instance-ociexacs-node1 job
Completed stop_database_instance-ociexacs-node1 job
-----------------
Running update_database_resource-ociexacs-node1 job
Completed update_database_resource-ociexacs-node1 job
-----------------
Running start_database_instance-ociexacs-node1 job
Completed start_database_instance-ociexacs-node1 job
-----------------
Running stop_database_instance-ociexacs-node2 job
Completed stop_database_instance-ociexacs-node2 job
-----------------
Running update_database_resource-ociexacs-node2 job
Completed update_database_resource-ociexacs-node2 job
-----------------
Running start_database_instance-ociexacs-node2 job
Completed start_database_instance-ociexacs-node2 job
-----------------
Running exacs_post_patch_node_updation job
Completed exacs_post_patch_node_updation job
-----------------
Running update_dba_directories job
Completed update_dba_directories job
-----------------
Running datapatch_and_recompile_invalid_objects job
Datapatch execution on database 'stgdb01' is in progress
Datapatch execution on database 'stgdb01' is complete
Recompilation of invalid objects on database 'stgdb01' is in progress
Recompilation of invalid objects on database 'stgdb01' is complete
Completed datapatch_and_recompile_invalid_objects job
-----------------
Running release_lock job
Completed release_lock job
-----------------
Running invoke_backup_asst job
Completed invoke_backup_asst job
-----------------
Running post_move_validation job
Completed post_move_validation job
-----------------
Running generate_dbsystem_details job
Completed generate_dbsystem_details job
dbaascli execution completed


Post validations:
SQL> select INSTANCE_NAME,host_name,status,logins,version,VERSION_FULL,to_char(STARTUP_TIME,'DD/MM/YYYY HH24:MI:SS') "STARTUP_TIME" from gv$instance;
INSTANCE_NAME      HOST_NAME          STATUS       LOGINS     VERSION           VERSION_FULL      STARTUP_TIME
---------------- ------------------  ------------ ---------- ----------------- ----------------- -------------------
stgdb011           ociexacs-node1      OPEN         ALLOWED    19.0.0.0.0         19.12.0.0.0       28/09/2022 21:18:18
stgdb012           ociexacs-node1      OPEN         ALLOWED    19.0.0.0.0         19.12.0.0.0       28/09/2022 21:20:22

SQL> select COMP_ID,COMP_NAME,VERSION,VERSION_FULL,STATUS from dba_registry;
COMP_ID         COMP_NAME                            VERSION         VERSION_FULL                   STATUS
-------------- ------------------------------------ ---------------- ------------------------------ --------
CATALOG         Oracle Database Catalog Views        19.0.0.0.0      19.12.0.0.0                     VALID
CATPROC         Oracle Database Packages and Types   19.0.0.0.0      19.12.0.0.0                     VALID
RAC             Oracle Real Application Clusters     19.0.0.0.0      19.12.0.0.0                     VALID
JAVAVM          JServer JAVA Virtual Machine         19.0.0.0.0      19.12.0.0.0                     VALID
XML             Oracle XDK                           19.0.0.0.0      19.12.0.0.0                     VALID
CATJAVA         Oracle Database Java Packages        19.0.0.0.0      19.12.0.0.0                     VALID
APS             OLAP Analytic Workspace              19.0.0.0.0      19.12.0.0.0                     VALID
XDB             Oracle XML Database                  19.0.0.0.0      19.12.0.0.0                     VALID
OWM             Oracle Workspace Manager             19.0.0.0.0      19.12.0.0.0                     VALID
CONTEXT         Oracle Text                          19.0.0.0.0      19.12.0.0.0                     VALID
ORDIM           Oracle Multimedia                    19.0.0.0.0      19.12.0.0.0                     VALID
SDO             Spatial                              19.0.0.0.0      19.12.0.0.0                     VALID
XOQ             Oracle OLAP API                      19.0.0.0.0      19.12.0.0.0                     VALID
OLS             Oracle Label Security                19.0.0.0.0      19.12.0.0.0                     VALID
DV              Oracle Database Vault                19.0.0.0.0      19.12.0.0.0                     VALID
15 rows selected.

SQL> select OWNER,OBJECT_NAME,OBJECT_TYPE from dba_objects where STATUS='INVALID';
no rows selected


Sunday 4 September 2022

zsh: no matches found

"zsh: no matches found" typically occurs in the Zsh shell when you use wildcard characters (such as *, ?, or []) in a command, and there are no files or directories that match the specified pattern in the current directory.

Here are a few common scenarios where you might encounter this error:
Using a command with a wildcard pattern that doesn't match any files:
$ ls *.xyz
zsh: no matches found: *.xyz

In this example, Zsh couldn't find any files in the current directory with the ".xyz" extension.
Using a command with a wildcard pattern, but the pattern itself doesn't match anything:

$ echo [a-z]
zsh: no matches found: [a-z]

If there are no lowercase letters in the current directory, the [a-z] pattern won't match anything.

To resolve this issue, you can do the following:

1.Double-check your command or wildcard pattern to ensure it matches existing files or directories in the current directory.
2.Use proper escaping or quoting if necessary. For example, if you want to list files with a literal asterisk in their names, you can use single or double quotes to prevent globbing:

$ ls '*.*'

If you want to use a wildcard pattern to match files in subdirectories as well, consider enabling the globstar option in Zsh:

$ setopt globstar
$ ls **/*.txt

The ** pattern will match files in subdirectories.

How to Delete a Primary Key Index in Oracle

Deleting a primary key index can be a complex task, as it involves modifying the structure of the database table. Here are the steps you can follow to delete a primary key index:

Identify the name of the primary key index: 

SELECT index_name FROM dba_constraints WHERE table_name = 'table_name' AND constraint_type = 'P';

Drop the primary key constraint: Before you can drop the primary key index, you must first drop the primary key constraint. 

ALTER TABLE table_name DROP PRIMARY KEY;

Drop the primary key index: Once the primary key constraint has been dropped, you can then drop the primary key index

DROP INDEX index_name ON table_name;

It's important to note that deleting a primary key index will also remove the associated primary key constraint, which can have implications for data integrity and referential integrity in your database. Be sure to fully understand the implications of removing a primary key index before proceeding.