Total Pageviews

Tuesday 27 October 2015

Install MongoDB on Redhat 6

Compiled versions of MongoDB for Linux provide a simple option for installing MongoDB for other Linux systems without supported packages.

Install for 64-bit Linux

1 . Download the binary files for the desired release of MongoDB.Download the binaries from https://www.mongodb.org/downloads.

2 Extract the files from the downloaded archive.

[oracle@node1 mongoDB]$ tar -zxvf mongodb-linux-x86_64-rhel62-3.0.7
mongodb-linux-x86_64-rhel62-3.0.7/README
mongodb-linux-x86_64-rhel62-3.0.7/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-rhel62-3.0.7/GNU-AGPL-3.0
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongodump
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongorestore
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongoexport
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongoimport
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongostat
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongotop
mongodb-linux-x86_64-rhel62-3.0.7/bin/bsondump
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongofiles
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongooplog
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongoperf
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongod
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongos
mongodb-linux-x86_64-rhel62-3.0.7/bin/mongo


3 Copy the extracted archive to the target directory.
Copy the extracted folder to the location from which MongoDB will run.

mkdir -p  /data01/mongoDB/mongodb/
cp -R -n mongodb-linux-x86_64-rhel62-3.0.7/ /data01/mongoDB/mongodb/


4
Ensure the location of the binaries is in the PATH variable.
The MongoDB binaries are in the bin/ directory of the archive. To ensure that the binaries are in your PATH, you can modify your PATH.

For example, you can add the following line to your shell’s rc file (e.g. ~/.bashrc):

export PATH=<mongodb-install-directory>/bin:$PATH
Replace <mongodb-install-directory> with the path to the extracted MongoDB archive.


export PATH=/data01/mongoDB/mongodb/bin:$PATH


Run MongoDB

1. Create the data directory.

Before you start MongoDB for the first time, create the directory to which the mongod process will write data. By default, the mongod process uses the /data/db directory. If you create a directory other than this one, you must specify that directory in the dbpath option when starting the mongod process later in this procedure.

The following example command creates the data directory . ( Default location is /data/db. )

mkdir -p /data01/mongoDB/db/

2 .Set permissions for the data directory.

Before running mongod for the first time, ensure that the user account running mongod has read and write permissions for the directory.

3 . Run MongoDB.
To run MongoDB, run the mongod process at the system prompt. If necessary, specify the path of the mongod or the data directory. See the following examples.

Run without specifying paths
If your system PATH variable includes the location of the mongod binary and if you use the default data directory (i.e., /data/db), simply enter mongod at the system prompt:

mongod
Specify the path of the mongod . If your PATH does not include the location of the mongod binary, enter the full path to the mongod binary at the system prompt:

<path to binary>/mongod

[oracle@node1 ~]$ which mongod

/data01/mongoDB/mongodb/bin/mongod


Specify the path of the data directory
If you do not use the default data directory (i.e., /data/db), specify the path to the data directory using the --dbpath option:

[oracle@node1 ~]$ mongod --dbpath /data01/mongoDB/db/

mongod: /usr/lib64/libssl.so.10: no version information available (required by mongod)
mongod: /usr/lib64/libcrypto.so.10: no version information available (required by mongod)
mongod: /usr/lib64/libcrypto.so.10: no version information available (required by mongod)
2015-10-27T01:26:59.213-0400 I JOURNAL  [initandlisten] journal dir=/data01/mongoDB/db/journal
2015-10-27T01:26:59.213-0400 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2015-10-27T01:26:59.583-0400 I JOURNAL  [initandlisten] preallocateIsFaster=true 4.26
2015-10-27T01:26:59.854-0400 I JOURNAL  [initandlisten] preallocateIsFaster=true 3
2015-10-27T01:27:01.562-0400 I JOURNAL  [initandlisten] preallocateIsFaster=true 10.6
2015-10-27T01:27:01.562-0400 I JOURNAL  [initandlisten] preallocating a journal file /data01/mongoDB/db/journal/prealloc.0
2015-10-27T01:27:08.844-0400 I -        [initandlisten]   File Preallocator Progress: 471859200/1073741824 43%
2015-10-27T01:27:11.207-0400 I -        [initandlisten]   File Preallocator Progress: 681574400/1073741824 63%
2015-10-27T01:27:14.075-0400 I -        [initandlisten]   File Preallocator Progress: 775946240/1073741824 72%
2015-10-27T01:27:17.134-0400 I -        [initandlisten]   File Preallocator Progress: 859832320/1073741824 80%
2015-10-27T01:27:21.530-0400 I -        [initandlisten]   File Preallocator Progress: 933232640/1073741824 86%
2015-10-27T01:27:26.223-0400 I -        [initandlisten]   File Preallocator Progress: 996147200/1073741824 92%
2015-10-27T01:27:37.468-0400 I JOURNAL  [initandlisten] preallocating a journal file /data01/mongoDB/db/journal/prealloc.1
2015-10-27T01:27:40.330-0400 I -        [initandlisten]   File Preallocator Progress: 471859200/1073741824 43%
2015-10-27T01:27:43.282-0400 I -        [initandlisten]   File Preallocator Progress: 566231040/1073741824 52%
2015-10-27T01:27:47.742-0400 I -        [initandlisten]   File Preallocator Progress: 608174080/1073741824 56%
2015-10-27T01:27:50.298-0400 I -        [initandlisten]   File Preallocator Progress: 744488960/1073741824 69%
2015-10-27T01:27:53.087-0400 I -        [initandlisten]   File Preallocator Progress: 817889280/1073741824 76%
2015-10-27T01:27:56.464-0400 I -        [initandlisten]   File Preallocator Progress: 901775360/1073741824 83%
2015-10-27T01:27:59.441-0400 I -        [initandlisten]   File Preallocator Progress: 964689920/1073741824 89%
2015-10-27T01:28:02.206-0400 I -        [initandlisten]   File Preallocator Progress: 1038090240/1073741824 96%
2015-10-27T01:28:17.693-0400 I JOURNAL  [initandlisten] preallocating a journal file /data01/mongoDB/db/journal/prealloc.2
2015-10-27T01:28:20.164-0400 I -        [initandlisten]   File Preallocator Progress: 492830720/1073741824 45%
2015-10-27T01:28:23.287-0400 I -        [initandlisten]   File Preallocator Progress: 566231040/1073741824 52%
2015-10-27T01:28:26.361-0400 I -        [initandlisten]   File Preallocator Progress: 671088640/1073741824 62%
2015-10-27T01:28:29.421-0400 I -        [initandlisten]   File Preallocator Progress: 765460480/1073741824 71%
2015-10-27T01:28:32.484-0400 I -        [initandlisten]   File Preallocator Progress: 849346560/1073741824 79%
2015-10-27T01:28:35.216-0400 I -        [initandlisten]   File Preallocator Progress: 954204160/1073741824 88%
2015-10-27T01:28:38.353-0400 I -        [initandlisten]   File Preallocator Progress: 1038090240/1073741824 96%
2015-10-27T01:28:54.789-0400 I JOURNAL  [durability] Durability thread started
2015-10-27T01:28:54.789-0400 I JOURNAL  [journal writer] Journal writer thread started
2015-10-27T01:28:54.815-0400 I CONTROL  [initandlisten] MongoDB starting : pid=3131 port=27017 dbpath=/data01/mongoDB/db/ 64-bit host=node1.localdomain
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] db version v3.0.7
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] git version: 6ce7cbe8c6b899552dadd907604559806aa2e9bd
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] build info: Linux ip-10-101-218-12 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 BOOST_LIB_VERSION=1_49
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] allocator: tcmalloc
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] options: { storage: { dbPath: "/data01/mongoDB/db/" } }
2015-10-27T01:28:54.922-0400 I INDEX    [initandlisten] allocating new ns file /data01/mongoDB/db/local.ns, filling with zeroes...
2015-10-27T01:28:55.376-0400 I STORAGE  [FileAllocator] allocating new datafile /data01/mongoDB/db/local.0, filling with zeroes...
2015-10-27T01:28:55.376-0400 I STORAGE  [FileAllocator] creating directory /data01/mongoDB/db/_tmp
2015-10-27T01:28:55.554-0400 I STORAGE  [FileAllocator] done allocating datafile /data01/mongoDB/db/local.0, size: 64MB,  took 0.156 secs
2015-10-27T01:28:55.569-0400 I NETWORK  [initandlisten] waiting for connections on port 27017

[oracle@node1 sf_SOFTWARES]$ ps -ef| grep mongo
oracle    3131  2884  2 01:26 pts/0    00:00:03 mongod --dbpath /data01/mongoDB/db/


4 . Begin using MongoDB.

[oracle@node1 bin]$ ./mongo

./mongo: /usr/lib64/libssl.so.10: no version information available (required by ./mongo)
./mongo: /usr/lib64/libcrypto.so.10: no version information available (required by ./mongo)
./mongo: /usr/lib64/libcrypto.so.10: no version information available (required by ./mongo)
MongoDB shell version: 3.0.7
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-10-27T01:28:54.823-0400 I CONTROL  [initandlisten]
>
> db
test

Saturday 10 October 2015

Configure DDL replication for GoldenGate

[oracle@node1 ggs]$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

GGSCI (node1.localdomain) 1> edit params ./GLOBALS
GGSCHEMA ggadmin

SQL> alter system set recyclebin=off deferred ;

System altered.


SQL> grant restricted session to ggadmin ;

Grant succeeded.

[oracle@node1 ggs]$ pwd
/data01/oracle/ggs
[oracle@node1 ggs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Oct 10 03:34:49 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @marker_setup.sql

Marker setup script

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:GGADMIN


Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGADMIN

MARKER TABLE
-------------------------------
OK

MARKER SEQUENCE
-------------------------------
OK

Script complete.


SQL> @ddl_setup.sql

Oracle GoldenGate DDL Replication setup script

Verifying that current user has privileges to install DDL Replication...

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:GGADMIN

Working, please wait ...
Spooling to file ddl_setup_spool.txt

Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...

Check complete.



Using GGADMIN as a Oracle GoldenGate schema name.

Working, please wait ...

DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGADMIN

CLEAR_TRACE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

CREATE_TRACE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

TRACE_PUT_LINE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

INITIAL_SETUP STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDLVERSIONSPECIFIC PACKAGE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDLREPLICATION PACKAGE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDLREPLICATION PACKAGE BODY STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDL IGNORE TABLE
-----------------------------------
OK

DDL IGNORE LOG TABLE
-----------------------------------
OK

DDLAUX PACKAGE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDLAUX PACKAGE BODY STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

SYS.DDLCTXINFO PACKAGE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

SYS.DDLCTXINFO PACKAGE BODY STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDL HISTORY TABLE
-----------------------------------
OK

DDL HISTORY TABLE(1)
-----------------------------------
OK

DDL DUMP TABLES
-----------------------------------
OK

DDL DUMP COLUMNS
-----------------------------------
OK

DDL DUMP LOG GROUPS
-----------------------------------
OK

DDL DUMP PARTITIONS
-----------------------------------
OK

DDL DUMP PRIMARY KEYS
-----------------------------------
OK

DDL SEQUENCE
-----------------------------------
OK

GGS_TEMP_COLS
-----------------------------------
OK

GGS_TEMP_UK
-----------------------------------
OK

DDL TRIGGER CODE STATUS:

Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors

DDL TRIGGER INSTALL STATUS
-----------------------------------
OK

DDL TRIGGER RUNNING STATUS
-----------------------------------
ENABLED

STAYMETADATA IN TRIGGER
-----------------------------------
OFF

DDL TRIGGER SQL TRACING
-----------------------------------
0

DDL TRIGGER TRACE LEVEL
-----------------------------------
0

LOCATION OF DDL TRACE FILE
------------------------------------------------------------------------------------------------------------------------
/data01/app/oracle/diag/rdbms/ggsrc/ggsrc/trace/ggs_ddl_trace.log

Analyzing installation status...


STATUS OF DDL REPLICATION
------------------------------------------------------------------------------------------------------------------------
SUCCESSFUL installation of DDL Replication software components

Script complete.
SQL>

SQL> @role_setup.sql

GGS Role setup script

This script will drop and recreate the role GGS_GGSUSER_ROLE
To use a different role name, quit this script and then edit the params.sql script to change the gg_role parameter to the preferred name. (Do not run the script.)

You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter GoldenGate schema name:GGADMIN
Wrote file role_setup_set.txt

PL/SQL procedure successfully completed.


Role setup script complete

Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:

GRANT GGS_GGSUSER_ROLE TO <loggedUser>

where <loggedUser> is the user assigned to the GoldenGate processes.

SQL> grant GGS_GGSUSER_ROLE to HR ;

Grant succeeded.

SQL> revoke GGS_GGSUSER_ROLE from ggadmin ;

Revoke succeeded.

SQL> @ddl_enable.sql

Trigger altered.

Oracle is now ready to replicate DDL operation along with DML operations . You can now configure the extract process with DDLOPTIONS paramter to  control DDL replication for that extract process .

Create dblink for an user

declare
uid number;
sqltext varchar2(1000) := 'CREATE DATABASE LINK TEST CONNECT TO "TEST_USER" IDENTIFIED BY "TestPWD" USING ''TEST_TNS''' ;
myint integer;
begin
select user_id into uid from all_users where username like 'MYUSER';
myint:=sys.dbms_sys_sql.open_cursor();
sys.dbms_sys_sql.parse_as_user(myint,sqltext,dbms_sql.native,UID);
sys.dbms_sys_sql.close_cursor(myint);
end ;


SQL> select host , db_link , owner  from  dba_db_links where db_link like '%TEST%' ;

    DB_LINK                 OWNER               HOST
----------------------------------------------------------------------
    TEST                    MYUSER              TEST_TNS