Presented by Roger Schrag Database Specialists, Inc. http://www.dbspecialists.com Linuxorld !on"erence and #xpo $%% &ugust %'(), (%%% San *ose, !ali"ornia !opyright + (%%% Database Specialists, Inc. &ll rights reser,ed Contents -,er,iew....................................................................................................... hy I rote /his /utorial 0y 1ac2ground &n Introduction to -racle /echnology........................................................3 Plat"orm Independence Database /erminology /he 4iles /hat !ontrol an -racle Instance /he 4iles /hat 0a2e 5p an -racle Database /he -racle Process &rchitecture #n,ironment 6ariables Installation 1est Practices: -4& Interacting with a Database -racle 7uic2 Start Installing the -racle So"tware and !reating a De"ault Database..............)( Prepare the Ser,er Install the -racle So"tware !reate an -racle Database !omplete the Ser,er !on"iguration Summary 0anaging 8our Database...........................................................................9. Starting and Stopping !onnecti,ity and /roubleshooting Schemas, /ablespaces, and Segments 4ault /olerance and 1ac2ups -ptimi:ing 8our Database.........................................................................;9 /uning Database &ccess within an &pplication Si:ing the S<& 1alancing Dis2 I/- 0anaging Database !onnections /uning Sorts !on"iguring Rollbac2 Segments here /o <et 0ore In"ormation...............................................................;% -racle Documentation -ther Publications -racle /echnology =etwor2 -racle 5ser <roups 4ree eb Resources Page ) !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com !on"iguring -racle on Linux 4or Pea2 Per"ormance Page 9 Database Specialists, Inc. www.dbspecialists.com Overview It$s relati,ely easy to install an -racle database on your Linux ser,er. 1ut to reali:e the "ull scalability, a,ailability, and per"ormance potential that -racle o""ers, you need to 2now some important in"ormation about how -racle wor2s. 0ost o" us don$t ha,e the time to read the do:ens o" boo2s a,ailable on the sub>ect or attend wee2s o" -racle training. /his tutorial will teach Linux system administrators or other technical "ol2s new to -racle the basics o" how to install and con"igure -racle on Linux in such a way that the database will o""er good per"ormance and reliability e,en as it grows ,ery large. 4irst, we$ll ha,e a lightning "ast introduction to -racle speci"ically "or system administrators. e$ll loo2 at the -racle architecture, how it uses memory and dis2 resources, the ,arious "iles that ma2e up an -racle database, and a collection o" installation best practices 2nown as the -ptimal 4lexible &rchitecture or -4&. =ext, we$ll discuss the steps re?uired to install -racle. e$ll tal2 about getting your Linux ser,er ready "or -racle, using the -racle Installer, database creation issues such as choosing a character set and a bloc2 si:e, resi:ing the de"ault database so that it will meet your needs, and creating your application schema. /hen we$ll tal2 about administering your new database. /his includes starting and stopping the database, using administration tools, and troubleshooting connecti,ity problems. =ext, and perhaps most interesting, we$ll tal2 about how to 2eep your database healthy as it grows. e$ll discuss tips "or 2eeping your database manageable and highly a,ailable, as well as how to tune it "or optimal per"ormance. 4inally, we$ll loo2 at resources a,ailable to people new to the -racle arena in order to learn more about the care and "eeding o" their -racle databases and applications. Why I Wrote This Tutorial /here are se,eral @how toA guides a,ailable on the internet today that will show you how to install -racle on Linux. 0ost o" these guides were written by Linux enthusiasts who are new to -racle. /hrough persistence and sheer will Bone writer explains in his guide, @It too2 me (C tries to get -racle wor2ingAD these "ol2s ha,e managed to get -racle up and running, and they want to share their 2nowledge and sa,e you some misery. I want to share my 2nowledge also, but I approached the topic "rom a di""erent angle. I$,e wor2ed with -racle databases "or o,er ten years, and I can almost install -racle on Solaris or EP'5F in my sleep. Linux was the new ingredient "or me. I wrote this tutorial to assist Linux users who are new to -racle. 1ut I am hoping that this tutorial does more than >ust explain how to get -racle to run on your Linux box. 0y goal is to help you understand how it wor2s, and to empower you to ma2e it perform. My Backgroun I ha,e been an -racle D1& and application architect "or o,er ten years, and I am the "ounder o" Database Specialists, Inc., a consulting group speciali:ing in business solutions based on -racle technology. e ha,e extensi,e experience in e'commerce, -racle &pplications, and custom applications in,ol,ing -racle databases. Page ; !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com !on"iguring -racle on Linux 4or Pea2 Per"ormance Page . Database Specialists, Inc. www.dbspecialists.com !n Introuction to Oracle Technology In this section o" the tutorial we will tal2 about the mantra o" plat"orm independence, -racle database terminology, the di""erent "iles that ma2e up an -racle database, the -racle process architecture, the en,ironment ,ariables -racle cares about, a set o" installation best practices, how administrators interact with the database, and a ?uic2 start punch list to getting -racle up and running. Platform Ine"enence -racle !orporation stri,es toward plat"orm independence "or all o" its products, and to date they ha,e been ,ery success"ul. -racle databases and application code tend to be extremely portable, and -racle s2ills garnered on one plat"orm will be extremely trans"erable to other plat"orms. /his ma2es it possible "or people with lots o" -racle experience on other plat"orms to get up to speed ,ery ?uic2ly on -racle on Linux. Plat"orm independence mani"ests itsel" in the -racle world in many ways. e$ll loo2 at documentation and plat"orm abstraction. -racle documentation comes in two ,arieties. /here is the @genericA and the @plat"orm speci"ic.A /he bul2 o" -racle$s documentation is the "ormer and applies to all plat"orms. hen a generic manual needs to address a topic that is plat"orm speci"ic, the manual will s2irt the issue and re"er the reader to the manual speci"ic to his or her plat"orm. 4or each plat"orm, -racle publishes an installation guide and an administrator$s re"erence manual that co,ers all the plat"orm speci"ic details re"erenced in the generic documentation. -racle implements plat"orm independence by abstracting issues that tend to ,ary "rom plat"orm to plat"orm. &ll application de,elopment, and as much database administration as possible, will re"er to the abstraction instead o" the underlying plat"orm speci"ic issue. !onsider data storage as an example. #arlier ,ersions o" indows were limited to eight character case' insensiti,e "ile names, while 5nix, 60S, and 06S all ta2e radically di""erent approaches to naming and locating data "iles. -racle gets around this by storing data in @tablespaces.A & tablespace is a collection o" one or more operating system "iles, and each tablespace in the database has a uni?ue name not to exceed 9G characters. &pplications and database administrators almost always re"er to tablespaces instead o" their underlying operating system "iles. /his techni?ue o" abstraction has the side e""ect o" introducing lots o" -racle'speci"ic terminology. #ata$ase Terminology I" you in,ite a do:en -racle database administrators o,er "or dinner, you are li2ely to get smothered in >argon and lingo. /he terminology is ine,itable, so let$s go o,er some o" the most commonly used terms. /hese are the terms you$ll need to understand in order to read -racle texts or get assistance "rom others more "amiliar with -racle: DBA: /hese three letters stand "or @database administrator.A #,eryone has their own idea o" what a D1& does, and many articles ha,e been published on this single topic. & D1& is usually in,ol,ed in the logical design o" a database, per"orms the physical design and implementation, assists de,elopers with di""icult database issues, and is responsible "or ensuring good per"ormance, proper security, and bac2up and reco,ery strategies. Page C !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com Database: In the -racle arena, a database is a collection o" operating system "iles that ma2e up one physical data store or node. /here can be many, many di""erent types o" data, each with its own attributes, stored in one database. It$s not uncommon "or users o" simple des2top database products to thin2 o" a database as one collection o" records, all with the same attributes. In -racle, we would call that a table, not a database. Database Name: #,ery -racle database has a name, typically eight characters or less. /here is also a global name, which is the database name with a domain su""ix. /he de"ault domain is @.-RLDA which is "ine "or most purposes. In small to medium si:ed shops, it$s a good idea to gi,e each database a uni?ue name and use one common domain. Instance: &n instance is a set o" operating system processes and shared memory structures that allow an application to access data in a database. Database applications ne,er access an -racle database directly. Rather, they communicate with -racle ser,er processes that per"orm all database access on an application$s behal". /he processes that ma2e up the instance are responsible "or such tas2s as writing updates to dis2, coordinating distributed transactions with remote instances, and rolling bac2 incomplete transactions when an application crashes. =ote that when a database is accessible to applications, it has an instance. In most en,ironments, there will be a one'to'one ratio between databases and instances. 1ut they are not the same thing and the two terms should not be used interchangibly. hen -racle Parallel Ser,er is used, multiple -racle instances Beach running on a separate physical ser,erD will access one common database. Instance Name: #,ery -racle instance has a name. SID Bstanding "or @system identi"ierAD is another term "or instance name. -n 5nix plat"orms instance names can be up to eight characters in length. /he purpose o" the instance name is so that applications may identi"y which instance they wish to access when multiple instances are running on one ser,er. B!onsider a machine with "our -racle databases and "our instances.D hen -racle Parallel Ser,er is not being used, the con,ention is to gi,e the instance the same name as the database it accesses. /his will help preser,e your sanity, although it is technically not re?uired. SGA: /he S<&, or system global area, is a collection o" shared memory structures created by an -racle instance. /he S<& includes a cache o" most recently accessed data bloc2s, a cache o" most recently executed S7L statements, latches "or implementing loc2ing mechanisms, among many other things. /he S<& is implemented on 5nix plat"orms as a collection o" shared memory segments. #ach process o" the instance, as well as each ser,er process used by applications to access the database, attaches itsel" to the S<& upon startup. Starting the database: 8ou open an -racle database to applications by starting up an instance and mounting it to the database. /his is o"ten re"erred to as @starting the database.A Net8 or SQL*Net: I" an application wants to access an -racle database ,ia an instance running on the same machine as the application itsel", an -racle ser,er process will be started and the application will communicate with the ser,er process through traditional interprocess communication BIP!D mechanisms. 1ut i" the application needs to access a database running on another ser,er, then -racle$s networ2ing in"rastructure gets in,ol,ed. Eistorically, this in"rastructure was called S7LH=et. 1ut when -racle introduced -racleI, they changed the name to =etI. /hin2 o" them as the same thing, although =etI is newer and has some additional "eatures. Client/Server: -racle internally uses a client/ser,er architecture. #,en i" you are not de,eloping a "at client application using the client/ser,er model, there still is a client/ser,er architecture at the database le,el. /he application wishing to access -racle is seen as a client, and the -racle ser,er process is a ser,er. /he client sends re?uests to the ser,er, and the ser,er satis"ies them. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page 3 Database Specialists, Inc. www.dbspecialists.com Username: -racle supports many authentication mechanisms, but the most common is a standard username and password mechanism. #ach user in an -racle database has a uni?ue name up to 9G characters in length. Separate usernames in the database, o" course, don$t ha,e to map to separate real'li"e users. /wenty di""erent application de,elopers could sign on to a database using the same username and password. !on,ersely, one person could sign on to a database "i,e times, each time speci"ying a di""erent username and password. Schema: & schema is a separate namespace "or database ob>ects such as tables, indexes, and stored procedures. #,ery database ob>ect resides in exactly one schema. #ach database user has exactly one schema that bears the same name as their username. /his ma2es the term username synonymous with schema. Data Dictionar: #ach -racle database has a repository o" in"ormation indicating all o" the users de"ined in the database and all o" the ob>ects they own Btables, indexes, stored procedures, and so onD. /he data dictionary is actually a set o" database tables with names li2e userJ and tabJ. 8ou should ne,er update these tables manually, but it$s "ine "or you to ?uery them i" you li2e. S!S and S!S"#$: #,ery -racle database has two special users, S8S and S8S/#0. /hin2 o" S8S the way you thin2 o" root on a 5nix system. /he S8S user owns all o" the internal structures that ma2e up the data dictionary "or the database, and the S8S user also has e,ery possible pri,ilege on the entire database. /he S8S/#0 user, meanwhile, has D1& pri,ileges and is o"ten used as a generic D1& account. Control %iles, Data %iles, &edo Logs, and 'arameter %iles: /hese are the physical "iles that ma2e up an -racle database. e$ll loo2 at each o" these types o" "iles in greater detail later in this section o" the tutorial. "ables(ace: & tablespace is a named collection o" one or more physical "iles used "or storing database ob>ects. /ablespaces mas2 certain implementation details "rom application de,elopers. 4or example, a D1& can rename a data "ile without a""ecting the name o" a tablespace, or an application de,eloper can speci"y that certain data should be stored in a particular tablespace without needing to 2now i" the data will be stored in one "ile or striped across se,eral "iles. #)tent: &n extent is one contiguous chun2 o" physical storage within a tablespace. &n extent can ,ary in si:e "rom ) Kb to ) <b, as long as the storage is contiguous. Segment: & segment is a collection o" extents that belong to one ob>ect. #ssentially, a segment is the physical storage used to hold the data "or an ob>ect. 0ost segments in a database will hold the contents o" a table or an index, but there are other types o" segments as well. &ollbac* Segment: & rollbac2 segment stores @undoA in"ormation "or a transaction that is still in progress. /his allows -racle to bac2 out the transaction i" the application re?uests a rollbac2. Rollbac2 segments also allow -racle to o""er incredible concurrency by enabling one session to update data while another session is ?uerying the ,ery same dataLthe ?uerying session can use the data in the rollbac2 segment to reconstruct what the data loo2ed li2e be"ore it was updated. "em(orar Segment: & temporary segment holds a partial result set when too much data is in,ol,ed to complete the operation in memory. /emporary segments are most commonly used when sorting data "or ordering, grouping, or building an index. Identi+ier: 0ost identi"iers in -racleLwhether names o" users, tablespaces, tables, indexes, or e,en PL/S7L ,ariablesLare limited to 9G bytes in length and are case'insensiti,e. /o ma2e an identi"ier case' sensiti,e, or to use an -racle reser,ed word as an identi"ier, enclose the identi"ier in double ?uotes. 5nless ?uoted, identi"iers must start with a letter and may include letters, digits, and certain Bbut not allD special characters li2e M, J, and N. Page I !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com The Files That Control an Oracle Instance &n -racle instance is controlled by parameter "iles and optionally a password "ile. Let$s loo2 at these two types o" "iles. & (arameter +ile is a text "ile containing a collection o" name',alue pairs that con"igure an -racle instance. /here are o,er )GG con"igurable parameters. #ach has a de"ault ,alue, and only those that you wish to set to non'de"ault ,alues need to be listed in the parameter "ile. hen you start an -racle instance, -racle loo2s "or a parameter "ile named initSID.ora Bwhere SID is the name o" the instanceD and uses the parameter "ile to con"igure the instance. arameter "iles are read once when an instance is started. !hanges you ma2e to a parameter "ile will not ta2e e""ect until the instance is shut down and restarted. /he parameter "ile speci"ies such things as the location and name o" the database to mount, how much memory to set aside "or a bu""er cache, and the maximum number o" processes that will be able to access the instance. 4igure ( on the next page shows a sample parameter "ile. hen -racle Parallel Ser,er is not being used, all o" the instance parameter settings should be stored in one parameter "ile called initSID.ora. hen -racle Parallel Ser,er is used, some parameter settings will need to be the same "or all instances mounting the same database, while others can ,ary "rom instance to instance. /here"ore, when using -racle Parallel Ser,er, each instance should ha,e its own parameter "ile called initSID.ora containing settings "or that intance only, and all initSID.ora "iles should re"erence one common con"ig.ora "ile that contains the settings that need to be the same "or all instances. & (ass,ord +ile indicates to the instance the usernames and passwords o" people authori:ed to start up and shut down the instance. -nce a database is open, a table in the database$s data dictionary is used to authenticate users wishing to access the database. Eowe,er, this doesn$t help much i" the database has not been opened yet. /his is where the password "ile comes in. & password "ile is o"ten not used in smaller shops running -racle on 5nix, because there is an alternati,e. Instead o" chec2ing a password "ile to see i" a user is authori:ed to start the instance, -racle can as2 the operation system to authenticate the user. -n 5nix plat"orms this amounts to seeing i" the user belongs to a special 5nix group, typically called @dbaA. /he net result is that anybody with a 5nix login that belongs to the dba group can start up and shut down all instances running on the ser,er. Password "iles are sometimes used in larger shops that ha,e many databases. In such shops the D1&s may use an -racle tool called #nterprise 0anager which allows you to start up and shut down databases "rom a central location. In this arrangement, the D1& ne,er logs on to the actual ser,er where the instance is located, so operating system authentication cannot be used. Eence the need "or a password "ile. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page % Database Specialists, Inc. www.dbspecialists.com # # initMYDB.ora # ============ # # Parameter file for MYDB database. # # config parameters control_files = (/u02/oradata/MYDB/control0.ctl! /u0"/oradata/MYDB/control02.ctl! /u0#/oradata/MYDB/control0".ctl$ bac%ground_dump_dest = /u0/app/oracle/admin/MYDB/bdump core_dump_dest = /u0/app/oracle/admin/MYDB/cdump user_dump_dest = /u0/app/oracle/admin/MYDB/udump db_bloc%_si&e = '(2 db_files = '0 db_name = MYDB compatible = '.0.) rollbac%_segments = (r0!r02!r0"!r0#$ utl_file_dir = /u0/app/oracle/admin/MYDB/bdump log_arc*i+e_dest = /u0/app/oracle/admin/MYDB/b%/arc* log_arc*i+e_format = ,-.log log_arc*i+e_start = true # tuning parameters s*ared_pool_si&e = .000000 sort_area_si&e = #0(.000 db_bloc%_buffers = 2000 db_file_multibloc%_read_count = .# processes = 00 sessions = 00 log_c*ec%point_inter+al = 0000 log_buffer = ."'#0 se/uence_cac*e_entries = 00 se/uence_cac*e_*as*_buc%ets = '( 0ob_/ueue_processes = 2 ma1_dump_file_si&e = 02#0 4igure (: & sample parameter "ile. Page (G !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com The Files That Make %" an Oracle #ata$ase &n -racle database is made up o" control "iles, data "iles, online redo logs, and archi,ed redo logs. Let$s loo2 at each o" these types o" "iles. #,ery -racle database has at least one control +ile. I" a database has multiple control "iles, then they are all identical to each other. & control "ile is a relati,ely small Busually under ) 0bD binary "ile that contains in"ormation about the database such as its name, character set, and the names o" all data "iles and redo logs. !ontrol "iles also contain synchroni:ation in"ormation used during reco,ery "rom a crash or media "ailure. I" you lose e,ery copy o" the control "ile "or the database, you stand to lose the entire database. 4or this reason, an -racle database will typically ha,e three control "iles located on separate physical de,ices. Since control "iles are relati,ely small and incur little I/-, there is no reason not to use multiple control "iles. /he data +iles o" a database hold all o" the segments o" the database. /his will include the actual application data, as well as database structures such as the data dictionary, rollbac2 segments, and temporary segments. #ach data "ile is part o" exactly one tablespace. #,ery -racle database has at least one data "ile, belonging to the S8S/#0 tablespace. Data "iles ta2e up the bul2 o" the physical storage used by the database. -n some ,ersions o" 5nix including Linux, physical "iles are limited in si:e to ) <b. /his won$t put much o" a damper on the si:e o" your -racle database, because one database can easily ha,e o,er (GGG data "iles. hen transactions update data in the database, -racle updates bloc2s in the data "iles. 4or "ault tolerance purposes, -racle also writes entries to the online redo log. /hese entries will contain the minimal in"ormation needed by -racle so that it could replay or @redoA the transactions at a "uture time in order to bring a bac2up copy o" the database up to date. /he online redo log consists o" two or more physical "iles, typically the same si:e, that "orm a circular bu""er. /he term @redo log "ilesA re"ers to the indi,idual "iles that ma2e up the online redo log. /he online redo log will typically consist o" three or "our such "iles, each ha,ing a "ixed si:e anywhere "rom ( 0b to (GG 0b. /he optimal si:e depends on the amount o" transaction acti,ity and reco,erability re?uirements "or the database. Initially -racle writes entries to the "irst redo log "ile. hen this "ile "ills up, -racle switches to the next. &t this time -racle begins "lushing dirty bu""ers "rom its bu""er cache. &"ter the last redo log "ile is "illed, -racle goes bac2 to the "irst one and o,erwrites it. 1e"ore -racle o,erwrites a redo log "ile, it will "irst ma2e sure the "lush o" dirty bu""ers initiated when that log "illed has been completed. /he online redo log allows -racle to de"er writes to data "iles while still being able to reco,er the database with no data loss i" the instance is terminated abruptly without "irst "lushing dirty bu""ers to dis2. In production en,ironments and other situations where data loss cannot be tolerated, an archived redo log will be maintained "or the database in addition to the online redo log. /he archi,ed redo log is a collection o" physical "iles, each the exact si:e o" the online redo log "iles, that hold all redo log entries since the database was created. #ach "ile in the archi,ed redo log will ha,e a se?uence number in the "ile name so that you can ?uic2ly tell the proper ordering o" the "iles. hen an archi,ed redo log is maintained "or the database, the database is said to be operating @in archi,elog modeA Bas opposed to @noarchi,elog modeAD. In archi,elog mode, -racle will start copying an online redo log "ile to the archi,ed redo log as soon as it "ills. -racle will not begin o,erwriting the online redo log until it has completed copying it to the archi,ed redo log. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page (( Database Specialists, Inc. www.dbspecialists.com The Oracle Process !rchitecture &n -racle database ser,er will typically ha,e an -racle database, an instance, =etI, and one or more database applications. /he applications may run on the same ser,er as the database and instance Bin which case =etI might technically not be re?uiredD but typically the applications are distributed among networ2ed computers. &n -racle instance consists o" se,eral daemon processes, all attached to the shared global area or S<&. -n 5nix, the S<& is implemented as one or more shared memory segments. -n indows =/, the entire -racle instance is implemented as one big process sharing one memory space which includes the S<&. B-n indows =/ the daemons are implemented as threads within the one process.D /he daemons ma2ing up an -racle instance are listed in 4igure ) below. #,ery -racle instance will ha,e at least P0-=, S0-=, L<R, and one D1n. /he rest are optional and con"igurable. /he @nA in a daemon name indicates a digit :ero through nine, meaning that there can be multiple copies o" that daemon running. Name %-nction Descri(tion P0-= Process monitor Process watchdogO cleans up a"ter crashed processes S0-= System monitor System watchdogO per"orms system'wide management duties L<R Log writer rites entries to the online redo log D1n Database writer rites dirty bu""ers to the data "iles !KP/ !hec2point 5pdates synchroni:ation in"ormation in the control "ile and the headers o" all data "iles &R!E &rchi,er !opies "illed online redo log "iles to the archi,ed redo log R#!- Reco,erer !oordinates with remote instances in order to reco,er "ailed distributed transactions S=Pn *ob ?ueue Runs ?ueued >obs that ha,e been scheduled to run at speci"ied time inter,als Dnnn Dispatcher !onnects an application re?uesting database ser,ices with a shared ser,er that is a,ailable to per"orm the ser,ices Bmulti'threaded ser,er con"iguration onlyD Snnn Shared ser,er Ser,ices database re?uests "rom applications Bmulti' threaded ser,er con"iguration onlyD L!Kn Loc2 !oordinates cache coherency with other instances that ha,e mounted the same database B-racle Parallel Ser,er onlyD 4igure ): /he daemons ma2ing up an -racle instance & database is made accessible to applications in three phases. 4irst an instance is started, then the database is mounted, and "inally the database is opened. 4igure 9 on the next page shows a diagram o" the -racle process architecture, and this will pro,e help"ul "or this discussion. /o start an instance -racle reads the parameter "iles "or the instance, builds the S<&, and starts daemon processes according to the parameter settings. -nce the instance has been started, a number o" -racle daemons will be running and each will be attached to the S<&. /he S<& will be correctly si:ed "or when the database is opened, but at this time it will be almost completely empty. Page () !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com 4igure 9: /he -racle process architecture /o mo-nt the database, -racle reads the contents o" the control "ile "or the database and populates data structures in the S<&. Parameters in the parameter "iles indicate the name o" the database and the location o" the control "iles. /his is how the instance determines which database to mount. &"ter the database has been mounted, most o" the S<& will still be empty and it will not yet be possible to access data in the database or e,en the data dictionary "or the database. Eowe,er, it will be possible to access control "ile type in"ormation in the S<&, such as the names o" the data "iles that ma2e up the database. /o o(en the database, -racle chec2s the headers o" all data "iles against synchroni:ation in"ormation in the control "ile in order to ,eri"y the state o" the database. I" the database was not shut down cleanly the last time, -racle will automatically per"orm what is called @instance reco,eryA in order to ma2e the database consistent again be"ore applications may access it. hen per"orming instance reco,ery, -racle will use the online redo log as necessary to redo any transactions that had be committed but were ne,er written to dis2, and the contents o" the rollbac2 segments to undo any transactions that had not yet committed when the database was shut down. B/hese two reco,ery steps are called @rolling "orwardA and @rolling bac2,A respecti,ely.D -nce -racle determines that the database is consistent, the database becomes a,ailable "or applications to access it. /he database is now considered @open.A Initially the bu""er cache and shared S7L areas within the S<& will be nearly empty. 1ut they will "ill, o" course, as the database is accessed. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page (9 Database Specialists, Inc. www.dbspecialists.com &pplications access an -racle database by connecting to the instance, preparing and submitting a re?uest, and retrie,ing the results. /he low'le,el &PI applications use to access -racle databases is called the -racle !all Inter"ace, or -!I. /here are a huge number o" wrappers a,ailable to ma2e the &PI loo2 di""erentLProH!, *D1!, D1I/D1D, and -D1! are >ust a "ew o" them. 1ut since these &PIs ultimately boil down to -!I, they all will share similar concepts. &n application connects to an -racle instance by speci"ying a username, a password, and optionally a =etI identi"ier. I" the desired instance is running on the same ser,er as the application itsel", the application can set the -R&!L#MSID en,ironment ,ariable to the name o" the instance. In this case, the application will "or2 o"" an -racle ser,er process that attaches itsel" to the S<&. 1ecause the -racle ser,er process has its setuid bit set, the ser,er process will be able to read all o" the data "iles "or the database and read and write to the S<&. I" the application wishes to connect to an instance on a remote ser,er, then =etI will be in,ol,ed. /he application will either speci"y a =etI alias "or the desired database or set the /-M/&SK en,ironment ,ariable to the =etI alias. =etI will resol,e the alias to a host name, instance name, and protocol in"ormation Bsuch as /!P/IP and a port numberD. /he application will then send a message using the correct protocol to the correct port number on the ser,er running the desired instance. & =etI listener process running on the remote ser,er will "or2 o"" an -racle ser,er process and the application will relay its database access re?uests through this ser,er process. -nce an application is connected to an -racle instance, it submits database access re?uests ,ia its -racle ser,er process. 1asically, the application prepares and submits S7L or PL/S7L statements to the ser,er process "or execution. /he ser,er process will read and write bu""ers in the S<&$s bu""er cache as re?uired to satis"y the re?uest, also reading bloc2s "rom data "iles into the bu""er cache when necessary and writing to the S<&$s redo log bu""er as necessary. It$s interesting to note, howe,er, that the ser,er process will not write dirty bu""ers "rom the bu""er cache bac2 to data "iles. =or will it write redo log entries "rom the S<&$s redo log bu""er to the online redo log "iles. /hese tas2s are relegated to D1n and L<R, respecti,ely. &pplications interact with the -racle ser,er process in a client/ser,er "ashion. /he application submits a re?uest and the ser,er process satis"ies it. /he -racle ser,er process will only respond to the application$s re?uests, and will not initiate acti,ity on its own. In "act, i" a D1& 2ills an idle database connection, the application will not learn its connection has been terminated until the next time it submits a re?uest. &pplications execute all PL/S7L calls and S7L statements other than ?ueries by preparing the statement and then submitting an instruction to execute the statement. -racle will return status in"ormation indicating success, how many rows were processed, and so on. -racle may also return ,alues to the application. &pplications execute S7L ?ueries a little bit di""erently. 4irst they prepare the statement and then submit the instruction to execute it. /he -racle ser,er process might not do much processing at this point, howe,er. /he next step is "or the application to re?uest a set o" results. /his may be one row or one hundred, depending on what the application as2s "or. It is this re?uest "or results that triggers the actual processing in the -racle ser,er process. /he application may as2 "or results repeatedly until the entire result set has been returned to the application. hen the application is "inished accessing the -racle database, it submits an instruction to disconnect. /his causes the -racle ser,er process to detach itsel" "rom the S<& and exit. Page (; !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com &nvironment 'aria$les hen an application connects to an -racle instance, or when a D1& starts an instance and opens a database, -racle reads the settings o" se,eral en,ironment ,ariables. /hese ,ariables help -racle "ind the correct libraries and determine which database to access, among other things. 4igure ; shows the main en,ironment ,ariables o" interest to -racle on 5nix. Bindows =/ uses the registry to hold this in"ormation, instead o" en,ironment ,ariables.D .ariable '-r(ose Sam(le .al-e Im(ortance -R&!L#ME-0# Location o" -racle so"tware installation /uG(/app/oracle/product/I.G.. Re?uired LDMLI1R&R8MP&/E Location o" -racle shared libraries Include J-R&!L#ME-0#/lib Re?uired P&/E Location o" -racle executables Include J-R&!L#ME-0#/bin Re?uired -R&!L#MSID =ame o" local -racle instance to access 08D1 -ptional /-M/&SK =etI alias o" -racle instance to access 08D1 -ptional =LSML&=< Language and character set o" client application americanMamerica.5S3&S!II -ptional -R&M=LS99 Location o" -racle client =LS character set data J-R&!L#ME-0#/ocommon/nls/admin/data -ptional -R&!L#M1&S# Location o" -4& directory structure /uG(/app/oracle -ptional D1& Location o" instance'related administrati,e "iles /uG(/app/oracle/admin -ptional 4igure ;: #n,ironment ,ariables o" interest to -racle -R&!L#ME-0# must be set and LDMLI1R&R8MP&/E and P&/E must include the right -racle directory in order "or -racle to locate the proper executables, libraries, and =etI con"iguration "iles. -R&!L#MSID or /-M/&SK may be set to allow an application to access a database without speci"ying the desired instance explicitly. I" both are set, then /-M/&SK will ta2e precedence. &lso, i" the application speci"ies a =etI alias when connecting, this will ta2e precedence o,er both the -R&!L#MSID and /-M/&SK en,ironment ,ariables. =ote that in 4igure ; both -R&!L#MSID and /-M/&SK ha,e the same sample ,alue. /his can be misleading, as the -R&!L#MSID contains the name o" an -racle instance while /-M/&SK contains a =etI alias. It >ust happens to be good practice to name =etI aliases the same as the -racle instance they re"erence. =LSML&=< and -R&M=LS99 indicate the language and character set o" the client application, and help -racle locate resource "iles "or con,erting between character sets. /hese ,ariables are not re?uired i" #nglish and 3 bit &S!II are to be used. 4or all other languages and character sets, howe,er, both should be set correctly. /he "ormatting o" the =LSML&=< ,ariable is a bit oddLsee the plat"orm speci"ic installation guide "or a list o" supported ,alues. =ote that early releases o" -racle "or Linux may not support languages other than #nglish. -R&!L#M1&S# and D1& assist D1&s by allowing them to ?uic2ly na,igate to certain important directories in the -racle hierarchy. /he exact meaning o" these ,ariables will become more clear when we loo2 at installation best practices on the next page. 8ou can set all o" these en,ironment ,ariables in your login scriptLsuch as .bashrc, .pro"ile or .cshrc. 8ou may choose to hardcode these ,ariables to the appropriate ,alues "or your implementation, or you may choose to integrate your login script with scripts pro,ided by -racle expressly "or setting up en,ironments. hile it may seem easier at "irst to >ust hardcode e,erything, integrating with the -racle scripts is de"initely the way to go. /his will ma2e it much easier to support multiple instances running on one ser,er, and will minimi:e the complexity o" "uture -racle so"tware upgrades. e will co,er login scripts in greater detail when we wal2 through the process o" installing -racle so"tware and building a de"ault database. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page (. Database Specialists, Inc. www.dbspecialists.com Installation Best Practices( OF! -,er the years, the consulting group within -racle !orporation de,eloped a set o" best practices "or installing and con"iguring -racle databases. /hey called it the -ptimal 4lexible &rchitecture, or -4&. /oday the -4& is a relati,ely compact set o" rules that help lead to an -racle installation that is easy to support and highly scalable. &round (%%. or so -racle began integrating -4& concepts into the so"tware installer on the 5nix plat"orm so that per"orming a @de"aultA installation would yield a somewhat -4& compliant system. -racle 3.9 and later install on 5nix in a reasonably good way B-racle I.G and later on Linux, since -racle 3.9 was ne,er released "or LinuxD. It$s interesting to note that the indows =/ group at -racle was apparently o"" in their own worldO indows =/ -racle installations donPt approach any semblance o" -4& compliance until -racleIi. /he administrator$s re"erence manual in -racle$s plat"orm speci"ic documentation contains a thorough explanation o" the -4&. /he basic bene"its o" the -4& are: & standard methodology that will be "amiliar to experienced -racle D1&s & naming con,ention that is simple and ma2es sense & standard "or locating "iles that ma2es things easy to "ind Support "or multiple databases and/or ,ersions o" -racle so"tware on one ser,er & separation between -racle so"tware and database "iles, ma2ing upgrades easier & well thought out operating system security policy Distributing I/- across many physical storage de,ices /he -4& guidelines co,er the "ollowing areas: &ssigning and naming mount points Directory hierarchy "or -racle so"tware, database "iles, and administrati,e "iles =aming con,entions "or all "iles that ma2e up a database or control an instance =aming tablespaces &ssigning segments to tablespaces 4igure . shows the basic directories o" an -4& compliant -racle installation, and 4igure C shows sample directory and "ile names "or an -4& compliant -racle database. Director Descri(tion J-R&!L#M1&S# Root o" the -4& directory structure J-R&!L#M1&S#/product/Q,ersionR -racle so"tware installation, or -R&!L#ME-0# "or a speci"ic ,ersion o" -racle so"tware J-R&!L#M1&S#/admin/J-R&!L#MSID &dministrati,e area "or a speci"ic instance. Subdirectories include: ' p"ile ' bdump ' cdump ' udump ' create Qmount pointR/oradata/QdbnameR Data "iles, online redo logs, and control "iles "or a speci"ic database 4igure .: 1asic directories o" an -4& compliant -racle installation Page (C !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com %ile or Director Location -R&!L#M1&S# /uG(/app/oracle -R&!L#ME-0# /uG(/app/oracle/product/I.G.. 08D1 admistrati,e "ile tree /uG(/app/oracle/admin/08D1 08D1 parameter "ile /uG(/app/oracle/admin/08D1/p"ile/init08D1.ora 08D1 alert log /uG(/app/oracle/admin/08D1/bdump/alertM08D1.log 08D1 control "iles /uG)/oradata/08D1/controlG(.ctl /uG9/oradata/08D1/controlG).ctl /uG;/oradata/08D1/controlG9.ctl 08D1 online redo logs /uG)/oradata/08D1/redoG(.log /uG)/oradata/08D1/redoG9.log /uG9/oradata/08D1/redoG).log /uG9/oradata/08D1/redoG;.log 08D1 data "iles /uG;/oradata/08D1/systemG(.db" /uG;/oradata/08D1/tempG(.db" /uG./oradata/08D1/rbsG(.db" /uGC/oradata/08D1/tableG(.db" /uG3/oradata/08D1/indexG(.db" 4igure C: Sample directory and "ile names "or an -4& compliant -racle database Interacting with a #ata$ase -racle pro,ides two ,ery basic tools "or interacting with an -racle database. hile application de,elopers will probably interact through a wide selection o" &PIs and end users will access data through applications or ?uery tools, the D1& is o"ten le"t to use -racle$s basic tools. SQL*'l-s is a simple character mode tool that lets you connect to an -racle instance and submit arbitrary S7L statements and PL/S7L code. /he tool o""ers rudimentary output "ormatting capabilities, allowing S7LHPlus to be used as a ,ery crude reporting tool. S7LHPlus also has scripting capabilities. <hough the scripting "eatures seem prehistoric compared to modern languages and tools, you can do a surprising amount o" automation with S7LHPlus scripting. Server $anager is an e,en more bare'bones character mode tool. Li2e S7LHPlus, it lets you connect and submit arbitrary commands. /he output "ormatting and scripting capabilities o" Ser,er 0anager are e,en more limited than those o" S7LHPlus. Eowe,er, Ser,er 0anager allows you to startup and and shut down -racle instancesLsomething you cannot do with S7LHPlus. D1&s who want to get beyond basic tools ha,e an increasing number o" options a,ailable. -racle now o""ers #nterprise 0anager, a <5I tool "or managing multiple -racle databases. Depending on your -racle licensing arrangement, certain modules o" #nterprise 0anager may be a,ailable to you "ree o" charge. 5n"ortunately, the #nterprise 0anager that comes with -racle releases prior to -racleIi is ?uite limited. 4or one thing, the earlier ,ersion only runs on the indows plat"orm. 4or another, it stores a lot o" important in"ormation on the indows client, undermining the possibilities o" remote administration or ha,ing a team o" -racle D1&s share duties. /he newer ,ersion o" #nterprise 0anager shipping with -racleIi is *a,a based, and is supposed to run "rom a web browser. /his might ma2e it a more appealing database administration tool. 1esides #nterprise 0anager, there are a host o" other D1& tools a,ailable today. Some o" the more basic ones are a,ailable "or "ree on the internet, while a whole host o" companies are mar2eting ,ery complex and sophisticated products "or e?ually sophisticated prices. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page (3 Database Specialists, Inc. www.dbspecialists.com Oracle )uick *tart In order to get up and running on -racle, you$ll "irst need to install the -racle so"tware and create a de"ault database. =ext you$ll want to ad>ust the de"ault database to impro,e its -4& compliance and ma2e the database more usable. B/he de"ault database won$t get you ,ery "ar, unless you will >ust be playing around with a "ew Kb o" data.D -nce you$,e got a ,iable database running, you are ready to create your application schemas and establish connecti,ity between your applications and the database. =ow you are set to do your application de,elopment. Soon it becomes time to thin2 about real world issues such as capacity planning, per"ormance, security, bac2up and reco,ery, and implementing schema or application changes while you are already in production. In the next section o" this tutorial, we$ll wal2 through the process o" installing -racle so"tware and creating a de"ault database. e$ll go through this in blistering detail, because there are many issues and lots o" @gotchasA that lead people new to -racle technology to the conclusion that -racle is o,erly complicated and di""icult to install. &ctually, it$s all ,ery simple i" you ha,e the right in"ormation. Page (I !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com !on"iguring -racle on Linux 4or Pea2 Per"ormance Page (% Database Specialists, Inc. www.dbspecialists.com Installing the Oracle *oftware an Creating a #efault #ata$ase In this section o" the tutorial we will wal2 through the steps o" installing -racle I.G.. Standard #dition in a Red Eat ..) Linux en,ironment and creating a de"ault database. Subse?uent sections will loo2 at how to manage the database and optimi:e per"ormance. In this section we will drill down to a great le,el o" detail so that e,en the system administrator who is new to -racle can get up and running ?uic2ly. Linux is extremely similar to "la,ors o" 5nix such as Solaris. &bout %.S o" the material here is directly applicable to other 5nix plat"orms. /he main areas o" di,ergence are the setting o" the operating system 2ernel parameters and the locations o" the oratab "ile and local bin directory. /here are "our phases to getting -racle up and running on your database ser,er: (. Prepare the ser,er ). Install the -racle so"tware 9. !reate an -racle database ;. !omplete the ser,er con"iguration e will wal2 through these phases one at a time, detailing all the steps in,ol,ed. /he end result will be a ,ery usable database that can be scaled up ?uite large. -" course, e,ery implementation is uni?ue, and you will need to e,aluate each step care"ully against your particular re?uirements. 1ut this section o" the tutorial will get you o"" to a ,ery solid start. Pre"are the *erver /hese steps con"igure your machine so that it will be ready to accept the -racle so"tware and database. In this section, we will ma2e sure the operating system meets -racle$s minimum re?uirements, create a special user and group to @ownA the so"tware, and create some directories that will be used by the -racle so"tware and database. &ll o" the steps in this section are run as the root user. (. 0a2e sure that your ,ersion o" Linux is su""icient. -racle wor2s with many di""erent distributions o" Linux. /he 2ey re?uirements are that the 2ernel be ).G.99 or higher, and <=5 ! libraries be ).G.C or higher. 0any users ha,e reported that the <=5 ! libraries must in "act be ).G.C or ).G.3Tthat the @or higherA is not true. 8ou will greatly simpli"y your li"e i" you wor2 with the Red Eat ..) distribution. /his pac2age is reasonably priced, readily a,ailable, and 2nown to wor2 ,ery well with -racle I.G.. Standard #dition. =ote that the Red Eat C.G distribution includes <=5 ! libraries ).(, and many users ha,e reported di""iculties installing -racle on Linux systems that use <=5 ! libraries ).(. B-racle has a patch a,ailable, i" you really want to use the newer <=5 ! libraries.D ). 0a2e sure that your hardware is su""icient. 8ou$ll need at least 9) 0b R&0, a !D R-0 dri,e, and about .GG 0b o" dis2 space. /his will let you create a small database "or prototypingO a real implementation will li2ely re?uire more R&0 and more dis2 space. Page )G !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com 9. 0a2e sure that the Linux 2ernel has parameters set su""iciently high "or -racle. /he -racle architecture ma2es hea,y use o" shared memory segments "or sharing data between multiple processes and semaphores "or handling loc2ing. 0any operating systems, such as Solaris, do not by de"ault o""er su""icient shared memory or semaphores "or maintaining an -racle database. Eappily, Red Eat Linux ..), by de"ault, builds a 2ernel that will support most -racle implementations. /ernel 'arameter &ed 0at 123 De+a-lt '-r(ose SE00&F Gx)GGGGGG B9) 0bD 0aximum si:e o" a single shared memory segment SE00I= ( 0inimum si:e o" a single shared memory segment SE00=I ()I 0aximum number o" shared memory segments in entire system SE0S#< ()I 0aximum number o" shared memory segments one process can attach S#00=S ;G%C 0aximum number o" semaphores in entire system S#00=I ()I 0aximum number o" semaphore sets in entire system S#00SL 9) 0aximum number o" semaphores per set /he "irst "our 2ernel parameters con"igure shared memory segments. /he Red Eat ..) de"aults allow your database S<&s to get as big as you could possibly want, when you consider that Linux is limited to ) <b o" physical memory. I" a database has an S<& bigger than 9) 0b, it will be spread across multiple shared memory segments. /his is not a concern. /he last three 2ernel parameters con"igure semaphores. #ach -racle instance re?uires one semaphore "or each process. -racle does not seem to care how many semaphores are in each set, but it appears that one instance cannot handle more than 9G sets. /he Red Eat ..) de"aults allow you to ha,e "our instances on one ser,er, with each instance ha,ing about %CG processes. /his should be su""icient "or most implementations. Recompiling a Linux 2ernel is somewhat complicated and de"initely re?uires that you 2now what you are doing. e won$t co,er it here, but you probably won$t need to recompile your 2ernel to install -racle, anyway. ;. !reate a Linux group that will be used by the -racle so"tware owner and database administrators. 8ou can call it what you li2e, but the standard is @dbaA. I" you will be installing -racle on multiple Linux ser,ers on your networ2, you might want to 2eep the groupid the same on all ser,ers. I created my dba group with the command: groupadd 2g "00 dba .. !reate a Linux user that will be the -racle so"tware owner. 8ou can call it what you li2e, but the standard is @oracleA. I" you will be installing -racle on multiple Linux ser,ers on your networ2, you might want to 2eep the userid the same on all ser,ers. =ote that this user$s home directory will not be the -R&!L#ME-0# or where the actual -racle so"tware is installedO this user$s home directory should be in the same place as other users$ home directories. /his user$s initial group should be the dba group created in the pre,ious step. I created my oracle user with the commands: useradd 3c 45racle soft6are o6ner4 3d /*ome/oracle 3g dba 3m 2n 7 3s /bin/bas* 3u "00 oracle pass6d oracle !on"iguring -racle on Linux 4or Pea2 Per"ormance Page )( Database Specialists, Inc. www.dbspecialists.com C. !reate mount points "or the -racle so"tware and the -racle database. #ach mount point should correspond to a separate physical dis2 de,ice. 8ou$ll need at least one mount point. /ypically you use one mount point "or the -racle so"tware and as many as you can a""ord "or each database. B0ore physical de,ices allow better per"ormance.D & nice con,ention is to call the mount points /uG(, /uG), and so on. 1ecause mount points are typically owned by root and the -racle installer will run as the oracle user and not root, you should create some subdirectories now to a,oid permissions problems later. !reate an app subdirectory below the so"tware mount point, and oradata subdirectories below the mount points to be used "or databases. B8ou can put so"tware and a database on the same mount point i" you wish.D 0a2e these subdirectories owned by the oracle user and dba group, and gi,e them 3.. permissions. 3. !hoose a directory that the -racle so"tware will re"er to as the @local binA directory. & common choice is /usr/local/bin, and your installation will go more smoothly i" you stic2 with this choice. 0a2e sure this directory is on users$ path by de"ault. I. I" you downloaded a trial ,ersion o" -racle o"" o" the internet, then untar the distribution. I" you ha,e the so"tware on !D R-0, then mount the !D R-0 now. I use automount to mount my !Ds, but alternati,ely you can use a command li2e: mount 3t iso(..0 /de+/cdrom /cdrom %. !reate the /etc/oratab "ile. &"ter installation, this will be a plain text "ile that brie"ly describes the -racle so"tware installations and databases on the ser,er. /he "ile must exist be"ore installation can begin. /he easiest way to create the "ile is simply to create an empty "ile called /etc/oratab and change the ownership to oracle, the group to dba, and the permissions to CC;. <ernati,ely, you can set the -R&!L#M-=#R en,ironment ,ariable and execute a shell script on the !D R-0: 589:;<_5=><8=oracle e1port 589:;<_5=><8 cd /cdrom/orainst ./oratab.s* Page )) !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com Install the Oracle *oftware /hese steps install the -racle database so"tware onto your ser,er so that you will then be able to create databases and use ser,er'side tools li2e S7LHPlus and Ser,er 0anager. In this section, we will prepare the oracle user$s en,ironment, run the -racle Installer, and tidy up a "ew minor messes that the installer lea,es behind. e will create a database later by in,o2ing the -racle Installer a second time. /his allows us to choose our own database bloc2 si:e instead o" being "orced to use the de"ault. &ll o" the steps in this section, except where noted, are run as the oracle user. (. #dit the oracle user$s login "ile so that the en,ironment will be con"igured automatically on login. I" you are using 1ash, then edit the .bashrc "ile. I" you are using 1ourne or Korn shell, then edit .pro"ile. 4or now, we will hardcode certain things. 1ut a"ter the so"tware and database are installed, we will come bac2 and eliminate all hardcodings. Eere is what I added to my .bashrc: umas% 022 # -ubstitute ?our 5racle soft6are mount point in t*e line belo6. e1port 589:;<_B9-<=/u0/app/oracle e1port 589:;<_@5M<=A589:;<_B9-</product/'.0.) # -ubstitute t*e name of ?our 5racle database belo6. e1port 589:;<_-BD=MYDB e1port ;D_;BB898Y_P9C@=A589:;<_@5M</lib # -ubstitute terminal t?pe in line belo6. +t00 or +t220 is # recommended. e1port 589:;<_C<8M=+t00 # Dollo6ing t6o lines are not re/uired if ?ouEll be using t*e # default c*aracter set! F3bit 9-:BB. Co use anot*er c*aracter # set! see 9ppendi1 : of t*e Bnstallation Guide and c*ange # >;-_;9>G accordingl?. e1port 589_>;-""=A589:;<_@5M</ocommon/nls/admin/data e1port >;-_;9>G=american_america.H-F9-:BB # Dill in t*e follo6ing line as ?ou 6is*! but ma%e sure t*at # A589:;<_@5M</bin! /bin! /usr/bin! and Ilocal binJ are all # in t*e P9C@. e1port P9C@=... # Bf ?our /+ar/tmp doesnEt *a+e at least 20 Mb free for t*e # 5racle Bnstaller to use (or is not 6ritable b? oracle$! t*en # complete t*e follo6ing line. e1port CMPDB8=... # <nsure t*at -8:@5M< and C=5_C9-K are not set. # Bf ?ou 6ill be using La+a! include t*e follo6ing t6o linesM e1port :;9--P9C@=A589:;<_@5M</0dbc/lib/classes.&ip e1port ;D_;BB898Y_P9C@=A;D_;BB898Y_P9C@MA589:;<_@5M</0dbc/lib ). Log out and log bac2 in as the oracle user so that the en,ironment is set correctly. 9. 5se "tp to trans"er a small "ile to a remote host to pro,e to yoursel" that /!P/IP networ2ing is installed and wor2ing properly on your ser,er. ;. #nsure that the mount point you designated "or the -racle so"tware has su""icient "ree space. &llow ;GG 0b as a bare minimum. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page )9 Database Specialists, Inc. www.dbspecialists.com .. Double chec2 that you are logged in as oracle and not root. /hen start the -racle Installer. I recommend that with this release o" -racle, you simpli"y your li"e and use the character mode ,ersion o" the installer. /o do this, ma2e sure your DISPL&8 en,ironment ,ariable is not set, and that -R&!L#M/#R0 is set accordingly. Start the installer with these commands: cd /cdrom/orainst ./orainst e$ll wal2 through the installer prompts one at a time: a. !hoose !ustom Install. b. Read two not ,ery interesting readme "iles. c. !hoose Install, 5pgrade, or De'Install So"tware. d. !hoose Install =ew Product T Do =ot !reate D1 -b>ects. e. !on"irm settings "or -R&!L#M1&S# and -R&!L#ME-0#. /hese should be correct, because you set your en,ironment ,ariables be"orehand. ". !on"irm log "ile locations. /he -racle Installer will write "our log "iles in the J-R&!L#ME-0#/orainst directory. g. !hoose Install "rom !D'R-0. h. !hoose the language you want your -racle installation to support. /his is the language that banners, prompts, and error messages will be displayed in. /he languages a,ailable "or your data stored in the database will be dictated by the character set you choose when creating the database, and not by how you answer this installer prompt. I chose &merican #nglish. i. !on"irm the root.sh location. /his "ile will contain post'installation steps to be per"ormed by the root user. I" you run the installer multiple times, you$ll be prompted to mo,e the pre,ious root.sh "ile to another location. >. -n the So"tware &sset 0anager screen, select the products you wish to install and choose the Install button. =ote that selecting products that ha,e sub'products Bli2e @=etI Protocol &daptersAD doesn$t do anythingLyou need to select the sub'products themsel,es. Eere$s what I installed: !lient So"tware =etI /!P/IP Protocol &dapter 5nix Installer *D1! Dri,ers Ser,er Documentation Standard RD10S PL/S7L ProH!/!UU S7LHPlus I recommend installing the 5nix Installer. /his will ma2e it easier to per"orm maintenance operations Bsuch as relin2ingD in the "uture without ha,ing to dig out the !D R-0. &lso, note that the Ser,er Documentation selection will only install Linux plat"orm'speci"ic documentationO the generic -racle product documentation is contained on a separate !D R-0. 2. !hoose the Linux group you created in the pre,ious section as the D1& group. &ny Linux user belonging to this group will ha,e "ull database administration pri,ileges o,er all databases on this ser,er. l. !hoose the Linux group you created in the pre,ious section as the osoper group. &ny Linux user belonging to this group will ha,e @operatorA pri,ileges o,er all databases on this ser,er. 8ou could use a separate Linux group "or this purpose, but most installations do "ine with using the same Linux group "or both D1& and osoper. m. !hoose the *D1! dri,ers you wish to install Bi" you selected *D1! dri,ers on the So"tware &sset 0anager screenD. /here is support "or *DK (.G and (.(, and there are dri,ers that re?uire =etI or dri,ers that run on a thin client. n. !on"irm the directory "or your online documentation, i" you chose to install it. /he de"ault is J-R&!L#ME-0#/doc, and this seems li2e a good choice. o. !hoose whether to install documentation in E/0L "ormat, PD4 "ormat, or both. Remember, this only applies to the Linux plat"orm'speci"ic documentation. Page ); !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com p. &t this point, the -racle Installer installs so"tware onto your ser,er. ?. I encountered one glitch during the so"tware installation. 8ou will not encounter this problem unless you chose to install Ser,er Documentation. /he installer reported a write error, which may ha,e occurred because the installer tried to copy a "ile without creating the directory "irst. I "ixed this problem easily by going to another window on the ser,er and creating the directory speci"ied in the error message. /hen I chose the Retry option in the -racle Installer, and things continued normally. r. hen the installation is complete you$ll recei,e a message that the re?uested actions ha,e been per"ormed. !hoose -K, and you will be returned to the So"tware &sset 0anager screen. s. #xit the installer. C. In J-R&!L#ME-0#/bin you will "ind a shell script called oraen,. /his script can be called "rom .bashrc or .pro"ile to set up a user$s en,ironment. 5n"ortunately, there are se,eral ,ariables that the script does not setLsome handy, some ,ery important. 0a2e a bac2up copy o" the script and then edit it, adding the "ollowing lines to the ,ery end: # Begin customi&ations 589:;<_B9-<=Ndirname A589:;<_@5M<N 589:;<_B9-<=Ndirname A589:;<_B9-<N DB9=A589:;<_B9-</admin 589_>;-""=A589:;<_@5M</ocommon/nls/admin/data # -ubstitute c*aracter set ?ou plan to use in follo6ing line. >;-_;9>G=american_america.H-F9-:BB e1port 589:;<_B9-< DB9 589_>;-"" >;-_;9>G case OA;D_;BB898Y_P9C@O in PA5;D@5M</libP$ ;D_;BB898Y_P9C@=Nec*o A;D_;BB898Y_P9C@ Q 7 sed OsRA5;D@5M</libRA589:;<_@5M</libRgON RR PA589:;<_@5M</libP$ RR PM$ ;D_;BB898Y_P9C@=AS;D_;BB898Y_P9C@TA589:;<_@5M</libM RR OO$ ;D_;BB898Y_P9C@=A589:;<_@5M</lib RR P$ ;D_;BB898Y_P9C@=A;D_;BB898Y_P9C@MA589:;<_@5M</lib RR esac # Dollo6ing case statement onl? re/uired if using LDB:. case OA;D_;BB898Y_P9C@O in PA5;D@5M</0dbc/libP$ ;D_;BB898Y_P9C@=Nec*o A;D_;BB898Y_P9C@ Q 7 sed OsRA5;D@5M</0dbc/libRA589:;<_@5M</0dbc/libRgON RR PA589:;<_@5M</0dbc/libP$ RR PM$ ;D_;BB898Y_P9C@=AS;D_;BB898Y_P9C@TA589:;<_@5M</0dbc/libM RR OO$ ;D_;BB898Y_P9C@=A589:;<_@5M</0dbc/lib RR P$ ;D_;BB898Y_P9C@=A;D_;BB898Y_P9C@MA589:;<_@5M</0dbc/lib RR esac e1port ;D_;BB898Y_P9C@ # <nd customi&ations !on"iguring -racle on Linux 4or Pea2 Per"ormance Page ). Database Specialists, Inc. www.dbspecialists.com 3. I made a "urther edit to J-R&!L#ME-0#/bin/oraen, that you may or may not need. &"ter editing my .bashrc to call oraen, each time a new shell is created Bwe$ll do this in a "uture stepD I "ound that sometimes my ser,er would run out o" processes. I ha,e not seen this beha,ior on other Linux ser,ers, so I might ha,e something peculiar in my con"iguration. I" your ser,er starts gi,ing you ,"or2 errors "urther down in the installation process, then come bac2 and per"orm this step. -therwise, you may wish to try and get by without it. /he edit is as "ollows: 4ind the line in J-R&!L#ME-0#/bin/oraen, that contains a call to dbhome. Replace it with the "ollowing: # Begin customi&ations #589@5M<=Ndb*ome OA589:;<_-BDON # Dollo6ing t6o lines ta%en from db*omeM 589C9B=/etc/oratab 589@5M<=Na6% 3DM O/UAS589:;<_-BDTM/ Sprint 77A2R e1itTO 7 A589C9B 2V/de+/nullN # <nd customi&ations I. In J-R&!L#ME-0#/bin you$ll "ind a script called dbshut. /his is a utility that you can run to shut down databases on the ser,er. 5n"ortunately, it shuts down databases with normal priority. /his means that i" any users are logged into a database, the shutdown will hang until they log out. 8ou might want to change this script to shut down databases with immediate priority. /o do this, "ind the two lines that contain >ust the word @shutdownA. !hange these to read @shutdown immediateA. %. Loo2 at the script J-R&!L#ME-0#/orainst/root.sh. /his is a script that the installer created during so"tware installation. It$s a collection o" commands that need to be run as the root user. 8ou should re,iew the script care"ully and decide whether to run it as is, or hand'pic2 the commands you wish to run as root. Running the script as is creates more problems than it "ixes. Really, all you need to do as root is copy oraen,, dbhome, and coraen, "rom J-R&!L#ME-0#/bin to the local bin directory. I" you do choose to run root.sh, please be ad,ised that there is a documented serious security problem. root.sh will set the setuid bit on se,eral "iles in J-R&!L#ME-0#/bin, and change some o" them to be owned by root. =othing in J-R&!L#ME-0#/bin should be owned by root, and only the oracle and dbsnmp executables should ha,e a setuid bit turned on. -racle !orporation has released an emergency patch called setuidMpatch.sh to address this problem. /he problem is also present on all 5nix releases o" -racleI and -racleIi through and including I.(... (G. hether or not you run root.sh, double'chec2 a "ew "ile permissions. /he permissions on J-R&!L#ME-0#/bin/oracle should be C3.(. 0y installation came out as ;3... &lso, oraen, in J-R&!L#ME-0#/bin and the local bin directory should ha,e permissions 3... 0y installation came out as 333. Create an Oracle #ata$ase /hese steps create an -racle database on your ser,er. In this section we will create a de"ault -racle database, twea2 the de"ault con"iguration so that the database is actually usable, create application users and tablespaces in the database, and con"igure =etI. &ll o" the steps in this section are run as the oracle user. (. !hoose a bloc2 si:e "or your -racle database. /he de"ault is ) Kb, and this is appropriate "or ,ery small demo or @sand boxA databases. I" you anticipate your database growing beyond perhaps (GG 0b in si:e, you should use a bloc2 si:e o" I Kb or (C Kb. ). /he -racle Installer will not as2 you what bloc2 si:e you want, and you cannot change a database$s bloc2 si:e a"ter creation. I" you want your database to ha,e a bloc2 si:e other than ) Kb, then you will need to edit the "ile J-R&!L#ME-0#/rdbms/install/rdbms/cn"g.orc to set the dbMbloc2Msi:e to I(%) or (C9I;. 0a2e sure the line is not commented out. Page )C !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com 9. Double chec2 that you are logged in as oracle and not root. /hen start the -racle Installer. &gain, I recommend that with this release o" -racle you simpli"y your li"e and use the character mode ,ersion o" the installer. /o do this, ma2e sure your DISPL&8 en,ironment ,ariable is not set, and that -R&!L#M/#R0 is set accordingly. /his time we will run the -racle Installer installed on your systemO we no longer ha,e a need "or the so"tware !D R-0. Start the installer with these commands: cd A589:;<_@5M</orainst ./orainst e$ll wal2 through the installer prompts one at a time: a. !hoose !ustom Install. b. Read two not ,ery interesting readme "iles. c. !hoose !reate/5pgrade Database -b>ects. d. !hoose !reate Database -b>ects. e. !on"irm settings "or -R&!L#M1&S# and -R&!L#ME-0#. /hese should be correct, because you set your en,ironment ,ariables be"orehand. =ote that the installer will want the parent directory abo,e -R&!L#M1&S# to be writable by the oracle user. /his does not ma2e a lot o" sense, but the easiest thing to do is humor the installer and open up permissions on that directory B"or example, /uG(/appD temporarily. &"ter the database is created, you can loc2 down the permissions again. ". !on"irm log "ile locations. /he -racle Installer will write "our log "iles in the J-R&!L#ME-0#/orainst directory. g. !on"irm the setting "or -R&!L#MSID. /his should be correct, because you set your en,ironment ,ariables be"orehand. h. -n the So"tware &sset 0anager screen, you$ll see a list o" all products that ha,e been installed. Select e,ery product except the -nline /ext 6iewer and choose Install. /his will cause -racle to do whate,er database setup is re?uired "or each product. 0any products Bli2e the /!P/IP protocol adapterD donPt ha,e any database ob>ects associated with them, but some Bli2e S7LHPlus and PL/S7LD do. It$s sa"est to select all products, but donPt select the -nline /ext 6iewer because the installer will gi,e you an error message i" you do. i. !hoose !reate Product D1 -b>ects "or Ser,er 0anager. >. !hoose 4ilesystem'1ased Database Bunless you want to deal with raw de,ices, in which case you are on your ownD. 2. !hoose =o to Distribute control "iles o,er three mount points. /he de"ault database that the installer builds "or you will need twea2ing whether you distribute "iles across three mount points or not. /he mess is a little easier to clean up i" it$s all in one directory instead o" spread across three. l. #nter the mount point where the installer should create the databaseL"or example, /uG(. 8ou should ha,e already created an oradata subdirectory under the mount point and made it owned by the oracle user, or else you will run into "ile permission problems. m. !hoose a character set "or the database. 5S3&S!II is the de"ault on Linux and 5nix. BIt is not the de"ault on indows =/.D I" you want to use a di""erent character set, then you should ha,e set =LSML&=< and -R&M=LS99 be"ore in,o2ing the installer. 8ou cannot change a database$s character set a"ter creation. I" you want to store non'#nglish text in your database, such as umlauts and diacritical mar2s, then you should de"initely not use 5S3&S!II as your character set. See &ppendix ! o" the Installation <uide "or a list o" recogni:ed character sets. n. !hoose a national character set "or the database. /his is the character set to use "or storing data o" type =!E&R, =6&R!E&R), and =!L-1. &gain, see &ppendix ! o" the Installation <uide "or a list o" recogni:ed character sets. o. #nter passwords "or the S8S/#0 and S8S users. Remember that -racle passwords are not case'sensiti,e, must start with a letter, and certain special characters are not allowed. I$,e heard that putting a period in the S8S/#0 or S8S password will cause the installer to crash, but I$,e ne,er tried it. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page )3 Database Specialists, Inc. www.dbspecialists.com p. I" you want to be able to start up and shut down this database without actually logging on to the ser,er, then choose 8es when as2ed, @Do you want to set the passwords "or the internal users Bdba and operatorDVA /his will cause the installer to create a password "ile external to the database. /his is necessary i" you will be controlling your database remotely "rom #nterprise 0anager. ?. #nter a password "or the =etI listener. r. !hoose whether or not you want the installer to con"igure the multi'threaded ser,er B0/SD on your database. 0/S is typically not appropriate unless there will be large numbers o" -L/P users. s. !hoose 8es and -K repeatedly to accept the names and si:es that the installer is proposing "or your database "iles. &ctually these de"aults are pretty aw"ul, but it$s much easier to "ix later. t. 8ou might be as2ed which *DK dri,ers you wish to install. /his is not rele,ant to database creation, so >ust choose them all and humor the installer. u. 8ou will be as2ed i" you would li2e to load the S7LHPlus help "acility. 8ou should probably choose =o, as the E/0L and PD4 documentation is in"initely more use"ul. 1ut i" you do li2e the S7LHPlus help "acility, "eel "ree to install it. ,. 8ou will be as2ed i" you would li2e to load the S7LHPlus demo tables. /hese include the ,enerable emp and dept tables in the scott/tiger schema. I" you are new to -racle or would li2e an easy schema to start testing with, then choose 8es. In most cases, howe,er, you$ll chose =o. w. /he installer now creates the database and lea,es it running. x. hen the database creation is complete you$ll recei,e a message that the re?uested actions ha,e been per"ormed. !hoose -K, and you will be returned to the So"tware &sset 0anager screen. y. #xit the installer. ;. /he -racle Installer probably told you to run root.sh again, but you de"initely should not. .. !on"igure and run the =etI listener. #dit J-R&!L#ME-0#/networ2/admin/listener.ora to suit your needs. 8ou$ll need to "ill in the -R&!L#MSID. 8ou might need to change the host name or IP. BIn my case my ser,er is multi'homed, but I only want the database to accept connections "rom the internal networ2.D 8ou will probably want to lea,e the extproc settings as they areO extproc is part o" the mechanism that allows PL/S7L to call out to procedures outside the database. 8ou may set globalMname to the host name. /his will allow clients to connect to the database by speci"ying the host name as the =etI aliasLin this way clients don$t need to ha,e a tnsnames.ora "ile. 0y listener.ora "ile loo2s li2e this: Page )I !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com # # DilenameM ;istener.ora # ;B-C<><8 = (9DD8<--_;B-C = (9DD8<--= (P85C5:5;= BP:$(K<Y= MYDB$$ (9DD8<--= (P85C5:5;= BP:$(K<Y= P>PK<Y$$ (9DD8<--= (P85C5:5;= C:P$(@ost= (2..'..$(Port= )2$$ $ -BD_;B-C_;B-C<><8 = (-BD_;B-C = (-BD_D<-: = (G;5B9;_DB>9M<= m?*ost.dbspecialists.com.$ (589:;<_@5M<= /u0/app/oracle/product/'.0.)$ (-BD_>9M< = MYDB$ $ (-BD_D<-: = (-BD_>9M< = e1tproc$ (589:;<_@5M< = /u0/app/oracle/product/'.0.)$ (P85G89M = e1tproc$ $ $ -C98CHP_=9BC_CBM<_;B-C<><8 = 0 :5>><:C_CBM<5HC_;B-C<><8 = 0 C89:<_;<W<;_;B-C<><8 = 5DD C. Prepare a tnsnames.ora "ile in J-R&!L#ME-0#/networ2/admin on the ser,er and distribute it to all clients. #dit the de"ault "ile to suit your needs. 4ill in the -R&!L#MSID. !hange the host name or IP i" needed. 0y tnsnames.ora "ile loo2s li2e this: # # DilenameM Cnsnames.ora # e1tproc_connection_data = (D<-:8BPCB5> = (9DD8<-- = (P85C5:5; = BP:$(K<Y = MYDB$$ (:5>><:C_D9C9 = (-BD = e1tproc$$ $ MYDB = (D<-:8BPCB5> = (9DD8<-- = (P85C5:5;= C:P$(@ost= (2..'..$(Port= )2$$ (:5>><:C_D9C9 = (-BD = MYDB$$ $ MYDB_B<X = (D<-:8BPCB5> = (9DD8<-- = (P85C5:5; = B<X$(P85G89M = /u0/app/oracle/product/'.0.)$ (arg+0 = oracleMYDB$ (args = 4(D<-:8BPCB5> = (;5:9;=Y<-$(9DD8<--=(P85C5:5;=B<X$$$4$ (en+s = 4589:;<_@5M<=/u0/app/oracle/product/'.0.)!589:;<_-BD=MYDB4$ $ $ 3. !reate bdump, cdump, and udump directories in J-R&!L#M1&S#/admin/J-R&!L#MSID. /he installer on Linux ,iolates the -4& standard in the placement o" these three directories, and we will mo,e them to where they belong. I. Shut down the database. %. /he de"ault database was created with three control "iles all in one directory. 0o,e two o" the control "iles to other directories that are on separate physical de,ices. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page )% Database Specialists, Inc. www.dbspecialists.com (G. /he de"ault parameter "ile that the installer created "or the database is de"icient in se,eral ways. 8ou should mo,e the three parameter "iles in J-R&!L#M1&S#/admin/J-R&!L#MSID/p"ile to a bac2up directory and create a new parameter "ile "rom scratch. Some o" the things you should correct or impro,e upon are: a. 8ou might want to merge the con"ig.ora "ile contents into the init.ora "ile. 5nless you are using -racle Parallel Ser,er, there is not a lot o" ,alue in spreading the parameters between two "iles. b. 5pdate the controlM"iles parameter to re"lect the new control "ile locations. c. 5pdate the bac2groundMdumpMdest, userMdumpMdest, and coreMdumpMdest parameters to comply with the -4& standard. d. 5pdate the sharedMpoolMsi:e, dbMbloc2Mbu""ers, and sortMareaMsi:e parameters to reasonable ,alues based on how much physical memory your ser,er has a,ailable. e. 5pdate the sessions and processes parameters based on how many concurrent sessions you anticipate. Eere$s the parameter "ile I ended up with. # # initMYDB.ora # ============ # # Parameter file for MYDB database. # # config parameters control_files = (/u02/oradata/MYDB/control0.ctl! /u0"/oradata/MYDB/control02.ctl! /u0#/oradata/MYDB/control0".ctl$ bac%ground_dump_dest = /u0/app/oracle/admin/MYDB/bdump core_dump_dest = /u0/app/oracle/admin/MYDB/cdump user_dump_dest = /u0/app/oracle/admin/MYDB/udump db_bloc%_si&e = '(2 db_files = '0 db_name = MYDB compatible = '.0.) rollbac%_segments = (r0!r02!r0"!r0#$ # tuning parameters s*ared_pool_si&e = .000000 sort_area_si&e = #0(.000 db_bloc%_buffers = 2000 db_file_multibloc%_read_count = .# processes = 00 sessions = 00 log_c*ec%point_inter+al = 0000 log_buffer = ."'#0 se/uence_cac*e_entries = 00 se/uence_cac*e_*as*_buc%ets = '( 0ob_/ueue_processes = 2 ma1_dump_file_si&e = 02#0 # limit trace file si&e # to ) Meg eac* ((. Restart the database so that the new parameter settings ta2e e""ect. Page 9G !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com (). /wea2 the de"ault install so that the database will be usable "or more than tri,ial tas2s and will be capable o" o""ering decent per"ormance. hile later sections o" this tutorial will go into this in greater detail, here is an o,er,iew o" some o" the things you$ll probably want to do: a. Relocate data "iles to spread them o,er multiple physical de,ices. b. #nlarge the online redo logsLthe de"ault log si:e o" .GG Kb is o"ten too small. Since you can$t resi:e online redo logs, you$ll need to drop and recreate them. &t the same time, you can gi,e the logs -4& compliant names, and you can relocate them as appropriate to distribute I/-. c. Resi:e the temporary tablespaceLthe de"ault si:e o" ( 0b won$t be big enough unless your database will be extremely small. d. <er the temporary tablespace to gi,e it a content type o" /#0P-R&R8 and appropriate de"ault storage parameters. &lso, ma2e sure all users including S8S and S8S/#0 ha,e the /#0P tablespace designated as their temporary tablespace. e. Resi:e the rollbac2 segment tablespaceLthe de"ault si:e o" (. 0b won$t be big enough unless your database is somewhat small. ". Depending on the anticipated si:e o" your database and the expected number and type o" concurrent users, you may want to ad>ust the number o" rollbac2 segments and their storage parameters. &t the ,ery least, you$ll probably want to set the -P/I0&L storage parameter "or each rollbac2 segment except S8S/#0. g. &d>ust the si:ing and de"ault storage o" the /--LS and 5S#RS tablespaces as needed i" you will be using these tablespaces. (9. !reate new tablespaces "or holding application segments. !reate separate tablespaces with data "iles on separate physical de,ices "or tables and indexes. 8ou may want to split your application segments into se,eral tablespaces, based on ob>ect si:e, permanence, ,olatility, I/- ,olume, or any o" a number o" other criteria. (;. !hoose de"ault storage parameters care"ully "or each application tablespace. -ne strategy I highly recommend is as "ollows: a. Set I=I/I&L to either ()I2, ;m, or ()Im, depending on the planned si:es o" the ob>ects to be placed in the tablespace. b. Set =#F/ the same as I=I/I&L. c. Set 0I=#F/#=/S to ( and 0&F#F/#=/S to (G);. d. Set P!/I=!R#&S# to G. (.. !reate application roles i" desired. <ernati,ely, you can use the de"ault roles !-==#!/, R#S-5R!#, and D1&. (C. !reate your application users that will own the application schemas. Set the de"ault tablespace to one o" your application tablespaces designated to hold tables, and set the temporary tablespace to /#0P. &ssign ?uotas on all o" the application tablespaces where the user will need to be able to create schema ob>ects. B8ou can use the 2eyword 5=LI0I/#D.D 8ou should not set any ?uota on the temporary tablespace. Do not plan to create any application ob>ects in the S8S or S8S/#0 schemas, or store any application ob>ects in the S8S/#0 or /#0P tablespaces. (3. <rant roles and/or system pri,ileges to the application users. =ote that i" you grant the R#S-5R!# role to a user, that user will also recei,e the 5=LI0I/#D /&1L#SP&!# system pri,ilege. /his will let the user create ob>ects in any tablespace they wish, regardless o" ?uotas. I recommend you re,o2e 5=LI0I/#D /&1L#SP&!# "rom all users other than S8S. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page 9( Database Specialists, Inc. www.dbspecialists.com Com"lete the *erver Configuration /hese steps complete the con"iguration o" your ser,er "or smooth -racle operation. /hese steps could ha,e been per"ormed earlier, but are more straight"orward i" per"ormed a"ter a database has been created. In this section we will con"igure the ser,er to start the database and =etI listener automatically whene,er the ser,er is rebooted, change the oracle user$s login script to eliminate hardcoding, and create indi,idual operating system accounts "or each database user.
(. #dit the /etc/oratab "ile to ,eri"y that the entry "or your database is correct. &ll o" the lines in the "ile should be comments Bstarting with a pound symbolD except "or one. /his one line should contain the name o" your -racle instance, its -R&!L#ME-0#, and a 8 or =. & 8 indicates that the database should be started automatically on ser,er reboot, and an = indicates that it should not. /he three "ields should be separated by colons. & sample /etc/oratab "ile loo2s li2e this: # # /etc/oratab # =========== # MYDBM/u0/app/oracle/product/'.0.)MY ). #dit the login "ile "or the oracle user to eliminate hardcodings and call the oraen, script to set the en,ironment instead. /he "ollowing should wor2 with 1ash, 1ourne shell, or Korn shell: # -ettings for 5racle en+ironment 589:;<_-BD=MYDB 589<>W_9-K=>5 e1port 589:;<_-BD 589<>W_9-K . oraen+ 9. !reate separate Linux accounts "or D1&s and database users who will log onto the ser,er. 8ou should only log in as oracle when installing or patching so"tware. /he Linux accounts "or D1&s should be members o" the dba group, and other users should not be members o" the dba group. <i,e each o" these accounts a login "ile li2e oracle$s so that their en,ironment initiali:es correctly when they log in. Page 9) !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com ;. /o ma2e the database and =etI listener start up automatically when the ser,er reboots, you$ll need to create a dbora "ile in /etc/rc.d/init.d and lin2 it to /etc/rc.d/rc9.d. 8ou$ll need to do this as the root user. 4irst create a "ile called dbora in /etc/rc.d/init.d as "ollows: #Y/bin/s* 589_@5M<=/u0/app/oracle/product/'.0.) 589_5=><8=oracle if Z Y 3f A589_@5M</bin/dbstart 3o Y 3d A589_@5M< [ t*en ec*o O5racle startupM cannot startO e1it fi case OAO in 4start4$ # -tart t*e 5racle databases and >et' listener su 3 A589_5=><8 3c OA589_@5M</bin/dbstartO \ su 3 A589_5=><8 3c OA589_@5M</bin/lsnrctl startO \ RR 4stop4$ # -top t*e 5racle databases and >et' listener su 3 A589_5=><8 3c OA589_@5M</bin/lsnrctl stopO \ su 3 A589_5=><8 3c OA589_@5M</bin/dbs*utO \ RR esac =ote that the spacing around the brac2ets shown here is di""erent "rom what appears in the -racle documentation. &"ter creating the dbora "ile, you need to lin2 it to /etc/rc.d/rc9.d: ln 3s /etc/rc.d/init.d/dbora /etc/rc.d/rc0.d/K0dbora ln 3s /etc/rc.d/init.d/dbora /etc/rc.d/rc".d/K0dbora ln 3s /etc/rc.d/init.d/dbora /etc/rc.d/rc".d/-((dbora *ummary /his section o" the tutorial wal2ed you through all o" the intricate details o" getting -racle up and running on the Linux plat"orm. It may loo2 complicated, but that$s only because this document goes down to a nitty gritty le,el o" detail. Please 2eep in mind, though, that the re?uirements are di""erent "or e,ery -racle implementation. I am extremely con"ident that i" you "ollow these steps to install -racle I.G.. Standard #dition on a ser,er running Red Eat ..) Linux, then the process will go ,ery smoothly "or you. Eowe,er, no single document can address e,ery speci"ic hardware con"iguration and e,ery set o" business needs. Please use these steps as a starting point to get -racle up and running in your shop. =ext, you$ll want to 2eep your database managable and ma2e it per"ormLand the next sections in this tutorial will help you with that. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page 99 Database Specialists, Inc. www.dbspecialists.com Managing +our #ata$ase In this section we$ll co,er the basics o" managing an -racle database. 4irst we$ll loo2 at starting and stopping the database. /hen we$ll loo2 at connecti,ity issues and general troubleshooting tactics. /hen we$ll discuss how to organi:e schemas, tablespaces, and segments. 4inally, we$ll ha,e a basic o,er,iew o" "ault tolerance and bac2ups. *tarting an *to""ing &s we discussed in an earlier section, there are three steps to ma2ing an -racle database accessible to applications. e call the whole process @startingA or @openingA the database. 8ou most commonly start a database using Ser,er 0anager or #nterprise 0anager. Ser,er 0anager is the lowest common denominatorO it exists Bin one "orm or anotherD in all -racle en,ironments and on all plat"orms. -n 5nix plat"orms you in,o2e Ser,er 0anager by entering s+rmgrl at the shell prompt. B/he @lA stands "or @line mode.A /here once was a hideous ,ersion o" Ser,er 0anager that tried to simulate a <5I in a character mode en,ironment. /han2"ully, this was abandoned.D 8ou should set your -racle en,ironment be"ore starting Ser,er 0anager. -R&!L#ME-0# and the -racle directories included in P&/E and LDMLI1R&R8MP&/E will allow -racle to locate the proper binaries and shared libraries. -R&!L#MSID and /-M/&SK will tell -racle which instance you wish to access. In Ser,er 0anager you$ll need to authenticate yoursel" be"ore you can do anything use"ul. I" your database is already open to applications, you can simply use the :5>><:C command to connect to an instance. In this case you$ll need to pro,ide a username and password, and the instance will chec2 these against the list o" users held in the data dictionary o" the database. 1ut what do you do i" the database isn$t open yetV ith the database closed, there is no access to the data dictionary "or authentication. /here are two options: operating system authentication or a password "ile external to the database. Shops that run -racle on 5nix and do not use #nterprise 0anager tend to ta2e the operating system authentication route. In this scenario, the D1& logs on to the database ser,er using a 5nix account that is a member o" a pri,ileged group, typically called @dbaA. In Ser,er 0anager, the D1& gi,es the special :5>><:C command :5>><:C / 9- -Y-DB9. /his tells Ser,er 0anager to ha,e the operating system authenticate the user "or the purposes o" starting up or shutting down the database. 1ac2 in -racle 6C the command was :5>><:C B>C<8>9;. 8ou$ll still hear old'time D1&s re"er to :5>><:C B>C<8>9; and it does still wor2, but -racle is promising to de'support it soon. So go with :5>><:C / 9- -Y-DB9 instead. Shops that run -racle on less secure operating systems, or use #nterprise 0anager "or centrali:ed database startup and shutdown, cannot rely on the operating system "or authenticationLbecause the D1& ne,er logs onto the database ser,er at all. In these situations a password "ile is used. &s part o" database creation, the orap6d utility is used to generate a "ile external to the database that contains passwords. In Ser,er 0anager the D1& connects with the command :5>><:C username/pass6ord 9- -Y-DB9. Ser,er 0anager then chec2s this in"ormation against the contents o" the password "ile. -nce you ha,e per"ormed the appropriate :5>><:C command, Ser,er 0anager will respond with @!onnected to an idle instance.A /his basically means that you are authenticated, but there is no instance running. 8ou may now start up the database using the -C98CHP command. /ypically you won$t use any o" the options that come with -C98CHP, but it$s good to 2now the most common options because they are use"ul in certain situations. 4igure ( shows the most common options. Page 9; !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com Command Descri(tion -C98CHP /a2es a database all the way "rom being closed to being "ully accessible to applications Bcreates an instance, mounts the database, opens the databaseD -C98CHP >5M5H>C !reates an instance, but does not mount or open the database -C98CHP M5H>C !reates an instance and mounts the database, but does not open it -C98CHP 8<-C8B:C Same as S/&R/5P, but only allows database users with the @restricted sessionA system pri,ilege to access the database -C98CHP PDB;<=EfilenameE Same as S/&R/5P, but uses the speci"ied parameter "ile to con"igure the instance, instead o" the usual initSID.ora 4igure (: !ommon Ser,er 0anager commands "or opening an -racle database Shutting down an -racle database is e?ually easy. 4irst, authenticate yoursel" in Ser,er 0anager >ust li2e be"ore. /hen issue the desired shutdown command. 4igure ) shows the di""erent options a,ailable. It$s ,ery common to use the "irst two. Eope"ully you won$t need the third. Command Descri(tion -@HCD5=> Pre,ents any new logins to the database, and shuts the database down cleanly a"ter the last existing session logs out -@HCD5=> BMM<DB9C< Kills all existing sessions and shuts the database down cleanly -@HCD5=> 9B58C &bruptly 2ills all -racle processes and "rees up all system resources used by the instance 4igure ): Ser,er 0anager commands "or closing an -racle database /he -@HCD5=> command without any options Balso called a @normal shutdownAD could potentially hang inde"initely, because it only ta2es one user who "ails to log out to hold things up. &n immediate shutdown also may not be so immediate, because -racle will "irst 2ill all sessions and clean up a"ter them. &n abort shutdown is always instantaneous because -racle indiscriminantly 2ills e,erything o"". 8ou shouldn$t use -@HCD5=> 9B58C unless you really need to, because it basically crashes the instance and "orces -racle to per"orm crash reco,ery the next time you open the database. B/he crash reco,ery is automatic, but could ta2e a while i" you aborted the instance in the middle o" a huge transaction.D I" you choose to use #nterprise 0anager instead o" Ser,er 0anager, you will need to ha,e a password "ile external to the database and you$ll also need to ha,e =etI con"igured on both the #nterprise 0anager client and the database ser,er. #nterprise 0anager is a <5I tool allowing you to point and clic2 your way toward doing D1& tas2s. <hough the user inter"ace is substantially di""erent "rom Ser,er 0anager$s command line inter"ace, the concepts and "eatures a,ailable are basically the same. I" all o" your database applications will run on the same physical ser,er as the -racle databases they access, then opening the database is the only thing you need to do in order "or your applications to be able to access the database. Eowe,er, it$s more typical these days to distribute processing among networ2ed ser,ers. I" any database applications will be running on separate ser,ers "rom the database ser,er, you will need to start the =etI listener be"ore these applications can access the database. /he =etI listener runs on the same ser,er as the database. 8ou only need to run one =etI listener per physical ser,er, e,en i" you ha,e multiple databases running on the ser,er. 8ou need to con"igure the =etI listener be"ore you can start it. /he most common way to con"igure =etI is to edit a listener.ora "ile manually. e did this while setting up the de"ault database in the pre,ious section. <ernati,ely, -racle does o""er <5I networ2 con"iguration tools that will generate the con"iguration "iles "or you. In smaller shops, it will probably be easier to >ust edit the listener.ora "ile manually. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page 9. Database Specialists, Inc. www.dbspecialists.com /he con"iguration "iles "or =etI tell the listener where and with which protocols to listen "or connection re?uests "rom clients, and also which databases are a,ailable on the ser,er. -n 5nix it is most common to ha,e =etI listen on port (.)( "or connection re?uests using /!P/IP protocol. Eowe,er, many di""erent protocols are supported, and protocol interchange is e,en possible. 8ou control the =etI listener with the lsnrctl command. 8ou may enter lsnrctl on the command line by itsel", in which case you will be prompted to enter a listener command. <ernati,ely, you may enter a listener command directly on the command line a"ter the lsnrctl. 4igure 9 shows the most common listener control commands. Command Descri(tion -C98C Starts the =etI listener -C5P Stops the =etI listener 8<;59D Reads the con"iguration "iles anew -C9CH- Shows the status o" the =etI Listener -<8WB:<- Lists the listener ser,ices currently running, along with connection statistics "or each ser,ice 4igure 9: !ommon commands "or controlling the =etI listener /he =etI listener$s primary "unction is to establish a connection between a database application Btypically running on a remote ser,erD and an -racle instance Btypically running on the local ser,erD. -nce the =etI listener has established a connection between the application and the instance, the two communicate directly without in,ol,ing the =etI listener. /he 2ey point to note is that stopping and restarting the =etI listener while a database is open will not disrupt existing database sessions. hile the listener is down applications will not be able to connect, but existing connections will not be a""ected. In most situations, you want the -racle databases to be open and the =etI listeners to be running at all times. /ypically, these ser,ices are started automatically when the ser,er starts up. e saw how to do this when we set up a de"ault database in the pre,ious section. Connectivity an Trou$leshooting #ach -racle instance maintains a log 2nown as the @alert log.A /his is a plain text "ile called alertMSID.log, where SID is the name o" the instance. It resides in the directory speci"ied by the bac2groundMdumpMdest initiali:ation parameter. -racle writes to this log when an instance is started or stopped, when a signi"icant database change is made Bsuch as adding a new tablespaceD, and when something signi"icantly goes wrong that a""ects the instance or database as a whole Bsuch as a dis2 "ailureD. hene,er you ha,e doubts about what$s going on in your instance, the alert log is a good place to loo2. It$s also a good idea to re,iew the alert log periodically "or problems you might not be aware o". 8ou can archi,e or compress your alert log i" it gets too big. /his can be done without shutting down the instanceL the instance will create a new alert log i" the old one is missing. hen something bad happens in a particular -racle daemon or ser,er process, a trace "ile will be dumped and a message will be written to the alert log. /race "iles "or daemons are written to the bac2groundMdumpMdest, while trace "iles "or ser,er processes are written to the userMdumpMdest. /race "iles are plain text, although the in"ormation sometimes is not ,ery intelligible unless you wor2 in -racle$s orldwide /echnical Support di,ision. Page 9C !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com hen an application is unable to connect to a database due to a networ2ing or connecti,ity problem, the =etI client called by the application will write a s?lnet.log "ile. /his "ile will be located on the client Bthe machine running the applicationD in the wor2ing directory o" the application trying to connect. /he "ile will be plain text, containing diagnostic in"ormation you can use to troubleshoot the problem. Some o" the most common =etI connecti,ity problems are as "ollows: 4&A5636178 "NS8co-ld not resolve service name: /his means that the =etI client Brunning on the application$s ser,erD was unable to "ind what ser,er and database the =etI alias pro,ided by the application maps to. 8ou should chec2 the tnsnames.ora "ile on the client to ma2e sure it includes the =etI alias you wish to use. &lso, ma2e sure the tnsnames.ora "ile is in the right locationLtypically J-R&!L#ME-0#/networ2/admin. 8ou should be able to connect to the database immediately a"ter "ixing the problem with tnsnames.ora. 4&A56339:8 "NS8-nable to connect to destination: /his indicates a networ2ing connecti,ity problem between the ser,er running the database application and the ser,er running the database. I" you tried to ping the database ser,er "rom the client, you would probably "ind (GGS pac2et loss. 4&A5633378 "NS8no listener: /he =etI listener on the database ser,er is not running. Start the listener and try again. 4&A5969:78 4&ACL# not available: /his indicates that the database is not open. Start the database and try again. 4&A5631918 "NS8listener co-ld not resolve SID given in connect descri(tor: /his indicates one o" two possible con"iguration problems. #ither the tnsnames.ora "ile on the client contains an incorrect instance name BSIDD in the !-==#!/MD&/& clause, or the =etI listener running on the database ser,er is not aware o" the speci"ied instance. 8ou$ll need to edit either the tnsnames.ora "ile on the client or the listener.ora "ile on the database ser,er and try again. I" you edit the listener.ora "ile, you$ll need to restart or reload the =etI listener on the database ser,er. *chemas, Ta$les"aces, an *egments !reating database users and schemas is an important D1& responsibilityLboth the organi:ational planning and the actual creating and dropping o" the accounts. Eow you di,ide your end user population into database users and how you separate your database ob>ects into indi,idual schemas will ha,e huge impacts on the security, maintainability, and scalability o" your system. 8ou should come up with a coherent plan be"ore creating a single database user. 4or simple applications, D1&s will typically create one -racle user as the @application owner.A &ll o" the database ob>ects to be used by the applicationLsuch as tables, indexes, and stored proceduresLare created in this user$s schema. !omplicated applications are usually di,ided into separate modules or components, with a separate owner user created "or each. In applications where the database will authenticate the end users directly, a separate -racle user is created "or each end user. /he schemas "or these users will typically be empty except "or synonyms allowing the user to re"erence database ob>ects in the application owner schema. &ppropriate pri,ileges on the application owner$s schema ob>ects are granted to the end user database users, typically through database roles. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page 93 Database Specialists, Inc. www.dbspecialists.com In applications where the application will authenticate the end users, one @application runtimeA -racle user is usually created. /he application always accesses the database ,ia this generic database user. & table o" users in the application owner schema or some other mechanism is used to allow the application to authenticate end users. &s with the indi,idual end user schemas, the generic schema will typically be empty except "or synonyms. !lient/ser,er applications with a small to medium number o" end users are typically de,eloped using the indi,idual database user model, as are applications that re?uire ,ery high security. Internet applications are typically de,eloped using the generic application user model, due to the potentially huge user community and the expense o" ha,ing -racle create new sessions and authenticate users on e,ery E//P re?uest. -nce a strategy has been de,ised "or users and schemas, a plan should be de,eloped "or the tablespaces that will ma2e up the physical storage o" the database. /ablespace planning is more straight"orward than user and schema planning. #,ery -racle database should ha,e se,en classes o" tablespaces. /he de"ault database created earlier in this tutorial will ha,e the "irst "i,e. It$s up to you to create the other two, and possibly enhance some or all o" the "irst "i,e. 4igure ; lists these se,en types o" tablespaces. "ables(ace Contents Name in De+a-lt Database Data dictionary and -racle internals S8S/#0 Rollbac2 segments R1S /emporary segments /#0P -racle and third party tools /--LS 5nclassi"ied user segments 5S#RS &pplication tables n/a &pplication indexes n/a 4igure ;: Se,en types o" tablespaces #,ery -racle database must ha,e a S8S/#0 tablespace "or the data dictionary and internals. 8ou$ll ne,er need to create an additional tablespace in this class. 0ost database are "ine with one tablespace each "or rollbac2 segments and temporary segments. -n larger, high concurrency databases, howe,er you may choose to add additional tablespaces "or rollbac2 and temporary segments in order to distribute I/- load e""ecti,ely. /ablespaces "or tools and unclassi"ied user segments are not always necessary, especially i" you are not installing any -racle or third party tools that create database schema ob>ects. Eowe,er, it is de"initely a good idea to ha,e a 5S#RS tablespace to ser,e as a general dumping ground "or those segments that will only be around "or a little while or you aren$t sure where to put. /he remaining two tablespace classes are where you$ll want to "ocus your planning. !hoosing how to distribute your application segments among tablespaces will strongly impact per"ormance, scalability, and manageability o" your database. Rule number one is to always store tables and indexes in separate tablespaces. -ne o" the most common ways to access data in a ?uery is ,ia an index scan "ollowed by a "etch "rom the table by rowid. I" a table is stored in the same tablespace as its indexes, then it is li2ely that both will be stored on the same physical de,ice. /his would lead to "ierce I/- contention e,ery time the table is accessed ,ia its index. Page 9I !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com 4rom there, the rules get more ,ague. In general, it is a good idea to use separate tablespaces "or separate applications or schemas. /his will allow you to per"orm maintenance on one application$s data without impacting other applications using the same database. It$s also a good idea to separate highly ,olatile segments or segments temporary in nature Bsuch as a temporary table you create and drop whene,er a report is runD "rom the more static or permanent data. 4urther, large tables and indexes Bsay, o,er .GG 0b or ( <bD should be gi,en exclusi,e tablespaces o" their own. Small databases "or simple applications will o"ten ha,e >ust two application tablespacesLone to hold tables and one to hold indexes. It$s not uncommon, howe,er, "or large databases ser,ing complex applications to ha,e .G or more tablespaces. & greater number o" tablespaces may seem li2e more o" a management o,erhead, but the ability to isolate outages and manage "ree space allocation on a more granular le,el become increasingly important as the si:e and complexity o" a database grows. #,ery segment in e,ery tablespace o" an -racle database has a wealth o" indi,idual si:ing parameters, collecti,ely called @storage parameters.A 4igure . lists the di""erent parameters. Name '-r(ose initial Si:e o" the initial extent next Si:e o" the next extent to be allocated pctincrease 4actor by which to increase the si:e o" each successi,e next extent minextents Initial number o" extents to allocate maxextents 0aximum number o" extents the segment is allowed to ha,e pct"ree Space to lea,e empty in each new bloc2 to allow "or updates that cause data to ta2e up more space pctused Eow much space in a bloc2 must be "ree be"ore additional data will be inserted 4igure .: Segment storage parameters /he degree to which you can "ine tune the storage o" each indi,idual segment in the database can boggle the mind. /here are a number o" old wi,es$ tales and urban legends "loating around about the best way to set storage parameters. /he more complex strategies are based on limitations o" older ,ersions o" -racle which ha,e long since been o,ercome. Sadly, some are based on plain old misin"ormation. /he segment si:ing strategy I use is based on hea,y'duty research per"ormed internally at -racle !orporation. /his strategy also happens to be the simplest around. I mentioned it brie"ly in the steps "or creating a de"ault database. /he underlying principles are as "ollows: I" all extents in a tablespace are the same si:e, the "ree space will ne,er be "ragmented. -racle$s extent management o,erhead is minimal as long as segments ha,e "ewer than (G); extents. Storage parameters are easier to administer i" all segments in a tablespace ha,e the same settings. /he strategy is to set the de"ault storage parameters "or each application tablespace, and let all application segments inherit their storage parameters "rom the de"aults "or the tablespace to which they are assigned. /he de"ault storage parameters "or each tablespace should be set as "ollows: a. Set I=I/I&L to either ()I2, ;m, or ()Im, depending on the planned si:es o" the ob>ects to be placed in the tablespace. b. Set =#F/ the same as I=I/I&L. c. Set 0I=#F/#=/S to ( and 0&F#F/#=/S to (G);. d. Set P!/I=!R#&S# to G. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page 9% Database Specialists, Inc. www.dbspecialists.com Fault Tolerance an Backu"s I" the data you will be storing in your database has any ,alue to you whatsoe,er, you$ll want to ta2e steps to ma2e your database "ault tolerant. 8ou$ll also want to bac2 up the data in your database so that you are protected against disastersLboth o" the hardware "ailure and user error ,ariety. /o ma2e your database "ault tolerant, you should eliminate single points o" "ailure where,er possible. /he control "ile and online redo log are critical to an -racle databaseLthe entire database will "ail with the loss o" either. /here"ore, you should always ha,e redundant copies o" your control "ile and online redo log as an absolute minimum. 8ou can use R&ID to 2eep redundant copies o" the "iles, or you can ha,e -racle per"orm so"tware mirroring Bwhere -racle writes identical bloc2s to multiple "ilesD. & bene"it o" ha,ing -racle mirror these "iles "or you is that you$ll be co,ered i" somebody accidentally deletes a "ile "rom the "ile system. B5nless, o" course, they delete all mirrored copiesWD So"tware mirroring o" the control "ile incurs ,ery little I/- or o,erhead. 0irroring online redo log "iles can cause a signi"icant increase in I/- on update'intensi,e systems, but dis2 storage is cheap these days. R&ID is common enough these days that you should consider using it "or all o" the data "iles in your database as well. 1ut you should not thin2 that R&ID eliminates the need "or a bac2up and reco,ery strategy. It is still possible "or R&ID systems to "ail, and R&ID won$t help you in the case o" user error or a catostrophic e,ent. 1ac2up strategies "or -racle can be ,aried and complex. Eea,y tomes ha,e been published on the sub>ect. 4igure C gi,es a ,ery high le,el ,iew Bsay, at ;G,GGG "eet or moreD o" some o" the options a,ailable. $ethod Descri(tion 0o, "o #xport rite database contents to an operating system "ile 5se the e1p utility !old 1ac2up !apture a point'in'time snapshot o" the entire database Shut down the database cleanly and use operating system commands to copy the control "ile, online redo log, and all data "iles Eot 1ac2up !apture a rolling snapshot o" indi,idual data "iles while the database is in use 5se operating system commands to copy data "iles while the database is open, in"orming the instance along the way so that additional logging measures can be used to ensure a ,iable bac2up Reco,ery 0anager -racle$s new tool to simpli"y hot and cold bac2ups 5se the rman utility 4igure C: Eigh le,el o,er,iew o" -racle database bac2up options Eere are a "ew pearls o" wisdom to start you along the path toward a proper bac2up and reco,ery strategy: I" you$,e shut the database down cleanly, you can use ordinary operating system commands to ta2e a cold bac2up o" the database. 4or the bac2up to be usable, you will need to capture one copy o" the control "ile, one copy o" each online redo log "ile, and e,ery data "ile. &ll "iles need to be captured while the database is closed, and without opening the database in between copying "iles It is ,ery easy to use the e1p utility to export the contents o" a database to a single operating system "ile. 8ou can use an export "ile to reload an empty database or migrate a database between -racle ,ersions or operating system plat"orms. 5nderstand, howe,er, that this techni?ue is not ,ery scalable. It gets resource intensi,e and slow i" your database is bigger than a "ew <b in si:e. It$s easy to restore indi,idual schema ob>ects "rom an export "ile. Eot and cold bac2ups, on the other hand, are typically used to restore an entire database and not indi,idual schema ob>ects. Page ;G !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com In order to ta2e hot bac2ups, your database needs to be running in archi,elog mode. /his re?uires that you manage the archi,ed redo log. Unless o-r database is r-nning in archivelog mode and o- s-bmit the correct commands to the instance be+ore and a+ter co(ing each tables(ace; o- cannot co( data +iles ,hile the database is o(en and e)(ect them to be viable2 &n export "ile only allows you to reco,er a database to the point in time o" the export. B/he point in time will be "u::y unless the consistent=? export option is used.D & cold bac2up o" a database not running in archi,elog mode also only allows you to reco,er the database to one point in time. -nly a hot or a cold bac2up ta2en "rom a database running in archi,elog mode allows you to reco,er the database "rom a bac2up and @roll it "orwardA up to the point o" "ailure. In order to roll a hot or cold bac2up "orward to the point o" "ailure, you$ll need all archi,ed redo log "iles since the beginning o" the bac2up o" the oldest "ile in the bac2up set. I" an archi,ed redo log is missing "rom the se?uence, you will not be able to roll "orward past that point. Please ta2e the "i"th bullet item ,ery seriously. 1ecause o" the way -racle optimi:es writes, you can ne,er assume that a "ile is ?uiesced. #,en i" there is no acti,ity on the database, you cannot assume that all data "iles are in a consistent state. -racle trac2s the state o" each data "ile in both the control "ile and each data "ile$s header. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page ;( Database Specialists, Inc. www.dbspecialists.com O"timi-ing +our #ata$ase /he -racle database is a phenomenally tunable and con"igurable product. /he di""erence in per"ormance between a ,anilla install and a well tuned system can be ama:ing. It$s not unheard o" to reduce a report$s running time "rom (I hours to ten minutes by changing one line o" code. In this section o" the tutorial we$ll ta2e a high le,el loo2 at se,eral areas where you can optimi:e your -racle system. In each area we$ll ta2e a pee2 at the most common tuning issues. /o learn more about each o" these tuning areas, consult the -racleI tuning manual. Tuning #ata$ase !ccess within an !""lication /he highest impact tuning you can do in an -racle system is application tuning. -ptimi:e the ?ueries and application logic to get the most out o" -racle. -racle S7L and PL/S7L are ,ery power"ul, and the -racle engine is ,ery capable when it comes to processing and sorting large ,olumes o" data. hen S7L or PL/S7L o""ers a certain "unctionality your application needs, you should use -racle$s nati,e capabilities instead o" engineering your own application logic to do the same thing. /he ,Js?larea ,iew in e,ery -racle database allows D1&s to see the statements that are currently cached inside the S<&. 4igure ( shows a simple S7LHPlus ?uery you can use to :ero in on resource'intensi,e statements within your application. & @logical readA is a re?uest "or a bloc2 o" data "rom a data "ile. /he re?uest may result in a cache hit Bi" the bloc2 is already in the bu""er cache inside the S<&D or a physical read "rom dis2. @#xecsA is the number o" times the statement has been executed since it entered the S<&. -X;V :5;HM> s/l_te1t D58M9C a#0 -X;V -<;<:C dis%_reads p*?s_rds! buffer_gets logicl_rds! 2 e1ecutions e1ecs! s/l_te1t " D85M +As/larea #P 58D<8 BY buffer_getsR P@Y-_8D- ;5GB:;_8D- <]<:- -X;_C<]C 3333333333 3333333333 3333333333 3333333333333333333333333333333333333333 0 0 ) B<GB> dbms_s/l.+ariable_+alue^8<M5C< (Mb! Mb2! Mb"$R <>DR
' F(((# "F"# begin run_re/uests (-Y-D9C<$R endR .# ro6s selected. -X;V 4igure (: Loo2ing "or resource'intensi,e statements "rom within S7LHPlus hen the same statement is executed multiple times, -racle only needs to parse it once. /he parsed representation, including execution plan, will be cached in the S<&$s shared S7L area. /his can dramatically cut down processing time when applications execute huge numbers o" simple ?ueries. Page ;) !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com & 2ey to maximi:ing the bene"it o" the shared S7L area is to use bind ,ariables in your S7L statements where,er possible. 0ost database &PIs these days support bind ,ariables, although the syntax ,aries "rom one to the next. *D1!, Perl D1I/D1D, and ProH! all support bind ,ariables. Depending on the &PI in,ol,ed, each S7L statement executed in an application can result in multiple networ2 roundtrips between the application$s ser,er and the database ser,er. 8ou can o"ten reduce networ2 tra""ic and boost per"ormance by pushing logic into the database. 4or ?ueries, there could be as many networ2 roundtrips as rows "etched i" you don$t use arrays "or "etching multiple rows at once. *i-ing the *.! 8ou can boost database per"ormance across the board by si:ing the S<& optimally. I" you ma2e the S<& too small, your cache hit ratios will be low and you$ll ha,e more physical I/- and parsing o,erhead than necessary. I" the S<& is too big, the system may run low on physical memory and resort to swapping. /he S<& is composed o" many di""erent memory structures and areas. 8ou can ?uery ,Jsgastat to see the names and si:es o" the di""erent components that ma2e up the S<&. -racle database so"tware is optimi:ed on the assumption that the entire S<& "or an instance is always in physical memory at all times. It is imperati,e, there"ore, that you not ma2e the S<& so big that physical memory gets exhausted. /he si:ing o" many o" an S<&$s components are either directly or indirectly con"igurable ,ia the parameter "ile "or the instance. /he two parameters that will ha,e the greatest impact on the o,erall si:e o" the S<& are dbMbloc2Mbu""ers and sharedMpoolMsi:e. /he dbMbloc2Mbu""ers parameter speci"ies the si:e o" the bu""er cache in the S<&, used to hold the most recently used bloc2s "rom the data "iles o" the database. /he actual si:e o" the bu""er cache will be e?ual to the bloc2 si:e "or the database times the number o" bu""ers. 4igure ) shows a ?uery in S7LHPlus that will determine the bu""er cache hit ratio cumulati,e since the instance was started. Ratios ,ary based on the application, but hit ratios in the bu""er cache are usually o,er %GS on well tuned systems. 8ou can also set the dbMbloc2MlruMstatistics and dbMbloc2MlruMextendedMstatistics parameters to cause the instance to maintain statistics about how the cache hit ratio would ha,e di""ered i" there were "ewer or more bu""ers. -X;V -<;<:C (-.+alue a -2.+alue 3 -".+alue$ 2 / (-.+alue a -2.+alue$ *it_ratio " D85M +As?sstat -! +As?sstat -2! +As?sstat -" # =@<8< -.name = 4db bloc% gets4 ) 9>D -2.name = 4consistent gets4 .P 9>D -".name = 4p*?sical reads4R @BC_89CB5 3333333333 .('.2F0"## -X;V 4igure ): Determining the bu""er cache hit ratio /he sharedMpoolMsi:e parameter determines the si:e o" the shared S7L area in the S<&. /he shared S7L area is where the instance caches the parsed representations o" the most recently used S7L statements. &lso held inside the shared pool is the dictionary cache, a separate cache that holds the recently used portions o" the data dictionary. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page ;9 Database Specialists, Inc. www.dbspecialists.com /he optimal setting "or sharedMpoolMsi:e ,aries greatly "rom one situation to the next. /he amount o" PL/S7L code stored in the database, the degree to which the application uses bind ,ariables, and the general complexity and si:e o" the application will all in"luence the demands put on the shared S7L area. & simple application using bind ,ariables and no stored procedures or database triggers may only need a sharedMpoolMsi:e o" I 0b, but a hea,ily used application which does not use bind ,ariables could concei,ably su""er per"ormance degraation with a sharedMpoolMsi:e under C; 0b. Balancing #isk I/O 1ecause I/- in,ol,es access to a physical storage de,ice which is slow compared to !P5 speed, many databases are o"ten I/- bound. -nce you$,e si:ed the S<& optimally to minimi:e physical I/-s, you should stri,e to balance those physical I/-s across multiple de,ices so that no one de,ice is a bottlenec2 and so that contention is minimi:ed. 8ou may ?uery ,J"ilestat and S8S.dbaMdataM"iles in order to "ind out how many physical reads and writes ha,e ta2en place in each data "ile since the instance was started. I" you ha,e timed statistics enabled "or the instance Beither ,ia the initiali:ation parameter or the 9;C<8 -Y-C<M -<C CBM<D_-C9CB-CB:- = C8H< commandD you can also see the time spent to per"orm these I/-s. 8ou can use this in"ormation to spread data "iles across dis2s in a way to distribute the I/- e,enly. I" one data "ile has more than its share o" the acti,ity, you may want to split its tablespace into multiple tablespaces and distribute the @hotA segments across multiple "iles on di""erent de,ices. 8ou should also distribute data "iles across physical de,ices in a manner to a,oid contention. -racle ,ery o"ten needs to read "rom a table and its indexes in alternating "ashion, so placing the table and index on the same physical de,ice could cause se,ere contention. 4or this reason, tables should always be separated "rom their indexes. -racle also writes to the online redo log whene,er a transaction commits. Placing the online redo log "iles on the same de,ice as hea,ily used tables or indexes can cause contention. -nline redo log "iles can e,en contend with each other i" -racle is archi,ing one redo log while the next one is being written to by current transaction acti,ity. 4or this reason online redo logs should be spread across two or more physical de,ices in a ping pong "ashion with no data "iles sharing these de,ices. Managing #ata$ase Connections !onnecting to an -racle instance that is running in the de"ault architecture can be somewhat expensi,e. 4irst, -racle must "or2 a new process. /hen the process must attach itsel" to the S<& and authenticate the user. /he stateless nature o" E//P lends itsel" to an en,ironment with a huge number o" incredibly short database sessions. I" each o" these sessions in,ol,ed a brand new connection, the o,erhead o" connecting and disconnecting would be se,ere. 4or this reason, many application ser,er architectures and middleware products support connection caching and pooling. =etI also o""ers new "eatures "or multiplexing and pooling database connections. 0any shops using -racle "or internet'dri,en applications ha,e chosen to de,elop their own database connection management ser,ers in *a,a or Perl. hene,er using an architecture where database connections will be reused, it is important to ensure that each user o" a database connection properly ends its transactions and "rees up all system resources used. &lso consider how security and authentication will be per"ormed. Page ;; !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com Tuning *orts Sorts are necessary when building an index or when ?uerying data with a DIS/I=!/, <R-5P 18, or -RD#R 18 clause. -racle has a ,ery power"ul and e""icient sort algorithm. &ll sorts begin in memory. I" the amount o" memory re?uired "or a sort reaches a certain threshold, then -racle splits the sort in two, writing hal" to a temporary segment in a temporary tablespace while per"orming the other hal" in memory. &l"ter both hal,es are sorted, they are merged together. /his @di,ide and con?uerA approach can be repeated in"initely many times so that the hugest sort can still be per"ormed in a bounded amount o" memory. /he sortMareaMsi:e initiali:ation parameter determines the maximum amount o" memory one database session should e,er use "or sorting. /his establishes the threshold at which sorts will in,ol,e temporary segments and writes to dis2. 5n"ortunately, the de"ault setting "or sortMareaMsi:e in the de"ault database is C..9C bytes. 8ou should de"initely bump this parameter to at least ( 0b, and probably more. Eow high you go will depend on the amount o" physical memory on the database ser,er and how many concurrent sessions will typically be per"orming sorts at once. 8ou can o,erride the sortMareaMsi:e setting "or an indi,idual session with the 9;C<8 -<--B5> -<C sort_area_si&e command. /his is handy "or speeding up huge indexing operations. hen sorts are too big to be per"ormed in memory, you want the dis2 writes to be as e""icient as possible. It$s important to set each database user$s temporary tablespace designation correctly. =e,er use the S8S/#0 tablespace as a temporary tablespace. 0ost databases will ha,e one tablespace used only "or temporary segments, although you may wish to ha,e se,eral such tablespaces i" many users will be doing "re?uent large sorts and you want to distribute I/- widely. &ll tablespaces used "or temporary segments should ha,e their content type set to /#0P-R&R8 instead o" the de"ault o" P#R0&=#=/. /his causes -racle to use an enhanced space allocation mechanism that is optimi:ed "or the "re?uent creation and destruction nature o" temporary segments. In addition to ma2ing sorts as e""icient as possible, you should also tune application logic to minimi:e the amount o" sorting re?uired. /his includes examining >oin conditions care"ully to a,oid !artesian products and a,oiding o,eruse o" the DIS/I=!/ 2eyword. Configuring 0oll$ack *egments Rollbac2 segments are among the most elusi,e and misunderstood structures in an -racle database. Rollbac2 segments hold @undoA in"ormation so that a transaction may be rolled bac2. 1ut they also allow a database session to ?uery a table in a read'consistent way e,en while another database session is updating the ,ery same table. Rollbac2 segments are used li2e circular bu""ers, except that they can expand as well. hen -racle reaches the end o" a rollbac2 segment, it sees i" any o" the earlier bloc2s in the segment can be reused. I" not, the segment extends. hen a transaction commits, all o" the bloc2s in the rollbac2 segment allocated to that one transaction are mar2ed as no longer being needed and a,ailable "or reuse. hen a transaction begins, -racle assigns it to one rollbac2 segment, probably the rollbac2 segment currently hosting the "ewest transactions. -ptionally, a transaction may speci"y which rollbac2 segment it wants to use. 0ultiple transactions can share one rollbac2 segment, but i" too many transactions share one rollbac2 segment, contention "or the rollbac2 segment header can occur. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page ;. Database Specialists, Inc. www.dbspecialists.com /he optimal number o" rollbac2 segments "or a database depends on the typical number o" concurrent transactions. =ote that a session per"orming ?ueries only does not constitute a transaction and does not get assigned to a rollbac2 segment. It$s reasonable to expect a "ew transactions to share one rollbac2 segment, but you shouldn$t ha,e .G concurrent transactions share >ust two rollbac2 segments. /he optimal si:e o" rollbac2 segments ,aries depending on the application. -L/P and web'based e' commerce applications tend to ha,e many small transactions. /his situation is suited to many small rollbac2 segments in order to minimi:e rollbac2 segment header contention. 1atch applications are usually more suited to a smaller number o" large rollbac2 segments, because the system will ha,e "ew concurrent transactions but each transaction may be large. In reality, most systems ha,e a mix o" both large and small transactions. 8ou should create enough rollbac2 segments so that header contention is a,oided. Rollbac2 segments should be moderate in si:e, but should be able to grow when large transactions occur. It may be a good idea to set the -P/I0&L storage parameter "or rollbac2 segments so that i" one segment swells enormously due to a long transaction, it will be able to shrin2 and release storage "or use by other rollbac2 segments in the "uture. Page ;C !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com !on"iguring -racle on Linux 4or Pea2 Per"ormance Page ;3 Database Specialists, Inc. www.dbspecialists.com Where To .et More Information /here is a lot o" great in"ormation about -racle technology a,ailable. 8ou can "ind much o" it on the internet "or "ree. Oracle #ocumentation Don$t o,erloo2 the -racle documentation !D that comes with all -racle so"tware. It can be o,erwhelming, but there is a lot o" excellent re"erence in"ormation there. 4igure ( gi,es you a roadmap to help you get started. <hat !o- Are Loo*ing %or 4racle $an-al "(e <eneral -racle concepts -racleI !oncepts <eneric Eow to install -racle -racleI Installation <uide Plat"orm speci"ic Details about -racle particular to your plat"orm -racleI &dministrator$s <uide Plat"orm speci"ic <eneral D1& duties -racleI &dministrator$s <uide <eneric init.ora parameters and data dictionary ,iews -racleI Re"erence <eneric Eow to use the export, import, and S7LHLoader utilities -racleI 5tilities <uide <eneric Per"ormance and tuning -racleI /uning <uide <eneric S7L language syntax -racleI S7L Re"erence <eneric PL/S7L language syntax -racleI PL/S7L 5ser$s <uide and Re"erence <eneric Eow to use S7LHPlus S7LHPlus 5ser$s <uide <eneric 4igure (: here to loo2 "or answers in the -racle documentation set Other Pu$lications /here are numerous boo2s in print co,ering all "acets o" -racle technology. I li2e the -$Reilly boo2s the best. 8ou can ,iew their o""erings at http://oracle.oreilly.com. Ke,in Loney has written some o" the -racle Press boo2s which are highly regarded. 8ou can read Ke,in$s plugs about his boo2s at http://www.2e,inloney.com. 8ou can also learn more about all o" the -racle Press boo2s at http://www.osborne.com/oracle/index.htm. Oracle Technology 1etwork /he -racle /echnology =etwor2 at http://technet.oracle.com has a wealth o" in"ormation speci"ically targeted "or de,elopers. Registering to become a member gi,es you instant "ree access to nearly all online documentation, a collection o" white papers and technical presentations, discussion "orums, and "ree de,eloper licenses "or certain -racle products. /he discussion "orums are also accessible at http://www.de>anews.com. Page ;I !on"iguring -racle on Linux 4or Pea2 Per"ormance Database Specialists, Inc. www.dbspecialists.com Oracle %ser .rou"s 8ou can get a huge amount o" in"ormation by >oining an -racle user group. Di""erent groups meet monthly, ?uarterly, or annually. &t these meetings you can attend technical sessions presented by other -racle users and swap tips and techni?ues with other people in similar situations to you. Some o" these groups also maintain a repository o" tips and techni?ues on their websites. /he International -racle 5ser <roupL&mericas meets annually and has a website at http://www.ioug.org. /he =orthern !ali"ornia -racle 5ser <roup meets ?uarterly in the San 4rancisco 1ay &rea. /heir website is http://www.nocoug.org. Free We$ 0esources 8ou can also "ind a lot o" use"ul in"ormation and a help"ul online ser,ice at my company$s website http://www.dbspecialists.com. 8ou$ll "ind handy scripts "or -racle D1&s at http://www.dbspecialists.com/download.html. /here are also white papers o" a ,ery technical @nuts and boltsA nature a,ailable at http://www.dbspecialists.com/present.html. 4inally, and probably most uni?ue, you can sign up "or Database Rx at http://www.dbspecialists.com/dbrx.html. Database Rx is a "ree web' based ser,ice that will examine your -racle database and gi,e you expert tuning ad,ice and recommend' ations. Database Rx can also monitor your databases on a daily basis and send you email when it disco,ers a potential problem you should in,estigate "urther. /he handy scripts, white papers, and use o" Database Rx are all "ree o" charge.
Roger Schrag has been an -racle D1& and application architect "or o,er ten years, starting out at -racle !orporation on the -racle 4inancials de,elopment team. Ee is the "ounder o" Database Specialists, Inc., a consulting group speciali:ing in business solutions based on -racle technology. 8ou can ,isit Database Specialists on the web at http://www.dbspecialists.com, and you can reach Roger by calling U(.;(..9;;.G.GG or ,ia email at rschragXdbspecialists.com. !on"iguring -racle on Linux 4or Pea2 Per"ormance Page ;% Database Specialists, Inc. www.dbspecialists.com