目前分類:Linux - BASIC (6)

瀏覽方式: 標題列表 簡短摘要

在 Oracle 的開發工具 JDeveloper 11g/12c 中除了支援 SVN Server ( Subversion ) 外,也支援 git ,但測試了 git 目前在繁體中文的 Windows 平台上支援並不好,不過摸了幾天,還是記錄一下配置心得。

環境:

1. git server 1.7.x on Oracle Linux 6.5

2. gitweb 1.7 on apache 2.x

3. git clinet on windows 8 downloadGit-1.8.5.2-preview20131230.exe

 一、安裝 git server

git_package.png  

# rpm -qa | grep git
gitweb-1.7.1-3.el6_4.1.noarch
git-1.7.1-3.el6_4.1.x86_64

二、設定 git repository:project.git 在 /opt/git_root 目錄下

# pwd
/opt/git_root
# mkdir project.git
# cd project.git/
# git init --bare
Initialized empty Git repository in /opt/git_root/project.git/

註:可以修改 /opt/git_root/project.git/description 來說明此專案目的

# vi description
git Version Control Project

三、設定 repository:project.git 權限給 AD 的 Domain Users 有權限存放資料,參考:AD Account Login Linux Server (oracle linux 與 Windows AD 帳號認證整合)

# ls -al
total 40
drwxr-xr-x. 7 root root 4096 Jan 21 12:05 .
drwxr-xr-x. 3 root root 4096 Jan 21 11:35 ..
drwxr-xr-x. 2 root root 4096 Jan 21 11:35 branches
-rw-r--r--. 1 root root  150 Jan 21 12:04 config
-rw-r--r--. 1 root root   73 Jan 21 11:35 description
-rw-r--r--. 1 root root   23 Jan 21 11:35 HEAD
drwxr-xr-x. 2 root root 4096 Jan 21 11:35 hooks
drwxr-xr-x. 2 root root 4096 Jan 21 11:35 info
drwxr-xr-x. 7 root root 4096 Jan 21 11:49 objects
drwxr-xr-x. 4 root root 4096 Jan 21 11:35 refs

# chown -R root."WEI\Domain Users" refs/
# chown -R root."WEI\Domain Users" objects/
# chmod 775 -R refs/
# chmod 775 -R objects/

四、設定 gitweb:gitweb 預設安裝到了/var/www/git 下,其設定檔在 /etc/gitweb.conf ,另外,httpd 的設定檔為 /etc/httpd/conf.d/git.conf。

1) 修改 /etc/gitweb.conf

# vi /etc/gitweb.conf
our $projectroot = "/var/www/git";

2) 修改 /etc/httpd/conf.d/git.conf

# vi /etc/httpd/conf.d/git.conf
Alias /git /var/www/git
<Directory /var/www/git>
        Allow from all
        AllowOverride all
        Order allow,deny
        Options +ExecCGI
        AddHandler cgi-script .cgi
        DirectoryIndex gitweb.cgi
        SetEnv GITWEB_CONFIG /etc/gitweb.conf
        Dav On
        RewriteEngine Off
</Directory>

3) 重啟 apache server
# service httpd restart

4) 將 Git repository in /opt/git_root/project.git 連結到 /var/www/git 下

# ln -s /opt/git_root/project.git /var/www/git

5) 在 windows 平台用流覽器查看

gitweb_viewProject.png  
 六、測試

1) 在 windows 平台上安裝 Git-1.8.5.2-preview20131230.exe ,並將目錄 C:\Program Files (x86)\Git\cmd 加入 Windows 環境變數的 PATH  中

2) 在 windows 平台上將 Linux 主機上 git repository:project.git  clone 到 D:\git_repo 目錄下,並設定 D:\git_repo\project.git 資料夾為 UTF-8 編碼

D:\git_repo>git clone polin.wei@oradb12clinux:/opt/git_root/project.git
Cloning into 'project'...
polin.wei@oradb12clinux's password:
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

設定 D:\git_repo 目錄編碼為 utf-8:
    在 D:\git_repo\project.git 資料夾上,以滑鼠右鍵點選 Git Gui。
    按「Edit」,再點選「Option」。
    將 Global (All Repositories) 的「Default File Contents Encoding」改變為「utf-8」後,按「Save」。

3) 建立一份文字檔 readme.txt,內容為 "這是第一份文件"

D:\git_repo>cd project
D:\git_repo\project>notepad readme.txt
D:\git_repo\project>type readme.txt
這是第一份文件

4) commint 文件內容

D:\git_repo\project>git commit (這說明應該是:git 測試,但它變成了 git 晴)

git_vim_windows_commit.png  
[master (root-commit) 9ccc88e] git 晴
 1 file changed, 1 insertion(+)
 create mode 100644 readme.txt

Warning: Your console font probably doesn't support Unicode. If you experience s
trange characters in the output, consider switching to a TrueType font such as L
ucida Console!

5) 將文件上載到 git server on linux

D:\git_repo\project>git push origin master
polin.wei@oradb12clinux's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 232 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To polin.wei@oradb12clinux:/opt/git_root/project.git
 * [new branch]      master -> master

6) 使用 git gui 工具上傳,操作順序為:
  a. Rescan 查看有沒有文件被修改
  b. Stage Changed 設定文件內容為已被修改
  c. Commit 文件內容確認
  d. Push 到 Linux 主機上 git repository:project.git

git_gui_modify.png  

7) 再一次在 windows 平台用流覽器查看

gitweb_view_summary.png  

 

參考:

http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server

http://blog.xuite.net/yctseng/notes/35220134-gitweb

http://phpbb-tw.net/phpbb/viewtopic.php?t=53959

http://www.linuxso.com/linuxrumen/40000.html

http://www.linuxso.com/linuxrumen/40005.html

MIS 發表在 痞客邦 留言(0) 人氣()

程式碼的版本控制除了之前介紹的 CVS Server in Linux & Jdeveloper OAF in Window 開發環境的整合設定 ,還有功能較為強大的 SVN Server ( Subversion ),相信這兩個程式版本控制服務應該可以符合大部份開發人員對於版本控制的要求了。若是想架設在 Windows 平台的話,可以參考 Apache/2.0.59 (Win32) 與 SVN/1.4.3 的安裝 & Apache/2.0.59 (Win32) 與 SVN/1.4.3 對 AD 的認證  。

環境:

Oracle Linux:Oracle Linux Release 6 Update 5 for x86_64 (64 Bit)
    host: oradb12clinux
    ip: 192.168.3.50

SVN Server ( Subversion ):subversion-svn2cl-1.6.11-9.el6_4.noarch

Apache Server:1.6.11-9:httpd-2.2.15-26.0.1.el6.x86_64

認證套件:mod_dav_svn-1.6.11-9.el6_4.x86_64

Windows AD:Windows Server 2003    host: adserver.wei.com
    ip: 192.168.2.1

 Windows Client :TortoiseSVN

一、安裝相關套件

 svn_package  

# rpm -qa | grep httpd
httpd-tools-2.2.15-26.0.1.el6.x86_64
httpd-2.2.15-26.0.1.el6.x86_64
httpd-manual-2.2.15-26.0.1.el6.noarch

# rpm -qa | grep svn
mod_dav_svn-1.6.11-9.el6_4.x86_64
git-svn-1.7.1-3.el6_4.1.noarch
ltrace-0.5-23.45svn.el6.x86_64
subversion-svn2cl-1.6.11-9.el6_4.noarch

二、建立 SVN Server ( Subversion ) 的 repository 與權限設定

1) 執行 # svnadmin create /opt/svn_root/ebs_source , 這是為了要建立 SVN Server 的 repository

# svnadmin create /opt/svn_root/ebs_source
# ls -al ebs_source/
total 32
drwxr-xr-x. 6 root root 4096 Jan 17 11:08 .
drwxr-xr-x. 3 root root 4096 Jan 17 11:08 ..
drwxr-xr-x. 2 root root 4096 Jan 17 11:08 conf
drwxr-sr-x. 6 root root 4096 Jan 17 11:08 db
-r--r--r--. 1 root root    2 Jan 17 11:08 format
drwxr-xr-x. 2 root root 4096 Jan 17 11:08 hooks
drwxr-xr-x. 2 root root 4096 Jan 17 11:08 locks
-rw-r--r--. 1 root root  229 Jan 17 11:08 README.txt

 

2) 執行 htpasswd 建立檔案型認證檔:passwd ,新增使用者 polinwei & u01
# htpasswd -c /opt/svn_root/ebs_source/conf/passwd polinwei ==> passwd 檔案不在時, htpasswd 參數要下 -c
New password:
Re-type new password:
Adding password for user polinwei

# htpasswd /opt/svn_root/ebs_source/conf/passwd u01 ==> passwd 檔案己存在時, htpasswd 參數不要下 -c
New password:
Re-type new password:
Adding password for user u01

# cat /opt/svn_root/ebs_source/conf/passwd
polinwei:rOocF4eiWllRQ
u01:VHkwsuykRzVlM

3) 維護 Repository:ebs_source 的存取權限

# vi /opt/svn_root/ebs_source/conf/authz
[groups]
admins = polinwei
users  = u01
oracle_ebs_group = polinwei

[ebs_source:/] ==> 這就是 repository 的根目錄
* = r
@admins = rw
@oracle_ebs_group = rw
@users = r

#可以對每個 repository 下的目錄再作權限管理

[ebs_source:/wei]
@oracle_ebs_group = rw

[ebs_source:/test]
@admins = rw
@users = r

 4) svnserve.conf 設定檔原則上是可以不需修改,使用預設值即可

 

二、設定 apache 對 SVN Server ( Subversion ) 的存取權限

1)  編輯 Apache 的 httpd.conf

因檔案 /etc/httpd/conf/httpd.conf 中有  Include conf.d/*.conf 

# vi /etc/httpd/conf/httpd.conf
#
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf

所以只要編輯  /etc/httpd/conf.d/subversion.conf

# vi /etc/httpd/conf.d/subversion.conf

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

# 對 SVN Respository : ebs_source 作設定
<Location /ebs_source>
   DAV svn
   SVNPath /opt/svn_root/ebs_source
   AuthType Basic
   AuthName "Subversion repository"
   AuthzSVNAccessFile /opt/svn_root/ebs_source/conf/authz
   AuthUserFile /opt/svn_root/ebs_source/conf/passwd
   Require valid-user
</Location>

2) 變更 SVN Respository : ebs_source 實體目錄權限

# chown -R apache.apache ebs_source
# chcon -R -t httpd_sys_content_t ebs_source

3) 重啟 Apache 服務,與測試;網址應為 http://oradb12clinux/ebs_source/

# service httpd restart


svn_jdeveloper_client.png  

三、SVN Server ( Subversion ) 的存取權限與 Windows AD 帳號/密碼作整合

1) 將檔案型:認證密碼檔 passwd 前加 #,並設定對 Windows AD 以 LDAP 加 SSL 作認證

# vi /etc/httpd/conf.d/subversion.conf

<Location /ebs_source>
   DAV svn
   SVNPath /opt/svn_root/ebs_source
   AuthType Basic
   AuthName "Subversion repository"
   AuthzSVNAccessFile /opt/svn_root/ebs_source/conf/authz
#   AuthUserFile /opt/svn_root/ebs_source/conf/passwd
   Require valid-user

   SSLRequireSSL
   AuthzLDAPAuthoritative Off
   AuthLDAPURL ldap://adserver.wei.com:389/o=wei?cn?sub
   AuthBasicProvider ldap
</Location>

2) 維護 Repository:ebs_source 的存取權限

# vi /opt/svn_root/ebs_source/conf/authz
[groups]
admins = polinwei
users  = u01
oracle_ebs_group = polinwei,polin.wei

[ebs_source:/] ==> 這就是 repository 的根目錄
* = r
@admins = rw
@oracle_ebs_group = rw

#可以對每個 repository 下的目錄再作權限管理,注意:若目錄下權限群組名:oracle_ebs_group 沒定對時,會造成所有人沒有權限進入repository 的根目錄

[ebs_source:/wei]
@oracle_ebs_group = rw

[ebs_source:/test]
@admins = rw
@users = r

 

3) 重啟 Apache 服務,與測試;注意網址變為 https (port:443 SSL協定) https://oradb12clinux/ebs_source/ ;認證則為 windows AD 裡的帳號/密碼

# service httpd restart

 svn_ad_user_auth.png  

 

 

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

為了在Windows主機間達到資源共享的目的,微軟發展出 SMB(Server Message Block)通訊協定,利用其網路芳鄰共享檔案系統及印表機等資源;而Samba在Linux主機上實現SMB通訊協定的系統,達成Windows與 Linux主機的資源共享,再搭配 Winbind 模組解決 Samba 中統一登入問題。因為 Linux Server 愈來愈多,為了可以達到統一單一帳號來達到管理,因此; 接下來我們要利用 samba、winbind 來整合 AD 帳號,這樣我們就可以在 AD 管理帳號就可以了。

環境:

Windows Server 2003 AD Server: ADSERVER.WEI.COM (192.168.2.1)

Oracle Linux R6.5 for x86_64 (64 Bit) :cvs.wei.com (192.168.2.69)

一、Linux 相關套件安裝與設定

1) 在安裝 Linux 主機時,可以選取相關的套件

samba_krb5_package.png samba_winbind_package.png  

2) 檢查/驗證一下相關的套件是否有裝

[root@cvs ~]# rpm -qa | grep samba
samba-common-3.6.9-164.el6.x86_64
samba-client-3.6.9-164.el6.x86_64
samba4-libs-4.0.0-58.el6.rc4.x86_64
samba-winbind-3.6.9-164.el6.x86_64
samba-3.6.9-164.el6.x86_64
samba-winbind-clients-3.6.9-164.el6.x86_64


[root@cvs ~]# rpm -qa | grep winbind
samba-winbind-3.6.9-164.el6.x86_64
samba-winbind-clients-3.6.9-164.el6.x86_64


[root@cvs ~]# rpm -qa | grep krb5
krb5-workstation-1.10.3-10.el6_4.6.x86_64
krb5-server-1.10.3-10.el6_4.6.x86_64
pam_krb5-2.3.11-9.el6.x86_64
krb5-libs-1.10.3-10.el6_4.6.x86_64

3) 使用 UI 工具來作設定

winbind_auth.png

 

winbind_auth_adv.png  

設定好後 Apply,然後記得要在 Identity & Authentication 按下 Join Domain,在 AD 的 Computers 中應該可以看到此 Linux : cvs 主機

winbind_join_domain.png winbind_join_domain_win.png  

 

4) 啟動 Samba & Winbind Services

winbind_smb_enable_service.png  

5) 最後使用 AD Domain User 來作登入測試,應該就可以成功了。

winbind_domainUser_login.png  

6) 若有目錄要給 AD Domain Users 群組可以使用, 可以用指令 # chown -R root:"WEI\Domain Users" /opt/cvs_root/ 來賦予.

Oracle Linux 在使用 samba、winbind 來整合 AD 帳號的 UI 畫面已經整合的非常好,/etc/samba/smb.conf & /etc/krb5.conf 都不需去多作編輯:只有 /var/kerberos/krb5kdc/kdc.conf 檔案內容中的 EXAMPLE.COM 要改成您的 AD 網域(如:WEI.COM),以及將 master_key_type 前的 # 去除即可。相關檔案如下:

[root@cvs samba]# cat /etc/samba/smb.conf
#======================= Global Settings =====================================

[global]
#--authconfig--start-line--

# Generated by authconfig on 2014/01/15 15:41:06
# DO NOT EDIT THIS SECTION (delimited by --start-line--/--end-line--)
# Any modification may be deleted or altered by authconfig in future

   workgroup = WEI
   password server = ADSERVER.WEI.COM
   realm = WEI.COM
   security = ads
   idmap config * : range = 16777216-33554431
   template shell = /bin/bash
   winbind use default domain = false
   winbind offline logon = true

#--authconfig--end-line--

 

[root@cvs samba]# cat /etc/krb5.conf
[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = WEI.COM
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true

[realms]
 EXAMPLE.COM = {
  kdc = kerberos.example.com
  admin_server = kerberos.example.com
 }

 WEI.COM = {
  kdc = ADSERVER.WEI.COM
 }

[domain_realm]
 .example.com = EXAMPLE.COM
 example.com = EXAMPLE.COM

 

# vi /var/kerberos/krb5kdc/kdc.conf
[kdcdefaults]
 kdc_ports = 88
 kdc_tcp_ports = 88

[realms]
 WEI.COM = {
  master_key_type = aes256-cts
  acl_file = /var/kerberos/krb5kdc/kadm5.acl
  dict_file = /usr/share/dict/words
  admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
  supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
 }

 

二、Samba 3.x 伺服器設定說明

設定Samba最基礎的項目就是指定工作群組名稱(workgroup)及網域名稱,編輯 Samba設定檔smb.conf,以下設定都在該檔案內[global]標籤下同一段落完成。
/etc/samba/smb.conf

workgroup = WEI
realm = WEI.COM

 

避免分享資源時出現亂碼,分別設定Windows、Linux的字集。

display charset = Big5
dos charset = CP950

 

使用AD網域認證必須修改Samba的安全層級,並指定認證主機及增加Windows網路相關設定。

security = ads
password server = ADSERVER.WEI.COM
wins server = ADSERVER.WEI.COM
encrypt passwords = yes

 

Linux預設的使用者家目錄為/home/使用者名稱,針對AD網域使用者 必須另行設定其家目錄位置,主要參數為:%D代表網域名稱、%U代表使用者名稱。以下設定目的為讓網域使用者的家目錄集中在/home/網域名稱/目錄下 並以使用者帳號命名,同時讓使用者帳號自動套用網域名稱及不允許使用者離線登入。

template homedir = /home/%D/%U
winbind use default domain = false
winbind offline logon = true

 

設定AD網域使用者帳號對應到Linux使用者帳號及群組的範圍。

idmap config * : range = 16777216-33554431

 

預設Winbind快取時間為300秒,使用指令# getent passwd或# getent group時,會將NT/AD網域的使用者與群組一併列出。當使用者、群組數量太多,Winbind會無法正常傳回資料,開啟此功能可以避免這個狀況。

winbind enum users = yes
winbind enum groups = yes
winbind cache time = 300

 

若允許AD網域使用者以終端機方式登入系統,可指定AD帳號的Shell。

template shell = /bin/bash

 

視需要開啟對NT ACLs(Access Control List) 的支援。

nt acl support = yes

 

三、整合Windows AD網域帳號資訊說明

當系統查詢使用者帳號與群組時,預設由檔案尋找(/etc/passwd、/etc/group),為了使其搜尋不到相關資訊時,轉而使用Winbind向AD網域查詢,必須設定認證來源和順序。
/etc/nsswitch.conf

passwd: files winbind
shadow: files winbind
group: files winbind

 

設定本機 UID 與 GID 發放範圍,避免 AD 帳號與 Linux 本機帳號衝突,限制本機分配給新使用者的uid、gid不要超過9999。
/etc/login.defs

UID_MIN 500
UID_MAX 9999
GID_MIN 500
GID_MAX 9999
CREATE_HOME yes

 

四、Linux Server加入AD網域

在將主機加入網域之前,需先確認AD主機及Linux主機時間不得相差超過5分鐘,建議設定同一網路校時服務(Network Time Protocol),並設定DNS或host使Linux主機得知AD網域伺服器的IP位址,任修改其中一種能查詢到網域即可。
/etc/resolv.conf

Nameserver 192.168.2.1

/etc/hosts

192.168.2.1        adserver.wei.com

 

由於Windows Server 2003的AD是採用Kerberos的認證機制,因此必須設定Kerberos相關設定檔以便和AD溝通。
/etc/krb5.conf

[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = WEI.COM
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true

 WEI.COM = {
  kdc = ADSERVER.WEI.COM
 }

/var/kerberos/krb5kdc/kdc.conf

[kdcdefaults]
 kdc_ports = 88
 kdc_tcp_ports = 88

[realms]
 WEI.COM = {
  master_key_type = aes256-cts
  acl_file = /var/kerberos/krb5kdc/kadm5.acl
  dict_file = /usr/share/dict/words
  admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
  supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
 }

 

完成以上設定後重新啟動Samba及Winbind並加入設開機啟動。

# service smb restart
# service winbind restart
# chkconfig smb on
# chkconfig winbind on

 

文字模式下指令加入wei.com 網域,aduser為AD網域之使用者,只需一般權限即可。

# net ads join -U aduser
aduser's password:

 

設定與AD伺服器溝通時的使用者(經測試是不需要作此動作的)。

# wbinfo --set-auth-user=aduser
Password:

 

一般Windows使用者在加入網域後存取不會有太大的問題,但Linux Clients使用者需要向Kerberos要求憑證(ticket)。可下指定測試取得Kerberos核發的憑證,取得後使用者不需要再輸入帳號密碼 存取資源,注意網域名稱要大寫,若密碼正確會跳回命令提示字元。

# kinit 網域帳號@WEI.COM

 

取得Kerberos核發的憑證後,可以看Kerberos核發的Kicket狀態。

# klist

 

測試讀取AD帳號資訊和取得系統帳號資訊。

# wbinfo -u | -g 取得網域帳號 | 群組
# getent passwd

 

參考文件:

http://michaeljoking.myip.org/modules/tad_book3/page.php?tbdsn=18

http://blog.yam.com/gavint/article/2590383

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

繼上章 Oracle Linux Install Using LVM,我們談到 LVM 的好處在於可以動態放大檔案系統,接下來就來做做看,假設我們安裝 Oracle Linux 時的磁碟配置如下,Volume Group:vg0 有三個 Physical Volume 實體磁區(簡稱PV),依下圖的配置來看,vg0 還有大約 13 G 未分配的磁碟空間。

lvm_01

 

下圖是整個系統磁碟的配置情況:

lvm_02  

 

系統安裝完後,可以用指令 lvscan 來查詢 LVM 實際擁有的空間

[root@oradb12clinux ~]# lvscan
  ACTIVE            '/dev/vg0/lv_u01' [15.00 GiB] inherit
  ACTIVE            '/dev/vg0/lv_root' [10.00 GiB] inherit
  ACTIVE            '/dev/vg0/lv_swap' [4.00 GiB] inherit
  ACTIVE            '/dev/vg0/lv_opt' [8.00 GiB] inherit

 

也可以使用指令 df -h 來看各個磁碟現在的使用狀況

[root@oradb12clinux ~]# df -h
Filesystem                                             Size  Used Avail Use% Mounted on
/dev/mapper/vg0-lv_root                      9.9G  4.1G  5.4G  43%    /
tmpfs                                                    2.0G  176K  2.0G   1%    /dev/shm
/dev/sda1                                            194M   51M  134M  28%  /boot
/dev/sda2                                            811M   17M  753M   3%  /home
/dev/mapper/vg0-lv_opt                      7.9G  146M  7.4G   2%   /opt
/dev/mapper/vg0-lv_u01                       15G  166M   14G   2%  /u01

 

用指令 vgdisplay 查詢一下 Volume Group:vg0 是否有未分配的磁碟空間

[root@oradb12clinux oradb12c]# vgdisplay
  --- Volume group ---
  VG Name               vg0
  System ID             
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               49.99 GiB
  PE Size               4.00 MiB
  Total PE              12797
  Alloc PE / Size       10521 / 41.10 GiB
  Free  PE / Size       2276 / 8.89 GiB
  VG UUID               MJcTqC-prDM-v0Ys-4s2c-0Fze-vGFD-THI2Iw

 

當發生磁碟空間不足,而 vg0 仍有未分配的磁碟空間時,就可以利用指令 lvextend -L 來增大空間,這樣是不是很方便呢!!

[root@oradb12clinux ~]# lvextend -L +100M '/dev/vg0/lv_opt'
  Extending logical volume lv_opt to 8.10 GiB
  Logical volume lv_opt successfully resized

ot@oradb12clinux oradb12c]# lvextend -L +4096 '/dev/vg0/lv_root'
  Extending logical volume lv_root to 14.00 GiB
  Logical volume lv_root successfully resized


[root@oradb12clinux oradb12c]# lvscan
  ACTIVE            '/dev/vg0/lv_u01' [15.00 GiB] inherit
  ACTIVE            '/dev/vg0/lv_root' [14.00 GiB] inherit
  ACTIVE            '/dev/vg0/lv_swap' [4.00 GiB] inherit
  ACTIVE            '/dev/vg0/lv_opt' [8.10 GiB] inherit


[root@oradb12clinux oradb12c]# df -h
Filesystem                                             Size  Used Avail Use% Mounted on
/dev/mapper/vg0-lv_root                      9.9G  8.8G  644M  94% /
tmpfs                                                     2.0G  264K  2.0G   1% /dev/shm
/dev/sda1                                             194M   51M  134M  28% /boot
/dev/sda2                                             811M   17M  753M   3% /home
/dev/mapper/vg0-lv_opt                       7.9G  146M  7.4G   2% /opt
/dev/mapper/vg0-lv_u01                      15G  166M   14G   2% /u01

 

發現了沒?! Logical Volume 邏輯磁區(簡稱 LV)'/dev/vg0/lv_root' 變大了,變為 14G,但用 df -h 去看時仍為 9.9 G ,lv_opt 也是相同的情形,那是因為尚未讓系統知道磁碟空間己變大,可以使用 resize2fs 來讓系統重新分配,若出現 Cannot use resize2fs as it is online. Use ext2online instead.  訊息,則是告知您,因磁碟在online 的情況下不能使用指令 resize2fs ,需以指令 ext2online 來替代。

[root@oradb12clinux oradb12c]# resize2fs /dev/vg0/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg0/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg0/lv_root to 3670016 (4k) blocks.
The filesystem on /dev/vg0/lv_root is now 3670016 blocks long.

[root@oradb12clinux oradb12c]# resize2fs /dev/vg0/lv_opt
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg0/lv_opt is mounted on /opt; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg0/lv_opt to 2122752 (4k) blocks.
The filesystem on /dev/vg0/lv_opt is now 2122752 blocks long.

[root@oradb12clinux oradb12c]# df -h
Filesystem                                               Size  Used Avail Use% Mounted on
/dev/mapper/vg0-lv_root                       14G  8.8G  4.4G  67% /
tmpfs                                                      2.0G  264K  2.0G   1% /dev/shm
/dev/sda1                                               194M   51M  134M  28% /boot
/dev/sda2                                               811M   17M  753M   3% /home
/dev/mapper/vg0-lv_opt                         8.0G  146M  7.5G   2% /opt
/dev/mapper/vg0-lv_u01                        15G  166M   14G   2% /u01

 

再查詢一次,看吧!! 系統也同步將空間實際放大了

 附註:若要看各個 Logical Volume 邏輯磁區(簡稱 LV)的狀態,可以用指令lvdisplay 查詢

[root@oradb12clinux oradb12c]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg0/lv_u01
  LV Name                lv_u01
  VG Name                vg0
  LV UUID                qEiPkX-e9tf-SZow-0lWO-mani-vVG5-z8z3Su
  LV Write Access        read/write
  LV Creation host, time oradb12clinux.globeunion.com, 2013-10-24 00:26:18 +0800
  LV Status              available
  # open                 1
  LV Size                15.00 GiB
  Current LE             3840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:2
   
  --- Logical volume ---
  LV Path                /dev/vg0/lv_root
  LV Name                lv_root
  VG Name                vg0
  LV UUID                0O3A7O-Lecx-bYK8-orvi-HaG3-Wc9h-OdqZbq
  LV Write Access        read/write
  LV Creation host, time oradb12clinux.globeunion.com, 2013-10-24 00:26:26 +0800
  LV Status              available
  # open                 1
  LV Size                14.00 GiB
  Current LE             3584
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0
   
  --- Logical volume ---
  LV Path                /dev/vg0/lv_swap
  LV Name                lv_swap
  VG Name                vg0
  LV UUID                gV4fRO-FSVF-F7H2-pL9X-qJef-IfUO-mO6oLN
  LV Write Access        read/write
  LV Creation host, time oradb12clinux.globeunion.com, 2013-10-24 00:26:27 +0800
  LV Status              available
  # open                 2
  LV Size                4.00 GiB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1
   
  --- Logical volume ---
  LV Path                /dev/vg0/lv_opt
  LV Name                lv_opt
  VG Name                vg0
  LV UUID                18OarF-nVXJ-er3a-WsYn-lKJT-LEyJ-1YHcKr
  LV Write Access        read/write
  LV Creation host, time oradb12clinux.globeunion.com, 2013-10-24 00:26:27 +0800
  LV Status              available
  # open                 1
  LV Size                8.10 GiB
  Current LE             2073
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:3

 

參考:

http://www.dbvisit.com/forums/showthread.php?t=343

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

LVM (Logical Volume Mamager) 概念
使用 LVM,硬碟中的分割區必須加入『Logical Volume Group 邏輯磁區群組(簡稱 VG)』,這種分割區在 LVM 中稱為『Physical Volume 實體磁區(簡稱PV)』,各位可以把 VG 想成是一個大硬碟,然後再從其中切出一塊空間『Logical Volume 邏輯磁區(簡稱 LV)』對應至系統的檔案系統。
 
除了/boot 分割區,其餘的檔案系統皆可在 Volume Group 在這顆虛擬的大硬碟中。/boot 分割區不可以在 VG 中,因為開機管理程式將無法讀取到它。假如您想要  /  檔案系統在 VG 中,您必須另外建立一個  /boot 分割區,使其不屬於VG 的一員。
 
VG 可以分割為幾個 『Logical Volume 邏輯磁區』,將會指定它們的掛載點,例如  /opt  與  /,以及檔案系統類型,如 ext4。當某個檔案系統的容量全滿時,VG 中的剩餘空間可以增加到此檔案系統所對映的邏輯磁區以增大此檔案系統大小。
示意圖如下:

Linux LVM (Logical Volume Manager) Concept.png  

接下來我們用VMWare 來模擬實體機,一步步來安裝 Oracle Linux

Oracle Linux 的來源可從下面取得

https://edelivery.oracle.com/linux

01. 安裝前, 先定義規格

01_oracleLinuxSpec.png

02. 選擇全新安裝

02_oracleLinuxInstallSelect.png

03. 不作安裝來源的檢查

03_oracleLinuxDiskSkip.png

04. 用英文模式來安裝, 因為中文有時翻譯的可能會讓人看不懂

04_oracleLinuxLanguage.png

05. 鍵盤選擇 U.S. English

05_oracleLinuxKB.png

06. 選擇硬碟的類型

06_oracleLinuxStorage.png

07. 硬碟內的資料不保存

07_oracleLinuxDiscardData.png

08. 主機的名稱

08_oracleLinuxHostName.png

09. 時間區域 Time Zone:選亞洲/台北

09_oracleLinuxTZ.png

10. root 的密碼

10_oracleLinuxPW.png

11. 硬碟的配置, 依 LVM 的概念作分配, 選擇自行規劃

11_oracleLinuxHDLayout.png  

12. 先將實體硬碟 sdb & sdc 變成 LVM Physical Volume

12_oracleLinuxLVM01.png

13. 將這兩個LVM Physical Volume (PV):sdb & sdc 加入 Volume Group (VG) VolGroup1 裡

13_oracleLinuxVG_LV.png

14. 記得 /boot 不能放在 LV 裡, 且要將 Force to be a primary paritition 打勾, 這樣系統才開得起來

14_oracleLinuxBoot.png

15. 整個碟碟的規劃如下

15_oracleLinuxLayoutAll.png

16. boot loader 放在 /dev/sda 上, 這樣大致就設定完成

16_oracleLinuxBootLoader.png

17. 因為待會我們要安裝 Oracle Database 12c Release 1 (12.1) , 所以選擇 Customize Now 來挑選必要的 package 軟體

17_oracleLiuxPlatform.png  

The following package groups were included for this installation.

    Base System > Base
    Base System > Compatibility libraries
    Base System > Hardware monitoring utilities
    Base System > Large Systems Performance
    Base System > Network file system client
    Base System > Performance Tools
    Base System > Perl Support
    Servers > Server Platform
    Servers > System administration tools
    Desktops > Desktop
    Desktops > Desktop Platform
    Desktops > Fonts
    Desktops > General Purpose Desktop
    Desktops > Graphical Administration Tools
    Desktops > Input Methods
    Desktops > X Window System
    Applications > Internet Browser
    Development > Additional Development
    Development > Development Tools

安裝 Oracle Database 12c Release 1 (12.1.0.1)  的官方文件可以參考:

http://www.oracle-base.com/articles/12c/oracle-db-12cr1-installation-on-oracle-linux-6.php

http://www.oracle-base.com/articles/12c/oracle-db-12cr1-rac-installation-on-oracle-linux-6-using-virtualbox.php

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()

Linux kernel 自 2.6.28 開始正式支持新的檔案系統 Ext4。 Ext4 是 Ext3 的改進版,修改了 Ext3 中部分重要的資料結構,而不僅僅像 Ext3 對 Ext2 那樣,只是增加了一個日誌功能而已。Ext4 可以提供更佳的性能和可靠性,還有更為豐富的功能:

1. 與 Ext3 相容。 執行若干條命令,就能從 Ext3 線上遷移到 Ext4,而無須重新格式化磁片或重新安裝系統。原有 Ext3 資料結構照樣保留,Ext4 作用於新資料,當然,整個檔案系統因此也就獲得了 Ext4 所支援的更大容量。

2. 更大的檔案系統和更大的文件。 較之 Ext3 目前所支持的最大 16TB 檔案系統和最大 2TB 檔,Ext4 分別支持 1EB(1,048,576TB, 1EB=1024PB, 1PB=1024TB)的檔案系統,以及 16TB 的檔。

3. 無限數量的子目錄。 Ext3 目前只支持 32,000 個子目錄,而 Ext4 支持無限數量的子目錄。

4. Extents。 Ext3 採用間接塊映射,當操作大檔時,效率極其低下。比如一個 100MB 大小的檔,在 Ext3 中要建立 25,600 個資料塊(每個資料塊大小為 4KB)的映射表。而 Ext4 引入了現代檔案系統中流行的 extents 概念,每個 extent 為一組連續的資料塊,上述檔則表示為“該檔資料保存在接下來的 25,600 個資料塊中”,提高了不少效率。

5. 多塊分配。 當寫入資料到 Ext3 檔案系統中時,Ext3 的資料塊分配器每次只能分配一個 4KB 的塊,寫一個 100MB 檔就要調用 25,600 次資料塊分配器,而 Ext4 的多塊分配器“multiblock allocator”(mballoc) 支持一次調用分配多個資料塊。

6. 延遲分配。 Ext3 的資料塊分配策略是儘快分配,而 Ext4 和其它現代檔作業系統的策略是盡可能地延遲分配,直到檔在 cache 中寫完才開始分配資料塊並寫入磁片,這樣就能優化整個檔的資料塊分配,與前兩種特性搭配起來可以顯著提升性能。

7. 快速 fsck。 以前執行 fsck 第一步就會很慢,因為它要檢查所有的 inode,現在 Ext4 給每個組的 inode 表中都添加了一份未使用 inode 的列表,今後 fsck Ext4 檔案系統就可以跳過它們而只去檢查那些在用的 inode 了。

8. 日誌校驗。 日誌是最常用的部分,也極易導致磁片硬體故障,而從損壞的日誌中恢復資料會導致更多的資料損壞。Ext4 的日誌校驗功能可以很方便地判斷日誌資料是否損壞,而且它將 Ext3 的兩階段日誌機制合併成一個階段,在增加安全性的同時提高了性能。

9. “無日誌”(No Journaling)模式。 日誌總歸有一些開銷,Ext4 允許關閉日誌,以便某些有特殊需求的使用者可以借此提升性能。

10. 線上磁碟重組。 儘管延遲分配、多塊分配和 extents 能有效減少檔案系統碎片,但碎片還是不可避免會產生。Ext4 支援線上磁碟重組,並將提供 e4defrag 工具進行個別檔或整個檔案系統的磁碟重組。

11. inode 相關特性。 Ext4 支持更大的 inode,較之 Ext3 默認的 inode 大小 128 位元組,Ext4 為了在 inode 中容納更多的擴展屬性(如納秒時間戳記或 inode 版本),默認 inode 大小為 256 位元組。Ext4 還支援快速擴展屬性(fast extended attributes)和 inode 保留(inodes reservation)。

12. 持久預分配(Persistent preallocation)。 P2P 軟體為了保證下載檔案有足夠的空間存放,常常會預先創建一個與所下載檔案大小相同的空檔,以免未來的數小時或數天之內磁碟空間不足導致下載失敗。 Ext4 在檔案系統層面實現了持久預分配並提供相應的 API(libc 中的 posix_fallocate()),比應用軟體自己實現更有效率。

13. 預計啟用 barrier。 磁片上配有內部緩存,以便重新調整批量資料的寫操作順序,優化寫入性能,因此檔案系統必須在日誌資料寫入磁片之後才能寫 commit 記錄,若 commit 記錄寫入在先,而日誌有可能損壞,那麼就會影響資料完整性。Ext4 默認啟用 barrier,只有當 barrier 之前的資料全部寫入磁片,才能寫 barrier 之後的資料。(可通過 "mount -o barrier=0" 命令禁用該特性)


ext2 與 ext3

Linux ext2/ext3檔案系統使用索引節點來記錄檔資訊,作用像windows的檔案配置表。索引節點是一個結構,它包含了一個檔的長度、創建及修改時 間、許可權、所屬關係、磁片中的位置等資訊。一個檔案系統維護了一個索引節點的陣列,每個檔或目錄都與索引節點陣列中的唯一一個元素對應。系統給每個索引 節點分配了一個號碼,也就是該節點在陣列中的索引號,稱為索引節點號。 linux檔案系統將檔索引節點號和檔案名同時保存在目錄中。所以,目錄只是將檔的名稱和它的索引節點號結合在一起的一張表,目錄中每一對檔案名稱和 索引節點號稱為一個連接。 對於一個檔來說有唯一的索引節點號與之對應,對於一個索引節點號,卻可以有多個檔案名與之對應。因此,在磁片上的同一個檔可以通過不同的路徑去訪問 它。


Linux 之前預設情況下使用的檔案系統為Ext2,ext2檔案系統的確高效穩定。但是,隨著Linux系統在關鍵業務中的應用,Linux檔案系統的弱點也漸漸 顯露出來了:其中系統預設使用的ext2檔案系統是非日誌檔案系統。這在關鍵行業的應用是一個致命的弱點。本文向各位介紹Linux下使用ext3日誌文 件系統應用。


Ext3檔案系統是直接從Ext2檔案系統發展而來,目前ext3檔案系統已經非常穩定可靠。它完全相容ext2檔案系統。使用者可以平滑地過渡到一個日誌功能健全的檔案系統中來。這實際上了也是ext3日誌檔案系統初始設計的初衷。

Ext3日誌檔案系統的特點
1、高可用性:系統使用了ext3檔案系統後,即使在非正常關機後,系統也不需要檢查檔案系統。宕機發生後,恢復ext3檔案系統的時間只要數十秒鐘。

2、資料的完整性:ext3 檔案系統能夠極大地提高檔案系統的完整性,避免了意外宕機對檔案系統的破壞。在保證資料完整性方面,ext3檔案系統有2種模式可供選擇。其中之一就是 “同時保持檔案系統及資料的一致性”模式。採用這種方式,你永遠不再會看到由於非正常關機而存儲在磁片上的垃圾檔。

3、檔案系統的速度:儘管使用ext3檔案系統時,有時在存儲資料時可能要多次寫資料,但是,從總體上看來,ext3比ext2的性能還要好一些。這是因為ext3的日誌功能對磁片的驅動器讀寫頭進行了優化。所以,檔案系統的讀寫性能較之Ext2檔案系統並來說,性能並沒有降低。

4、資料轉換:由 ext2檔案系統轉換成ext3檔案系統非常容易,只要簡單地鍵入兩條命令即可完成整個轉換過程,用戶不用花時間備份、恢復、格式化分區等。用一個 ext3檔案系統提供的小工具tune2fs,它可以將ext2檔案系統輕鬆轉換為ext3日誌檔案系統。另外,ext3檔案系統可以不經任何更改,而直接載入成為ext2檔案系統。

5、多種日誌模式:Ext3 有多種日誌模式,一種工作模式是對所有的檔資料及metadata(定義檔案系統中資料的資料,即資料的資料)進行日誌記錄(data=journal 模式);另一種工作模式則是只對metadata記錄日誌,而不對資料進行日誌記錄,也即所謂data=ordered或者data=writeback 模式。系統管理人員可以根據系統的實際工作要求,在系統的工作速度與檔資料的一致性之間作出選擇。


附註:用SSD硬碟測試,測試結果除了表明 Intel SSD 的讀寫速度快得令人咋舌之外,還可以說明 Ext4 的各方面性能都超過了上一代 Ext3,甚至在大多數情況下,比沒有日誌功能的 Ext2 還要快出不少。

參考:http://blog.csdn.net/galdys/article/details/8268694

文章標籤

MIS 發表在 痞客邦 留言(0) 人氣()