In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Title: construction of oracle environment under Linux
Themes:
Oracle database environment preparation
Part I: install the oracle package
1. Installation
VMware Tools
Install vmware-tools tools
Step 1. Click-> Virtual Machine-> install Vmware Tools
Step 2, df-h
[root@server253] # df-h
Filesystem Size Used Avail Use% Mounted on
/ dev/sda2 20G 8.3G 11G 45% /
/ dev/sda1 99M 12M 83M 12% / boot
Tmpfs 1.5G 0 1.5G 0% / dev/shm
/ dev/scd0 2.8G 2.8G 0100% / media/Enterprise Linux dvd 20090908
Step 3. Hang in the VMwareTools image
Mount / dev/scd0 / mnt/
Df-h
[root@server253] # df-h
Filesystem Size Used Avail Use% Mounted on
/ dev/sda2 20G 8.3G 11G 45% /
/ dev/sda1 99M 12M 83M 12% / boot
Tmpfs 1.5G 0 1.5G 0% / dev/shm
/ dev/scd0 2.8G 2.8G 0100% / media/Enterprise Linux dvd 20090908
/ dev/scd0 2.8G 2.8G 0100% / mnt
Step 4, cp / mnt/VMwareTools … / etc/opt/
Cd / opt/
Ls
Step 5. Extract the VMwareTools package
Tar-zxvf VMwareTools...
Cd vmware-tools-distrib
Ls
Step 6. / vmware-install.pl
Go all the way back to the car.
Finally, reboot.
two。 Configure ip addr
Computer name
Configure the host
Firewall Settin
1, configure the IP address
Vim / etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0C:29:D3:D9:8D
ONBOOT=yes
IPADDR=192.168.1.253
NETMASK=255.255.255.0
/ etc/init.d/network restart
Chkconfig network on
Ifconfig eth0
2, configure the computer name
Vim / etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server253.oracle.com
Modify temporary hostname
Hostname server253.oracle.com
3. Configure the host
Vim / etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
:: 1 localhost6.localdomain6 localhost6
192.168.1.253 server253.oracle.com server253
Ping server253.oracle.com
Ping server253
4, firewall settin
System-config-securitylevel
3. Configure yum repository
Click Virtual Machine-> Settings-- > CD\ DVD (SATA)-> use ISO image file (M)->
Device status-> check connected
Df-h
Mount / dev/scd0 / mnt/
Vim / etc/yum.repos.d/server.repo
[base]
Name=rhel5.4
Baseurl= file:///mnt/Server
Enabled=1
Gpgcheck=0
4. The necessity of checking the software
Checking the Software Requirements
Binutils-2.15.92.0.2-13.EL4
Compat-db-4.1.25-9-
Compat-libstdc++-296-2.96-132.7.2
Control-center-2.8.0-12
Gcc-3.4.3-22.1.EL4
Gcc-c++-3.4.3-22.1.EL44
Glibc-2.3.4-2.9
Glibc-common-2.3.4-2.9
Libstdc++-3.4.3-22.1
Libstdc++-devel-3.4.3-22.1
Make-3.80-5
Pdksh-5.2.14-30
Sysstat-5.0.5-1
Setarch-1.6-1
[root@server253 ~] rpm-qa | grep compat-db
[root@server253 ~] # yum-y install compat-db
[root@server253 ~] # rpm-qa | grep pdksh
[root@server253 ~] # yum-y install pdksh
[root@server253 ~] # rpm-qa | grep sysstat
[root@server253 ~] # yum-y install sysstat
5. Check the network step
1. Ifconfig eth0
Eth0 Link encap:Ethernet HWaddr 00:0C:29:D3:D9:8D
Inet addr:192.168.1.253 Bcast:192.168.1.255 Mask:255.255.255.0
Inet6 addr: fe80::20c:29ff:fed3:d98d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:112 errors:0 dropped:0 overruns:0 frame:0
TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:14414 (14.0 KiB) TX bytes:16767 (16.3 KiB)
Base address:0x2000 Memory:fd5c0000-fd5e0000
Vim / etc/sysconfig/network
System-config-securitylevel
6. Analysis of configuration name
Vim / etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
:: 1 localhost6.localdomain6 localhost6
192.168.1.253 server253.oracle.com server253
Ping server253.oracle.com
Ping server253
7. Account name and group are required to create installation software
8. Determine whether nobody exists or not
Creating Required Operating System Groups and Users
Create three users
[root@server253 ~] # useradd dba
[root@server253 ~] # useradd oinstall
[root@server253 ~] # useradd oper
[root@server253 ~] # id oracle
Uid=500 (oracle) gid=500 (oracle) groups=500 (oracle)
Add users to the group
Usermod-g oinstall-G oinstall,dba,oper,oracle oracle
[root@server253 ~] # id oracle
Uid=500 (oracle) gid=502 (oinstall) groups=502 (oinstall), 500 (oracle), 501 (dba), 503 (oper)
8J verifying that the User nobody Exists to judge whether nobody exists or not
Reason: nobody must exist for external jobs
[root@server253 ~] # id nobody
Uid=99 (nobody) gid=99 (nobody) groups=99 (nobody)
9. Kernel parameters
Configuring Kernel Parameters
Vi / etc/sysctl.conf
Kernel.shmall = 2097152
Kernel.shmmax = 2147483648
Kernel.shmmni = 4096
Kernel.sem = 250 32000 100 128
Fs.file-max = 65536
Net.ipv4.ip_local_port_range = 1024 65000
Net.core.rmem_default = 1048576
Net.core.rmem_max = 1048576
Net.core.wmem_default = 262144
Net.core.wmem_max = 262144
-shmall: this parameter represents the total capacity (in pages) of shared memory segments that the system can use in turn. The default value is 2097152, which usually does not need to be modified.
-shmmax: this parameter defines the maximum size (in bytes) of shared memory segments that can be used by a single process. The default is 32MB, which is too low for ORACLE and is usually set to 2GB.
-shmmin: this kernel parameter is used to set the maximum number of system-wide shared memory segments. The default value of this parameter is 4096, which usually does not need to be changed.
-sem: this parameter represents the set semaphore
-file-max: this parameter represents the maximum number of file handles, and the file handle setting indicates the number of files that can be opened in the linux system
[root@server253] # sysctl-p
10. Configure SHELL restrictions
Configure SHELL restrictions
A,vim / etc/security/limits.conf
Oracle soft nproc 2047
Oracle hard nproc 16384
Oracle soft nofile 1024
Oracle hard nofile 65536
B,vi / etc/pam.d/login
Session required / lib/security/pam_limits.so
Session required pam_limits.so
C,Depending on the oracle user's default shell
Vi / etc/profile
If [$USER = "oracle"]; then
If [$SHELL = "/ bin/ksh"]; then
Ulimit-p 16384
Ulimit-n 65536
Else
Ulimit-u 16384-n 65536
Fi
Fi
11. Create the desired directory
Create the required directory
Identifying Required Software Directories
The root directory of Oracle Base Directory--- must be created manually
Mkdir-p / u01/app/oracle
B,Oracle Inventory Directory
Name: oracle_base/oraInventory-product list list
/ u01/app/oracle/oraInventory You do not need to create it. Install automatic creation
Directory where Oracle Home Directory software is installed
Each product installation will have a corresponding oralce home directory, You do not need to create this directory.
It is recommended that you create
/ u01/app/oracle/product/10.2.0/db_1
D, command
# mkdir-p / u01/app/oracle
# chown-R oracle:oinstall / u01/app/oracle
# chmod-R 775 / u01/app/oracle
test
Ll / u01/app
twelve。 Configure the oracle user environment
Configuring the oracle User's Environment
Su-oracle
Cd / home/oracle
Vim .bash _ profile
Umask 022
ORACLE_BASE=/u01/app/oracle root directory
ORACLE_SID=orcl
Export ORACLE_BASE ORACLE_SID
[root@server253 ~] # source .bash _ profile
13. Prepare to install the medium
A, how to upload installation media to linux
B,tool
C, upload using root, use decompression, view permissions
Unzip package name
Chown-R oracle:oinstall / U01
Chmod-R 775 / U01
14. Su-
Oracle
[oracle@server253 ~] $su-root
[root@server253 ~] # xhost +
Access control disabled, clients can connect from any host
[root@server253 ~] # su-oracle
[oracle@server253 ~] $xclock
15.
Install your database software
16. What to do during the installation process
[oracle@server253 ~] $cd / u01/database/
[oracle@server253 database] $. / runInstaller
A,vim / home/oracle/.base_profile
Umask 022
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
ORACLE_SID=orcl
PATH=$PATH:$HOME/bin
Export PATH ORACLE_BASE ORACLE_SID ORACLE_HOME
B, do not choose to create the database by default, just install the database software here
c. Finally, execute two scripts as root:
OrainstRoot.sh== is used to update the final product list information
Root.sh = = generate some usage scripts based on the information of the current host, such as dbca
[oracle@server253 ~] $source .bash _ profile
[oracle@server253 ~] $cd / u01/database/
[oracle@server253 database] $. / runInstaller
[root@localhost /] # / u01/app/oracle/oraInventory/orainstRoot.sh
[root@localhost /] # / u01/app/oracle/product/10.2.0/db_1/root.sh
Part two: create an intercept
[oracle@server253 ~] $netca
-bash: netca: command not found
View the path where netca is located
[oracle@server253 bin] $ls netca
Netca
[oracle@server253 bin] $pwd
/ u01/app/oracle/product/10.2.0/db_1/bin
[oracle@server253 ~] $vim .bash _ profile
Umask 022
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
ORACLE_SID=orcl
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
Export PATH ORACLE_BASE ORACLE_SID ORACLE_HOME
[oracle@server253 ~] $source .bash _ profile
[oracle@server253 ~] $netca
[oracle@server253 ~] $lsnrctl status
[oracle@server253 ~] $netstat-tunlp | grep 1521
(Not all processes could be identified, non-owned process info
Will not be shown, you would have to be root to see it all.)
Tcp 0 0 0.0.0.0 1521 0.0.0.015 * LISTEN 14633/tnslsnr
Part III: creating a database
-create a database-dbca--
One is to adopt the script method.
The second is to use graphical interface.
[oracle@server253 ~] $dbca
Create the first database using DBCA: orcl
Global database name: database name + domain name
Oracle sid: instance name
The default instance name is the same as the database name, or it can be different
Enterprise manager (EM)
EM manages the database in the form of web pages
There are two types of EM:
One is to use GRID CONTROL-, which can manage multiple hosts and multiple databases, and agent must be installed on the host.
Second, only one database can be managed by Database control.
Database management mode
1 grid control is not optional by default. Reason: you have not configured grid contol agent
2 dbconsole Management
Be sure to select this template
View the created database information
[oracle@server253 orcl] $ls
Adump bdump cdump dpdump pfile udump
[oracle@server253 orcl] $pwd
/ u01/app/oracle/admin/orcl
Cd admin/ instance name / audit trail warning log
[oracle@server253 admin] $cd orcl/bdump/
[oracle@server253 bdump] $ls
Alert_orcl.log orcl_lgwr_16683.trc orcl_lgwr_16778.trc orcl_lgwr_16845.trc
Cd / u01/app/oracle/oradata/ instance name / database file
Here are twelve files to write scripts.
[oracle@server253 orcl] $ls
Control01.ctl example01.dbf redo03.log temp01.dbf
Control02.ctl redo01.log sysaux01.dbf undotbs01.dbf
Control03.ctl redo02.log system01.dbf users01.dbf
[oracle@server253 orcl] $pwd
/ u01/app/oracle/oradata/orcl
Ps-elf | grep ora
[oracle@server253 dbs] $ps-elf | grep ora
0 S root 3548 3523 078 0-494stext Aug13? 00:00:10 hald-addon-storage: polling / dev/scd0
4 S root 9164 6840 0 77 0-1230 wait Aug13 pts/2 00:00:00 su-oracle
4 S oracle 9165 9164 0 76 0-1135 wait Aug13 pts/2 00:00:00-bash
4 S root 9261 9216 0 77 0-1230 wait Aug13 pts/2 00:00:00 su-oracle
4 S oracle 9262 9261 0 750-1135 wait Aug13 pts/2 00:00:00-bash
4 S root 9893 9753 0 77 0-1230 wait Aug13 pts/2 00:00:00 su-oracle
4 S oracle 9894 9893 0 750-1135 wait Aug13 pts/2 00:00:00-bash
4 S root 10010 9967 0 77 0-1230 wait Aug13 pts/2 00:00:00 su-oracle
4 S oracle 10011 10010 0 750-1135 wait Aug13 pts/2 00:00:00-bash
4 S root 14109 4694 0 77 0-1230 wait Aug13 pts/1 00:00:00 su-oracle
4 S oracle 14110 14109 076 0-1135-Aug13 pts/1 00:00:00-bash
0 S oracle 14633 10 76 0-10567 stext Aug13? 00:00:00 / u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER-inherit
0 S oracle 16837 10 78 0-250810-Aug13? 00:00:00 ora_pmon_orcl
0 S oracle 16839 10 78 0-250657-Aug13? 00:00:00 ora_psp0_orcl
0 S oracle 16841 10 78 0-250657-Aug13? 00:00:00 ora_mman_orcl
0 S oracle 16843 10 78 0-251174-Aug13? 00:00:00 ora_dbw0_orcl
0 S oracle 16845 10 76 0-254545-Aug13? 00:00:01 ora_lgwr_orcl
0 S oracle 16847 1078 0-250781-Aug13? 00:00:03 ora_ckpt_orcl
0 S oracle 16849 10 77 0-251051-Aug13? 00:00:00 ora_smon_orcl
0 S oracle 16851 10 800-250657-Aug13? 00:00:00 ora_reco_orcl
0 S oracle 16853 10 750-251056-Aug13? 00:00:01 ora_cjq0_orcl
0 S oracle 16855 10 78 0-251353-Aug13? 00:00:00 ora_mmon_orcl
0 S oracle 16857 10 78 0-250657-Aug13? 00:00:00 ora_mmnl_orcl
0 S oracle 16859 10 78 0-250817-Aug13? 00:00:00 ora_d000_orcl
0 S oracle 16861 10 750-250809-Aug13? 00:00:00 ora_s000_orcl
0 S oracle 16866 10 79 0-250657-Aug13? 00:00:00 ora_qmnc_orcl
0 S oracle 17090 10 78 0-251063-Aug13? 00:00:02 ora_j000_orcl
0 S oracle 17811 10 750-251044-Aug13? 00:00:00 ora_q000_orcl
0 S oracle 17813 10 78 0-250656-Aug13? 00:00:00 ora_q001_orcl
S oracle 17856 10 750-2031-Aug13 pts/1 00:00:00 / u01/app/oracle/product/10.2.0/db_1/perl/bin/perl / u01/app/oracle/product/10.2.0/db_1/bin/emwd.pl dbconsole / u01/app/oracle/product/10.2.0/db_1/server253.oracle.com_orcl/sysman/log/emdb.nohup
S oracle 17881 17856 078 0-148091 stext Aug13 pts/1 00:00:29 / u01/app/oracle/product/10.2.0/db_1/jdk/bin/java-server-Xmx256M-XX:MaxPermSize=96m-XX:MinHeapFreeRatio=20-XX:MaxHeapFreeRatio=40-DORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1-Doracle.home=/u01/app/oracle/product/10.2.0/db_1/oc4j-Doracle.oc4j.localhome=/u01/app/oracle/product / 10.2.0/db_1/server253.oracle.com_orcl/sysman-DEMSTATE=/u01/app/oracle/product/10.2.0/db_1/server253.oracle.com_orcl-Doracle.j2ee.dont.use.memory.archive=true-Djava.protocol.handler.pkgs=HTTPClient-Doracle.security.jazn.config=/u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_server253.oracle.com_orcl/config/jazn.xml-Djava.security .policy = / u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_server253.oracle.com_orcl/config/java2.policy-Djava.security.properties=/u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/home/config/jazn.security.props-DEMDROOT=/u01/app/oracle/product/10.2.0/db_1/server253.oracle.com_orcl-Dsysman.md5password=true-Drepapi.oracle.home=/u01 / app/oracle/product/10.2.0/db_1-Ddisable.checkForUpdate=true-Djava.awt.headless=true-jar / u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/home/oc4j.jar-config/ u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_server253.oracle.com_orcl/config/server.xml
0 S oracle 18060 10 77 0-253384-Aug13? 00:00:03 oracleorcl (LOCAL=NO)
0 S oracle 18062 10 750-251086-Aug13? 00:00:01 oracleorcl (LOCAL=NO)
0 S oracle 18064 10 750-251348-Aug13? 00:00:05 oracleorcl (LOCAL=NO)
0 S oracle 19902 17856 0 77 0-14604 stext Aug13 pts/1 00:00:03 / u01/app/oracle/product/10.2.0/db_1/bin/emagent
0 S oracle 19945 10 76 0-251627-Aug13? 00:00:02 oracleorcl (LOCAL=NO)
0 S oracle 19956 10 750-251093-Aug13? 00:00:01 oracleorcl (LOCAL=NO)
0 S oracle 24484 10 76 0-251073-Aug13? 00:00:00 oracleorcl (LOCAL=NO)
0 S oracle 24953 10 79 0-251081-00:00? 00:00:00 oracleorcl (LOCAL=NO)
0 S oracle 24957 10 78 0-251084-00:00? 00:00:00 oracleorcl (LOCAL=NO)
0 R oracle 25086 10011 0 77 0-1065-00:02 pts/2 00:00:00 ps-elf
0 R oracle 25087 10011 078 0-00:02 pts/2 00:00:00 grep ora
There's an extra folder.
[oracle@server253 ~] $cd $ORACLE_HOME
[oracle@server253 db_1] $ls
Assistants has log oraInst.loc server253.oracle.com_orcl
Bin hs md ord slax
Cdata install mesg oui sqlj
Cfgtoollogs install.platform mgw owm sqlplus
Clone inventory network perl srvm
Config javavm nls plsql sysman
Crs jdbc oc4j precomp uix
Css jdk odbc racg wwg
Ctx jlib olap rdbms xdk
Dbs jre OPatch relnotes
Demo ldap opmn root.sh
Diagnostics lib oracore root.sh.old
[oracle@server253 db_1] $pwd
/ u01/app/oracle/product/10.2.0/db_1
When the instance here is started, the first thing to read is the spfileorcl.ora file. Once this file is lost, your instance will collapse and debug later. The first file to be repaired is this file.
[oracle@server253 db_1] $cd dbs
[oracle@server253 dbs] $ls
Hc_orcl.dat initdw.ora init.ora lkORCL orapworcl spfileorcl.ora
[oracle@server253 dbs] $
How to prove the success of creating a database
[oracle@server253 ~] $sqlplus sys/oracle as sysdba
-bash: sqlplus: command not found
[oracle@server253 ~] $vim .bash _ profile
Umask 022
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
ORACLE_SID=orcl
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
Export ORACLE_BASE ORACLE_SID ORACLE_HOME PATH
[oracle@server253 ~] $source .bash _ profile
[oracle@server253 ~] $sqlplus sys/oracle as sysdba
SQL*Plus: Release 10.2.0.1.0-Production on Mon Aug 14 00:15:00 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
SQL >
Method 1:
SQL > select * from tab
3643 rows selected.
Method 2:
SQL > shutdown abort
ORACLE instance shut down.
SQL > exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
[oracle@server253 ~] $sqlplus sys/oracle as sysdba
SQL*Plus: Release 10.2.0.1.0-Production on Mon Aug 14 00:22:38 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL >
There are three processes in the startup process.
No mount
Mount
Open
If all three processes are OK, then the database starts successfully
SQL > startup
ORACLE instance started.
Total System Global Area 926941184 bytes
Fixed Size 1222672 bytes
Variable Size 243271664 bytes
Database Buffers 679477248 bytes
Redo Buffers 2969600 bytes
Database mounted.
Database opened.
SQL >
Part IV: oracle login mode
1. Introduction to the connection mode of database
Oracle login mode
Basic use of connection
Connect--
1. EM- Enterprise Manager (graphic management)
2. Isqlplus-- (JAVA)
3 、 sqlplus
Log in with 2.sys account
Sqlplus account / password as sysdba
[oracle@server253 ~] $sqlplus sys/oracle as sysdba
SQL*Plus: Release 10.2.0.1.0-Production on Mon Aug 14 06:27:25 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
SQL >
The 3.sys account uses system authentication
For example:
[oracle@server253 ~] $sqlplus xiaoming/oracle as sysdba
SQL*Plus: Release 10.2.0.1.0-Production on Mon Aug 14 06:29:53 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
SQL > show user
USER is "SYS"
SQL >
So the system account can still log in like this.
[oracle@server253 ~] $sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0-Production on Mon Aug 14 06:31:08 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
SQL >
Note: as long as your oracle account can log in to your system, then your SQL can log in
4. View the currently logged-in account
SQL > show user
USER is "SYS"
5. Log out
SQL > exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
[oracle@server253 ~] $
6. Login of ordinary account
When the oracle database is created, it provides three accounts:
Sys
Scott
Hr
When the scott account logs in by default, the password is tiger, but it is found that the account is locked when logging in.
[oracle@server253 ~] $sqlplus scott/tiger
SQL*Plus: Release 10.2.0.1.0-Production on Mon Aug 14 06:44:42 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-28000: the account is locked
Enter user-name:
7. Unlock the general account number
[oracle@server253 ~] $sqlplus / as sysdba
SQL > show user
USER is "SYS"
SQL > alter user scott account unlock
User altered.
[oracle@server253 ~] $sqlplus scott/tiger
SQL*Plus: Release 10.2.0.1.0-Production on Mon Aug 14 06:49:14 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-28001: the password has expired
Changing password for scott
New password:
Retype new password:
Password changed
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
SQL > show user
USER is "SCOTT"
SQL >
8. Modify the password of a general account
SQL > show user
USER is "SCOTT"
SQL > alter user scott identified by redhat
User altered.
Note: note: users can also change their own passwords, which are generally not allowed.
9. Unlock and change passwords at the same time
SQL > alter user scott account unlock identified by oracle
Alter user scott account unlock identified by oracle
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL > show user
USER is "SYS"
SQL > alter user scott account unlock identified by oracle
User altered.
SQL >
10. Unlock hr account number
Sqlplus / as sysdba
Alter user hr account unlock identified by redhat
Exit
Sqlplus hr/redhat
Show user
11. Switching between users
-conn hr/redhat---- switches to hr account
-conn / as sysdba-- switch to sys account
-conn sys/oracle as sysdba--- switches to sys account
SQL > show user
USER is "SYS"
SQL > alter user hr account unlock identified by redhat
User altered.
SQL > show user
USER is "SYS"
SQL > conn scott/oracle
Connected.
SQL > show user
USER is "SCOTT"
SQL >
twelve。 Help file
Help--
-help index-help Index
-? Shutdown---- finds the usage function of shutdown
-? Set- finds the usage function of set
SQL > help index
Enter Help [topic] for help.
@ COPY PAUSE SHUTDOWN
@ @ DEFINE PRINT SPOOL
/ DEL PROMPT SQLPLUS
ACCEPT DESCRIBE QUIT START
APPEND DISCONNECT RECOVER STARTUP
ARCHIVE LOG EDIT REMARK STORE
ATTRIBUTE EXECUTE REPFOOTER TIMING
BREAK EXIT REPHEADER TTITLE
BTITLE GET RESERVED WORDS (SQL) UNDEFINE
CHANGE HELP RESERVED WORDS (PL/SQL) VARIABLE
CLEAR HOST RUN WHENEVER OSERROR
COLUMN INPUT SAVE WHENEVER SQLERROR
COMPUTE LIST SET
CONNECT PASSWORD SHOW
SQL >? Shutdown
SHUTDOWN
-
Shuts down a currently running Oracle Database instance, optionally
Closing and dismounting a database.
SHUTDOWN [ABORT | IMMEDIATE | NORMAL | TRANSACTIONAL [LOCAL]]
SQL >? Set
SET
-
Sets a system variable to alter the SQL*Plus environment settings
For your current session. For example, to:
-set the display width for data
-customize HTML formatting
-enable or disable printing of column headings
-set the number of lines per page
In iSQL*Plus, you can also use the Preferences screen to set
System variables.
SET system_variable value
Where system_variable and value represent one of the following clauses:
APPI [NFO] {OFF | ON | text} NUM [WIDTH] {10 | n}
ARRAY [SIZE] {15 | n} PAGES [IZE] {14 | n}
AUTO [COMMIT] {OFF | ON | IMM [edit] | n} PAU [SE] {OFF | ON | text}
AUTOP [RINT] {OFF | ON} RECSEP {WR [APPED] | EA [Ch] | OFF}
AUTORECOVERY {OFF | ON} RECSEPCHAR {_ | c}
AUTOT [RACE] {OFF | ON | transfer [only]} SERVEROUT [PUT] {ON | OFF}
[explain] [stats] [SIZE {n | UNLIMITED}] [form]
BLO [CKTERMINATOR] {. | c | ON | OFF} {WRA [PPED] |
CMDS [EP] {; | c | OFF | ON} word [D _ WRAPPED] |
COLSEP {_ | text} TRU [NCATED]}]
CON [CAT] {. | c | ON | OFF} * shift [input] {VIS [IBLE] |
COPYC [OMMIT] {0 | n} INV [ISIBLE]}
COPYTYPECHECK {ON | OFF} * show [mode] {OFF | ON}
DEF [INE] {& | c | ON | OFF} * SQLBL [ANKLINES] {OFF | ON}
DESCRIBE [DEPTH {1 | n | ALL}] SQLC [ASE] {MIX [ED] |
[LINENUM {OFF | ON}] [INDENT {OFF | ON}] LO [WER] | UP [PER]}
ECHO {OFF | ON} * SQLCO[ NTINUE] {> | text}
* EDITF [ere] file_name [.ext] * SQLN [user] {ON | OFF}
EMB [EDDED] {OFF | ON} SQLPLUSCOMPAT [IBILITY] {x.y [.z]}
ESC [APE] {\ | c | OFF | ON} * SQLPRE [fix] {# | c}
FEED [BACK] {6 | n | ON | OFF} * SQLP [ROMPT] {SQL > | text}
FLAGGER {OFF | ENTRY | intermed [Iate] | FULL} SQLT [ERMINATOR] {; | c | ON | OFF}
* Flux [SH] {ON | OFF} * SUF [fix] {SQL | text}
HEA [DING] {ON | OFF} * TAB {ON | OFF}
HEADS [EP] {| | c | ON | OFF} * term [out] {ON | OFF}
INSTANCE [instance_path | LOCAL] * TI [ME] {OFF | ON}
LIN [ESIZE] {80 | n} ({150 | n} iSQL*Plus) TIMI [NG] {OFF | ON}
LOBOF [FSET] {1 | n} * trim [out] {ON | OFF}
LOGSOURCE [pathname] * trims [pool] {OFF | ON}
LONG {80 | n} UND [ERLINE] {- | c | ON | OFF}
LONGC [HUNKSIZE] {80 | n} VER [IFY] {ON | OFF}
MARK [UP] HTML [OFF | ON] WRA [P] {ON | OFF}
[HEAD text] [BODY text] [TABLE text] XQUERY {BASEURI text |
[ENTMAP {ON | OFF}] ORDERING {UNORDERED |
[SPOOL {OFF | ON}] ORDERED | DEFAULT} |
[pre [format] {OFF | ON}] NODE {BYVALUE | BYREFERENCE |
NEWP [AGE] {1 | n | NONE} DEFAULT} |
NULL text CONTEXT text}
NUMF [ORMAT] format
An asterisk (*) indicates the SET option is not supported in iSQL*Plus.
13. Enable the history feature
-need to install rlwrap package
It's a little troublesome because it's a source package.
Package at the end of .gz
So gunzip rlwrap-0.37.tar.gz
Rlwrap-0.37.tar
Tar-xvf rlwrap-0.37.tar
Source code installation is actually the easiest, there is no need to build a yum repository
The first way: unlock it in two steps.
It only takes one step to unlock the compressed package with .gz.
Tar-zxvf rlwrap-0.37.tar.gz
Vim REDEAME View installation instructions
Search
: / INSTALL
/ INSTALL
The installation of the source package requires two steps. In fact, the following is a composite step.
. / configure; make install
Root permission is required to install rlwrap-0.37.tar
. / configure; make install
If the installation is not successful, you need to check whether the two packages are installed.
Ls | grep readline
Readline-5.1-3.el5.i386.rpm
Readline-devel-5.1-3.el5.i386.rpm
Rpm-qa | grep readline
Ls | grep libter
Libtermcap-2.0.8-46.1.i386.rpm
Libtermcap-devel-2.0.8-46.1.i386.rpm
Rpm-qa | grep libter
-examination-
Su-oracle
Sqlplus / as sysdba
Selecct * from tab
Exit
If you find an error, you can't use it.
Because rlwrap is installed on the linux system, you must tell the oracle system every time you use it.
Rlwrap sqlplus / as sysdba
Now it is found that it can be viewed up and down.
It can be achieved by aliasing.
Alias sqlplus='rlwrap sqlplus', but this is temporary.
To take effect permanently, you need to configure the .bash _ profile file under the oracle home directory.
Ls-a
Vim .bash _ profile
Just add this item to alias sqlplus='rlwrap sqlplus'.
Source .bash _ profile after saving and exiting
Part V: text editor under oracle
In order to solve this problem
SQL > select ename,sal,hiredata
2 from emp
3 where sal=800
4
Select ename,sal,hiredata
*
ERROR at line 1:
ORA-00904: "HIREDATA": invalid identifier
-need to modify the editor-
Su-oracle
Vim .bash _ profile
EDITOR=vim
Export EDITOR
Source .bash _ profile
SQL > conn scott/oracle
Connected.
SQL > show user
USER is "SCOTT"
SQL > select ename,sal,hiredata
2 from emp
3 where sal=800
4
Select ename,sal,hiredata
*
ERROR at line 1:
ORA-00904: "HIREDATA": invalid identifier
Click on an ed to correct and edit.
SQL > ed
Wrote file afiedt.buf
1 select ename,sal,hiredate
2 from emp
3 * where sal=800
4
Or
SQL > ed
Wrote file afiedt.buf
1 select ename,sal,hiredate
2 from emp
3 * where sal=800
4 /
ENAME SAL HIREDATE
SMITH 800 17-DEC-80
SQL >
SQL > /
ENAME SAL HIREDATE
SMITH 800 17-DEC-80
SQL >
! You can also exit the oracle database
L list the cache information in oracle data
All objects under scott mode
Scott has a total of four objects in his account.
The objects here are called tables.
SQL > /
TNAME TABTYPE CLUSTERID
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
Get the information generated in the table
SQL > select * from EMP
2
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
-
7369 SMITH CLERK 7902 17-DEC-80 800
twenty
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
thirty
7521 WARD SALESMAN 7698 22-FEB-81 1250 500
thirty
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
-
7566 JONES MANAGER 7839 02-APR-81 2975
twenty
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
thirty
7698 BLAKE MANAGER 7839 01-MAY-81 2850
thirty
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
-
7782 CLARK MANAGER 7839 09-JUN-81 2450
ten
7788 SCOTT ANALYST 7566 19-APR-87 3000
twenty
7839 KING PRESIDENT 17-NOV-81 5000
ten
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
-
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
thirty
7876 ADAMS CLERK 7788 23-MAY-87 1100
twenty
7900 JAMES CLERK 7698 03-DEC-81 950
thirty
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
-
7902 FORD ANALYST 7566 03-DEC-81 3000
twenty
7934 MILLER CLERK 7782 23-JAN-82 1300
ten
14 rows selected.
Now I want to know what columns are in EMP?
Get eight columns from the emp table
SQL > desc emp
Name Null? Type
-
EMPNO NOT NULL NUMBER (4)
ENAME VARCHAR2 (10)
JOB VARCHAR2 (9)
MGR NUMBER (4)
HIREDATE DATE
SAL NUMBER (7 dint 2)
COMM NUMBER (7 dint 2)
DEPTNO NUMBER (2)
SQL >
SQL > select empno,ename,sal from emp
/ pass / can be executed again
-how to keep it forever-
SQL > select ename,sal from emp
SQL > save / u01/a.sql
Created file / u01/a.sql
Be sure to save the absolute path
-how to call the saved footsteps-
The first method: @ / u01/a.sql can be directly called out.
The second method: start / u01/a.sql
-set the saved command to the cache but not execute-
SQL > get / u01/b.sql
1 select ename,sal
2 from emp
3 * where sal=3000
Get calls it up, but does not execute it.
-what if I want to temporarily switch to the linux environment--
! You can go to the linux environment.
Exit switched from linux environment to oracle environment
-directly exit the oracle environment-
Exit can directly exit the oracle environment by entering exit under the oracle environment.
Host and! The function is the same
-delete a.sql under U01 without exiting oracle-
SQL > rm-rf / u01/a.sql
SP2-0734: unknown command beginning "rm-rf / u0..."-rest of line ignored.
SQL >
-add an exclamation point in front of it.
SQL >! Rm-rf / u01/a.sql
SQL >! Ls / u01
10201_database_linux32.zip app database rlwrap-0.37.tar.gz.bak
Afiedt.buf b.sql rlwrap-0.37.tar.gz
SQL >
SQL >! Mkdir / u01/aa
SQL >! Ls-l / U01
Total 654232
-rwxr-xr-x 1 oracle oinstall 668734007 Nov 6 2009 10201_database_linux32.zip
Drwxr-xr-x 2 oracle oinstall 4096 Aug 13 00:48 aa
-rw-r--r-- 1 oracle oinstall 43 Aug 13 00:33 afiedt.buf
Drwxr-xr-x 3 oracle oinstall 4096 Aug 8 22:38 app
-rw-r--r-- 1 oracle oinstall 43 Aug 13 00:32 b.sql
Drwxr-xr-x 6 oracle oinstall 4096 Jul 3 2005 database
-rwxrw-rw- 1 root root 251438 Nov 19 2011 rlwrap-0.37.tar.gz
-rwxr--r-- 1 root root 251438 Aug 12 21:55 rlwrap-0.37.tar.gz.bak
SQL >
-the requirement is to save all the commands used by the query plus the results of the query-
SQL > spool / u01/a.txt
SQL > select ename from emp
ENAME
-
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
ENAME
-
JAMES
FORD
MILLER
14 rows selected.
The result of SQL > spool off is complete.
SQL >!
[oracle@server253 U01] $ls
10201_database_linux32.zip app database
Aa a.txt rlwrap-0.37.tar.gz
Afiedt.buf b.sql rlwrap-0.37.tar.gz.bak
[oracle@server253 U01] $vim a.txt
[oracle@server253 U01] $
Vim a.txt
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.