标签:ystemd off eric mct nis doc 完成后 监听 关闭防火墙
[jonathan@localhost ~]$ su root #切换到root Password: [root@localhost]# groupadd oinstall #创建用户组oinstall [root@localhost]# groupadd dba #创建用户组dba [root@localhost]# useradd -g oinstall -g dba -m oracle #创建oracle用户,并加入到oinstall和dba用户组 [root@localhost]# passwd oracle #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆 Changing password for user oracle. New password: # 密码 BAD PASSWORD: The password is shorter than 8 characters Retype new password: # 确认密码 passwd: all authentication tokens updated successfully. [root@localhost]# id oracle # 查看新建的oracle用户 uid=1001(oracle) gid=1002(dba) groups=1002(dba)
[jonathan@localhost ~]$ su root Password: [root@localhost]# mkdir -p /data/oracle #oracle数据库安装目录 [root@localhost]# mkdir -p /data/oraInventory #oracle数据库配置文件目录 [root@localhost]# mkdir -p /data/database #oracle数据库软件包解压目录 [root@localhost]# cd /data [root@localhost data]# ls #创建完毕检查一下(强迫症) database oracle oraInventory [root@localhost data]# chown -R oracle:oinstall /data/oracle #设置目录所有者为oinstall用户组的oracle用户 [root@localhost data]# chown -R oracle:oinstall /data/oraInventory [root@localhost data]# chown -R oracle:oinstall /data/database
oracle默认不支持CentOS系统安装,Oracle Database 11g Release 2 的 OS要求参考:link
修改文件 /etc/RedHat-release
[root@localhost data]# cat /proc/version Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015 [root@localhost data]# cat /etc/redhat-release CentOS Linux release 7.1.1503 (Core) [root@localhost data]# vi /etc/redhat-release [root@localhost data]# cat /etc/redhat-release redhat-7 [root@localhost data]#
下载地址 :https://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html?intcmp=ocom-hp-0219
把file1 和file2 下载下来
下载完成后,使用Xftp 软件上传到centos中,我这里放在(/home/oracle)目录中(这里不进行操作说明)
CentOS 7.2默认使用的是firewall作为防火墙
[root@localhost /]# systemctl status firewalld.service #查看防火墙状态,运行中 ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2016-04-07 18:54:29 PDT; 2h 20min ago Main PID: 802 (firewalld) CGroup: /system.slice/firewalld.service └─802 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Apr 07 18:54:25 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon... Apr 07 18:54:29 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon. [root@localhost /]# systemctl stop firewalld.service #关闭防火墙 [root@localhost /]# systemctl status firewalld.service #再次查看防火墙状态,发现已关闭 ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: inactive (dead) since Thu 2016-04-07 21:15:34 PDT; 9s ago Main PID: 802 (code=exited, status=0/SUCCESS) Apr 07 18:54:25 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon... Apr 07 18:54:29 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon. Apr 07 21:15:33 localhost systemd[1]: Stopping firewalld - dynamic firewall daemon... Apr 07 21:15:34 localhost systemd[1]: Stopped firewalld - dynamic firewall daemon. [root@localhost /]# systemctl disable firewalld.service #禁止使用防火墙(重启也是禁止的) Removed symlink /etc/systemd/system/dbus-org.Fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. [root@localhost /]#
关闭selinux(需重启生效)
[root@localhost /]# vi /etc/selinux/config
[root@localhost /]# cat /etc/selinux/config
将 SELINUX=disabled #此处修改为disabled
[root@localhost /]# vi /etc/sysctl.conf
在最下面添加以下内容:
net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.conf.all.rp_filter = 1 fs.file-max = 6815744 #设置最大打开文件数 fs.aio-max-nr = 1048576 kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024 kernel.shmmax = 2147483648 #最大共享内存的段大小 kernel.shmmni = 4096 #整个系统共享内存端的最大数 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围 net.core.rmem_default = 262144 net.core.rmem_max= 4194304 net.core.wmem_default= 262144 net.core.wmem_max= 1048576
[root@localhost /]# sysctl -p net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.conf.all.rp_filter = 1 sysctl: setting key "fs.file-max": Invalid argument fs.file-max = 6815744 #设置最大打开文件数 fs.aio-max-nr = 1048576 sysctl: setting key "kernel.shmall": Invalid argument kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024 sysctl: setting key "kernel.shmmax": Invalid argument kernel.shmmax = 2147483648 #最大共享内存的段大小 sysctl: setting key "kernel.shmmni": Invalid argument kernel.shmmni = 4096 #整个系统共享内存端的最大数 kernel.sem = 250 32000 100 128 sysctl: setting key "net.ipv4.ip_local_port_range": Invalid argument net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 [root@localhost /]#
[root@localhost /]# vi /home/oracle/.bash_profile
添加以下内容:
export ORACLE_BASE=/data/oracle #oracle数据库安装目录 export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle数据库路径 export ORACLE_SID=orcl #oracle启动数据库实例名 export ORACLE_TERM=xterm #xterm窗口模式安装 export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系统环境变量 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系统环境变量 export LANG=en_US #防止安装过程出现乱码 export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #设置Oracle客户端字符集
生效
[root@localhost /]# source /home/oracle/.bash_profile
[oracle@localhost /]$ cd /home/oracle #进入/home/oracle目录(之前使用Xftp上传的位置) [oracle@localhost src]$ ls linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip [oracle@localhost src]$ unzip linux.x64_11gR2_database_1of2.zip -d /data/database/ #解压 (省略...) [oracle@localhost src]$ unzip linux.x64_11gR2_database_2of2.zip -d /data/database/ #解压 (省略...) [oracle@localhost src]$ su root Password: [root@localhost src]# chown -R oracle:oinstall /data/database/database/
退出当前用户 登录oracle用户
到/data/database/database/目录下,执行./runInstaller
会启动图形界面进行安装
点击下一步
点击下一步
实际开发中,服务器没有图形界面,我们选择服务类安装,下一步
不需要集群,选择单实例安装,下一步
下一步
选择语言,下一步
下一步
选择目录,下一步
下一步
下一步
内存
字符集
下一步
下一步
下一步
设置密码
下一步
先决条件检查,缺少依赖包(直接忽略 进行安装)
finish配置完成
等待安装完成
安装成功之后,会弹出这个界面:
设置密码
然后会让你以root身份登录终端,执行以下脚本。
执行脚本:
[root@localhost myos]su root [root@localhost myos]# cd /home/myos/application/oracle/oraInventory [root@localhost oraInventory]# sh orainstRoot.sh [root@localhost oraInventory]# cd /home/myos/application/oracle/oracle/product/11.2.0/dbhome_1 [root@localhost dbhome_1]# sh root.sh
安装完成
上面安装成功之后,服务监听和本地网络服务应该是就配置好了,我实际安装的过程中都会提示服务名称已经存在。如果没有的话,我们可以按照下面的步骤进行配置。
打开终端,输入: [root@localhost dbhome_1]# netca Oracle Net Services Configuration:
弹出界面:
创建监听服务(充当oracle服务器,让别的oracle客户端连接本oracle服务器)
配置本地网络服务名(充当oracle客户端,连接别的oracle服务器)
我填的是自己服务器的名称,不知道填其他服务器的ip可不可以
进行连接测试
连接成功
到此就配置完毕了。
[myos@localhost ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-APR-2018 18:06:52 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 05-APR-2018 17:41:44 Uptime 0 days 0 hr. 25 min. 8 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/myos/application/oracle/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Listener Log File home/myos/application/oracle/oracle/diag/tnslsnr/localhost/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
其中:
1、Linux oracle数据库listener.ora存放路径 /home/myos/application/oracle/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 2、Linux oracle数据库tnsnames.ora存放路径 /home/myos/application/oracle/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora 3、ORACLE启动监听器 (1)切换至普通安装用户(我的是myos) su - myos (2)启动监听器 lsnrctl start (3)停止监听器 lsnrctl stop
如果使用Navicat Premium软件远程连接不了Centos的Oracle数据库
出现:“ORA-12514 TNS 监听程序当前无法识别连接描述符中请求服务”
具体操作步骤如下:
一、修改数据库服务器中listener.ora文件内容
命令:
[oracle@localhost admin]$ vi /data/oracle/product/11.2.0/db_1/network/admin/listener.ora
修改为:
# listener.ora Network Configuration File: /data/oracle/product/11.2.0/db_1/network/admin/listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /data/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) ) LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.102) #这里为centos的ip地址 (PORT = 1521) ) ) ADR_BASE_LISTENER = /data/oracle
二、修改数据库服务器中tnsnames.ora文件内容
命令:
[oracle@localhost admin]$ vi /data/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
修改为:
# tnsnames.ora Network Configuration File: /data/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. rcl = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.102)(PORT = 1521)) #这里的host为centos的ip地址 ) (CONNECT_DATA = (SID = orcl) ) )
修改完成。
重启监听
lsnrctl start
使用Navicat Premium软件远程连接
即可连接成功
标签:ystemd off eric mct nis doc 完成后 监听 关闭防火墙
原文地址:https://www.cnblogs.com/pxblog/p/10545073.html