Search This Blog

Tuesday, July 27, 2010

Physical Standby Database


Create Physical Standby Database
 
SQL> ALTER DATABASE FORCE LOGGING;
SQL> ALTER DATABASE ADD STANDBY LOGFILE [THREAD 1] [GROUP n] ('/oracle/dbs/log1c.rdo','/oracle/dbs/log2c.rdo') SIZE 50M;
SQL> SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;
SQL> CREATE PFILE FROM SPFILE;
SQL> !vi $ORACLE_HOME/dbs/initPRIM.ora
PRIM.__db_cache_size=1090519040
PRIM.__java_pool_size=16777216
PRIM.__large_pool_size=16777216
PRIM.__shared_pool_size=335544320
PRIM.__streams_pool_size=0

*.audit_file_dest       ='/opt/app/oracle/admin/PRIM/adump'
*.background_dump_dest  ='/opt/app/oracle/admin/PRIM/bdump'
*.core_dump_dest        ='/opt/app/oracle/admin/PRIM/cdump'
*.user_dump_dest        ='/opt/app/oracle/admin/PRIM/udump'

*.compatible='10.2.0.1.0'
*.db_block_size=8192
*.db_file_multiblock_read_count=16

*.db_domain=''
*.db_name='PRIM'
*.db_unique_name='PRIM'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(PRIM,STAND)'
*.control_files='/u01/oradata/PRIM/control01.ctl','/u01/oradata/PRIM/control02.ctl','/u01/oradata/PRIM/control03.ctl'

*.db_recovery_file_dest='/backup/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.log_archive_dest_10='
        LOCATION=USE_DB_RECOVERY_FILE_DEST ARCH MANDATORY REOPEN=5
        VALID_FOR=(ALL_LOGFILES, ALL_ROLES)
        DB_UNIQUE_NAME=PRIM'
*.log_archive_dest_9='
        SERVICE=STAND LGWR SYNC AFFIRM
        VALID_FOR=(ONLINE_LOGFILE, PRIMARY_ROLE)
        DB_UNIQUE_NAME=STAND'
LOG_ARCHIVE_DEST_STATE_10=ENABLE
LOG_ARCHIVE_DEST_STATE_9=ENABLE
STANDBY_FILE_MANAGEMENT=AUTO
*.log_archive_format='%t_%s_%r.arc'
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=STAND
FAL_CLIENT=PRIM
DB_FILE_NAME_CONVERT='/u01/oradata/STAND/','/u01/oradata/PRIM/','/u02/oradata/STAND/','/u02/oradata/PRIM/'
LOG_FILE_NAME_CONVERT='/u01/oradata/STAND/','/u01/oradata/PRIM/','/u02/oradata/STAND/','/u02/oradata/PRIM/'

*.dispatchers='(protocol=TCP)'
*.job_queue_processes=10
*.max_dispatchers=10
*.open_cursors=300
*.pga_aggregate_target=524288000
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1468006400
*.shared_servers=10
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;
RMAN> backup tag "full_db_archivelog" database plus archivelog;
RMAN> backup tag "standby_controlfile" current controlfile for standby; 

SQL> shutdown immediate
SQL> startup nomount
RMAN> set DBID=1111111111111
RMAN> restore standby controlfile from "/backup/STANDBY_CONTROLFILE_from_PRIMary_.bkp"
SQL> CREATE PFILE='/backup/initSTAND.ora' FROM SPFILE;
SQL> SHUTDOWN IMMEDIATE
SQL> !vi /backup/initSTAND.ora
PRIM.__db_cache_size=1090519040
PRIM.__java_pool_size=16777216
PRIM.__large_pool_size=16777216
PRIM.__shared_pool_size=335544320
PRIM.__streams_pool_size=0

*.audit_file_dest ='/opt/app/oracle/admin/STAND/adump'
*.background_dump_dest ='/opt/app/oracle/admin/STAND/bdump'
*.core_dump_dest ='/opt/app/oracle/admin/STAND/cdump'
*.user_dump_dest ='/opt/app/oracle/admin/STAND/udump'

*.compatible='10.2.0.1.0'
*.db_block_size=8192
*.db_file_multiblock_read_count=16

*.db_domain=''
*.db_name='PRIM'
*.db_unique_name='STAND'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(PRIM,STAND)'
*.control_files='/u01/oradata/STAND/control01.ctl','/u01/oradata/STAND/control02.ctl','/u01/oradata/STAND/control03.ctl'

*.db_recovery_file_dest='/backup/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.log_archive_dest_10='
        LOCATION=USE_DB_RECOVERY_FILE_DEST ARCH MANDATORY REOPEN=5
        VALID_FOR=(ALL_LOGFILES, ALL_ROLES)
        DB_UNIQUE_NAME=STAND'
*.log_archive_dest_9='
        SERVICE=PRIM LGWR SYNC AFFIRM
        VALID_FOR=(ONLINE_LOGFILE, PRIMARY_ROLE)
        DB_UNIQUE_NAME=PRIM'
LOG_ARCHIVE_DEST_STATE_10=ENABLE
LOG_ARCHIVE_DEST_STATE_9=ENABLE
STANDBY_FILE_MANAGEMENT=AUTO
*.log_archive_format='%t_%s_%r.arc'
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=PRIM
FAL_CLIENT=STAND
DB_FILE_NAME_CONVERT='/u01/oradata/PRIM/','/u01/oradata/STAND/','/u02/oradata/PRIM/','/u02/oradata/STAND/'
LOG_FILE_NAME_CONVERT='/u01/oradata/PRIM/','/u01/oradata/STAND/','/u02/oradata/PRIM/','/u02/oradata/STAND/'

*.dispatchers='(protocol=TCP)'
*.job_queue_processes=10
*.max_dispatchers=10
*.open_cursors=300
*.pga_aggregate_target=524288000
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1468006400
*.shared_servers=10
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
SQL> STARTUP pfile='/backup/initSTAND.ora' MOUNT
RMAN> restore database;
RMAN> list backup of archivelog all;
RMAN> recover database until sequence (above_seq# + 1);
SQL> SELECT GROUP#, SEQUENCE#, THREAD#, BYTES, USED, ARCHIVED, STATUS FROM V$STANDBY_LOG;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP pfile='/backup/initPRIM.ora' NOMOUNT
SQL> CREATE SPFILE FROM PFILE='/backup/initPRIM.ora'
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP
Switchover
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
  ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY *
  ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected
SQL> SELECT SID, SERIAL#,PROCESS, PROGRAM FROM V$SESSION WHERE TYPE='USER' AND SID <>(SELECT DISTINCT SID FROM V$MYSTAT);
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
Failovers
SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;
SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE 'file_paths'; 
SQL> SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#) OVER (PARTITION BY thread#) AS LAST from 
V$ARCHIVED_LOG; SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE 'file_paths';
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH SKIP; 
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;

Summary of Oracle commands


Listener & Connect:
Easy connect:
SQL> CONNECT hr/hr@host1.home.com:1521/dba10g
SQL> CONNECT username/passwd@10.10.10.10:1521/SERVICE_NAME
$ sqlplus xxxx/yyyy@10.l0.10.10:1521/SERVICE_NAME
$ sqlplus xxxx/yyyy@"(description=(address=(protocol=TCP) (host=10.10.10.10) (port=1521)) (connect_data=(SID=DEV)))"

Test Listener:
$ tnsping db.us.oracle.com:1521/dba10g
$ tnsping orcl
$ ps -ef | grep tns
$ netstat -lt | grep 1521
$ netstat -anp|grep 1521
$ watch -n 1 "lsnrctl services"

Register a new listener:
in tnsnames.ora add:
my_local_lsn= (ADDRESS = (PROTOCOL = TCP)(Host = x.x.x.x)(Port = 1521))

in sqlplus:
ALTER SYSTEM SET LOCAL_LISTENER='my_local_lsn';

OR:

without any changes in tnsnames.ora:

ALTER SYSTEM SET LOCAL_LISTENER='(ADDRESS = (PROTOCOL = TCP)(Host = x.x.x.x)(Port = 1521))';

 Oracle Enterprise Manager 10g Database Control:
# emca -deconfig dbcontrol db (to drop old config files)
# emca -config dbcontrol db (to create new config files)
# emca -config dbcontrol db -repos recreate


 Flashback:
  • Row movement must be enabled on the table that you are performing the flashback operation on:
ALTER TABLE employees ENABLE ROW MOVEMENT;
  • Flashback Query:
UPDATE employees SET salary =
(SELECT salary FROM employees
AS OF TIMESTAMP TO_TIMESTAMP
('2005-05-0411:00:00','yyyy-mm-ddhh24:mi:ss')
WHERE employee_id = 200)
WHERE employee_id = 200;
SELECT versions_xid, salary FROM employees
VERSIONS BETWEEN TIMESTAMP t1 and t2
WHERE employee_id = 200;

Tuesday, July 20, 2010

Memory Requirements for Oracle 11g

The following are the memory requirements for installing Oracle Database 11g release 2 (11.2):
■ At least 1 GB of RAM
To determine the RAM size, enter the following command:
# grep MemTotal /proc/meminfo
If the size of the RAM is less than the required size, then you must install more memory before continuing.

■ The following table describes the relationship between installed RAM and the configured swap space requirement:
Note: On Linux, the HugePages feature allocates non-swappable memory for large page tables using memory-mapped files. If you enable HugePages, then you should deduct the memory allocated to HugePages from the available RAM before calculating swap space.

Available                                  RAM Swap Space Required
Between 1 GB and 2 GB            1.5 times the size of RAM
Between 2 GB and 16 GB          Equal to the size of RAM 
More than 16 GB                       16 GB

■ To determine whether the system architecture can run the software, enter the following command:
# grep "model name" /proc/cpuinfo

Note: This command displays the processor type. Verify that the processor architecture matches the Oracle software release that you want to install. If you do not see the expected output, then you cannot install the software on this system.

To determine the size of the configured swap space, enter the following command:
# grep SwapTotal /proc/meminfo
If necessary, refer to the operating system documentation for information about how to configure additional swap space.
To determine the available RAM and swap space, enter the following command:
# free

Note: Oracle recommends that you take multiple values for the available RAM and swap space before finalizing a value. This is because the available RAM and swap space keep changing depending on the user interactions with the computer.

Automatic Memory Management
Starting with Oracle Database 11g, the Automatic Memory Management feature requires more shared memory (/dev/shm)and file descriptors. The shared memory should be sized to be at least the greater of MEMORY_MAX_TARGET and MEMORY_TARGET for each Oracle instance on that computer. 
To determine the amount of shared memory available, enter the following command:
# df -k /dev/shm/

Note: MEMORY_MAX_TARGET and MEMORY_TARGET cannot be used when LOCK_SGA is enabled or with HugePages on Linux.

Tuesday, July 6, 2010

Oracle 10g Release 2 Grid Control Installation On Red Hat Enterprise Linux and CentOS

In this article I'll describe the installation of Oracle 10g Release 2 Grid Control on Red Hat Enterprise Linux and CentOS. The article is based on a server installation with a minimum of 2G swap, secure Linux disabled and the following package groups installed:

  • X Window System
  • GNOME Desktop Environment
  • Editors
  • Graphical Internet
  • Text-based Internet
  • Server Configuration Tools
  • Development Tools
  • Administration Tools
  • System Tools
The Oracle 10g Grid Control allows you to monitor all aspects of your infrastructure including database and application servers. Like the Oracle9i Management Server it replaces, the grid control requires a database repository. A complete installation includes a repository in a 10.1.0.4.0 database. It is possible to install the repository in an existing database of a different version, but I try to install the product as it is shipped.

The grid control uses agents on each server to enable monitoring and interaction. As a result, once the grid control is installed it is necessary to install an agent on each server you wish to monitor. The installation of an agent is described in it's owner section. All other tasks relate only to the grid control.

Download Software

Download the following software:
For convenience you may want to download the agent distribution separately. If you are monitoring servers on different platforms the relevant agents must be downloaded.

Unpack Files

First unzip the grid control installation files:
unzip Linux_Grid_Control_full_102010_disk1.zip
unzip Linux_Grid_Control_full_102010_disk2.zip
unzip Linux_Grid_Control_full_102010_disk3.zip

Hosts File

The /etc/hosts file must contain a fully qualified name for the server:
    

Set Kernel Parameters

Modify the /etc/sysctl.conf file to include the lines appropriate to your operating system:
# Red Hat Enterprise Linux 3.0 and CentOS 3.x
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.shmmin = 1
kernel.shmseg = 10
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536


# Red Hat Enterprise Linux 4.0 and CentOS 4.x
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.shmall = 2097152
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
Run the following command to change the current kernel parameters:
/sbin/sysctl -p
Disable secure linux by editing the /etc/selinux/config file, making sure the SELINUX flag is set as follows:
SELINUX=disabled
Alternatively, this alteration can be done using the GUI tool (Applications > System Settings > Security Level). Click on the SELinux tab and disable the feature.

Setup

The documentation states that the following packages are required by the relevant operating systems:
# Red Hat Enterprise Linux 3.0 and CentOS 3.x
glibc-2.2.4-31.7
make-3.79
binutils-2.11.90.0.8-12
gcc-2.96
openmotif21-2.1.30-11


# Red Hat Enterprise Linux 4.0 and CentOS 4.x
glibc-2.3.4-2.9
make-3.79
binutils-2.15.92.0.2-13
gcc-3.4.3-22.1
libaio-0.3.96
glibc-common-2.3.4-2.9
setarch-1.6-1
pdksh-5.2.14-30
openmotif21-2.1.30-11
sysstat-5.0.5-1
gnome-libs-1.4.1.2.90-44.1
libstdc++-3.4.3-22.1
libstdc++devel-3.4.3-22.1
compat-libstdc++-296-2.96-132.7.2
compat-db-4.1.25-9
control-center-2.8.0-12
xscreensaver-4.18-5.rhel4.2
Depending on the update/respin version of Red Hat or CentOS, the exact package versions and locations may vary. The installation of the required packages is shown below, with the versions and locations relevant for CentOS 4.1. The commented packages represent those that are already loaded.
# From CentOS 4.1 Disk 1
cd /media/cdrom/CentOS/RPMS
#rpm -Uvh glibc-2.3.4-2.9.i386.rpm
#rpm -Uvh glibc-common-2.3.4-2.9.i386.rpm
#rpm -Uvh make-3.80-5.i386.rpm
#rpm -Uvh binutils-2.15.92.0.2-13.i386.rpm
#rpm -Uvh setarch-1.6-1.i386.rpm
#rpm -Uvh pdksh-5.2.14-30.i386.rpm
#rpm -Uvh libstdc++-3.4.3-22.1.i386.rpm
rpm -Uvh compat-libstdc++-33-3.2.3-47.3.i386.rpm

# From CentOS 4.1 Disk 2
cd /media/cdrom/CentOS/RPMS
#rpm -Uvh gcc-3.4.3-22.1.i386.rpm
#rpm -Uvh gnome-libs-1.4.1.2.90-44.1.i386.rpm
#rpm -Uvh libstdc++-devel-3.4.3-22.1.i386.rpm
#rpm -Uvh compat-db-4.1.25-9.i386.rpm
#rpm -Uvh control-center-2.8.0-12.i386.rpm
#rpm -Uvh xscreensaver-4.18-5.rhel4.2.i386.rpm

# From CentOS 4.1 Disk 3
cd /media/cdrom/CentOS/RPMS
rpm -Uvh libaio-0.3.103-3.i386.rpm
rpm -Uvh openmotif21-2.1.30-11.RHEL4.4.i386.rpm
rpm -Uvh sysstat-5.0.5-1.i386.rpm
rpm -Uvh compat-libstdc++-296-2.96-132.7.2.i386.rpm
Create the new groups and users:
groupadd oinstall
groupadd dba
groupadd oper

useradd -g oinstall -G dba -s /bin/ksh oracle
passwd oracle
Create the directories in which the Oracle software will be installed:
mkdir -p /u01/app/oracle/product/10.2.0/oms10g
mkdir -p /u01/app/oracle/product/10.2.0/db10g
mkdir -p /u01/app/oracle/product/10.2.0/agent10g
chown -R oracle:oinstall /u01
Login as root and issue the following command:
xhost +
Login as the oracle user and add the following lines at the end of the .profile file:
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db10g; export ORACLE_HOME
ORACLE_SID=emrep; export ORACLE_SID
PATH=.:/usr/sbin:#$ORACLE_HOME/bin:$PATH; export PATH
PATH=$PATH:$ORACLE_HOME/dcm/bin:$ORACLE_HOME/opmn/bin; export PATH
PATH=$PATH:$ORACLE_HOME/Apache/Apache/bin; export PATH

PS1="`hostname`> "
set -o emacs
set filec

Grid Control Installation

Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable:
DISPLAY=:0.0; export DISPLAY
Start the Oracle Universal Installer (OUI) by issuing the following command in the installation software directory:
./runInstaller
During the installation select the appropriate ORACLE_HOME for the grid control (oms) and select the new database option. The installation will automatically install an agent in the agent home. For a more detailed look at the installation process, click on the links below to see screen shots of each stage.
  1. Specifiy Installation Type
  2. Specifiy Installation Location
  3. Specify Inventory directory and credentials
  4. Unsupported language message
  5. Product-Specific Prerequisite Checks
  6. Prerequisite Check warning message
  7. Specify Configuration
  8. Specify Optional Configuration
  9. Specify Security Options
  10. Summary
  11. Install - OEM Repository Database
  12. Install - OEM Grid Console
  13. Install - OEM Management Agent
  14. Execute Configuration scripts
  15. Configuration Assistants (1)
  16. Configuration Assistants (2) - Database Configuration Assistant
  17. End of Installation
On completion the grid control will be available via a browser using the following style of URL:
http://:/em
The server name and port (typically 4889) should be adjusted to the values specified in the $ORACLE_HOME/sysman/setupinfo.txt files.

Starting and Stopping Grid Control Services

The following script shows how the whole grid control is started and stopped:
# Start everything
/u01/app/oracle/product/10.2.0/db10g/bin/dbstart
/u01/app/oracle/product/10.2.0/oms10g/opmn/bin/opmnctl startall
/u01/app/oracle/product/10.2.0/agent10g/bin/emctl start agent

# Stop everything
/u01/app/oracle/product/10.2.0/agent10g/bin/emctl stop agent
/u01/app/oracle/product/10.2.0/oms10g/opmn/bin/opmnctl stopall
/u01/app/oracle/product/10.2.0/db10g/bin/dbshut
The dbstart and dbshut commands require the "/etc/oratab" file to be editied to allow auto startup/shutdown.

By default, the database supporting the repository is in NOARCHIVELOG mode.

Agent Installation

This agent installation assumes you are using a doing an installation on a Linux machine which already has a database or application server installed. As such there are no prerequisites as they should match those of the original product installation.

First, unpack the agent installation:
gunzip Linux_Grid_Control_agent_download_10_2_0_1.cpio.gz
cpio -idmv < Linux_Grid_Control_agent_download_10_2_0_1.cpio
If one doesn't already exist, make an appropriate directory for the agent software to be loaded into, like:
mkdir -p /u01/app/oracle/product
chown -R oracle:oinstall /u01
Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable:
DISPLAY=:0.0; export DISPLAY
Start the Oracle Universal Installer (OUI) by issuing the following command in the "./linux/agent" directory:
chmod -R u+x *
cd linux/agent
./runInstaller
During the installation, select the "Additional Management Agent" option, enter the installation base directory of "/u01/app/oracle/product/10.2.0" and grid control srver when prompted. The agent will be installed in the "/u01/app/oracle/product/10.2.0/agent10g" directory. For a more detailed look at the installation process, click on the links below to see screen shots of each stage.
  1. Specifiy Installation Type
  2. Specifiy Installation Location
  3. Unsupported language message
  4. Product-Specific Prerequisite Checks
  5. Specify Oracle Management Service Location
  6. Specify Agent Registration Password
  7. Summary
  8. Install
  9. Execute Configuration scripts
  10. Configuration Assistants
  11. End of Installation
With the installation complete the server should now be visible on the grid controls list of targets.

Starting and Stopping Agent Services

The following commands can be used to start and stop the agent:
# Start Agent
/u01/app/oracle/product/10.2.0/agent10g/bin/emctl start agent

# Stop Agent
/u01/app/oracle/product/10.2.0/agent10g/bin/emctl stop agent
For more information see:
Hope this helps. Regards Tim...

Summary of MySQL commands

To start, stop, restart mysql server:
$ /etc/init.d/mysqld start
$ /etc/init.d/mysqld stop
$ /etc/init.d/mysqld restart
$ /etc/init.d/mysql start
$ /etc/init.d/mysql stop
$ /etc/init.d/mysql restart
Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:
# service mysqld start
# service mysqld stop
# service mysqld restart
Setup a password for root user & Login:
# mysqladmin -u root password NEWPASSWORD
# mysql -u root -p
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD('your_new_password') where USER='The_user_@_localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit 
Getting the LOST password of root user:
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld --skip-grant-tables
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('123456') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> quit;
 Export and Import Dump:
# mysqldump -u "your_username" -p --lock-tables "your_database" > your_database_dump.sql
# mysqldump -u "your_username" -p --lock-tables --databases DB1 [DB2 DB3...] > your_database_dump.sql
# mysqldump -u "your_username" -p --lock-tables --all-databases > your_database_dump.sql
# mysql -u "your username" -p"your_database" < database_dump.sql
# mysql -u "your_username" -p < your_database_dump.sql
Privilege:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'192.168.3.10' identified by 'yourpassword' ;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE TEMPORARY TABLES ON db_name.* TO 'user_name'@'%'
mysql> Flush Privileges;
mysql> SHOW GRANTS FOR 'root'@'localhost';
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
 ERROR 1153 (08S01) at line xxx: Got a packet bigger than 'max_allowed_packet' bytes:
# vi /etc/my.cnf

[mysqld]
max_allowed_packet=100M

#/etc/init.d/mysqld restart
mysql> show variables like 'max_a%'

Monday, July 5, 2010

Identifying Open Ports/Services on Linux

Many tools are available to map open network ports to actual processes and files in
Linux. We will take a look at just one example.

First, we need to look at our listening network ports. We will utilize the ‘-anp –tcp’ flags
to the netstat command to list all processes (-a), don’t map port numbers to friendly name
(-n), list the process ID associated with the network port (-p) and for this example, we
will limit the output to only TCP listeners (--tcp):

[jklemenc]# netstat -anp --tcp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
PID/Program name  
tcp     0      0 0.0.0.0:544             0.0.0.0:*               LISTEN      1826/xinetd        
tcp     0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      4677/mysqld        
tcp     0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      16446/sshd          
tcp     0      0 0.0.0.0:2105            0.0.0.0:*               LISTEN      1826/xinetd        
tcp     0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      841/sshd            
tcp     0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      1925/httpd          

In this example, we are interested in the TCP/443 network listener. The output indicates
that httpd is running as process ID 1925 and has TCP/443 open. A quick check using the
‘ps’ command with the PID (-p) parameter to display only the PID returned above along
with a parameter to display the full path of the file (-f):

[jklemenc]# ps -p 1925 -f
UID        PID  PPID  C STIME TTY          TIME CMD
root      1925     1  0  2004 ?        00:03:36 /usr/sbin/httpd

We see from above that /usr/sbin/http is running as PID 1925 as user root.
Related Posts with Thumbnails