Skip to main content

issues and fix with Vagrant and PG / Ora software related

The below are issues and fix with Vagrant and PG / Ora software related :

****************************************************************************

1. How do I prevent “No supported authentication methods available” when using putty to connect vagrant machine

go to /etc/sshd/sshd-config -> change PasswordAuthenticator as Yes from No and save it and restart machine


2. How to fix from windows to PG Linux server connectivity..


To check ip tables off or not in vagrant linux or vm

[root@pgnode1 bin]# iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target     prot opt in     out     source               destination           

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target     prot opt in     out     source               destination           

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target     prot opt in     out     source               destination           
[root@pgnode1 bin]# iptables -F
[root@pgnode1 bin]#


If existing then, it wont allow to connect pgadmin running on windows

3.  how to install PG10/11 on Cent os 7?

Installation on Linux 7 :

rpm -qa  | grep -i postgresql

Remove OLD Installation

yum install postgresql-10

By Default Installation will be /usr/pgsql/10

Configuration will be installed at /var/lib/pgsql/10/data

After installation, you can change the port number 5432 to anything which is not being used.
to do that, go to /var/lib/pgsql/10/data, Update the Port value to xxxx
then sudo postgresql -> set the parameter export PGPORT=XXXX and add it into .bash_profile.
Without setting this parameter, pgsql wont work.

To edit pg hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident
bash-4.2$

4. How to fix  Windows code page (1252) while entering into psql running on windows machine.


C:\Program Files\PostgreSQL\10\bin>psql --host=127.0.0.1 --port=5430 --username=postgres -d postgres

Issue :

psql (10.4)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.


Fix :

Start -> Run -> regedit
Go to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
Add new string value named "Autorun" with value "chcp 1252"
Then reopen CMD.exe

5. How to connect from windows to linux using port forward.

Tried to access pgsql running on vagrant linux from windows 10 host machine
        guest vagrant linux pgsql port number : 5432 , Forwarded Port : 5430 ==> add it in .vagrant file.
 
a. Set postgresql.conf to listen on all addresses:
# postgresql.conf
listen_addresses = '*'

b. # pg_hba.conf
#TYPE   DATABASE  USER  CIDR-ADDRESS  METHOD
host    all       all   0.0.0.0/0     trust

c. Open windows PG admin 4 GUI. In that window, Give HostName/Address, Give only localhost or 127.0.0.1 and Port number as 5430(forwarded port )
Note : Dont give the actual linux server name or IP where it is running eventhough you can ping linux vagrant from windows host.


6. how do you install 12.2 demo example from git to install sample db (dvdrental)
 
  fix :

  download and install only software version of 12.2
  If you include db version too then by default it will create pdb and cdb where demo will get trouble in scripts

  after installing software , you have to install cdb database only thru manual commands.

  dbca -silent -createDatabase -templateName General_Purpose.dbc -createAsContainerDatabase false -gdbname cdb1 -sid cdb1 -responseFile NO_VALUE -characterSet AL32UTF8 -memoryPercentage 30 -emConfiguration NONE
  Enter SYS user password:

Enter SYSTEM user password:

  After that you can use the commands

  sqlplus system/welcome123@examprod
  @mksample welcome123 welcome123 hr123 oe123 pm123 ix123 sh123 bi123 EXAMUSER TEMP /tmp/ EXAMPROD

7. If you convert your vagrant to vmdk using Oracle VMware , how the new location will be recognized ?

   Issue :

   After copying existing vagrant vmdk and vob files to the new location, oracle virtual box does not recognize the new copied hard disk.
   It said that UUID is already existing.
 
   Scenario : 1
   *************
 
    Issue 1 : A hard disk with UUID {55b773b8-cbcb-42ea-9a44-1368b30ed823} or with the same properties ('V:\VBOX\VDI\XP_Work_Template_20GB.vmdk') is already registered.
     Fix : C:\Program Files\Oracle\VirtualBox>vboxmanage.exe  internalcommands sethduuid  "C:\Users\mahak\Google Drive\ora12c_node1\OL7U5_x86_64-disk1.vmdk"
UUID changed to: 8d45f2ab-94b4-4906-9b0f-cd55acbd67bb

C:\Program Files\Oracle\VirtualBox>vboxmanage.exe  internalcommands sethduuid  "C:\Users\mahak\Google Drive\ora12c_node1\OL7U5_x86_64-disk2.vmdk"
UUID changed to: a9b3f217-85ef-42a0-9b2b-6474ffc72e1c


   Scenario: 2
   ***********
 
Failed to open virtual machine located with .vbox file and getting error:

Could not find an open hard disk with UUID {64150349-221f-49df-b4fe-9e63e4d10d82}.
Result Code:
VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
Component:
VirtualBox
Interface:
IVirtualBox {c28be65f-1a8f-43b4-81f1-eb60cb516e66}
 
   Fix :
 
   open vbox ..
 
   Solution:
1. Open the .vbox file with Notepad or any other editor.
2. Search with the UUID shown in error message on Notepad window.
3. You will find something similar as below:

<StorageController name="SATA Controller" type="AHCI" PortCount="1" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
<AttachedDevice type="HardDisk" port="0" device="0">
  <Image uuid="{64150349-221f-49df-b4fe-9e63e4d10d82}"/>
</AttachedDevice>
  </StorageController>
4. Remove this <StorageController> entry
5. Double click .vbox file again to open VirtualBox, add back the SATA controller and virtual disk in your VM directory.
6. Run the VM again, done :)
 
8.  HOw to create vagrant box if you dont have ?


If you dont have base image like .box then, you can create base image from oracle vm .vmdk files by providing virtual machine name as input as below.

Running Oracle VM Virtual Name ==>  Base ==>  Create vagrant  Machine ==> You can create n number of vagrant machines from single base.

C:\Users\mahak\Google Drive\ora12c_node1_cloud>vagrant package --base ora12c_node1_cloud --output C:\Users\mahak\Google Drive\ora12c_node1_cloud\ora12c_cloud.box
==> ora12c_node1_cloud: Clearing any previously set forwarded ports...
==> ora12c_node1_cloud: Exporting VM...
==> ora12c_node1_cloud: Compressing package to: C:/Users/mahak/Google

C:\HashiCorp\GD_Local>ren Google Google.box

C:\HashiCorp\GD_Local>ren Google Google.box

It will create the commented all entries vagrant file. So you should copy the contents from running machine vagrant to here and make changes.

C:\HashiCorp\GD_Local>vagrant box add -name Google.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ame' (v0) for provider:
box: Unpacking necessary files from: file://C:/HashiCorp/GD_Local/Google.box
box: Progress: 100% (Rate: 23.6M/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'ame' (v0) for 'virtualbox'!

9.  How do you setup ssh connectivity between two nodes.

step1 : login as a root user check selinux status.
******
$sestatus

OutputSELinux status:           enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31

to change :

/etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted

Save it.

step2 :
********

Make sure to have openssh-server and openssh-clients rpms installed. use yum install/remove <package_anme>

step 3 :
********

  go to /etc/ssh/sshd_config file and make sure the below changes.

PubkeyAuthentication yes
PasswordAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys
ChallengeResponseAuthentication no

step 4 :
********

systemctl enable/disable/restart/status/stop/start  sshd.service

step 5.
*******

login as postgres user and go to $HOME directory.

run the command ssh-keygen -t rsa.
once created copy id_rsa.pub to authorized_keys file


•set permissions 700 to ~/.ssh and 600 to authorized_keys file.

step 5. do the same thing on other servers and insert the pubs keys to the corresponding auth keys file and shakeout by self verification first.




Comments

Popular posts from this blog

How to configure Barman along with One Node Wal Streaming.

How to configure Barman : Step 1 : Remove existing postgres Instllations if you have for safer side. sudo su root ==> yum remove postgres* & yum remove barman* step 2 : Install this on Both Prod & Backup servers. PostgreSQL 11 You can install the 2ndQuadrant's General Public RPM repository for PostgreSQL 11 by running the following instructions as a user with sudo privileges on the destination Linux server: curl https://dl.2ndquadrant.com/default/release/get/11/rpm | sudo bash The above command will run a shell script that will install the repository definition in your server. You can check the content of the script by running: curl https://dl.2ndquadrant.com/default/release/get/11/rpm | less Step 3 : Install EPEL depends on OS version on prod :  CentOS/RHEL - 7 rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm yum install postgresql11-server yum install postgresql11-contrib  ===> Th

PG Frequently used DBA Commands

************************************************************************************************************************************************** NOTE :  By default if You connect any DB in the Cluster with out specified User Name, Eventhough those DBs are owned by different users, then internally postgres will be the User and Public is the default Schema Name respective to that. If you create any tables after logging into DB, It will use Public Schema only since this will be the default search path. If you connect db along with particular user then, objects will be created to the respective corresponding schema pointed to the owner. Even you revoke Public Schema access to respective of all users or specified users, By default search path will be public only. But since public is revoked, it will look out who is the owner of the schema to own the object as owner. ALTER ROLE advuser IN DATABASE "Adventureworks"     SET search_path TO adv_s

PG Replication on 10 Master / Slave Configuration using traditional cp

How to do Streaming / Replication Setup on PG : ************************************* Stage 1 : Note down, In this Stage 1, The below example shows that Primary and Standby replication only..No fail over & Fail Back..           For failover , refer stage 2 and fail back refer stage 3 . Primary : Primary Side  : 192.168.100.11 Secondary   : 192.168.100.12 1. CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'replicator'; 2. Edit postgresql.conf as below ALTER SYSTEM SET wal_level TO 'replica';    Must be at least set to hot_standby  until version 9.5 or replica ALTER SYSTEM SET archive_mode TO 'ON'; ALTER SYSTEM SET max_wal_senders TO '3'; ALTER SYSTEM SET wal_keep_segments TO '10'; ALTER SYSTEM SET listen_addresses TO '*'; ALTER SYSTEM SET hot_standby TO 'ON'; ALTER SYSTEM SET archive_command TO 'cp %p /mnt/server/archivedir/%f';  You may not need archive_mode or archive_command or res