今天玩vm的收获-1,LVM管理真方便-2,ip地址改完了别忘了修改listener和local_listener

联系:QQ(5163721)

标题:今天玩vm的收获-1,LVM管理真方便-2,ip地址改完了别忘了修改listener和local_listener

作者:Lunar©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.]

今天继续整合vm,遇到两个问题,一个是,空间和一两句话说不清楚的目录问题,一个是ip地址问题,都是小蚂蚁问题,记录一下,好玩,O(∩_∩)O哈哈~
这个是空间问题:
你可以看到,我的这个有2个盘分别存放了grid软件和oracle软件,分别用了两个盘,分别挂载到两个目录: /u01 和 /u01/app/oracle
于是,我就想到应该扩展根目录,然后把tar文件放到根目录下,在解压,应该就自动合并到/u01/app/oracle了。

[root@lunar ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      7.8G  5.6G  1.8G  76% /
/dev/sda1              99M   50M   45M  53% /boot
tmpfs                 731M     0  731M   0% /dev/shm
/dev/sdc1              12G  7.7G  3.6G  69% /u01
/dev/sde1              12G  5.6G  5.7G  50% /u01/app/oracle
/dev/sdf1              30G  4.2G   24G  15% /other
[root@lunar ~]#

我的一个11.2.0.3的vm也是/u01/app/oracle目录。
我们都知道,使用root用户tar一个目录,解tar时,直接按照原有目录解压,但是今天测试了好几个参数,都不行
我怀疑就是因为不同的盘上有了相同的目录,比如/dev/sde1 挂载到了 /u01/app/oracle,跟不够大,我把tar过来的11.2.0.3.tar放到了新建的盘/dev/sdf1上
挂载到/other上,因此解压的时候,目录就变成/other/u01/app/oracle了
这样我的这套11.2的环境就有问题,需要修改一些东西,比较麻烦。。。

弄好后,测试下两个环境,一个oracle 12.1,一个是oracle 11.2.0.3

[oracle@lunar ~]$ cat ora12.env 
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.1/dbhome_1
export ORACLE_SID=lunarbb
#export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=$ORACLE_HOME/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin:Xll:/sbin:/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;

export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"

umask 022
alias ss="sqlplus / as sysdba"
alias ll="ls -lrt"
set -o vi

[oracle@lunar ~]$ . ora12.env 
[oracle@lunar ~]$ 

这里启动数据库,遇到另一个小问题:

[oracle@lunar ~]$ ss

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 11 14:00:14 2013

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

Connected to an idle instance.

SYS@lunarbb>create pfile='/tmp/a.ora' from spfile;
create pfile='/tmp/a.ora' from spfile
*
ERROR at line 1:
ORA-01565: error in identifying file '?/dbs/spfile@.ora'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


Elapsed: 00:00:00.05
SYS@lunarbb>exit
Disconnected
[oracle@lunar ~]$ 

找不到spfile,检查下,果然没有spfile和init:


[oracle@lunar dbhome_1]$ pwd
/u01/app/oracle/product/12.1/dbhome_1
[oracle@lunar dbhome_1]$ cd dbs
[oracle@lunar dbs]$ ls
hc_lunarbb.dat  initlunarbb.ora.bak  init.ora.bak  lkLUNARBB  orapwlunarbb  PDB3.XML  pfile.bak  snapcf_lunarbb.f
[oracle@lunar dbs]$
[oracle@lunar dbs]$ cat initlunarbb.ora.bak
SPFILE='+DATA/lunarbb/spfilelunarbb.ora'
[oracle@lunar dbs]$ mv initlunarbb.ora.bak initlunarbb.ora
[oracle@lunar dbs]$

再重启,还是不行:
SYS@lunarbb>startup
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00130: invalid listener address '(ADDRESS=(PROTOCOL=TCP)(HOST=lunar)(PORT=192.168.56.129))'
SYS@lunarbb>

弄个pfile出来看看,把这个“鸡肋”LOCAL_LISTENER注释掉试试看,然后果然可以了,没有报其他错误了,说明我的vm还是好的
(最近每天折腾vm,都是从活动硬盘上copy回来的,总是有各种妖怪问题):

[oracle@lunar dbs]$ ss

SQL*Plus: Release 12.1.0.1.0 Production on Mon Nov 11 14:04:40 2013

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

Connected to an idle instance.

SYS@lunarbb>create pfile='/tmp/a.ora' from spfile='+DATA/lunarbb/spfilelunarbb.ora';

File created.

Elapsed: 00:00:00.28
SYS@lunarbb>

注释下面一行:
#*.local_listener='LISTENER_LUNARBB'

然后启动ok了
SYS@lunarbb>startup pfile=/tmp/a.ora
ORACLE instance started.

Total System Global Area  346562560 bytes
Fixed Size                  2288240 bytes
Variable Size             297797008 bytes
Database Buffers           37748736 bytes
Redo Buffers                8728576 bytes
Database mounted.
Database opened.
SYS@lunarbb>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@lunarbb>

我这个人养成了一种习惯,不找原因,先琢磨workround,但是回过头来,还是要看看怎么弄的


SYS@lunarbb>startup
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00130: invalid listener address '(ADDRESS=(PROTOCOL=TCP)(HOST=lunar)(PORT=192.168.56.129))'
SYS@lunarbb>

怀疑ip地址有问题,检查/etc/hosts,果然,这里的ip地址不对,从活动硬盘copy来的,里面ip沿用的以前的vm的配置:


[root@lunar product]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               lunar localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6

192.168.56.1 lunar-win
192.168.14.129  lunar

[root@lunar product]# 

再次启动还是不行。。。。。。
SYS@lunarbb>startup
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00130: invalid listener address '(ADDRESS=(PROTOCOL=TCP)(HOST=lunar)(PORT=192.168.56.129))'
SYS@lunarbb>

检查tnsnames.ora,发现问题了:


[oracle@lunar admin]$ cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LUNARBB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.129)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = lunarbb)
    )
  )

LISTENER_LUNARBB =
  (ADDRESS = (PROTOCOL = TCP)(HOST = lunar)(PORT = 192.168.56.129))

BBPDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.129)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = bb)
    )
  )
[oracle@lunar admin]$ 

这里 LISTENER_LUNARBB 使用的是机器名,而
oracle在启动的时候会根据local_listener参数的设置去找检查相应的主机名和端口号,我这里有两个错误:
1,主机名,很可能这里的HOST = lunar本身就有问题,因为我以前的老ip对应着现在的新ip的主机名,都是lunar
2,端口号写成了主机名(这个错误很奇怪,这东西按说都是自动生成的。。。。。。)


修改后,新的如下:
LISTENER_LUNARBB =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.129)(PORT = 1521))


再次启动,ok了,O(∩_∩)O哈哈~
SYS@lunarbb>startup
ORACLE instance started.

Total System Global Area  346562560 bytes
Fixed Size                  2288240 bytes
Variable Size             297797008 bytes
Database Buffers           37748736 bytes
Redo Buffers                8728576 bytes
Database mounted.
Database opened.
SYS@lunarbb>

今天还学习了一个,使用LVM管理,很方便的扩展一个目录,今天是扩展的根目录,感谢bbq同学O(∩_∩)O哈哈~
逻辑卷真方便,这里顺便记录一下:
假设你新加的硬盘是sdf
在vm上新建一个盘,使用fdisk -l找出这个盘,比如我这里是 /dev/sdf(比如,大小30g),然后创建pv:
pvcreate /dev/sdf

这里创建默认的rootvg是 VolGroup00:
vgextend VolGroup00 /dev/sdf

扩展逻辑卷,一般默认是VolGroup00做vg lv是LogVol00,我的这个是30g,但是要考虑到一部分管理空间,因此,可以使用类似29.5G左右:
lvextend -L+29.5G /dev/VolGroup00/LogVol00

然后再扩根目录:
resize2fs -p /dev/VolGroup00/LogVol00

现在再看就已经扩展好了,O(∩_∩)O哈哈~

[root@lunar ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       37G  5.6G   29G  17% /
/dev/sda1              99M   50M   45M  53% /boot
tmpfs                 731M     0  731M   0% /dev/shm
/dev/sdc1              12G  6.4G  4.9G  57% /u01
/dev/sde1              12G  9.7G  1.7G  86% /u01/app/oracle
[root@lunar ~]# 

当你查看逻辑卷的时候,会发现多了一个逻辑卷,大小是你的盘的10%左右:
[root@lunar ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                546Q5i-4IXf-ai8Q-zgCx-2siu-WSN9-54BcjP
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                37.47 GB
  Current LE             1199
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                zf7Ua0-IakS-0ZDO-cbt7-noxp-jmFA-W1p72w
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                3.91 GB
  Current LE             125
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
[root@lunar ~]# 

差点想删除,后来bbq说,这个是swap ,不能删除 *^_^*
[root@lunar ~]# cat /etc/fstab
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/sdc1     /u01            ext3       defaults     1 1
/dev/sde1     /u01/app/oracle            ext3       defaults     1 1

[root@lunar ~]# 

此条目发表在 FAQ 分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注