在Linux虚拟机上安装Oracle
一、安装前准备
在操作系统为centos7的虚拟机上安装Oracle11g
以下操作是在root用户下操作的
1、添加oracle用户和组
groupadd oinstall groupadd dba useradd -g oinstall -G dba -m oracle |
修改用户oracle的密码
#passwd oracle |
2、创建文件夹并授权
mkdir /oracle mkdir /oracle/app mkdir /oracle/app/oracle mkdir /oracle/app/oradata mkdir /oracle/app/oracle/product chown -R oracle:oinstall /oracle/app |
3、内存参数设置
1) 修改文件/etc/security/limits.conf
vim /etc/security/limits.conf |
在/etc/security/limits.conf文件中加入如下内容
oracle soft nproc 2047
oracle hard nofile 65536
oracle hard memlock 52428800
oracle soft memlock 52428800 |
2) 修改文件/etc/sysctl.conf
vim /etc/sysctl.conf |
在/etc/sysctl.conf文件中加入如下内容
kernel.shmall=2097152
kernel.shmmax=4294967295
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576 |
4、oracle用户环境变量设置
切换用户,从root切换到oracle,以下操作是在oracle用户下操作的
su - oracle |
编辑.bash_profile文件
vim .bash_profile |
在.bash_profile文件中加入如下内容
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:/usr/lib:/usr/local/lib
export ORACLE_SID=orcl |
5、安装oracle依赖包
以下操作是在root用户下操作的
yum install -y gcc yum install -y libaio-devel yum install -y gcc-c++ yum install -y elfutils-libelf-devel yum install -y compat-libstdc++-33 |
二、Centos7 安装图形化界面&远程桌面
以下操作是在root用户下操作的
1、安装图形化界面
yum groupinstall "GNOME Desktop" "Graphical Administration Tools" |
如果没有xclock,同样需要安装xclock
yum install xorg-x11-apps |
更新系统的运行级别,设置默认启动图形界面
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target |
2、安装和配置VNC Server
yum install tigervnc-server -y cp /lib/systemd/system/[email protected] /etc/systemd/system/ cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service |
2.1配置root远程桌面连接
vim /etc/systemd/system/[email protected]:1.service |
找到下面的关键行,根据自己的实际情况进行修改,主要修改用户名
[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target
[Service] Type=forking User=root #将<user>替换成root
# Clean any existing files in /tmp/.X11-unix environment ExecStartPre=-/usr/bin/vncserver -kill %i ExecStart=/usr/bin/vncserver %i PIDFile=/root/.vnc/%H%i.pid #将<user>替换成root ExecStop=-/usr/bin/vncserver -kill %i
[Install] WantedBy=multi-user.target |
设置root连接的vnc连接密码
vncpasswd |
2.2 配置oracle远程桌面连接(用于oracle软件安装需要图形化界面)
cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:2.service vim /etc/systemd/system/[email protected]:2.service |
找到下面的关键行,根据自己的实际情况进行修改,主要修改用户名
[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target
[Service] Type=forking User=oracle #将<user>替换成oracle
# Clean any existing files in /tmp/.X11-unix environment ExecStartPre=-/usr/bin/vncserver -kill %i ExecStart=/usr/bin/vncserver %i PIDFile=/home/oracle/.vnc/%H%i.pid #将<user>替换成oracle ExecStop=-/usr/bin/vncserver -kill %i
[Install] WantedBy=multi-user.target |
设置oracle连接的vnc连接密码,需要先切换到oracle用户再执行设置密码
su - oracle vncpasswd |
3、设置开机启动 & 启动和停止
systemctl enable [email protected]:1.service systemctl enable [email protected]:2.service |
启动命令
systemctl start [email protected]:1.service or systemctl start [email protected]:1 or vncserver :1 |
停止命令
systemctl stop [email protected]:1.service or systemctl stop [email protected]:1 or vncserver -kill :1 |
查看状态
systemctl status [email protected]:1 vncserver -list //显示所有终端编号和进程ID ps aux |grep vnc //可查看所有终端的详细信息,包括终端编号、进程ID、服务端口号等 |
4、关闭防护墙
sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service
5、重启虚拟机
三、oracle安装步骤
1、启动安装界面
1) 在本地启动Xmanager - Passive。
2) 在Linux虚拟机上输入export DISPLAY=本地IP:0.0。
3) 最后做测试,,输入命令: xclock 看是不是打开个时钟,如果能打开时钟界面,说明远程服务器上的图形已经映射到XManager上来。
4) 将安装包上传到/oracle下,此地址可根据实际情况进行修改
5) 如果有乱码的情况,可以执行export LANG=en_US。
6) 新建临时文件
mkdir -p /tmp/oracle/tmp
export TMP=/tmp/oracle/tmp/
export TMPDIR=/tmp/oracle/tmp/
chmod -R 777 /tmp/oracle/
7) 在在/database目录执行./runInstaller,弹出安装界面。
2、开始安装
进行检查时,提示Sawp Size。
点击Sawp Size可以看到,oracle在安装过程中进行检查系统环境的时候,关于swap(交换分区)的大小预期为15.5139G,而系统实际上只有7.999G。
因此我们需要增加大约8G的系统swap才符合oracle的要求。
解决办法:增加大约8G的系统swap
步骤如下:
1、使用root用户,在/tmp下执行下面语句
dd if=/dev/zero of=swapfree bs=32k count=262144
(增加swap大小为bs*count,bs为block,count为数量)
2、将创建的文件用做交换分区
执行语句:mkswap swapfree
3、开启这个交换空间
执行语句:swapon swapfree
4、通过free命令查看,交换空间在原来交换空间的基础上增加了8G
5、在/etc/fstab中加入下面两行,设置此交换分区开机启动
/dec/hdb5swap swap defaults 0 0
/tmp/swapfreeswap swap defaults 0 0
设置完成后,在oracle安装界面点击checkagain,错误提示消失。
Sawp Size解决办法参照于:https://blog.****.net/liuyongyu111/article/details/53472346
Packages的问题选择了勾选右上角的Ignore all,进行下一步。
错误解决办法:
cd$ORACLE_HOME/sysman/lib
cpins_emagent.mk ins_emagent.mk.bak
vimins_emagent.mk
命令模式输入/NMECTL 进行查找,快速定位要修改的行
在后面追加参数-lnnz11 第一个是字母l 后面两个是数字1
保存退出后Retry
参照:http://blog.itpub.net/29475508/viewspace-2120836/
当看到上述界面时,说明需要使用root用户执行上述脚本:
sh /oracle/app/oraInventory/orainstRoot.sh sh /oracle/app/oracle/product/11.2.0/dbhome_1/root.sh |
安装完成,可以通过访问进行验证是否安装完成。
参照地址:
http://baijiahao.baidu.com/s?id=1567372171598142&wfr=spider&for=pc
https://blog.****.net/sunny05296/article/details/72780457
http://baijiahao.baidu.com/builder/preview/s?id=1564735350184338