Linux与云计算——第二阶段Linux服务器架设 第一十二章:数据库搭建—Oracle Database 12c

Linux与云计算——第二阶段Linux服务器架设

第一十二章:数据库搭建—Oracle Database 12c

3.1 预需求

安装 Oracle Database 12c.html

在安装以前,更改一些安装Oracle数据时的要求设置linux

[1] 安装 Desktop Environment, refer to here.

[2] 安装required.

[root@server ~]# yum -y install binutils compat-libcap1 gcc gcc-c++ glibc glibc.i686 glibc-devel glibc.i686 ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcc libgcc.i686 libstdc++ libstdc++l7.i686 libstdc++-devel libstdc++-devel.i686 compat-libstdc++-33 compat-libstdc++-33.i686 libXi libXi.i686 libXtst libXtst.i686 make sysstatc++

[3] 编辑内核参数.

[root@server ~]# MEMTOTAL=$(free -b | sed -n '2p' | awk '{print $2}') 数据库

[root@server ~]# SHMMAX=$(expr $MEMTOTAL / 2) 安全

[root@server ~]# SHMMNI=4096 bash

[root@server ~]# PAGESIZE=$(getconf PAGE_SIZE)服务器

[root@server ~]# cat >> /etc/sysctl.conf << EOF网络

fs.aio-max-nr = 1048576session

fs.file-max = 6815744oracle

kernel.shmmax = $SHMMAX

kernel.shmall = `expr \( $SHMMAX / $PAGESIZE \) \* \( $SHMMNI / 16 \)`

kernel.shmmni = $SHMMNI

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

EOF

[root@server ~]# sysctl -p

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmmax = 6274715648

kernel.shmall = 392169728

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

[4] 为数据库建立用户和组

[root@server ~]# i=54321; for group in oinstall dba backupdba oper dgdba kmdba; do

groupadd -g $i $group; i=`expr $i + 1`

done

[root@server ~]# useradd -u 1200 -g oinstall -G dba,oper,backupdba,dgdba,kmdba -d /home/oracle oracle

[root@server ~]# passwd oracle

Changing password for user oracle.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

[root@server ~]# mkdir -p /u01/app/oracle

[root@server ~]# chown -R oracle:oinstall /u01/app

[root@server ~]# chmod -R 775 /u01

[root@server ~]# vi /etc/pam.d/login

# near line 14: add

session    required     pam_selinux.so open

session    required     pam_namespace.so

 session    required     pam_limits.so

 session    optional     pam_keyinit.so force revoke

session    include      system-auth

-session   optional     pam_ck_connector.so

[root@server ~]# vi /etc/security/limits.conf

# 结尾处加入:

 oracle  soft  nproc   2047

oracle  hard  nproc   16384

oracle  soft  nofile  1024

oracle  hard  nofile  65536

oracle  soft  stack   10240

oracle  hard  stack   32768

[5] 用oracle用户登陆,设置环境变量

dlp login: oracle

Password:

[oracle@server ~]$ vi ~/.bash_profile

#结尾处添加:

umask 022

export ORACLE_BASE=/u01/app/oracle

# 为安装建立一个临时目录

 [oracle@server ~]$ mkdir tmp

3.2 安装Oracle 12c

[1] 用以前在设置中建立的用户登陆来管理数据库。

wKiom1eugVGjYkm_AAKvMxgmDCc439.png-wh_50[2]在linux操做系统上传和下载Oracle Databse 12c

 http://www.oracle.com/technology/software/products/database/index.html

[3] Oracle文件上传后,将其移到tmp目录并运行以下的安装程序。

 [oracle@server ~]$ cd tmp

[oracle@server tmp]$ unzip linuxamd64_12102_database_1of2.zip

[oracle@server tmp]$ unzip linuxamd64_12102_database_2of2.zip

[oracle@server tmp]$ ./database/runInstaller

[4] 安装程序启动以下。首先,从Oracle安全问题接收一些信息设置您的电子邮件地址和密码等。

 wKioL1eugcDi_YgsAADGVvCs118396.png-wh_50

 [5]在这个界面, 选择 "Install database software only". 

wKioL1eugczxs-kBAACyZ4IAXoE166.png-wh_50

[6]选择"Single Instance Database ***".

 wKiom1eugeOQDw_AAAC1droA0vc787.png-wh_50

[7]选择语言.

wKioL1eugiTBAtrGAADpjhQNpf4226.png-wh_50

 [8] 选择你要安装的版本

wKiom1eugjuzmqtpAAD2EAWeVCk603.png-wh_50

 [9] 为“甲骨文”指定基本目录和文件。在这个例子中,默认状况下,继续进行下一个。

 wKioL1eugk_SmWNYAADiHRHltKI970.png-wh_50

[10] 指定已经安装的目录,默认继续.

 wKiom1eugoaSy08zAADf8QkNMpU916.png-wh_50

 [11]指定特权组,默认继续.

wKioL1eugpjSUDGYAAELk78O0rM466.png-wh_50

[12] 检查前的要求。若是有些设置没有按照建议配置,就会出来相关的通知,请再次确认它们。

wKioL1eugvyjsIs6AAD8COHVK38095.png-wh_50

[13] 配置文件的总结。选择安装,就OK了.

wKiom1eugxHSU6dDAAD4PgBiD_E856.png-wh_50

[14]开始安装

wKiom1eugyTTeZHsAAE5_-vlhkU517.png-wh_50

[15]  下面的界面出现以后,找到一个终端开始用root用户执行下面的操做.

 wKioL1eugzayanMmAABdDkdt9GA968.png-wh_50

[root@server ~]# /u01/app/oraInventory/orainstRoot.sh

Changing permissions of /u01/app/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.

The execution of the script is complete.

[root@server ~]#

[root@server ~]# /u01/app/oracle/product/12.1.0/dbhome_1/root.sh

Performing root user operation.

The following environment variables are set as:

    ORACLE_OWNER= oracle

    ORACLE_HOME=  /u01/app/oracle/product/12.1.0/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:    # Enter

   Copying dbhome to /usr/local/bin ...

   Copying oraenv to /usr/local/bin ...

   Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

[16] 安装完成,点击关闭。

 wKiom1eug0uxmnqWAACfAL5TnLI435.png-wh_50

[17] 为oracle用户设置环境变量

[oracle@server ~]$ vi ~/.bash_profile

# 结尾处添加

export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1

export PATH=$PATH:$ORACLE_HOME/bin

[oracle@server ~]$ source ~/.bash_profile

[oracle@server ~]$ rm -rf tmp

3.3 增长Oracle Net Listener

在oracle网络上建立oracle监听

[1]登陆oracle界面,输入netca命令

wKiom1euhK_haroVAAGeLB6InLo678.png-wh_50

[2]检查 "Listener Configuration"  

wKioL1euhL2z2eF6AAEgcpVJLW0067.png-wh_50

[3]一直next下去.

wKioL1euhMrhyheXAAEC1PxzQDo874.png-wh_50

[4] 输入监听名字,任意选择一个。    

wKiom1euhNfB1Pn0AADzfRno-SM163.png-wh_50    

[5] 默认"TCP".   

wKiom1euhOXAikobAADfUEDwJ9Q436.png-wh_50                                  

[6] Set a port. This example goes next   

wKioL1euhPOz3Q8CAADsbAPDzyU944.png-wh_50

 [7] If you'd like to create more with keeping default.  Listeners, Answer "Yes". This example selects "No".

wKioL1euhQKjt9BlAAD7rgTS36Y114.png-wh_50

[8]配置完成. 

wKiom1euhRKi16brAADlgdGvTEU908.png-wh_50

[9] 在建立监听器,tnslsnr侦听端口配置以下。

[oracle@server~]$ ss -napt

State      Recv-Q Send-Q          Local Address:Port       Peer Address:Port

LISTEN     0      128                         *:22                    *:*

LISTEN     0      128                 127.0.0.1:631                   *:*

LISTEN     0      100                 127.0.0.1:25                    *:*

ESTAB      0      52                  10.0.0.30:22             10.0.0.5:50113

LISTEN     0      128                        :::1521                 :::*      users:(("tnslsnr",3988,9))

LISTEN     0      128                        :::22                   :::*

LISTEN     0      128                       ::1:631                  :::*

LISTEN     0      100                       ::1:25                   :::*

[oracle@server ~]$ tnsping localhost

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 04-JUL-2015 01:03:07

Copyright (c) 1997, 2014, Oracle.  All rights reserved.

Used parameter files:

Used HOSTNAME adapter to resolve the alias

Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)

(PORT=1521)))

OK (0 msec)

3.4 建立数据库

 [1] 登陆数据库,而且输入如下的命令。

wKioL1euhcST_XsrAAEX20xISsw405.png-wh_50

 [2] Select "Create Database" and go next.

wKiom1euhdLQWaDoAACmxUieBxo913.png-wh_50

[3] On this example, select "Advanced Mode" and go next.

wKiom1euhd6RmuKrAADs-ssq0L8374.png-wh_50

[4] This example selects "General   

wKioL1euheyRjDoiAADp5M3WqC8967.png-wh_50      

[5] Set Grobal Database name and SID Purpose ***" and go next.  like follows. Input any one you like.

wKiom1euhfzDhVUoAAEAArXe4h0958.png-wh_50

[6] This example goes next with keeping  

wKioL1euhgig6URcAADWA7trvEM109.png-wh_50 

[7] Set passwords. Please set a default.password for a user for security. 

wKiom1euhhfCIZCRAADZ1FuOV1k889.png-wh_50

[8]配置监听. 

wKioL1euhiSDMEkGAADkCjlaqZM438.png-wh_50

[9]配置内存设置.

wKiom1euhjqROZqmAAEcmmMt3ks006.png-wh_50

[10] 配置简单的示例和脚本     

wKiom1euhkqzRMFvAAD_3_BsAhc244.png-wh_50        

[11]配置 memory

wKioL1euhliyPvlhAAEKVWFtLds112.png-wh_50

[12] 指定最大进程                     

wKiom1euhmzBPLusAADr8QIoXV8202.png-wh_50

[13] 字符设置

wKiom1euhoqzrC2uAAEX11PLqq0911.png-wh_50

[14] 选择链接模式。若是您的服务器没有多客户端,请选择“专用服务器模式”。若是您的服务器有许多客户端,请选择“共享服务器”

wKioL1euhpezPUsyAAEUjw0qQJU667.png-wh_50

[15]继续

wKioL1euhqPSY5THAADh1ctXl3E584.png-wh_50

[16]配置完成,选择“finish”

wKiom1euhrCg36D-AAFEkKjXS4o233.png-wh_50

[17] 数据库开始建立. 

wKiom1euhrzyu7khAADT1JCKcys783.png-wh_50

 [18] 点击关闭。

wKioL1euhsfgViW4AAEOOqK8lF8358.png-wh_50

[19] 添加SID到数据库

[oracle@dserver~]$ vi /etc/oratab

#更改以下

dlp:/u01/app/oracle/product/12.1.0/dbhome_1:Y

[oracle@server ~]$ vi ~/.bash_profile

# 结尾添加

export ORACLE_SID=dlp

3.5 使用企业管理器

使用企业管理器,它有可能在图像化界面管理数据库

[1]建立完成数据库以后,数据库服务是运行状态也有可能访问企业管理器。访问数据库建立完成时所显示的网址,而后显示登陆表单,并有可能与数据库用户登陆。

wKioL1euhwLCNDxrAAEkq11HsOM018.png-wh_50

[2]登陆成功后,就能够开始管理了


3.6 建立Systemd file

为数据库服务建立系统目录。

[1] Login as root user and create Systemd files.

[root@server ~]# vi /etc/sysconfig/dlp.oracledb

# 建立新的:定义环境变量

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1

ORACLE_SID=dlp

#配置监听服务

 [root@server ~]# vi /usr/lib/systemd/system/dlp@lsnrctl.service

# this is an example, modify for free

 [Unit]

Description=oracle net listener

After=network.target

 

[Service]

Type=forking

EnvironmentFile=/etc/sysconfig/dlp.oracledb

ExecStart=/u01/app/oracle/product/12.1.0/dbhome_1/bin/lsnrctl start

ExecStop=/u01/app/oracle/product/12.1.0/dbhome_1/bin/lsnrctl stop

User=oracle

 

[Install]

WantedBy=multi-user.target

 

# configure database service

[root@server ~]# vi /usr/lib/systemd/system/dlp@oracledb.service

# this is an example, modify for free

 [Unit]

Description=oracle net listener

After=network.target lsnrctl.service

 

[Service]

Type=forking

EnvironmentFile=/etc/sysconfig/dlp.oracledb

ExecStart=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbstart /u01/app/oracle/product/12.1.0/dbhome_1

ExecStop=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbshut /u01/app/oracle/product/12.1.0/dbhome_1

User=oracle

 

[Install]

WantedBy=multi-user.target

[root@server ~]# systemctl daemon-reload

[root@server ~]# systemctl enable dlp@lsnrctl dlp@oracledb

相关文章
相关标签/搜索