創(chuàng)建swap分區(qū)是為了彌補(bǔ)物理內(nèi)存的不足,也就是虛擬內(nèi)存的概念,把硬盤的一部分劃分作為虛擬內(nèi)存,但這個(gè)空間不是越大越好,硬盤的速度遠(yuǎn)低于內(nèi)存,設(shè)置不當(dāng)反而拖慢系統(tǒng)的速度。
阿里云的主機(jī)默認(rèn)沒有swap分區(qū),可以使用free命令查看。
使用dd命令創(chuàng)建一個(gè)swap分區(qū): dd if=/dev/zero of=/home/swap bs=1024 count=1048576 (count的值是:size(多少M(fèi))* 1024,我這里設(shè)置的1G虛擬內(nèi)存,也就是count=1024000)
格式化swap分區(qū): mkswap /home/swap
把格式化后的文件分區(qū)設(shè)置為swap分區(qū): swapon /home/swap (關(guān)閉SWAP分區(qū)命令為:[root@localhost Desktop]#swapoff /home/swap)
swap分區(qū)自動(dòng)掛載:vi /etc/fstab 在文件末尾加上"/home/swap swap swap default 0 0"
yum -y install gcc gcc-c++ make binutils compat-libstdc++-33 glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel sysstat ksh
groupadd -g 200 oinstall #添加oinstall組,組的id為200
groupadd -g 201 dba #添加dba組,組的id為201
useradd -u 440 -g oinstall -G dba oracle #添加用戶oracle,并specified它的id為440.
passwd oracle #輸入oracle用戶的密碼
id oracle #查看用戶id和所屬組。
vim /etc/selinux/config #編輯配置文件,關(guān)閉SELINUX
setenforce 0 #立即關(guān)閉SELINUX
把下面兩個(gè)文件上傳到CentOS7-64bits服務(wù)器的/app/oracle目錄下(我比較喜歡把軟件安裝在/app下)
linux.x64_11gR2_database_1of2.zip和linux.x64_11gR2_database_2of2.zip
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
在/app/oracle目錄下會(huì)出現(xiàn)database目錄。
vim /app/oracle/database/response/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=可以寫本機(jī)地址
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/app/oracle/oraInventory
SELECTED_LANGUAGES=zh_CN,en
ORACLE_HOME=/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=512
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle2018
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.automatedBackup.enable=false
DECLINE_SECURITY_UPDATES=true
oracle賬號(hào)登陸,在/app/oracle/database路徑下執(zhí)行開始安裝
./runInstaller -silent -responseFile /app/oracle/database/response/db_install.rsp
安裝成功之后會(huì)出現(xiàn)如下:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/app/oracle/oraInventory/orainstRoot.sh
/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
/app/oracle/oraInventory/orainstRoot.sh
/app/oracle/product/11.2.0/db_1/root.sh
你~/.bash_profile
export PATH
export ORACLE_BASE=/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
export TNS_ADMIN=$ORACLE_HOME/network/admin
使用下面命令使環(huán)境變量生效:source ~/.bash_profile
為了使sqlplus能夠訪問遠(yuǎn)程oracle數(shù)據(jù)庫(kù),不但要配置“TNS_ADMIN”環(huán)境變量,還需要環(huán)境變量指向的地址(我這里是/app/oracle/product/11.2.0/db_1/network/admin/)中放入tnsnames.ora文件
下面是我tnsnames.ora的內(nèi)容,其中orcl是數(shù)據(jù)庫(kù)名字。
localoracle =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
確認(rèn)并修改/app/oracle/database/response/dbca.rsp,其中修改的都是CREATEDATABASE操作的內(nèi)容,其他的不動(dòng)。
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
CHARACTERSET="AL32UTF8"
用oracle賬號(hào)調(diào)用下面的命令
dbca -silent -responseFile /app/oracle/database/response/dbca.rsp
#執(zhí)行結(jié)束后需要輸入2次oracle設(shè)置的密碼
驗(yàn)證Oracle安裝是否成功:
su --u 甲骨文腳本
sqlplus "/as sysdba"
從選項(xiàng)卡中選擇 *;
如果成功運(yùn)行,表示oracle已經(jīng)啟來,否則需要運(yùn)行“startup”命令啟動(dòng)oracle.
位置:/app/oracle/product/11.2.0/db_1/network/admin
文件內(nèi)容
# copyright (c) 1997 by the Oracle Corporation
#
# NAME
# listener.ora
# FUNCTION
# Network Listener startup parameter file example
# NOTES
# This file contains all the parameters for listener.ora,
# and could be used to configure the listener by uncommenting
# and changing values. Multiple listeners can be configured
# in one listener.ora, so listener.ora parameters take the form
# of SID_LIST_<lsnr>, where <lsnr> is the name of the listener
# this parameter refers to. All parameters and values are
# case-insensitive.
# <lsnr>
# This parameter specifies both the name of the listener, and
# it listening address(es). Other parameters for this listener
# us this name in place of <lsnr>. When not specified,
# the name for <lsnr> defaults to "LISTENER", with the default
# address value as shown below.
#
# LISTENER =
# (ADDRESS_LIST=
# (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
# (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
LISTENER=(DESCRIPTION_LIST=(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
)
)
# SID_LIST_<lsnr>
# List of services the listener knows about and can connect
# clients to. There is no default. See the Net8 Administrator's
# Guide for more information.
#
# SID_LIST_LISTENER=
# (SID_LIST=
# (SID_DESC=
# #BEQUEATH CONFIG
# (GLOBAL_DBNAME=salesdb.mycompany)
# (SID_NAME=sid1)
# (ORACLE_HOME=/private/app/oracle/product/8.0.3)
# #PRESPAWN CONFIG
# (PRESPAWN_MAX=20)
# (PRESPAWN_LIST=
# (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
# )
# )
# )
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=orcl)
(SID_NAME=orcl)
(ORACLE_HOME=/app/oracle/product/11.2.0/db_1)
(PRESPAWN_MAX=20)
(PRESPAWN_LIST=
(PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
)
)
)
# PASSWORDS_<lsnr>
# Specifies a password to authenticate stopping the listener.
# Both encrypted and plain-text values can be set. Encrypted passwords
# can be set and stored using lsnrctl.
# LSNRCTL> change_password
# Will prompt for old and new passwords, and use encryption both
# to match the old password and to set the new one.
# LSNRCTL> set password
# Will prompt for the new password, for authentication with
# the listener. The password must be set before running the next
# command.
# LSNRCTL> save_config
# Will save the changed password to listener.ora. These last two
# steps are not necessary if SAVE_CONFIG_ON_STOP_<lsnr> is ON.
# See below.
#
# Default: NONE
#
# PASSWORDS_LISTENER = 20A22647832FB454 # "foobar"
# SAVE_CONFIG_ON_STOP_<lsnr>
# Tells the listener to save configuration changes to listener.ora when
# it shuts down. Changed parameter values will be written to the file,
# while preserving formatting and comments.
# Default: OFF
# Values: ON/OFF
#
# SAVE_CONFIG_ON_STOP_LISTENER = ON
# USE_PLUG_AND_PLAY_<lsnr>
# Tells the listener to contact an Onames server and register itself
# and its services with Onames.
# Values: ON/OFF
# Default: OFF
#
# USE_PLUG_AND_PLAY_LISTENER = ON
# LOG_FILE_<lsnr>
# Sets the name of the listener's log file. The .log extension
# is added automatically.
# Default=<lsnr>
#
# LOG_FILE_LISTENER = lsnr
# LOG_DIRECTORY_<lsnr>
# Sets the directory for the listener's log file.
# Default: <oracle_home>/network/log
#
# LOG_DIRECTORY_LISTENER = /private/app/oracle/product/8.0.3/network/log
# TRACE_LEVEL_<lsnr>
# Specifies desired tracing level.
# Default: OFF
# Values: OFF/USER/ADMIN/SUPPORT/0-16
#
# TRACE_LEVEL_LISTENER = SUPPORT
# TRACE_FILE_<lsnr>
# Sets the name of the listener's trace file. The .trc extension
# is added automatically.
# Default: <lsnr>
#
# TRACE_FILE_LISTENER = lsnr
# TRACE_DIRECTORY_<lsnr>
# Sets the directory for the listener's trace file.
# Default: <oracle_home>/network/trace
#
# TRACE_DIRECTORY_LISTENER=/private/app/oracle/product/8.0.3/network/trace
# CONNECT_TIMEOUT_<lsnr>
# Sets the number of seconds that the listener waits to get a
# valid database query after it has been started.
# Default: 10
#
# CONNECT_TIMEOUT_LISTENER=10
使用lsnrctl start命令啟動(dòng)偵聽器
聯(lián)系客服