操作系统安装:
CentOS7 安装: (华为服务器)
"/boot" 4G "/swap":32G "/":780G "/home":50G
--永久关闭防火墙
systemctl disable firewalld
--永久关闭selinux
vi /etc/selinux/config
--创建预装软件目录
mkdir /orasoft
1.更改网络配置:
vim /etc/sysconfig/network-scripts/ifcfg-enp2s0f0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp2s0f0
UUID=9f2339ba-2ac6-4dfe-bc37-8d7b67206955
DEVICE=enp2s0f0
ONBOOT=yes
IPADDR=192.168.80.12
PREFIX=24
GATEWAY=192.168.80.1
DNS1=123.129.80.8
DOMAIN=123.129.80.9
IPV6_PRIVACY=no
--重启服务
systemctl network restart
--拷贝文件(--->192.168.80.12)
scp /orasoft/ root@192.168.80.12:/
--改权限
chmod -R 777 /orasoft
2.改主机信息:
vim /etc/hosts
127.0.0.1 localhost
::1 localhost
192.168.80.12 hdgz
3.配置sysctl.conf (固定不变的)
vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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=1048586
执行
#/sbin/sysctl -p
4.修改/etc/security/limits.conf
vim /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.修改/etc/pam.d/login
vim /etc/pam.d/login
session required pam_limits.so
6.禁止网络时间服务、防火墙等服务启动
systemctl disable ntpd.service
systemctl stop ntpd.service
systemctl stop firewalld
systemctl disable firewalld
10.关闭SELinux
vim /etc/selinux/config
SELINUX=disabled
11.安装Oracle必备包
cd /home/orasoft/centos7/Packages
rpm -Uvh binutils-2.*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh elfutils-libelf-0.*
rpm -Uvh elfutils-libelf-devel-*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh-2*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
yum install binutils compat-libstdc++-33* elfutils-libelf-0.* elfutils-libelf-devel-* gcc-4.* gcc-c++-4.* glibc-2.* glibc-common-2.* glibc-devel-2.* glibc-headers-2.* ksh-2* libaio-0.* libaio-devel-0.* libgcc-4.* libstdc++-4.* libstdc++-devel-4.* make-3.* sysstat-7.* unixODBC-2.* unixODBC-devel-2.* tigervnc tigervnc-server -y
192.168.110.11->192.168.85.80 拷贝文件:
scp -r /orasoft/ora11g/*.* root@192.168.85.80:/home/orasoft/
12.配置VNC远程桌面
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
vim /etc/systemd/system/vncserver@:1.service
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
vncpasswd
vncserver :1
----------------------------作为服务启动VNC-----------------------
systemctl daemon-reload
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
vim /etc/systemd/system/vncserver@:2.service
ExecStart=/sbin/runuser -l oracle -c "/usr/bin/vncserver %i"
PIDFile=/home/oracle/.vnc/%H%i.pid
systemctl enable vncserver@:2.service
systemctl start vncserver@:2.service
netstat -tulnp | grep vnc
vncserver -kill :2
----------------------------作为服务启动VNC----------------------
rpm -i --force --nodeps pdksh-5.2.14-21.x86_64.rpm
13. 创建用户、组和文件路径
groupadd -g 1100 oinstall
groupadd -g 1101 dba
groupadd -g 1102 oper
useradd -u 1100 -g oinstall -G dba,oper -d /home/oracle -m oracle
passwd oracle
xx232
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01/
14.建立用户环境变量
su - oracle
vim .bash_profile
--JF-------------------------------------------------------------------------------------
ORACLE_BASE=/home/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=YMSGZ; export ORACLE_SID
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
PATH=${PATH}:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
export NLS_LANG=American_America.ZHS16GBK
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
安装字体:
mkfontscale mkfontdir fc-cache -fv
source /etc/profile
15.图形安装Oracle11.2.0(略)
界面显示个别有问题。这个到时候问问姜工有没有好的解决方法(CentOS7)
16.安装rlwrap
yum install libtermcap-devel readline readline-devel -y
解压缩:
tar -xvf rlwrap-XX
make
make install
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
17.数据库操作(创建表空间)
create tablespace YMS_TBS datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs01.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs02.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs03.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs04.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs05.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs06.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs07.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs08.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs09.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs10.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs11.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs12.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs13.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs14.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs15.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs16.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs17.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs18.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs19.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs20.dbf' size 10G autoextend on next 500M maxsize unlimited;
alter tablespace YMS_TBS add datafile '/u01/app/oracle/oradata/YMSGZ/yms_tbs21.dbf' size 10G autoextend on next 500M maxsize unlimited;
18. 创建用户
create user xx1 identified by "xxxxx" default tablespace YMS_TBS temporary tablespace temp quota unlimited on yms_tbs;
19.角色赋权
create role appdba;
grant
create session,
debug connect session,
create materialized view,
create procedure,
create sequence,
create synonym,
create table,
create trigger,
create type,
create view,
create database link,
global query rewrite,
resumable,
select any dictionary,
create indextype
to appdba
/
grant appdba to hdgz;
20.归档及备份
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
---
alter system checkpoint;
alter system archive log current;
rman设置:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backupset/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_YMSGZ.f'; # default
21.计划任务
--目录创建,授权
create directory expbackup as '/expbackup'; --本地备份用
grant read,write on directory expbackup to hdgz;
create directory uploaddp as '/uploaddp'; -- FTP用
grant read,write on directory uploaddp to hdgz;
脚本:
vim /scripts/expdp_ymsgz.sh
#!/bin/bash
a=`date "+%y_%m%d_%H%M"`
echo $a
/u01/app/oracle/product/11.2.0/db_1/bin/expdp system/xxx232 schemas=hdgz exclude=TABLE:\"IN \(\'YD_PICTURE\'\)\" directory=expbackup dumpfile=expdp_ymsgz_$a.dmp log=expdp_ymsgz_$a.log compre
ssion=data_only job_name=expdp_ymsgz
vim /scripts/backup_ymsgzdb.sh
#!/bin/bash
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_SID=YMSGZ
/u01/app/oracle/product/11.2.0/db_1/bin/rman target / cmdfile /scripts/backup_ymsgzdb.scr log /arcbackup/backup_bmsdb.log
exit 0
vim /scripts/backup_ymsgzdb.scr
backup as compressed backupset tag 'ymsgzfull' format '/arcbackup/db_%d_%T_%s_%p_%c.bak' database;
crosscheck archivelog all;
crosscheck backupset;
crosscheck copy;
delete noprompt archivelog until time "sysdate-5";
delete noprompt obsolete;
exit;
crontab -e
vim /var/spool/cron/root
30 1 * * * find /expbackup -type f -name 'expdp_' -mtime 5 -exec rm -rf '{}' ';'
30 2 * * * su - oracle -c "/scripts/expdp_ymsgz.sh"
30 3 * * * su - oracle -c "/scripts/backup_ymsgzdb.sh"
10 5 * * * su - oracle -c "/scripts/upload_ymsgz.sh