logo资料库

linux虚拟机和oracle数据库安装详细步骤.doc

第1页 / 共12页
第2页 / 共12页
第3页 / 共12页
第4页 / 共12页
第5页 / 共12页
第6页 / 共12页
第7页 / 共12页
第8页 / 共12页
资料共12页,剩余部分请下载后查看
Linux 虚拟机和 oracle 数据库安装步骤 一:首先准备材料 vmWare10, oracle11g 安装包,xmanager4(ftp)工具,还有一些安装过程中 缺少的 rpm 文件,我用的是 iso5,想简单可以用 iso6 二:开始安装所需软件 1:我先安装 vm10,选择典型安装,一步一步的安装完成即可,没什么注意事项。只需要输 入注册码即可。 2:安装 ftp 软件 xmanager 三: 1:需要配置网络连接 内外能够相互 ping 通才可以。需要把虚拟机的网络连接改为桥接模 式,才能相互 ping 通。ping 通后测试一下 ftp 工具是否能连接上,xshell 和 xftp。测试通过 ok,配置 xshell 时需要注意连接写对 ip 地址,在一个就是登陆验证的用户名和密码一般都 写为:root 2:开始修改系统配置文件。 password,因为 root 权限最大,后期上传文件时是要求权限的。 /etc/security/limits.conf, 加 nproc nproc nofile nofile 入 内 容 2047 16384 1024 65536 改 1:vi /etc/security/limits.conf 修 oracle oracle oracle oracle 按 ESC 退出,:wq 强制保存 2:vi /etc/pam.d/login soft hard soft hard 添加一下语句:session required /lib/security/pam_limits.so session required pam_limits.so 按 ESC 退出,按 :wq 强制保存。 打开修改/etc/sysctl.conf,在最后加入以下内容 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 fs.file-max = 6815744 net.ipv4.ip_local_port_range = 9000 65500 net.core.wmem_max = 1048576 fs.aio-max-nr = 1048576 4:要是 /etc/sysctl.conf 生效,输入命令 sysctl -p
5:、修改系统环境变量/etc/profile 修改环境变量/etc/profile,加入以下内容 if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi 四:创建相关的用户和组 1:创建用户 [root@localhost ~]# groupadd dba [root@localhost ~]# groupadd oinstall [root@localhost ~]# useradd -g oinstall -G dba oracle 2:修改密码 [root@localhost ~]# passwd oracle Changing password for user oracle New UNIX password: 输入第一次 BAD PASSWORD: it is based on a dictionary word Retype new UNIX password: 输入第二次 passwd: all authentication tokens updated successfully.
[root@localhost ~]# 3:创建 oracle 所需目录 [root@localhost ~]# mkdir /home/oracle/app [root@localhost ~]# mkdir /home/oracle/app/oracle [root@localhost ~]# mkdir /home/oracle/app/oradata [root@localhost ~]# mkdir /home/oracle/app/oracle/product [root@localhost ~]# mkdir /usr/local/oracle 这个目录是存放数据库的解压文件 的。 以下命令将 oracle 安装目录(/home/oracle/app)赋予 oracle 用户 oinstall 用户 组 [root@localhost ~]# chown -R oracle:oinstall /home/oracle/app [root@localhost ~]# 4: 设置 ORACLE 环境变量 修改 oracle 用户主目录(/home/oracle)的的环境变量配置文件.bash_profile。 使用以下命令 [root@localhost oracle]#vi /home/oracle/.bash_profile export ORACLE_SID=orcl export ORACLE_BASE=/home/oracle/app export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib 5:把 oracle 的压缩包用 ftp 传到虚拟机里面。 6:把 oracle 的两个压缩文件解压到之前创建的 usr/local/oracle 文件里面 7:在安装过程中会提示你缺少那些安装包,你就需要到相应的 ISO 文件中查找 到相应的包,安装进去。但是要以 root 的身份进行安装,如果以 oracle 身份安 装的话,会提示,[oracle@localhost installingdpm]$ rpm -ivh compat-libstdc++-33-3.2.3-61.i386.rpm warning: compat-libstdc++-33-3.2.3-61.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 error: can't create transaction lock on /var/lib/rpm/__db.000 所以我们要以 root 用户安装。 而且还有一个地方在安装 elfutils-libelf-devel-0.125 这个包时,实际上这个包里 面有两个文件(elfutils-libelf-devel-0.125-3.el5.i386.rpm elfutils-libelf-devel-static-0.125-3.el5.i386.rpm),且这两个文件要一起安装才 行,就是这样的命令,如下: rpm -ivh --force --nodeps elfutils-libelf-devel-0.125-3.el5.i386.rpm elfutils-libelf-devel-static-0.125-3.el5.i386.rpm 两个包之间用空格隔开。 安装到 84%的时候,可能会提示你去执行两个脚本,如图
执行完后,点击 ok,继续安装。 8:安装完成以后,且换到 oracle 用户重新开始安装 oracle。 9:当我们启动 oracle 监听器时,可能会报错如下: [oracle@mydb]$ lsnrctl start lsnrctl: error while loading shared libraries: /u01/app/oracle/product/11.2.0/lib/libclntsh.so.11.1: cannot restore segment prot after reloc: Permission denied 解决方法是: 解答: 什么原因导致这些错误呢?原凶就是在安装 LINUX 时开启了 SELinux,记得关闭 SELinux 解决方法: (1)查看 selinux 的状态为 Enforcing 模式(setenforce 1 设置 SELinux 成为 Enforcing 模式,即开启 SElinux)
[root@mydb]# getenforce Enforcing (2)setenforce 0 设置 SELinux 成为 permissive 模式(即临时关闭 SElinux) [root@mydb]# setenforce 0 (3)查看 selinux 的状态为 Permissive 模式(setenforce 0 设置 SELinux 成为 Permissive 模式) [root@mydb]# getenforce Permissive 5、查看 Selinux 的配置文件是否修改 [root@mydb bin]# vi /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # # # enforcing - SELinux security policy is enforced. permissive - SELinux prints warnings instead of enforcing. disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # # targeted - Only targeted network daemons are protected. strict - Full SELinux protection. SELINUXTYPE=targeted 我也不清楚,如果用 root 用户安装会不会出现上述问 题,也可能会出新问题。 监听启动完毕后,进入 oracle,切换用户,到 oracle su - oracle 输入命令: SQL> sqlplus /nolog SQL> conn /as sysdba
Connected to an idle instance. SQL> show user; USER is "SYS" SQL> SQL> startup ORACLE instance started Total System Global Area 417546240 bytes Fixed Size 2213936 bytes Variable Size 134219728 bytes Database Buffers 272629760 bytes Redo Buffers 8482816 bytes Database mounted. Database opened. SQL> 测试连接之前,需要先把虚拟机的防火墙关闭 [root@localhost ~]# sudo service iptables stop Flushing firewall rules: Setting chains to policy ACCEPT: filter Unloading iptables modules: [root@localhost ~]# [ OK ] [ OK ] [ OK ]
虽然关闭了防火墙,但是还需要彻底搞定就需要修改配置文件了 原来是因为 linux 下没有开启对 8011 的端口访问权限造成的。通过下面的命令可以开启允许对外访问的网 络端口: /sbin/iptables -I INPUT -p tcp --dport 8011 -j ACCEPT #开启 8011 端口 /etc/rc.d/init.d/iptables save #保存配置 /etc/rc.d/init.d/iptables restart #重启服务 查看端口是否已经开放 /etc/init.d/iptables status 结果如下 分类: 软件开发技术 **************************************************************************************** 以,oracle 用户登录 sqlplus ,创建用户和表空间 [root@localhost ~]# su - oracle [oracle@localhost ~]$ sqlplus "/as sysdba" SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /home/oracle/app/oradata/orcl/system01.dbf
分享到:
收藏