Rootop 服务器运维与web架构

2012-02-09
发表者 Venus
暂无评论

通过web界面管理oracle11g

[oracle@rhel55 bin]$ emctl start dbconsole      //启动 Enterprise Manager
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
https://rhel55:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ………. started.
——————————————————————
Logs are generated in directory /u01/oracle/rhel55_venus/sysman/log

默认用主机名访问,我这里把主机名rhel55改为我的ip192.168.2.22,通过浏览器访问:

https://192.168.2.22:1158/em/console/aboutApplication   打开登陆界面。

前提需要先开启监听程序,要不会报如下类似错误:

监听程序

状态  关闭

主机  rhel55

端口  1521

名称  LISTENER

Oracle 主目录  /u01/oracle

位置  /u01/oracle/network/admin

详细资料  TNS-12541: TNS: 无监听程序

开启监听:

[oracle@rhel55 ~]$ lsnrctl start

通过web访问即可,推荐一个入门的资料:

http://wenku.baidu.com/view/df8f6f45b307e87101f696aa.html

2012-02-08
发表者 Venus
暂无评论

oracle数据库忘记sys、system密码

修改密码如下:

[oracle@rhel55 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 7 09:35:58 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn /as sysdba
已连接。
SQL> alter user sys identified by oracle123;

用户已更改。

SQL> alter user system identified by oracle123;

用户已更改。

SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
[oracle@rhel55 ~]$

[oracle@rhel55 ~]$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 7 09:39:16 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

请输入用户名:  system
输入口令:   //刚才设置的密码

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

2012-02-07
发表者 Venus
暂无评论

解决oracle命令行执行命令时返回值为????问号

redhat5.5+oracle11gr2,命令行执行命令时,返回结果值为问号,应该是编码的问题:

[oracle@rhel55 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 7 08:58:14 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn /as sysdba
????

执行select   *   from   V$NLS_PARAMETERS 查询出值为:

PARAMETER
—————————————————————-
VALUE
—————————————————————-
NLS_NCHAR_CHARACTERSET
AL16UTF16

编码是utf16。
对于表操作现在不熟,临时的解决方法是:

oracle用户登录执行:

[oracle@rhel55 ~]$ export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.AL32UTF8″   //通过环境变量设置为utf8

还可以修改oracle变量文件.bash_profile中添加export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.AL32UTF8″

然后source .bash_profile生效,下次开机就自动执行。最好的方法是修改数据库,等研究会了在补充上。

2012-02-04
发表者 Venus
暂无评论

redhat enterprise linux 5.5下oracle 11gR2 安装文档

oracle 11g r2下载地址:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

可参考官方文档,注意数据库的版本。

Oracle 11g Release 2 (11.2) for Linux x86安装文档:

http://download.oracle.com/docs/cd/E11882_01/install.112/ 7/toc.htm

我本机环境是32位redhat enterprise linux 5.5

Make sure to download and unzip both files to the same directory.

解压下载的两个安装包,确定解压到同一个文件夹中!

安装以下软件包,推荐yum方式。

将系统光盘挂载到本机,搭建本地yum环境。安装以下软件包:

yum install –y binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make numactl-devel sysstat unixODBC unixODBC-devel

添加相关用户和组:

groupadd oinstall

groupadd dba

mkdir -p /u01/oracle

添加一个oracle用户, 根目录是 /u01/oracle, 主组是 oinstall 副组是dba

useradd -g oinstall -G dba -d /u01/oracle oracle

拷贝系统变量到用户家目录。

cp /etc/skel/.*  /u01/oracle

会提示你略过目录,略过即可。

为oracle用户设置密码 123

passwd oracle

为u01更改属组属组权限:

chown -R oracle:oinstall /u01

检查 nobody 是否存在 :id nobody

缺省存在的。如果不存在

useradd  nobody

更改系统参数:

vi /etc/sysctl.conf

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 536870912

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

vi /etc/security/limits.conf

oracle           soft    nproc   2047

oracle           hard    nproc   16384

oracle           soft    nofile  1024

oracle           hard    nofile  65536

vi /etc/pam.d/login    //添加一行

session    required     pam_limits.so

设置oracle 用户环境变量

su – oracle

vi .bash_profile

ORACLE_BASE=/u01

ORACLE_HOME=$ORACLE_BASE/oracle

ORACLE_SID=venus              //实例名

PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

mv database /u01/

cd /u01

chown -R oracle:oinstall database/

修改的系统参数比较多东西, 重启一下系统,然后进入GUI界面开始安装。

使用oracle账号 登陆图形界面 进行安装:

打开终端,执行如下命令:

cd /u01/database

./runInstaller         //开始安装

安装选项参考:

Installation Optiong

install database software only

Grid Options

Single instance database installation

Product Languages

English

Database Edition

Enterprise Edition (3.95)

Installation Location

Oracle Base: /u01

Software Loacation: /u01/oracle

提示: yes

Create Inventory

mkdir /oraInventory

chown -R oracle:oinstall oraInventory

Operating System Groups

Next

Prerequis ite Checks

Ignore All

Summary

Finish

Install Product

安装完毕, 提示用root账户执行如下脚本。

/oraInventory/orainstRoot.sh

/u01/oracle/root.sh

直接按回车, 缺省值就可以

Finish

The installation of Oracle Database was successful

====================================

上面只是安装了数据库软件,数据库没有创建,还有配置 监听器 Listener

运行命令:

netca

一直点下一步 , 最后 Finish

ps -ef 可以查看Listener是否配置成功

———–

dbca

一直 Next,      Global Database Name 和 SID 都是输入 venus   //这里要注意跟ORACLE_SID=venus 一致

选择 User the Same…..All Accounts

密码: 123456

选择 Sample Schemas

Memory 内存分配,默认就可以了

Character Sets 选择 Use Unicode(AL32UTF8)

然后一直 Next , 到最后 Finish

弹出一个 Confirmation , 点击 OK 就可以了, 然后自动进行安装

安装到目录 /u01/oradata/venus

测试:

用 oracle 用户 远程登录, 然后

$ sqlplus /nolog

SQL> conn / as sysdba

Connected to an idle instance.

SQL> startup

[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Fri Jun 25 15:05:54 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn / as sysdba

Connected.

SQL> create table test( id integer,name char(10));

Table created.

SQL> insert into test values(0,’Jack’);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from test;

ID NAME

———- ———-

0 Jack

关闭数据库

SQL>  shutdown immediate

SQL>  quit

成功。

2012-02-03
发表者 Venus
暂无评论

LRM-00109: could not open parameter file ‘/u01/oracle/dbs/init*.ora’

[oracle@rhel55 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Wed Feb 1 20:52:34 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file ‘/u01/oracle/dbs/initwilson.ora’

解决办法:
[oracle@rhel55 dbs]$ export ORACLE_SID=venus
[oracle@rhel55 dbs]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Wed Feb 1 21:10:51 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area  849530880 bytes
Fixed Size                  1339824 bytes
Variable Size             503320144 bytes
Database Buffers          339738624 bytes
Redo Buffers                5132288 bytes
????????
????????
SQL>

问题出在设置oracle用户.bash_profile文件的ORACLE_SID变量时,写为了 ORACLE_SID=wilson ,在startup的时候报错,其实真正的数据库实例名称是venus。

从Oracle9i开始,spfile被引入Oracle数据库,
Oracle首选spfile<ORACLE_SID>.ora文件作为启动参数文件;
如果该文件不存在,Oracle选择spfile.ora文件;
如果前两者都不存在,Oracle将会选择init<ORACLE_SID>.ora文件;
如果以上三个文件都不存在,Oracle将无法创建和启动instance。

这只是原因之一,不保证绝对解决。