Thursday, September 17, 2015

Setup VNC server

On Linux  Server as root

Install Software  using  yum repository
yum install vnc-server
yum -y install libXfont
yum install xterm
yum install xorg

Change a File  & Add oracle and Port
vi /etc/sysconfig/vncservers
VNCSERVERS="1:oracle"
VNCSERVERARGS[1]="-geometry 800x600"

Now Change the Password for ONC user
sudo su - oracle
vncpasswd

set password= oracle
As root Start the service

chkconfig --list | grep -i vnc
service vncserver stop
service vncserver start

As root Start the service
maybe stop iptables
service iptables stop

Now Connect to the Box using VNC Client
Download a vnc client such as VNC-Viewer-5.2.3-Windows-32bit  (  yes it is 32 on 64bit box)



Q: How can I run multiple VNC server sessions on the same server at the same time by different users?

Ans:
Open the main config file and add all the users along with any of the id as shown below. So that the user will logon using that ID using vnc client.

# vi /etc/sysconfig/vncservers
VNCSERVERS="2:root 4:deepak "

Once done save the file and assign a vnc pwd to each user manually by logging into their account

NOTE: Make sure you login to the users account for assigning them password or else the vncserver services would not run properly for all the users

# su - deepak

$ vncpasswd
Password: [Give the password for VNC]
Verify: [Retype the password for VNC]
Restart the vncserver services
# service vncserver restart
Shutting down VNC server: 2:root 4:deepak                  [  OK  ]
Starting VNC server: 2:root
New 'server.example.com:2 (root)' desktop is server.example.com:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/server.example.com:2.log

4:deepak
New 'server.example.com:4 (deepak)' desktop is  server.example.com:4

Starting applications specified in /home/deepak/.vnc/xstartup
Log file is /home/deepak/.vnc/server.example.com:4.log

                                                            [  OK  ]
Now you can login to the Linux machine using VNC viewer client using the below syntax

192.168.0.100:2 ==> for user root
192.168.0.100:4 ==> for user deepak

You can also login to the server using your browser. Type the following links for the same

http://server-ip:5802 ==> for user root
http://server-ip:5804 ==> for user deepak

NOTE:
As you can see the port no. when you are trying to access your machine through the browser. It defines the ID of the user which you have assigned in the configuration file.

For example:

2:root - 5802
4:deepak - 5804
 

Saturday, August 29, 2015

Linux Symbolic Links

##########################################################################
Create a Soft or link between the Directories
##########################################################################

Situation :We have 2 databases with the Wallet Directory and files
We are going to move wallet to a Common location /deploy/database_wallet/
==========================================================================

/apps/oracle/product/11.2.0/db/admin/DB1/wallet/
                                                                                              -- a.txt
                                                                                              -- b.txt

/apps/oracle/product/11.2.0/db/admin/DB2/wallet/
                                                                                              -- c.txt
                                                                                              -- d.txt

Desired(Complete Directory and Contents should mapped to /deploy location
============================================================================
It should look like this

/apps/oracle/product/11.2.0/db/admin/DB1/wallet -> /deploy/database_wallet/DB1/wallet

/apps/oracle/product/11.2.0/db/admin/DB2/wallet -> /deploy/database_wallet/DB2/wallet

Work
=============================================================================
                                               
1) Create directories to the New Location which is /deploy & Change the Permissions

    mkdir -p /deploy/database_wallet/DB1/wallet
    mkdir -p /deploy/database_wallet/DB2/wallet

2) Copy original files which to the new Location

   copy  a.txt, b.txt to

   /deploy/database_wallet/DB1/wallet

   copy  c.txt, d.txt to

   /deploy/database_wallet/DB2/wallet

3) Now we have this

     /deploy/database_wallet/DB1/wallet/
                                                                         -- a.txt
                                                                         -- b.txt

     /deploy/database_wallet/DB2/wallet/
                                                                         -- c.txt
                                                                        -- d.txt

4) Now time to remove the Old Location (ONLY WALLET) and Map it to the New one
  
    rm -rd /apps/oracle/product/11.2.0/db/admin/DB1/wallet
    rm -rd /apps/oracle/product/11.2.0/db/admin/DB2/wallet

   Now the Old Location do not have wallet Directory at all

   Time to create a Directory with the Link

   ln -s /deploy/database_wallet/DB1/wallet    /apps/oracle/product/11.2.0/db/admin/DB1/wallet

   ln -s /deploy/database_wallet/DB2/wallet    /apps/oracle/product/11.2.0/db/admin/DB2/wallet


Now Checking
 
   ls -l /apps/oracle/product/11.2.0/db/admin/DB1

       lxxx xxx xxx /apps/oracle/product/11.2.0/db/admin/DB1/wallet -> /deploy/database_wallet/DB1/wallet



Friday, August 21, 2015

MySQL Useful Commands


========================================
                                            Misc Info
========================================

select database();  <- List Current Database

select version();   <- List Current version

select current_date, current_time,now(), database();

========================================
                            Create/Grant/Drop/Privs User
========================================

Note 1: user info is stored in database name called "mysql" and table "user"
Note 2: If you specify only the user name part of the account name, a host name part of '%' is used.
Note 3: If you want user to connect database from any machine then do not provide HOST in the user creation
Note 4: Must Grant to connect to specific database *.* will give access to all databases;

DESC mysql.user;

DROP user 'mysql'@'dbaovm03';

CREATE  user user1 identified by 'mysql';  

GRANT ALL ON db1.* to db1_user1;

CREATE USER 'mysql'@'%'; identified by 'mysql' [WITH GRANT OPTION];

GRANT ALL ON  *.* to user1  [WITH GRANT OPTION];

SELECT user,host,db from mysql.db where db = "*<database_name>*";

SELECT user,host,db from mysql.user;

SELECT * FROM mysql.tables_priv ;

SELECT * FROM mysql.columns_priv  ;

SELECT * FROM mysql.procs_priv  ;

SELECT CONCAT(QUOTE(user),'@',QUOTE(host)) UserAccount FROM mysql.user;

---------------------------------------------------------------------------------------------------------------------
Connect       -> mysql -uroot -pmysql [dbname]  (Do not put any space between -p (lower p) and pwd to avoid pwd prompt)
                        mysql --user=root --password=mysql
                        mysql -u root -pmysql -h localhost
                        mysql -u root -pmysql -h localhost -P 3306    [OK] for port "Caps P"
                        mysql -u root  -p mysql  --> prompt for the pwd and try to connect dbname=mysql

mySql Process while runnig -> ps -ef | grep -i mysqld_safe
                                                  ps -ef | grep -i /usr/bin/mysqld

list session current values    -> mysql>show status ;

list parameteres               -> mysql>show variables like '%';
                                            mysqladmin  -u root -p variables

Change Parater               -> mysql>set bulk_insert_buffer_size=40000;

list Databases                -> mysql>show databases

Create Database            -> mysql>create database [mycustomer];

List Tables                     -> mysql>show tables in information_schema;   [ show tables in DATABASE]

Desc Tables                   -> mysql>describe [tab]
                                           mysql>show columns from [tab];
Create table                   -> mysql>use [db]create table [tab](id integer primary key,nm varchar(30), ph varchar(10));

drop table                      -> mysql>use [db] , drop table [table Name]

drop database                -> mysqladmin -u root -p drop [dbname]

Error Log Default         -> /var/lib/mysql...

Commit                         -> mysql>commit;

help                               -> mysql>help   , mysql> help
                                                                                                                       
Load Data                     -> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;
                                     -> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet  LINES TERMINATED BY '\r\n';
                                     -> INSERT INTO pet VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);

start/stop                      -> service mysql start/stop
                                         /etc/init.d/mysql stop
                                         sudo -u mysql /usr/local/mysql/bin/mysqld stop
                                         mysqladmin -u root -p   shutdown

status details                 -> mysql> status 
                                         #mysqladmin -u root -p     status | extended-status
                                         #mysqladmin -uroot -ppwd   status | extended-status

Check Mysql is alive    ->  mysqladmin -uroot -p ping
                                          Output:mysqld is alive

                                           mysqladmin -uroot -p processlist

reload privs                -> mysqladmin -u root -p reload; mysqladmin -u root -p refresh

Dump a database        -> mysqldump -u root -p [dbname] > output_filename.sql

Restore database        -> mysql> create database [dbname];  mysql -u root -p [dbname] < dumpfile_name.sql

Drop column              -> msql>  ALTER TABLE [tableName] drop [ColumnName];

Rename Table            -> mysql> RENAME TABLE [tableA] TO [tableB];

========================================
   MYSQL from Command prompt
   You can add all commands in one lin eand execute
========================================
-- Prompt update and redirect output
mysql -u oas_user -p oas_user oas "update accounts a, password_reset_tokens t set status = 'Stub_Expired' 
where a.id = t.account_id and t.created_at < date_sub(sysdate(), INTERVAL 47 HOUR); commit;" > /tmp/expire_pending_accounts.output.txt

-- Prompt deletes and redirect output
mysql -u oas_user -p oas_user oas "delete from change_events where account_id in (select id from accounts where username LIKE '%@system.test.com'); delete from password_reset_tokens where account_id in (select id from accounts where username LIKE '%@system.test.com'); delete from accounts where username LIKE '%@system.test.com'; commit;" > /tmp/purge_test_accounts.output.txt

mysql -uoas_user -poas_user oas -e"select count(1) from information_schema.tables;"

mysql -uoas_user -poas_user oas -e"select count(1) from information_schema.tables;" > drew.txt

========================================
   MYSQL FLUSH
========================================

# mysqladmin -u root -p variables
# mysqladmin -u root -p kill 5
# mysqladmin -u root -p flush-hosts
# mysqladmin -u root -p flush-tables
# mysqladmin -u root -p flush-threads
# mysqladmin -u root -p flush-logs
# mysqladmin -u root -p flush-privileges
# mysqladmin -u root -p flush-status           

mysql> show storage engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                                    | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| MyISAM             | YES     | MyISAM storage engine                                          | NO          | NO | NO |
| CSV                     | YES     | CSV storage engine                                                 | NO           | NO | NO |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                   | NO           | NO | NO |
| BLACKHOLE      | YES     | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables     | NO| NO | NO |
| InnoDB                | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES  | YES |
| ARCHIVE              | YES     | Archive storage engine                                         | NO | NO| NO |
| PERFORMANCE_ SCHEMA | YES     | Performance Schema                          | NO| NO| NO|
| FEDERATED          | NO      | Federated MySQL storage engine                        | NULL | NULL| NULL|
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+

mysql> SHOW ENGINE INNODB MUTEX;
+--------+------------------------------+------------+
| Type   | Name                         | Status     |
+--------+------------------------------+------------+
| InnoDB | &buf_pool->flush_state_mutex | os_waits=1 |
| InnoDB | &log_sys->checkpoint_lock    | os_waits=2 |
+--------+------------------------------+------------+
========================================
Command Line
========================================
--basedir=e: /mysql
--datadir=d: /mysqldata
or

mysql --defaults-file=c:\my-opts

refrence other file
!include    file_name
!includedir dir_name

========================================
                        Logs and Locations
========================================

option file location  :   /etc/my.cnf  or $MYSQL_HOME/my.cnfor  or ~/.my.cnf
mysql can write to several types of logs
 
syslog: mysqld_safe option
--syslog[=tag]
--skip-syslog(default)

Or
general Query log     ,   slow query log    .  binay log

you can start server with file name ow everything will goto screen
 
mysqld --log-error=filename

hostname.err
mysqld_safe

general query log - Logs all SQL received by the server/Client Connections

You may also write in a table general_log tables in mysql database

SET GLOBAL general_log='ON'

SET GLOBAL general_log='OFF'

General QUERY LOG
------------------------------
set general_log to enable/disable
Set general_log_file to specify name of the logfile

--log-output options
1) TABLE -log to tables
2) FILE  -log to files
1) NONE  - do not log to tables or  files

Slow Query Log ( file or Table)
--------------------------------
Set server variable , Log query executing time longer than  long_query_time server  variable (in Sec)

Enable log
slow_query_log  or  slow_query_log_file=filename

Not Index Queries

--log-queries-not-using-indexes

mysql_install_db --user=mysql --datadir=/data/mysql/data

mysql_install_db --user=root --datadir=/data/mysql/data

DEFAULT database and Log /Err Location : /var/lib/mysql
DEFAULY cnf location /etc/my.cnf

========================================
  ==== MySQL Client Based programs ===
========================================

mysql
mysqladmin
mysqlimport
mysqldump

mysql -uroot --skip-column-names -rsp
mysql --host=<> --port=3351 --user=ro

Terminator
: or \g
\G ( Specifies vertical display of output)
\c (don't send current statement to server)
 
mysql> prompt aa >
PROMPT set to 'aa >'
aa >

root@localhostmysql>prompt \u@\h \d>
PROMPT set to '\u@\h \d>'
root@localhost mysql>


Adarsh Kumar
AK Technosoft Corp.
Database Design and  Consulting 

Saturday, May 23, 2015

Linux Basic Videos

--Basic Linux Tasks
https://www.youtube.com/watch?v=OnSUX2otYos

-- linux Commands
https://www.youtube.com/watch?v=_TlK0-5EJ-Y

-- Navigation in Linux
https://www.youtube.com/watch?v=OQZgrBDJ-js

-- Linux File Layout
https://www.youtube.com/watch?v=svh8sSuz5BI
https://www.youtube.com/watch?v=zRw0SKaXSfI
https://www.youtube.com/watch?v=ar37viZGQwk

-- Users, Groups and Permissions in Linux
https://www.youtube.com/watch?v=zRw0SKaXSfI

-- Linux Processes
https://www.youtube.com/watch?v=ls5cGi12kGw
https://www.youtube.com/watch?v=vsEJz9aKGKU
https://www.youtube.com/watch?v=0XdjODvsRN8
https://www.youtube.com/watch?v=svh8sSuz5BI

--Introduction to Servers
https://www.youtube.com/watch?v=CDxaRfwzFrs


-- Introduction to Networking
https://www.youtube.com/watch?v=rL8RSFQG8do

--Linux Network Configuration
https://www.youtube.com/watch?v=PEa1xopeufQ

--Administration of Networks in Linux - Linux Tutorial Series
https://www.youtube.com/watch?v=eqS-7wsWtsQ

--Introduction to Domains
https://www.youtube.com/watch?v=ut_oLhMhJsY&list=PLF360ED1082F6F2A5&index=20

--SSH and FTP for Remote Administration
https://www.youtube.com/watch?v=o-W_mDGX1bY

--Introduction to DHCP
https://www.youtube.com/watch?v=g7mroO_BLD0

-- Introduction to DNS (Domain Name Services)
https://www.youtube.com/watch?v=VwpP8PUzqLw

-- Network Mapping
https://www.youtube.com/watch?v=_uIOdTfp6Pw

--Troubleshooting Problems in a Linux System - Linux Tutorial Series
https://www.youtube.com/watch?v=nNo6lpCCKl0

-- Troubleshooting Problems in a Linux System Part 2
https://www.youtube.com/watch?v=8lNgMJzr8i8

--Troubleshooting Problems in a Linux System Part 3
https://www.youtube.com/watch?v=cyTi4v3q3VA

Saturday, January 31, 2015

Other Good Blogs & Scripts

Script Location from ORACLE-BASE


http://oracle-base.com/dba/scripts.php
.
--- Blogs ---




http://pjacksondba.blogspot.com/

http://tkyte.blogspot.com/

http://blog.tanelpoder.com/

http://jonathanlewis.wordpress.com/

http://carymillsap.blogspot.com/

http://karenmorton.blogspot.com/




Database Server Upgrade/Downgrade Compatibility Matrix (Doc ID 551141.1)
Patching & Maintenance Advisor: Database (DB) Oracle Database 11.2.0.x (Doc ID 331.1)
Oracle Recommended Patches -- Oracle Database (Doc ID 756671.1)
Introduction to Oracle Recommended Patches (Doc ID 756388.1)
Oracle Recommended Patches (PSU) for Enterprise Manager Base Platform (All Releases) (Doc ID 822485.1)
-- For Upgrade and Install
Oracle® Grid Infrastructure Installation Guide 12c Release 1 (12.1) for Microsoft Windows x64 (64-Bit)  E49041-03
-- Oracle Database Online Documentation 12c Release 1 (12.1)
https://docs.oracle.com/database/121/nav/portal_11.htm
Oracle® Grid Infrastructure Installation Guide 11g Release 2 (11.2) for IBM AIX on POWER Systems (64-Bit) E48294-01
Oracle® Grid Infrastructure Installation Guide 12c Release 1 (12.1) for IBM AIX on POWER Systems (64-Bit)
-- For Upgrade and Install
http://mirrors.iyunwei.com/oracle/docs/12.1-E16655-01/install.121/e38943.pdf
--
Oracle Database 12c R1 RAC on IBM AIX
http://www-03.ibm.com/support/techdocs/atsmastr.nsf/5cb5ed706d254a8186256c71006d2e0a/781e2275188c706886257c98006b1c6e/$FILE/IBM%20AIX%20Oracle%2012cR1-tips_SHANMUGAM%2026%20Feb%202014.pdf
--
http://docs.oracle.com/database/121/nav/portal_booklist.htm