Saturday, May 02, 2009

Using Regular Expression to Parse the authz File

The Original authz file

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

[groups]
Sales = wlin,jshi,zbai
Quality = wqiu,she,wzhang,juguo,lchen,chunmchen

[/]
* = rw
# This account will be used for the svn web client
svnwebclient = r

[/Sales]
@Sales = rw
* = r

[/Quality]
@Quality = rw
* = r

# This is the Sales' private folder
[/Sales/Private]
@Sales = rw
* =

# This is the Quality's private folder
[/Quality/Private]
@Quality = rw
* =


Using Regular Expression to Parse the authz File


    public Authz() {
        try {
            InputStream stream = getClass().getResourceAsStream("authz");
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

            StringBuilder authz = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                authz.append(line);
                authz.append(Constant.ENTER_SIGN);
            }

            // begins with [ and ends with ]
            String regex = "^\\[([^\\[]*)\\]$";
            String input = authz.toString();

            Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
            Matcher matcher = pattern.matcher(input);

            int location = 0;
            boolean found = false;
            // add global comments of the authz file
            if (matcher.find()) {
                System.out.println(authz.substring(location, matcher.start()));
                location = matcher.start();
                found = true;
            }
            // add each segment
            String segment = null;
            while (matcher.find()) {
                segment = authz.substring(location, matcher.start());
                location = matcher.start();
                System.out.print(segment);
                System.out.println("segment:" + matcher.group(1));               
            }
            // then last segment
            if (found) {
                segment = authz.substring(location);
                System.out.print(segment);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



Below is the output:

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').


[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

segment:groups
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

segment:groups
[groups]
Sales = wlin,jshi,zbai
Quality = wqiu,she,wzhang,juguo,lchen,chunmchen

segment:/
[/]
* = rw
# This account will be used for the svn web client
svnwebclient = r

segment:/Sales
[/Sales]
@Sales = rw
* = r

segment:/Quality
[/Quality]
@Quality = rw
* = r

# This is the Sales' private folder
segment:/Sales/Private
[/Sales/Private]
@Sales = rw
* =

# This is the Quality's private folder
segment:/Quality/Private
[/Quality/Private]
@Quality = rw
* =

Using JSP/Servlet/Filter to Implement Login Authorization

login.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ include file="/common/taglibs.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/common/meta.jsp"%>
<title>Login - <m:message key="webapp.title" /></title>
<link rel="stylesheet" type="text/css" href="<c:url value='/styles/login.css'/>" />
<script type="text/javascript" src="<c:url value='/scripts/login.js'/>"></script>
</head>
<body>
<%@ include file="/common/header.jsp"%>
<div id="login">
<%@ include file="/common/status.jsp"%>
<div id="loginContent">
<form action="<c:url value='/login.do'></c:url>" method="post" onsubmit="return check()">
<div><input type="hidden" name="uri" value="${uri}" /></div>
<div><input type="hidden" name="repos" value="${repos}" /></div>
<div><m:message key="login.username" /><input type="text" class="commonInput" name="username" value="${username}" /></div>
<div><m:message key="login.password" /><input type="password" class="passwordInput" name="password" value="${password}" /></div>
<div id="submit"><input type="submit" class="buttonInput" value="<m:message key="button.login" />" /></div>
</form>
</div>
</div>
<%@ include file="/common/footer.jsp"%>
</body>
</html>



LoginServlet.java

package sa.cdc.svn.web.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sa.cdc.svn.Constant;
import sa.cdc.svn.model.security.Certificate;
import sa.cdc.svn.service.server.ServerManager;
import sa.cdc.svn.web.BaseServlet;

public class LoginServlet extends BaseServlet {
    private static final long serialVersionUID = 8871588625655468698L;

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String loginPage = "/WEB-INF/pages/login.jsp";
        Certificate certificate = null;

        // redirect to this page after login
        String uri = request.getParameter("uri");
        uri = (uri == null) ? "/home.do" : uri;
       
        request.setAttribute("uriClick", uri);
       
        String repos = request.getParameter("repos");
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        String ip = request.getRemoteAddr();

        // first try to use current certificate
        certificate = (Certificate) request.getSession().getAttribute(Constant.SESSION_CERTIFICATE);
        if (certificate == null) {
            if ((repos == null || repos.length() == 0) && isReposOperation(uri)) {
                // repository can't be empty
                request.setAttribute("uri", uri);
                request.setAttribute(Constant.STATUS, Constant.STATUS_ERROR);
                request.setAttribute(Constant.MESSAGE, "Please select a repository to login.");
                request.getRequestDispatcher("/home.do").forward(request, response);
            } else if (username == null || password == null) {
                // username or password can't be null
                request.setAttribute("uri", uri);
                request.setAttribute("repos", repos);
                request.getRequestDispatcher(loginPage).forward(request, response);
            } else if (username.length() == 0 || password.length() == 0) {
                // username or password can't be empty
                request.setAttribute("uri", uri);
                request.setAttribute("repos", repos);
                request.setAttribute(Constant.STATUS, Constant.STATUS_ERROR);
                request.setAttribute(Constant.MESSAGE, "Please input username and password.");
                request.getRequestDispatcher(loginPage).forward(request, response);
            } else {
                // go into authentication
                ServerManager serverManager = new ServerManager(repos);
                certificate = serverManager.validateUser(username, password);
                if (certificate != null) {
                    // succeeded to login
                    request.getSession().setAttribute(Constant.SESSION_CERTIFICATE, certificate);
                    request.setAttribute(Constant.STATUS, Constant.STATUS_OK);
                    response.sendRedirect(request.getContextPath() + uri);
                    logInfo(request, "Login from [" + ip + "]");
                } else {
                    // failed to login
                    request.setAttribute("uri", uri);
                    request.setAttribute("repos", repos);
                    request.setAttribute(Constant.STATUS, Constant.STATUS_WARNING);
                    request.setAttribute(Constant.MESSAGE, "Username or password is invalid.");
                    request.getRequestDispatcher(loginPage).forward(request, response);
                }
            }
        } else {
            ServerManager serverManager = new ServerManager(repos);
            username = certificate.getUsername();
            password = certificate.getPassword();
            certificate = serverManager.validateUser(username, password);
            if (certificate != null) {
                // succeeded to login
                request.getSession().setAttribute(Constant.SESSION_CERTIFICATE, certificate);
                //logInfo(request, "login from [" + ip + "]");
                request.setAttribute(Constant.STATUS, Constant.STATUS_OK);
                response.sendRedirect(request.getContextPath() + uri);
            } else {
                // failed to login
                // remove the current invalid certificate
                request.getSession().removeAttribute(Constant.SESSION_CERTIFICATE);
                request.setAttribute("uri", uri);
                request.setAttribute("repos", repos);
                request.setAttribute(Constant.STATUS, Constant.STATUS_WARNING);
                request.setAttribute(Constant.MESSAGE, "Username or password is invalid.");
                request.getRequestDispatcher(loginPage).forward(request, response);
            }
        }
    }

    private boolean isReposOperation(String uri) {
        return (uri.equals("/authz.do") || uri.equals("/group.do") || uri.equals("/alias.do") || uri
                .equals("/account.do"));
    }

}



LogoutServlet.java

package sa.cdc.svn.web.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sa.cdc.svn.web.BaseServlet;

public class LogoutServlet extends BaseServlet {
    private static final long serialVersionUID = 9069229823236250773L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String ip = request.getRemoteAddr();
        logInfo(request, "Logout from [" + ip + "]");
        request.getSession().invalidate();
        response.sendRedirect(request.getContextPath() + "/home.do");
       
    }
}



AccessControlFilter.java

package sa.cdc.svn.web.security;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import sa.cdc.svn.Constant;
import sa.cdc.svn.model.security.Certificate;

public class AccessControlFilter implements Filter {

    @Override
    public void destroy() {
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;

        String uri = httpRequest.getRequestURI();
        uri = uri.substring(uri.indexOf('/', 1));
        request.setAttribute("uriClick", uri);
        // no need to filter login.do
        if (uri.equals("/login.do") || uri.equals("/home.do") || uri.equals("/logout.do")
                || uri.equals("/search.do")) {
           
            chain.doFilter(request, response);
            return;
        }
       
        HttpSession session = httpRequest.getSession();
        Certificate certificate = (Certificate) session.getAttribute(Constant.SESSION_CERTIFICATE);
        if (certificate != null) {
            // validate user if have permission
            boolean permitted = false;
            if (uri.equals("/authz.do"))
                permitted = certificate.hasRole(Constant.ROLE_CONTROLLER);
            else if (uri.equals("/group.do"))
                permitted = certificate.hasRole(Constant.ROLE_CONTROLLER);
            else if (uri.equals("/alias.do"))
                permitted = certificate.hasRole(Constant.ROLE_CONTROLLER);
            else if (uri.equals("/account.do"))
                permitted = certificate.hasRole(Constant.ROLE_CONTROLLER);
            else if (uri.equals("/davsvn.do"))
                permitted = certificate.hasRole(Constant.ROLE_ADMINISTRATOR);
            else if (uri.equals("/admin.do"))
                permitted = certificate.hasRole(Constant.ROLE_ADMINISTRATOR);
            else if (uri.equals("/webclient.do"))
                permitted = certificate.hasRole(Constant.ROLE_ADMINISTRATOR);
            if (permitted) {
                // transfer to next filter
                chain.doFilter(request, response);
            } else {
                // redirect to deny page
                request.setAttribute(Constant.STATUS, Constant.STATUS_WARNING);
                request.setAttribute(Constant.MESSAGE, "Have no permission to access " + uri + ".");
                request.getRequestDispatcher("/WEB-INF/pages/deny.jsp").forward(request, response);
            }
        } else {
            // go to login to get a certificate, forward to this uri after login
            httpResponse.sendRedirect(httpRequest.getContextPath() + "/login.do?uri=" + uri);
        }
    }
}



meta.jsp

<!-- Prevents caching at the Proxy Server -->
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="icon" href="<c:url value='/images/favicon.ico'/>" type="image/x-icon" />
<link rel="shortcut icon" href="<c:url value='/images/favicon.ico'/>" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="<c:url value='/styles/global.css'/>" />
<script type="text/javascript" src="<c:url value='/scripts/global.js'/>"></script>



taglib.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="m"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="n"%>



Status.jsp

<%@ include file="/common/taglibs.jsp"%>
<div id="status">
  <span style="background:url(<c:url value='/images/${status}.gif'/>) no-repeat;">
     <c:out value="${message}" />
  </span>
</div>

Friday, May 01, 2009

Install Solaris10 u3 sparc on Fujitsu PRIMEPOWER450

关键字

Fujitsu、Solaris、Sparc

操作环境

Fujitsu PRIMEPOWER450 2x SPARC64 V
Solaris 10 u3 sparc

IP: 61.144.43.227
Netmask: 61.144.43.224 255.255.255.240

综合知识

参考资料
Solaris 10 11/06 Installation Guide: Basic Installations
http://docs.sun.com/app/docs/doc/819-6394

下载文件(PC机)
CD: http://www.sun.com/download/sdl.jsp?5005588c-36f3-11d6-9cec-fc96f718e113=1
DVD: http://www.sun.com/download/sdl.jsp?5005588c-36f3-11d6-9cec-fc96f718e113=1
sol-10-u3-ga-sparc-dvd-iso-a.zip
sol-10-u3-ga-sparc-dvd-iso-b.zip
sol-10-u3-ga-sparc-dvd-iso-c.zip
sol-10-u3-ga-sparc-dvd-iso-d.zip
sol-10-u3-ga-sparc-dvd-iso-e.zip
sol-10-u3-companion-ga-iso.zip
sol-10-u3-ga-sparc-v1-iso.zip
md5sum-sparc.list.txt


任务介绍
在小型机上安装Solaris 10 sparc,双CPU,双网卡,三硬盘,完全安装。
原则1:推荐在安装界面配置好网卡的所有参数。

开始安装

制作安装文件

将sol-10-u3-ga-sparc-v1-iso.zip解压后刻录成安装光盘。

将下面五个文件解压:
sol-10-u3-ga-sparc-dvd-iso-a.zip
sol-10-u3-ga-sparc-dvd-iso-b.zip
sol-10-u3-ga-sparc-dvd-iso-c.zip
sol-10-u3-ga-sparc-dvd-iso-d.zip
sol-10-u3-ga-sparc-dvd-iso-e.zip

然后执行如下命令:
copy /b sol-10-u3-ga-sparc-dvd-iso-a + sol-10-u3-ga-sparc-dvd-iso-b + sol-10-u3-ga-sparc-dvd-iso-c + sol-10-u3-ga-sparc-dvd-iso-d + sol-10-u3-ga-sparc-dvd-iso-e sol-10-u3-ga-sparc-dvd.iso

得到DVD镜像:sol-10-u3-ga-sparc-dvd.iso

将sol-10-u3-ga-sparc-dvd.iso放在第2个硬盘/dev/dsk/c1t0d0s0上

正式开始安装

用安装光盘引导进入安装界面,选择Solaris Interactive安装方式。
Network Connectivity: Networked
Please select the interfaces you want to configure: hme0
Use DHCP for hme0: No
Host Name for hme0: jwcdb
IP Address for hme0: 61.144.43.227
Netmask for hme0: 255.255.255.240
Enable IPv6 for hme0: No
Set the Default Route for hme0: Specify one
Route IP Address for hme0: 61.144.43.234
Enable Kerberos: No
Name Services: DNS
Domain Name: pyp.edu.cn
Server's IP Address:
202.96.134.133
61.144.56.101
DNS Search List:
pyp.edu.cn
Accept
Select Software Localizations: Asia->Chinese(zh)
Select System Locale: English(POSIX)(C)
Package:Entire
Solaris: 44996

中间要选择启动相关网络服务,否则无法XManager登录。

预安装后重启。

下面加载DVD安装盘:
? mkdir /main
? mkdir /mnt/iso
? mount -F ufs /dev/dsk/c1t0d0s0 /main
? lofiadm -a /main/solaris10u3/sol-10-u3-ga-sparc-dvd.iso
? mount -F hsfs -o ro /dev/lofi/1 /mnt/iso

安装后期路过语言安装,因为已包含在前面的安装中。


初始设置:

允许root进行ssh登录:
? vi /etc/ssh/sshd_config
PermitRootLogin yes
svcadm restart network/ssh

将root的shell类型改为bash:
? vi /etc/passwd
root:x:0:0:Super-User:/:/usr/bin/bash

设置bash提示符为“? ”:
? vi /etc/profile
# Add by litchi
PATH=/usr/bin:/usr/sbin:/usr/sadm/bin:/usr/sfw/bin:/usr/ucb:/etc:.
PS1='? '

在登录时显示系统指定的消息:
? more /etc/motd
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
*************************************************************
*** Jiaowu Education System Provided by PanYu Polytechinc ***
*************************************************************

禁用Telnet
禁用Telnet:
? inetadm | grep telnet
enabled online svc:/network/telnet:default
? inetadm -d telnet


创建用户:

FTP欢迎信息:
修改FTP欢迎信息:
? vi /etc/ftpd/welcome.msg
"/etc/ftpd/welcome.msg" 1 line, 55 characters
Welcome to Jiaowu System Provided by Panyu Polytechnic

加快启动时间的修改:
# vi /boot/solaris/strap.rc
Options timeout=3^M
默认为10,现设为3

# vi /etc/bootrc
set boot_timeout 0
默认为5,现设为0

# vi /boot/solaris/bootenv.rc
setprop auto-boot-timeout 0
默认为5,现设为0

Install Soaris 10 u1 x86 on PC

任务介绍

在普通台式机上安装Solaris 10 x86,双网卡,双硬盘,完全安装。
原则1:推荐在安装界面配置好网卡的所有参数。

开始安装

将Solaris 10 Disk 1刻录成安装光盘,
将Solaris 10 DVD镜像文件和Language镜像文件放在第2个逻辑分区上,
在DOS下或Windows下准备一个未分配的主分区。
用安装光盘引导进入安装界面,选择Solaris Interactive安装方式。
Network Connectivity: Networked
Please select the interfaces you want to configure: rtls0
Use DHCP for rtls0: No
Host Name for rtls0: outer
IP Address for rtls0: 192.168.224.251
Netmask for rtls0: 255.255.255.0
Enable IPv6 for rtls0: No
Set the Default Route for rtls0: Specify one
Route IP Address for rtls0: 192.168.224.1
Enable Kerberos: No
Name Services: DNS
Domain Name: c204.com
Server's IP Address:
202.96.134.133
202.96.128.68
DNS Search List:
c204.com
Accept
Select Software Localizations: Asia->Chinese(zh)
Select System Locale: English(POSIX)(C)
Package:Entire
Solaris: 44996

预安装后重启。

下面加载DVD安装盘:
? mkdir /mnt/saved
? mkdir /mnt/iso
? mount -F pcfs /dev/dsk/c0d0p3:2 /mnt/saved
? lofiadm -a /mnt/saved/Solaris/sol-10-GA-x86-dvd-iso.iso
? mount -F hsfs -o ro /dev/lofi/1 /mnt/iso

下面加载Language安装盘:
? umount /mnt/iso
? lofiadm -d /dev/lofi/1
? lofiadm -a /mnt/saved/Solaris/sol-10-lang-GA-x86-iso.iso
? mount -F hsfs -o ro /dev/lofi/1 /mnt/iso

初始设置:
允许root进行ssh登录:
? vi /etc/ssh/sshd_config
PermitRootLogin yes
svcadm restart network/ssh

将root的shell类型改为bash:
? vi /etc/passwd
root:x:0:0:Super-User:/:/usr/bin/bash

设置bash提示符为“? ”:
? vi /etc/profile
# Add by litchi
PATH=/usr/bin:/usr/sbin:/usr/sadm/bin:/usr/sfw/bin:/usr/ucb:/etc:.
PS1='? '

在登录时显示系统指定的消息:
# more /etc/motd
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
*************************************************************
* Provided By Litchi chenliqun@pyp.edu.cn PanYu Polytechinc *
*************************************************************

加快启动时间的修改:
# vi /boot/solaris/strap.rc
Options timeout=3^M
默认为10,现设为3

# vi /etc/bootrc
set boot_timeout 0
默认为5,现设为0

# vi /boot/solaris/bootenv.rc
setprop auto-boot-timeout 0
默认为5,现设为0

Install Oracle 10g Release 2 on Solaris 10 u3 sparc

关键字

Solaris、Oracle、Sparc

操作环境

Fujitsu PRIMEPOWER450 2x SPARC64 V
Solaris 10 u3 sparc
Oracle 10g Release 2

综合知识

参考资料
安装帮助:B19306-01.zip内:
B19306_01\install.102\b15690\toc.htm
Sun ISV:http://isv.sun.com.cn/techdocs/0604/Solaris10_oracle.jsp

下载文件(PC机)
doc: http://www.oracle.com/technology/documentation/database10gr2.html
data: http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10201sol64soft.html
B19306-01.zip
10gr2_db_sol.cpio.gz

准备安装文件

解压:
10gr2_db_sol.cpio.gz

上传到服务器:
10gr2_db_sol.cpio

提取:
? cpio -idmv < 10gr2_db_sol.cpio


检查系统环境

用root登录服务器

查看系统版本(要求5.10 64-bit sparcv9)
? uname -a
SunOS jwcdb 5.10 Generic_118833-33 sun4us sparc FJSV,GPUZC-M
? isainfo -kv
64-bit sparcv9 kernel modules

查看物理内存(要求1024MB以上)
? /usr/sbin/prtconf | grep "Memory size"
Memory size: 4096 Megabytes

查看交换文件(视内存情况)
? /usr/sbin/swap -lh
swapfile dev swaplo blocks free
/dev/dsk/c0t0d0s1 32,129 16 12286064 12286064

临时文件空间(要求400M以上)
? df -h /tmp
Filesystem size used avail capacity Mounted on
swap 7.4G 88K 7.4G 1% /tmp


查看硬盘空间(要求2G以上)
? df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c0t0d0s0 12G 3.7G 7.7G 33% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 7.4G 1.1M 7.4G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
fd 0K 0K 0K 0% /dev/fd
swap 7.4G 88K 7.4G 1% /tmp
swap 7.4G 64K 7.4G 1% /var/run
/dev/dsk/c1t1d0s6 67G 2.9G 64G 5% /data -for oracle data
/dev/dsk/c1t0d0s0 67G 11G 55G 17% /main -for oracle software
/dev/dsk/c0t0d0s7 50G 2.7G 47G 6% /export/home

查看以下软件包是否存在
? pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibm SUNWlibms SUNWsprot \
> SUNWsprox SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt
system SUNWarc Lint Libraries (usr)
system SUNWbtool CCS tools bundled with SunOS
system SUNWhea SunOS Header Files
system SUNWi1of ISO-8859-1 (Latin-1) Optional Fonts
system SUNWlibm Math & Microtasking Library Headers & Lint Files (Usr)
system SUNWlibms Math & Microtasking Libraries (Usr)
system SUNWsprot Solaris Bundled tools
system SUNWtoo Programming Tools
system SUNWxwfnt X Window System platform required fonts
ERROR: information for "SUNWi1cs" was not found
ERROR: information for "SUNWi15cs" was not found
ERROR: information for "SUNWsprox" was not found

这里需要安装两个包:SUNWi1cs和SUNWi15cs

加载DVD安装镜像:
? lofiadm -a /main/solaris10u3/sol-10-u3-ga-sparc-dvd.iso
/dev/lofi/1
? mount -F hsfs -o ro /dev/lofi/1 /mnt/iso

安装这两个包
? pkgadd -d /mnt/iso/Solaris_10/Product/ SUNWi1cs
? pkgadd -d /mnt/iso/Solaris_10/Product/ SUNWi15cs

由10版本已将SUNWsprox合并到SUNWsprot,所以不必该程序包了。

卸载加载的文件
? umount /mnt/iso/
? lofiadm -d /dev/lofi/1

由于使用的Solaris 10 u3比较新,就不打补丁了。


检查网络配置

确保files出现在hosts行:
? cat /etc/nsswitch.conf | grep hosts
# DNS for hosts lookups, otherwise it does not use any other naming service.
# "hosts:" and "services:" in this file are used only if the
hosts: files dns
# before searching the hosts databases.

主机名:
? hostname
jwcdb

域名(不应该有任何值):
? domainname

查看是否使用了全限定主机名:
? cat /etc/hosts | grep 'jwcdb'
61.144.43.227 jwcdb jwcdb.pyp.edu.cn loghost


创建用户和组

创建Oracle Inventory组

如果已安装Oracle,可以查看到如下输出:
? more /var/opt/oracle/oraInst.loc
inventory_loc=/main/oracle/oraInventory
inst_group=oinstall

如果需要,创建oinstall组:
? groupadd oinstall

创建OSDBA组

? groupadd dba

如果OSOPER组

? groupadd oper

创建oracle用户:

查看是否存在oracle用户
? id -a oracle

创建
? useradd -g oinstall -G dba,oper -d /export/home/oracle -s /usr/bin/bash -c 'Oracle Software Owner' -m oracle

设置密码
? passwd -r files oracle

保证nobody用户存在:
? id -a nobody
uid=60001(nobody) gid=60001(nobody) groups=60001(nobody)


配置系统参数

? vi /etc/system
set noexec_user_stack=1

查看有没有为oracle创建资源项目:
? vi /etc/project | grep oracle

如果没有,如下创建:
? projadd -U oracle -c "oracle database" user.oracle
? projmod -sK "roject.max-shm-memory=(priv,10G,deny)" user.oracle

切换到Oracle检查一下:
% prctl -n project.max-shm-memory -i project user.oracle


创建所需目录

程序目录
? mkdir -p /main/oracle
? chown -R oracle:oinstall /main/oracle
? chmod -R 775 /main/oracle

数据目录
? mkdir -p /data/oracle
? chown -R oracle:oinstall /data/oracle
? chmod -R 775 /data/oracle

备份目录
? mkdir -p /main/oracle/flash_recovery_area
? chown -R oracle:oinstall /main/oracle/flash_recovery_area
? chmod -R 775 /main/oracle/flash_recovery_area

配置环境参数

用oracle登录
? su - oracle

设置环境参数
? vi .profile
umask 022
ORACLE_BASE=/main/oracle
ORACLE_SID=ORCL
export ORACLE_BASE ORACLE_SID

重新登录查看
% umask
0022
% env | more
-bash-3.00$ env | more
......
ORACLE_SID=ORCL
ORACLE_BASE=/main/oracle
......


重启系统
? reboot

开始安装过程

确保系统可以运行图形界面或可以远程运行图形界面,在此使用的远程桌面是X Manager 2.0
打开XBrowser,输入服务器的IP地址即可连上。

用oracle用户登录

运行database目录下的runInstaller

Select Installation Method
Advanced Installation

Specify Inventory directory and credentials
/opt/oracle/oraInventory
oinstall

Select Installation Type
Enterprise Edition

Sepcify Home Details
Name: OraDb10g_home1
Path: /main/oracle/oracle/product/10.2.0/db_1

Product-Specific Prerequisite Checks
全部通过即可!

Select Configuration Option
Create a database

Select Database Configuration
General Purpose

Specify Database Configuration Options
Global Database Name:cdtdb SID:ORCL
Select Database Character set: Simplified Chinese ZHS16GBK
选中Create database with sample schemas

Select Database Management Option
选中Use Database Control for Database Management
Enable Email Notification
61.144.43.235
sunkist@pyp.edu.cn

Specify Database Storage Option
选中File System
location:/main/oracle/oradata

Specify Backup and Recovery Options
选中Automated backups
location:/main/oracle/flash_recovery_area

Specify Database Schema Passwords
统一使用一个密码:***

Summary

Execute Configuration Scripts
按照提示,用root用户运行脚本

安装完成!

数据库实例安装日志:
/main/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/dbca/ORCL

iSQL*Plus URL:
http://jwcdb:5560/isqlplus

iSQL*Plus DBA URL:
http://jwcdb:5560/isqlplus/dba

Enterprise Manager 10g Database Control URL:
http://jwcdb:1158/em
用sys用户以sysdba身份登录

完成服务配置

用oracle登录
? su - oracle

修改配置文件
% vi .profile
# This is the default standard profile provided to a user.
# They are expected to edit it to meet their own needs.

MAIL=/usr/mail/${LOGNAME:?}
PS1='% '
umask 022
ORACLE_BASE=/main/oracle
export ORACLE_BASE
ORACLE_SID=ORCL
export ORACLE_SID
ORACLE_HOME=$ORACLE_BASE/oracle/product/10.2.0/db_1
export ORACLE_HOME
NLS_LANG="simplified chinese"_china.zhs16gbk --如果想使用英文,注释掉此行
export NLS_LANG
PATH=/usr/bin:/usr/sbin:$ORACLE_HOME/bin:/usr/sadm/bin:/usr/sfw/bin:/usr/ucb:/etc:.
export PATH

执行脚本:
% sqlplus "/ AS SYSDBA"
SQL> @?/rdbms/admin/utlrp.sql

开机自动运行

正确配置数据库实例入口
% vi /var/opt/oracle/oratab
ORCL:/main/oracle/oracle/product/10.2.0/db_1:Y

修正dbstart脚本:
% vi /main/oracle/oracle/product/10.2.0/db_1/bin/dbstart

将 ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
改为 ORACLE_HOME_LISTNER=$ORACLE_HOME

将 ORATAB=/etc/oratab
改为 ORATAB=/var/opt/oracle/oratab

创建自动运行脚本
% vi /etc/init.d/oracle
"/etc/init.d/oracle" 24 lines, 911 characters
#!/bin/sh
ORA_HOME=/main/oracle/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start') # Start the Oracle databases and listeners
echo "Start Oracle Database 10g Release 2"
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl start"
;;
'stop') # Stop the Oracle databases and listeners
echo "Stop Oracle Database 10g Release 2"
su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl stop"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
;;
esac

建立符号连接
? ln -s /etc/init.d/oracle /etc/rc2.d/S99oracle
? ln -s /etc/init.d/oracle /etc/rc0.d/K10oracle