2013年12月27日星期五

SublimeText的插件安装

最后还是同时装上了SublimeText2和3。

SublimtText用来安装插件的package controller插件,需要从console安装。ctrl+`
如果你系统使用python2,使用下面语句:
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation') 
如果你系统使用python3,使用下面语句:
import urllib.request,os;pf = 'Package Control.sublime-package';ipp = sublime.installed_packages_path();urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()));open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

如果,你要通过代理上网并且不是windows操作系统(Windows操作系统使用IE的代理配置),需要把代理配置写到urllib2.ProxyHandler()里,比如:
urllib2.ProxyHandler({'http':'cn-proxy.abc.com:80'})

安装pylint,需要你的python环境里有lint.py, 如果你没有lint.py, 就先安装pip, easy-setup什么的,参照这帖子:http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows

安装完pylint,还要把lint.py的路径写到pylint的用户配置文件,比如"pylint_path": "C:\\Python27\\Lib\\site-packages\\pip\\vendor\\html5lib\\filters"


2013年9月30日星期一

Oracle ADG 环境搭建

Oracle官方文档

不错的网络文章

《Oracle Data Guard理论知识》 这篇文章对于理解DataGuard如何利用log进行了介绍。
《Data Guard broker系列》《Data Guard Physical Standby Setup in Oracle Database 11g Release 2》 这篇文章有坑(没有提及_DBG, _DGMGRL),但总体顺序不错。
《Four Steps to create a Physical Standby Database》  这篇文章轮廓写得清晰。 上篇文章中没有提及listener.ora文件中的_DGB , _DGMGRL这两个static listener,是绝对的坑。 _DGB是Datagurad Broker用来侦听不同节点心跳的。_DGMGRL是用来保证数据库down的时候能够访问的。

《How to add and remove databases from Oracle cluseter》这篇主要示例了如何使用crvctl。

 

安装中遇到的一些问题&解决:

1)
现象:
SQL>  STARTUP NOMOUNT PFILE=’/tmp/initDB11G_stby.ora’;
ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated
ORA-01262: Stat failed on a file destination directory
Linux-x86_64 Error: 2: No such file or directory
SQL>
解决:
因为在standby上创建的fast_recovery_area时,把一个字母写错了…

2)
现象:
Warning: ORA-16714: the value of property ArchiveLagTarget is inconsistent with the database setting
解决:
先查看那些不一致,然后更正之。
DGMGRL>  show database 'db11g_stby' 'InconsistentProperties';
edit database 'db11g_stby' set property 'ArchiveLagTarget'=0;
可参考官方文档 http://docs.oracle.com/cd/E11882_01/server.112/e17023/cli.htm
3)
现象:
分别进入primary sqlplus , standby sqlplus执行—-》
SQL> select flashback_on from v$database;
SQL> alter database flashback on;
在standby 上
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-01153: an incompatible media recovery is active
SQL>
解决:SQL> STARTUP MOUNT;
ORACLE instance started.
Total System Global Area 2421825536 bytes
Fixed Size 2228880 bytes
Variable Size 1358957936 bytes
Database Buffers 1040187392 bytes
Redo Buffers 20451328 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.
4)
现象:switchover失败
DGMGRL> switchover to db11g_stby;
Performing switchover NOW, please wait…
Error: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Error: ORA-16625: cannot reach database “db11g_stby”
Failed.
Unable to switchover, primary database is still “db11g”
DGMGRL> show configuration;
Configuration – myconfigProtection Mode: MaxAvailability
Databases:
db11g      – Primary database
db11g_stby – Physical standby databaseFast-Start Failover: DISABLED
Configuration Status:
ORA-16623: database detected role change
ORA-16625: cannot reach database “db11g”
DGM-17017: unable to determine configuration status
DGMGRL>
解决:查看一下stby数据库broker参数,发现staticConnectorIdentifier默认使用1521端口。而我用的stby数据库是1522端口。
DGMGRL> show database  verbose ‘db11g_stby’;
RecvQEntries                    = ‘(monitor)’
SidName                         = ‘DB11G’
StaticConnectIdentifier         = ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))’
StandbyArchiveLocation          = ‘USE_DB_RECOVERY_FILE_DEST’
可以通过一下命令之一修改之:
//通过dgmgrl:
edit database db11g_stby set property StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))';
 或者 sqlplus:
alter system set StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))' scope=both;
参考:
《解决Oracle DataGuard Broker出现的TNS-12514错误》《Four steps to create a Physical Standby Database》 这篇文章里,是在添加了_DBG, _DGMGRL两个服务名之后,执行诸如如下的命令来确保提供合适的conenction给DG broker。下面的命令因为使用服务名而优于前文的链接字符串。
edit database db11g set property staticConnectidentifier=’DB11G’;
edit database db11g_DG1 set property staticConnectidentifier=’DB11G_DG1′;
5)
现象:-bash-3.2$ srvctl add ons
PRCR-1063 : Failed to create context
PRKH-1010 : Unable to communicate with CRS services.
PRKH-1000 : Unable to load the SRVM HAS shared library
PRKN-1008 : Unable to load the shared library “libsrvmhas11.so”
or a dependent library, from
LD_LIBRARY_PATH=”/scratch/dahyuan/app/oracle/product/11.2.0/grid/lib”
[java.lang.UnsatisfiedLinkError: /scratch/dahyuan/app/oracle/product/11.2.0/grid/lib/libsrvmhas11.so: libasmclnt11.so: cannot open shared object file: No such file or directory]
解决:
一种是你的server上真的缺少一些开发包,需要你编译安装。但我这里是因为LD_LIBRARY_PATH的问题,当时libary path没有/usr/lib和/usr/local/lib这两个目录。加上之后再运行root.sh就好了。 LD_LIBRARY_PATH应该至少包括/scratch/dahyuan/app/oracle/product/11.2.0/grid/lib:/usr/lib:/usr/local/lib。
参考:
《Oracle 安装 clusterware时遇到的问题》
6)
现象:-bash-3.2$ srvctl start ons
#
# An unexpected error has been detected by HotSpot Virtual Machine:
# SIGSEGV (0xb) at pc=0x00002ada0b2b3a84, pid=2082, tid=47115974751584
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0_24-rev-b08 mixed mode)
# Problematic frame:
# V [libjvm.so+0x3afa84]
#
# An error report file with more information is saved as hs_err_pid2082.log
#
# If you would like to submit a bug report, please visit:
#
/scratch/dahyuan/app/oracle/product/11.2.0/dbhome_1/bin/srvctl: line 240: 2082 Aborted $JRE $JRE_OPTIONS -DORACLE_HOME=$ORACLE_HOME -classpath $CLASSPATH $SRVM_PROPERTY_DEFS oracle.ops.opsctl.OPSCTLDriver “$@”
解决:
这个是因为使用了Database_HOME里的srvctl。应该使用grid_HOME/bin里的srvctl。
参考:
《SRVCTL文档》  To manage Oracle ASM on Oracle Database 11g release 2 (11.2) installations, use the SRVCTL binary in the Oracle Grid Infrastructure home for a cluster (Grid home). If you have Oracle RAC or Oracle Database installed, then you cannot use the SRVCTL binary in the database home to manage Oracle ASM.

7)
现象:
DGMGRL>  ENABLE FAST_START FAILOVER;
Error: ORA-16651: requirements not met for enabling fast-start failover
解决:
在primary 和 standby上用sqlplus 都执行,  alter database flashback on;


8)
现象:
DGMGRL> show database  verbose 'db11g_stby';
出现以下警告,
  Database Warning(s):

    ORA-16826: apply service state is inconsistent with the DelayMins property
解决:
在DGMGRL里执行,disable configuration;    再执行 enable configuration;  就可以解决。



2013年1月14日星期一

【翻译】The “reassociation” business of Fusion Middleware

原文出处:http://fusionsecurity.blogspot.jp/2011/10/reassociation-business.html 下面大致翻译了一下,不精准,笔记性质。

 从Fusion Middleware 11.1.1.4开始,OPSS(Oracle Platform Security Service)支持三种类型的安全存储(Security Store):文件、OID(Oracle Internet Directory)以及Oracle DataBase。当weblogic server的domain刚被创建出来时,默认地,OPSS是和文件类型的存储相关联的。文件存储比较适合开发阶段。对于生产环境,不推荐文件存储类型(请参考“ Multiple Nodes Servers Environments”)。如果你的运行环境是在一个台机器上只有唯一的一个weblogic domain、一个weblogic server,文件类型存储也是能工作的。但是99.99%的情况,你的SOA、WebCenter环境是运行在集群环境下的多个服务器上。文件存储不提供这种伸缩性,这种情况下,你应该考虑OID或者Oracle DataBase。

实际上,很多的Fusion应用时使用OID。:) OPSS安全存储由policy,credential,keys以及audit services组成。注意:我没有提及identity store service。因为,OPPS把identity store service'委托给了在weblogic server里配置的'identity provider'。 OPSS不是一个产品,它是Fusion Middleware使用的一组安全服务。 这个帖子十分详细地讲述了如何配置weblogic server domain使用以上的三种不同security store。这也是"reassociation(关联)"这个词的来历。 下面的内容和 “Configuring OPSS Security Store”(强烈推荐阅读)有些重叠。


 在更进一步讲述association之前,我们先说说jps-config.xml的关键点。

jps-config.xml
OPSS使用这个文件描述它所提供的服务。通过设置系统属性–Doracle.security.jps.config你可以指定OPSS从哪里读取这个文件,通常在JRF(Java Required Files)domain的setDomainEnv.sh里设置这个文件的位置。
缺省的位置是${DOMAIN_HOME}/config/fmwconfig/jps-config.xml。(定义在变量EXTRA_JAVA_PROPERTIES里)。建议不要轻易修改jps-config.xml,因为jps-config.xml包含了许多对其它文件的引用。 当以通过config.sh脚本来创建BPM,SOA或者WebCenter 域(domain)时,JRF template会自动被选中,因为这些鱼都依赖JRF。 jps-config.xml是作用于域范围的配置文件。并不存在针对server或者application这一层起作用的jps-config.xml文件。但是,jps-config.xml里context的概念,可以让你让不同的application使用不同的安全服务。这是另外一个话题了。 当执行了reassociation操作,配置的改变会被写入jps-config.xml。破损的jps-config.xml会让你的domain运行在不稳定的状态。所以,对jps-config.xml的修改要慎之又慎。不要手工修改这个文件,而是要用Enterprise Manager或者wlst。

  The Policy Store Policy store保存着Fusion Middleware实例上运行的application的所需要的全部安全策略,包括赋予pricials(users,groups, application roles)以及code 的允许权限。 比如,如果你查看BPM域上OOTB的policy store,你就会发现这些策略分成四组,供4个应用 (OracleBPMProcessRolesApp, OracleBPMComposerRolesApp, b2bui and soainfra)使用。另外还有一组对部署在这个域的所有应用都生效的code-source策略。 jps-config.xml文件里的default context定义了Fusion Middleware里所有应用都用到的服务。

The Credential Store Credential store保存着Fusion Middleware应用连接到其它系统所用的凭证。这不同于下面要讲到的boostrap credentials。 File Based Credential Store Service Instance 

Reassociating to OID 有两种方式做reassociation。 Enterprise Manager和wlst。(只大致介绍一下关键参数的含义,具体见原文。)
EM界面里的: Root DN: 这个需要再做reassociation之前在OID里创建。 Create New Domain: 这里不是表示“创建一个新域”的意思。这里的意识是说,要关联的OID是不是要要从源security store导入数据进行初始化。不选择这个checkbox意味着,你有多个domain共享这个security store。 Domain Name: 这里方便起见,EM使用weblogic域名。但实际上,它可以是任意名字。这个名字用于标识它为一个container节点。多个weblogic域可以绑定到相同的container,但是,一个weblogic域不能绑订到不同的container。

wlst里的参数: > reassociateSecurityStore(domain="farm1", admin="cn=orcladmin", password="welcome1", ldapurl=ldap://localhost:3060, servertype="OID", jpsroot="cn=SecurityStore",[join=”trueOrfalse”]) 理解了EM的输入,wlst就容易理解了。join这个参数,对应着EM里的是否'Create new domain'。

Bootstrap cwallet.sso 
当reassociated到OID时,weblogic需要知道连接到OID服务器的登录凭证。缺省地,这些凭证被保存在jps-config.xml bootstrap.credstore指定的位置。 如果以后需要修改这个credentials,可以使用以下wlst命令: > modifyBootStrapCredential(jpsConfigFile='',username='', password='') 这里 jpsConfigFile = 有效的jps config文件路径。 username = 用户名 password = 新密码 比如 > modifyBootStrapCredential(jpsConfigFile='/opt/wls/oracle/middleware/user_projects/domains/soa_domain/config/fmwconfig/jps-config.xml',username='cn=orcladmin', password='welcome1')