標籤

4GL (1) 人才發展 (10) 人物 (3) 太陽能 (4) 心理 (3) 心靈 (10) 文學 (31) 生活常識 (14) 光學 (1) 名句 (10) 即時通訊軟體 (2) 奇狐 (2) 爬蟲 (1) 音樂 (2) 產業 (5) 郭語錄 (3) 無聊 (3) 統計 (4) 新聞 (1) 經濟學 (1) 經營管理 (42) 解析度 (1) 遊戲 (5) 電學 (1) 網管 (10) 廣告 (1) 數學 (1) 機率 (1) 雜趣 (1) 證券 (4) 證券期貨 (1) ABAP (15) AD (1) agentflow (4) AJAX (1) Android (1) AnyChart (1) Apache (14) BASIS (4) BDL (1) C# (1) Church (1) CIE (1) CO (38) Converter (1) cron (1) CSS (23) DMS (1) DVD (1) Eclipse (1) English (1) excel (5) Exchange (4) Failover (1) Fedora (1) FI (57) File Transfer (1) Firefox (3) FM (2) fourjs (1) Genero (1) gladiatus (1) google (1) Google Maps API (2) grep (1) Grub (1) HR (2) html (23) HTS (8) IE (1) IE 8 (1) IIS (1) IMAP (3) Internet Explorer (1) java (4) JavaScript (22) jQuery (6) JSON (1) K3b (1) ldd (1) LED (3) Linux (120) Linux Mint (4) Load Balance (1) Microsoft (2) MIS (2) MM (51) MSSQL (1) MySQL (27) Network (1) NFS (1) Office (1) OpenSSL (1) Oracle (130) Outlook (3) PDF (6) Perl (60) PHP (33) PL/SQL (1) PL/SQL Developer (1) PM (3) Postfix (2) postfwd (1) PostgreSQL (1) PP (50) python (5) QM (1) Red Hat (4) Reporting Service (28) ruby (11) SAP (234) scp (1) SD (16) sed (1) Selenium (3) Selenium-WebDriver (5) shell (5) SQL (4) SQL server (8) sqlplus (1) SQuirreL SQL Client (1) SSH (3) SWOT (3) Symantec (2) T-SQL (7) Tera Term (2) tip (1) tiptop (24) Tomcat (6) Trouble Shooting (1) Tuning (5) Ubuntu (37) ufw (1) utf-8 (1) VIM (11) Virtual Machine (2) VirtualBox (1) vnc (3) Web Service (2) wget (1) Windows (19) Windows (1) WM (6) Xvfb (2) youtube (1) yum (2)
顯示具有 Ubuntu 標籤的文章。 顯示所有文章
顯示具有 Ubuntu 標籤的文章。 顯示所有文章

2024年9月11日 星期三

Ubuntu Linux 檔案系統擴充邏輯分割區

 https://www.concerto.one/posts/2021-09-28-Extend-Ubuntu-Linux-Volume.html

 

【運維管理】Ubuntu Linux 檔案系統擴充邏輯分割區

虛擬機更動磁區的實體大小之外,還需要追加擴充邏輯磁區,才能百分百將所有的實體磁碟空間納入儲存用途

虛擬機的設置中,僅更動硬碟的容量是不夠的

首先觀察虛擬機的硬碟 8G,執行 lsblk 檢查磁區的紀錄看起來如下。

[root@ubuntu]$ lsblk
NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda           8:0     0  8G   0  disk 
└─sda1        8:1     0  1M   0  part 
└─sda2        8:2     0  1G   0  part /boot
└─sda3        8:3     0  7G   0  part
  └─u-vg-lv   253:0   0  7G   0  lvm  /

接著,將虛擬機硬碟從 8G 更改至 16G 時,會發現 lsblk 檢查磁區的紀錄與前述相同,沒有反應出更動後新的變化。

執行 df -hT 會發現可用的儲存空間依然只有 4.4G,與原來完全相同。

[root@ubuntu]$ df -hT
Filesystem          Size  Used Avail Use% Mounted on
...
/dev/mapper/u-vg-lv 6.9G  2.2G 4.4G  34%  /
...

根據 lsblk 顯示的磁碟設備名稱與分割區位置來更改磁碟容量

從前述執行 lsblk 可以得知,我們要擴充分割區的磁碟名稱為 sda ,而分割區位置在第三個。所以構成的 growpart 參數如下。

[root@ubuntu]$ sudo growpart /dev/sda 3

再一次執行 lsblk 將會看到設備 sda 磁碟的尺寸從 8G 變成 16 G。但是邏輯分割區 u-vg-lv 依然是 7G。

[root@ubuntu]$ lsblk
NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda           8:0     0  16G  0  disk 
└─sda1        8:1     0  1M   0  part 
└─sda2        8:2     0  1G   0  part /boot
└─sda3        8:3     0  15G  0  part
  └─u-vg-lv   253:0   0  7G   0  lvm  /

擴充邏輯分割區將所有空間納入檔案系統

執行 pvs,根據顯示的結果,可以看出需要更動的磁碟名稱是 /dev/sda3。所以擴充設備分割區的指令如下。

sudo pvs
sudo pvresize /dev/sda3

接著擴充邏輯分割區的檔案系統。u-vg-lv 是掛載在磁碟設備 /dev/sda3 上邏輯分割區的名稱。

lvextend -r -l +100%FREE /dev/mapper/u-vg-lv

再一次執行 lsblk 檢查 lvextend 的執行結果。可以看到邏輯分割區 u-vg-lv 從原來的 7G 變成 15G。

[root@ubuntu]$ lsblk
NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda           8:0     0  16G  0  disk 
└─sda1        8:1     0  1M   0  part 
└─sda2        8:2     0  1G   0  part /boot
└─sda3        8:3     0  15G  0  part
  └─u-vg-lv   253:0   0  15G  0  lvm  /

2024年9月6日 星期五

Ubuntu 安裝 Python 3.12.3 + OpenSSL (openssl-3.3.2.tar.gz)

安裝OpenSSL
1. https://openssl-library.org/source/index.html 下載 OpenSSL source code (wget ...)
2. ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared (因為Python安裝時,只會吃ssl底下的目錄)
3.make; make test; sudo make install
4.
echo "/usr/local/ssl/lib64" > /etc/ld.so.conf.d/openssl.conf
5.sudo
ldconfig -v

安裝Python
1.(應該是需要這些)
  sudo apt-get install libbz2-dev
  sudo apt-get install libctypes-dev
  sudo apt-get install libffi-dev
  sudo apt-get install libncurses-dev
  sudo apt install libgdbm-compat-dev
  sudo apt-get install lzma
  sudo apt-get install liblzma-dev
  sudo apt-get install uuid-dev lzma-dev liblzma-dev
  sudo apt-get install nis
  sudo apt-get install libnsl2 libnss-nis
  sudo apt-get install libncurses5-dev
  sudo apt-get install libncurses-dev
  sudo apt-get install libreadline-dev
  sudo apt-get install nis
  sudo apt-get install tk
  sudo apt-get install tk-devel
  sudo apt-get install tk*dev
  sudo apt-get install nis
  sudo apt-get install libnsl-dev libnsl2
  sudo apt-get install libsqlite3-dev
  sudo apt install libssl*dev
或者
sudo apt-get update sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \ libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ xz-utils tk-dev libffi-dev liblzma-dev git

2. ../configure --enable-optimizations --with-openssl=/usr/local/ssl --with-ensurepip=install --with-openssl-rpath=/usr/local/ssl/lib64/

3. vim configure

Change

OPENSSL_LDFLAGS=-L/usr/local/ssl/lib

To:

OPENSSL_LDFLAGS=-L/usr/local/ssl/lib64

4. make -j$(nproc) ; sudo make altinstall

2024年9月5日 星期四

Ubuntu sqlpus 啟動會報錯 sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

$ sudo apt install libaio1 libaio-dev
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1

Ubuntu 的library 和CentOS 名稱不太一樣...沒辦法

2024年9月4日 星期三

使用Python 寫爬蟲範例

############################ ubuntu ############################
$ sudo apt install python3-pip
$ sudo apt install python3-selenium
$ sudo apt install python3-bs4
$ sudo apt install python3-requests
$ sudo apt install xvfb
$ export DISPLAY=:99
$ Xvfb :99 -screen 0 1024x768x16 &

############################ fedora ############################
$ sudo yum install python3-pip
$ sudo pip3 install selenium
$ Xvfb :99 -screen 0 1024x768x16 &sudo pip3 install bs4


$ wget https://github.com/mozilla/geckodriver/releases/download/v0.35.0/geckodriver-v0.35.0-linux64.tar.gz
$ tar xvf geckodriver-v0.35.0-linux64.tar.gz
$ sudo cp geckodriver /usr/local/bin/

$ cat get_fedex.py
#!/usr/bin/python3

# 載入需要的套件
from selenium import webdriver
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
from selenium.webdriver.firefox.service import Service
import requests
import time

# 開啟瀏覽器視窗(Chrome)# 方法一:執行前需開啟chromedriver.exe且與執行檔在同一個工作目錄
#driver = webdriver.Chrome()
#service = Service(executable_path='/usr/local/bin/geckodriver')
service = Service('/usr/local/bin/geckodriver')
driver = webdriver.Firefox(service=service)
#driver = webdriver.Firefox()

# 方法二:或是直接指定exe檔案路徑
#driver = webdriver.Firefox("/usr/local/bin")

driver.implicitly_wait(3) #等10秒,讓網頁資料load進來
driver.get("https://www.fedex.com/zh-tw/shipping/surcharges.html") # 更改網址以前往不同網頁
#time.sleep(100)

#driver.find_elements(By.CLASS_NAME,"fxg-gdpr__accept-all-btn cc-aem-c-button cc-aem-c-button--responsive cc-aem-c-button--primary")[0].click()
#buttons=driver.find_elements(By.CLASS_NAME,"fxg-gdpr__accept-all-btn cc-aem-c-button cc-aem-c-button--responsive cc-aem-c-button--primary")

button=driver.find_elements(By.CSS_SELECTOR,".fxg-gdpr__accept-all-btn")[0] #使用Selenium IDE找出來 "accept all cookie" 的按鈕
print(button)
button.click()

driver.refresh() #接受cookie後,要將網頁refresh, 重load資料

#使用Selenium IDE找出來要抓資料
data=driver.find_elements(By.CSS_SELECTOR,".fuelsurcharg-dynamic-datalookup .cc-aem-c-table__tbody:nth-child(2) .cc-aem-c-table__tbody__td:nth-child(1)")[0]
print(data.get_attribute("innerText"))
data=driver.find_elements(By.CSS_SELECTOR,".fuelsurcharg-dynamic-datalookup .cc-aem-c-table__tbody:nth-child(2) .cc-aem-c-table__tbody__td:nth-child(2)")[0]
print(data.get_attribute("innerText"))
data=driver.find_elements(By.CSS_SELECTOR,".fuelsurcharg-dynamic-datalookup .cc-aem-c-table__tbody:nth-child(2) .cc-aem-c-table__tbody__td:nth-child(3)")[0]
print(data.get_attribute("innerText"))

#print (driver.title)
#html=driver.page_source
#print (html)

#soup = BeautifulSoup(driver.page_source, 'lxml')
#print(soup.prettify())
#
#with open('index.html', 'w', encoding='utf-8',) as file:
#    file.write(soup.prettify())

driver.close() # 關閉瀏覽器視窗


2016年2月14日 星期日

Ubuntu11.10 使用 k3b 備份有CSS保護的DVD

https://jerry2yang.wordpress.com/2012/02/13/ubuntu11-10-%E4%BD%BF%E7%94%A8-k3b-%E5%82%99%E4%BB%BD%E6%9C%89css%E4%BF%9D%E8%AD%B7%E7%9A%84dvd/

要如何讓 k3b 可以備份有 CSS 保護的 DVD 呢?重點就是在如何安裝「libdvdcss」這個套件的方法了。
安裝「libdvdcss」:
拜訪 Linux Package Search,Search 「libdvdcss」套件, 找出符合系統版本的連結並依照說明安裝 「libdvdcss-dev」套件。


安裝步驟: 
  1. Add the following line to /etc/apt/sources.list:
    deb http://www.deb-multimedia.org wheezy main
  2. Update the package index:
    # sudo apt-get update
  3. Install GPG key of the repository:
    # sudo apt-get install deb-multimedia-keyring
  4. Install libdvdcss2 deb package:
    # sudo apt-get install libdvdcss2


操作:
接著就和正常的操作一樣,直接複製媒體。在必要時可能要需要使用「忽略讀取錯誤」進階選項。

2014年7月26日 星期六

如何在Ubuntu, Linux Mint 連接 4.x Android MTP device


1.
sudo apt-get install mtp-tools mtpfs

cat > /lib/udev/rules.d/69-mtp.rules
ATTR{idVendor}=="0b05", ATTR{idProduct}=="5480", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
 

cat > /etc/udev/rules.d/51-android.rules
# Asus AUSU_T00F
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="5480", MODE="0666" #MTP media, USB debug on


2.
sudo add-apt-repository ppa:webupd8team/unstable
sudo apt-get update
sudo apt-get install go-mtpfs

3. mount MTP device

sudo mtpfs -o allow_other /media/MyAndroid/
sudo go-mtpfs /media/MyAndroid

4. unmount MTP device

sudo fusermount -u /media/MyAndroid


http://ubuntuforums.org/showthread.php?t=2226702

2014年7月25日 星期五

用 xrandr 指令變更螢幕解析度


http://www.hongquan.me/?p=37

我在用virtual box新安装了一个linux mint 12, 但是最近在使用的时候发现一个问题。当我用Right_Ctrl + F键全屏进入mint的时候,发现整个屏幕明显没有被占满。上下留出一大段的黑色。看起来实在不爽。于是看了一下当前的屏幕分辨率,居然是 1440X793. 这个太没有道理了,我的显示器是分辨率是1440×900的,不知道从哪个地方跑出这么一个乱七八糟的分辨率来。
我开始认为应该是virtual box中设置错误。但是我怎么都没有找到在什么地方可以设置这个分辨率。于是我打算在mint里面修改以下这个分辨率。但是12(也就是ubuntu 11.10)里面已经找不到/etc/X11/xorg.conf这个文件了。在google之后我找到了方法。
首先使用xrandr命令列出当前的模式
RoyM1 ~ # xrandr
Screen 0: minimum 64 x 64, current 1440 x 900, maximum 32000 x 32000
VBOX0 connected 1440x793+0+0 0mm x 0mm
   1440x793       60.0 +
   1024x768       60.0
   800x600        60.0
   640x480        60.0
发现里面没有1440×900这个模式。于是使用xrandr添加一个新的模式进去。在添加之前,首使用cvt列出所需的模式的完整配置。然后添加这个新的模式并且应用。如下
RoyM1 ~ # cvt 1440 900
# 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
Modeline "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync
RoyM1 ~ # xrandr --newmode "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync
RoyM1 ~ # xrandr --addmode VBOX0 "1440x900_60.00" 
RoyM1 ~ # xrandr --output VBOX0 --mode "1440x900_60.00"
RoyM1 ~ #
这样以来,整个屏幕空间都被利用上了。感觉明显好了许多

 http://www.arthurtoday.com/2012/08/ubuntu-change-resolution-command.html

 其實,Ubuntu 目前在偵測螢幕解析度的功能上,已經算是滿準的,可是,就阿舍在筆電插上外接螢幕後,有時候這個外接螢幕的解析度就不是很準了哩 ! 所以,阿舍就得去找出設定解析度的畫面,然後,再調整設定,阿舍覺得這樣有點麻煩,如果可以指令來調的話,這樣阿舍在操作上,應該會比較順手吧 !



因此,阿舍就上網找了一下,呵呵 ! 似乎有不少人也和阿舍一樣的需求哩!而操作方式也很簡單,只要用 xrandr 指令 (Ubuntu 內建,不需要安裝) 加上 -s 參數及解析度就可以變更螢幕的解析度了,以阿舍要把解析度調成 1440x900 為例,操作指令如下 (要注意的是,解析度的中間是小寫英文字母的 “x",而不可以使用 “*” 符號哩!):

xrandr -s 1440x900

另外,阿舍想要更簡單一點的來切換螢幕解析度,所以,就在家目錄下建立一個檔名叫做「1440*900」的檔案,然後,在檔案裡加入下面這二行指令後就存檔。

#!/bin/bash

sudo xrandr -s 1440x900

接著,再用下面的指令來把這個檔案變更可執行檔。

chmod +x 1440*900

完成後,就可以在家目錄下,透過下面的指令執行這個檔案來切換螢幕解析度哩 ! 如果會需要經常切換不同的解析度的話,也可以用上述的方式來建立不同解析度的執行檔哩 !

./1440*900

2014年4月5日 星期六

System v 與 Upstart

http://tonytonyjan.net/2013/06/26/system-v-and-upstart/

| Comments
最近剛好將某個過去架設的 Heroku-like server,用 Upstart 將傳統的 System V 替換掉,在此做個筆記,這篇文章不會教你怎麼寫啟動腳本,就只是個簡介。
Upstart 早在 Ubuntu 6.10 的時候首次出現,以取代傳統的 sysvinit。結果因為好評不斷,Fedora 9、Debian、Google Chrome OS 也相繼使用。其中一個最大的原因在啟動程序時採用了異步啟動(asynchronously)的方式。即便如此,鑑於不是所有的程式都有 upstart 的格式,最新的 Ubuntu 版本仍然保留了傳統的 sysvinit 啟動方式。

System V

若遵循古法,當希望某程式能在 Linux 啟動的時候執行,會放個腳本在 /etc/init.d,(通常能在 /etc/init.d/skeleton 找到範例),同時用 update-rc.d(在 RedHat 家族是 chkconfig)決定是否啟用該服務。這個指令會根據 /etc/init.d/ 產生一堆軟連結(symbolic links)在 /etc/rc#.d/。內容物大概長的像 K##fooS##bar,用以決定 kill 或 start 的順序。
但是系統要啟動的時候,由於程序是乖乖的依序一個個執行(即便沒有相依關係),這將大大降低啟動的速度。為了改善這個問題,Upstart 誕生了。

Upstart

Upstart 是一個事件驅動的啟動工具,根據 job definition files(/etc/init/*.conf), 定義哪些服務應該在何時、何種情境下被執行,有別於 System V 的依序啟動,Upstart 的程序是異步執行的,好處是可以有效的利用系統資源,讓系統更快速的啟動(例如網路正在初始化的時候可以同時啟動一些硬碟或處理器相關的服務)。此外比起 System V 格式的腳本,*.conf 的腳本更易於閱讀使用。

停用/啟用

一般而言,除非你清楚某 service 是幹嘛的,否則應該養成別亂停用服務的習慣。
如果我們今天想停用/啟用某個服務,但不知道他是否支援 upstart,可以先到 /etc/init 看看他是否有設定檔,或執行以下指令測試:
$ sudo status mysql
mysql start/running, process 12461
$ sudo status postgresql
status: Unknown job: postgresql
以此為例,如果你想停用 mysql,可以直接在 /etc/init/mysql.conf 裡面,將檔頭附近某個以 start on 開頭的那行給註解掉,或是使用 manual 指令:
# sudo
$ echo 'manual' | sudo tee /etc/init/mysql.override # 當你不希望動到原設定,那就放個 `*.override`。
或是:
# root
$ echo manual >> /etc/init/smbd.conf
更詳細的使用方法請閱讀 man 5 init,裡面有包括 *.override 的使用案例。
至於 /etc/init/postgresql.conf 不存在,要馬自己寫,否則仍可用傳統的方式停用:
sudo update-rc.d apache2 disable
sudo service apache2 stop

2014年4月4日 星期五

chkconfig and sysv-rc-conf / rcconf

在Red Hat chkconfig 可以設定service是否在哪一個run level開機執行。

*************************************************************************
如果在Ubuntu,則有一個等價的指令:sysv-rc-conf

sysv-rc-conf --list [service name]
sysv-rc-conf [--level <runlevels>] <service name> <on|off>

example
1. sudo sysv-rc-conf 會出現類似GUI設定畫面
2. sudo sysv-rc-conf apache2 on
3. sudo sysv-rc-conf apache2 off

在Ubuntu不要用chkconfig,會有錯誤

*************************************************************************
sysv-rc-conf 還有另一等價指令在Ubuntu,叫rcconf

安裝:
sudo apt-get install dialog
sudo apt-get install rcconf

example:
1.sudo rcconf --list | grep apache2
2.sudo rcconf --on apache2
3.sudo rcconf --off apache2
4.sudo rcconf 會出現類似GUI設定畫面

Install PHP5, Apache, MySQL on Ubuntu

 http://www.howtogeek.com/howto/ubuntu/installing-php5-and-apache-on-ubuntu/


Install PHP5 and Apache on Ubuntu

sudo apt-get install apache2
(Note that if apache is already installed you can omit the first line. Your web files will now be found in /var/www/)

sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
(這會讓/etc/apache2/mods-enabled 新增php5的link)

sudo apt-get install mysql
sudo apt-get install php5-mysql

sudo /etc/init.d/apache2 restart

2014年3月15日 星期六

How to Install Slidewall Wallpaper Changer on Ubuntu, Linux Mint

http://ubuntuhandbook.org/index.php/2013/07/install-slidewall-ubuntu-linux-mint/

To install this app, press Ctrl+Alt+T to open terminal, then follow the below steps:
1.) Copy and paste this command and run. It adds the ppa repository to your system:
sudo add-apt-repository ppa:fioan89/slidewall
2.) Update package lists to make it available:
sudo apt-get update
3.) Finally install the software:
sudo apt-get install slidewall

2013年11月30日 星期六

UFW防火牆簡單設置

http://wiki.ubuntu.org.cn/index.php?title=UFW%E9%98%B2%E7%81%AB%E5%A2%99%E7%AE%80%E5%8D%95%E8%AE%BE%E7%BD%AE&variant=zh-tw



ufw是一個主機端的iptables類防火牆配置工具,比較容易上手。一般桌面應用使用ufw已經可以滿足要求了。


目錄

[編輯] 安裝方法

 sudo apt-get install ufw
當然,這是有圖形界面的(比較簡陋),在新立得里搜索gufw試試……

[編輯] 使用方法

1 啟用
 sudo ufw enable
 sudo ufw default deny 
作用:開啟了防火牆並隨系統啟動同時關閉所有外部對本機的訪問(本機訪問外部正常)。
2 關閉
 sudo ufw disable 
2 查看防火牆狀態
 sudo ufw status 
3 開啟/禁用相應埠或服務舉例
 sudo ufw allow 80 允许外部访问80端口
 sudo ufw delete allow 80 禁止外部访问80 端口
 sudo ufw allow from 192.168.1.1 允许此IP访问所有的本机端口
 sudo ufw deny smtp 禁止外部访问smtp服务
 sudo ufw delete allow smtp 删除上面建立的某条规则
 ufw deny proto tcp from 10.0.0.0/8 to 192.168.0.1 port 要拒绝所有的流量从TCP的10.0.0.0/8 到端口22的地址192.168.0.1
 可以允许所有RFC1918网络(局域网/无线局域网的)访问这个主机(/8,/16,/12是一种网络分级):
sudo ufw allow from 10.0.0.0/8
sudo ufw allow from 172.16.0.0/12
sudo ufw allow from 192.168.0.0/16

[編輯] 推薦設置

 sudo apt-get install ufw
 sudo ufw enable
 sudo ufw default deny 
這樣設置已經很安全,如果有特殊需要,可以使用sudo ufw allow開啟相應服務。

[編輯] 詳細使用說明

Ufw中文使用指南

2013年11月10日 星期日

2013年7月4日 星期四

Installing Oracle 11gR2 on Ubuntu 12.04

http://www.gizmojunkee.com/2012/05/installing-oracle-11gr2-on-ubuntu-12-04/


Installing Oracle 11gR2 on Ubuntu 12.04

30 May 2012 1 views 28 Comments
This howto should guide you though the installation of an Oracle Database 11g Release 2 on Ubuntu 12.04.
Ubuntu is not officially supported by Oracle so there will be a few tweaks to achieve a working solution.
I hope this might help you if you aim for a similar task.
Before we start with this Chapter I assume you have a clean Ubuntu 12.04
Server up and running. If that is not the case please check out my previous
post Ubuntu 12.04 LTE Server on Virtualbox 4.1 installation.

1. Download Oracle

first download the full Version of Oracle 11gR2 for linux OS from the Oracle side. Safe the 2 files somewhere
on your local PC. We will transfer them later to the VM.

2. Prepare the System

We have to install a few required packages for Oracle. Best way to install those is to use the standard
debian package manager. As I have installed Ubuntu on my Server and work primary on my MacBook Air
I will open a Terminal session and SSH into the Server as root. You can of course also just enter the
commands direct into the VM’s terminal to install the following packages:
aptitude -y install alien binutils build-essential libaio1 libaio-dev unixODBC unixODBC-dev
expat sysstat libelf-dev elfutils pdksh ia32-libs unzip libstdc++5 libstdc++6 cpp-4.4
g++-4.4 gawk ksh lesstif2 lib32bz2-dev lib32z1-dev libbeecrypt7 libdb4.8 libmotif4
libodbcinstq4-1 libodbcinstq4-1:i386 libqt4-core libqt4-gui lsb lsb-cxx lsb-qt4

3. Pre-Checks

check your /etc/hostname that it looks like below:
localhost.localdomain
and also check that in /etc/hosts the below line is present:
127.0.0.1        localhost.localdomain    localhost

4. Configure Memory Settings

For the installation we need a minimum of 1GB physical memory which we define when we setup the
Virtual Machine earlier, else you can check it with the following command:
grep MemTotal /proc/meminfo
Because the Oracle installation is demanding in resources we create some temp swap-space that will
disappear after a reboot. Bare that in mind, if you reboot the Server before completing the Oracle
installation you have to redo the below steps.
Check your current swap-space with this command:
grep SwapTotal /proc/meminfo
Now let’s create a temporary swap file for the installation.
dd if=/dev/zero of=/tmp/swap bs=1M count=4096
chmod 600 /tmp/swap
mkswap /tmp/swap
swapon /tmp/swap
Execute the command again to confirm the added swap-space
grep SwapTotal /proc/meminfo
Shared Memory is also important for Oracle, else you might face some ORA-00845 error messages.
Check your current Shared Memory with this command:
df -kh /dev/shm/
If you have less than 512MB edit /etc/fstab and add (either 1024M or 1512M) I am adding here 1.5GB
by adding the following line:
tmpfs /dev/shm tmpfs defaults,size=1512M 0    0
After remount and check the new size once again:
mount -o remount /dev/shm
df -kh /dev/shm/

5. System Group and Users

remember we did not create any Users with our Ubuntu installation so lets do that now
addgroup --system oinstall
addgroup --system dba
useradd -r -g oinstall -G dba -m -s /bin/bash -d /var/lib/oracle oracle
passwd oracle

6. Configure Kernel

Oracle requires additional kernel parameters, you either create a new kernel parameter file or add it to
the existing system kernel. I choose to add them to the existing system file. So lets make first a backup
Backup the original system file /etc/sysctl.conf by executing:
cp /etc/sysctl.conf /etc/sysctl.conf.original
Execute the following command to simply paste in the parameters:
cat - >> /etc/sysctl.conf
Now cut and paste the following
# Oracle 11gR2 kernel parameters
fs.aio-max-nr=1048576
fs.file-max=6815744
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
kernel.sem=250 32000 100 128
kernel.shmmax=2147483648
then press Ctrl-d to write the file

Note:

kernel.shmmax = max possible value, e.g. size of physical RAM.
Verify the above with:
cat /etc/sysctl.conf
and load the new Kernel parameter with the following command:
sysctl -p
Verify the new kernel settings:
sysctl -q fs.aio-max-nr
that should return — fs.aio-max-nr = 1048576
Before we now set the Oracle limits lets backup the original file:
cp /etc/security/limits.conf /etc/security/limits.conf.original
Next add the following limits to /etc/security/limits.conf:
cat - >> /etc/security/limits.conf
cut and paste the following and then write to the file with Ctrl-d

#Oracle 11gR2 shell limits
oracle soft nproc 2048
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
Check/add if the following line exits within /etc/pam.d/login
session required /lib/security/pam_limits.so
Check if the following line exits within /etc/pam.d/su
session required pam_limits.so

7. Create Oracle directories

It’s time to create some directories for Oracle and set the permissions.
mkdir -p /u01/app/oracle
mkdir -p /u02/oradata
chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02

8. Configuring the oracle user’s environment

Add following lines to /var/lib/oracle/.profile
We are creating here a AL32UTF8 database, so change this to US7ASCII if you want to create and
ASCII database. This will also map Oracle’s /bin to your $PATH to run Oracle’s binary directly at login:
# for Oracle User
if [ "$USER" = oracle ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
umask 022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=AL32UTF8
export NLS_LANG=.AL32UTF8
unset TNS_ADMIN
if [ -d "$ORACLE_HOME/bin" ]; then
PATH="$ORACLE_HOME/bin:$PATH"
fi

9. Fake Oracle installer

As mentioned before , Ubuntu is not listed as Oracle officially support platform and so we need
to fake it by creating symbolic links:
mkdir /usr/lib64
ln -s /etc /etc/rc.d
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/basename /bin/basename
ln -s /usr/bin/rpm /bin/rpm
ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib64/
Mask ourself as RedHat:
echo 'Red Hat Linux release 5' &gt; /etc/redhat-release

10. Copy the Oracle installation files to the Server

We discussed in the pre-post PuTTY, so we going to use that now to copy the files over to the Server.
Copy the file 2 files (linux.x64_11gR2_database_*.zip to oracle’s home directory and unzip them
cp linux.x64_11gR2_database_1of2.zip /var/lib/oracle
cp linux.x64_11gR2_database_2of2.zip /var/lib/oracle
cd /var/lib/oracle
unzip -q linux.x64_11gR2_database_1of2.zip
unzip -q linux.x64_11gR2_database_2of2.zip
chown -Rf oracle:oinstall /var/lib/oracle/
In case that cp don’t work use the scp command that comes with PuTTY to copy the files over.
scp linux.x64* oracle@ip_address:/var/lib/oracle

11. Starting Oracle Installer

Before we can do that we have to export the Display on our Ubuntu Server as root.
Go to your Ubuntu VM and login as root if not already and execute the following commands:
DISPLAY=:0.0
export DISPLAY
Next go back to PuTTY session and login to the Server as oracle (su – oracle if you are already as root).
No change to the database directory and start the installer with the following command:
cd /var/lib/oracle/database &amp;&amp; ./runInstaller

At the first screen of the Oracle Installer you can add your support Account if you have one, In case
you don’t just leave it empty and remove the default tick box for the email.














At the next tab [Select Installation Option] – choose the first setting Create and configure a database:














In [System Class] – choose Server Class:














In [Node Selection] – choose the option Single instance database installation:














In [Select Install Type] – choose Advanced install:














In [Select Product Languages] – choose to install at your demand I select all available languages:














In [Select Database Edition] – choose Enterprise Edition:














In [Specify Installation Location] – the default settings should be as below:
Oracle Base: /u01/app/oracle
Sofeware Location: /u01/app/oracle/product/11.2.0/dbhome_1














In [Create Inventory] –  it should default as below:
Inventory Directory: /u01/app/oraInventory
oraInventory Group Name: oinstall














In [Select Configure Type] – choose General Purpose / Transaction Processing:














In [Specify Database Identifiers] – configure as below:
Global database name: AL32UTF8.localdomain
Oracle Service Identifier (SID): AL32UTF8














In [Specify Configuration Options] – configure as below:
Memory -> Enable Automatic Memory Management: TRUE
Character sets: Use Unicode (AL32UTF8)


























In [Specify Management Options] – choose Use Database Control for database management
and leave the rest as default:














In [Specify Database Storage Options] – choose File System where:
Specify database file location: /u01/app/oracle/oradata














In [Specify Recovery Options] – choose Do not enable automated backups:














In [Specify Schema Passwords] – choose to your passwords and write them down:














In [Privileged Operating System Groups] – confirm as below:
Database Administrator (OSDBA) Group: dba
Database Operator (OSOPER) Group: oinstall














In [Preform Prerequisite Checks] –  just simply ignore all warning message
(since we are using Debian but not Oracle officially supported OS):














So just confirm everything in Summary:














And now let’s go for a coffee/tee break – you deserve it













Special note for Ubuntu 12.04: If you face error during installation so update as below:














When you see the above error, open a new session to the Server and execute the below commands:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
sed -i 's/^(s*$(MK_EMAGENT_NMECTL))s*$/1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk
sed -i 's/^($LD $LD_RUNTIME) ($LD_OPT)/1 -Wl,--no-as-needed 2/g' $ORACLE_HOME/bin/genorasdksh
sed -i 's/^(s*)($(OCRLIBS_DEFAULT))/1 -Wl,--no-as-needed 2/g' $ORACLE_HOME/srvm/lib/ins_srvm.mk
sed -i 's/^(TNSLSNR_LINKLINE.*$(TNSLSNR_OFILES)) ($(LINKTTLIBS))/1 -Wl,--no-as-needed 2/g' $ORACLE_HOME/network/lib/env_network.mk
sed -i 's/^(ORACLE_LINKLINE.*$(ORACLE_LINKER)) ($(PL_FLAGS))/1 -Wl,--no-as-needed 2/g' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
Then press Continue and keep going …














Now following the instructions and run the following commands with root user:
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh














Confirm with installation progress














In previous screen the installer mentioned that we can access Enterprise Manager Database Control URL
from https://localhost.localdomain:1158/em, so now let’s open the browser and test it with following account:
User Name: SYS
Password: your_secret_password
Connect As: SYSDBA
Once login it should show as below:

12. Post Configurations – Autostart Oracle during system boot

I like if everything boots up automatic so lets configure Oracle to start during system boot. You can of course
turn this feature later off, but the init.d script is very useful too. First we need to specify which database
instant will be started together with Oracle. (of course this is the first but maybe you have already done
this a few times).
Edit /etc/oratab as below:
AL32UTF8:/u01/app/oracle/product/11.2.0/dbhome_1:Y
Now lets create the init.d script as /etc/init.d/oracle
cat - >> /etc/init.d/oracle
copy and paste all below and complete it with Ctrl-d

#!/bin/bash
#

# Run-level Startup script for the Oracle Instance and Listener
#
### BEGIN INIT INFO
# Provides: Oracle
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Startup/Shutdown Oracle listener and instance
### END INIT INFO
ORA_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su - $ORA_OWNR -c "$ORA_HOME/bin/dbstart $ORA_HOME"
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"
#Optional : for Enterprise Manager software only
su - $ORA_OWNR -c "$ORA_HOME/bin/emctl start dbconsole"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
#Optional : for Enterprise Manager software only
su - $ORA_OWNR -c "$ORA_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNR -c "$ORA_HOME/bin/dbshut $ORA_HOME"
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 start|stop|restart|reload"
exit 1
esac
exit 0
Set the Permission:
chmod 755 /etc/init.d/oracle
Finally we need to install the script so Oracle will start during system bootup:
update-rc.d-insserv oracle defaults 99 01
NOTE: You may find the following error message during /etc/init.d/oracle/stop:
Shutdown Oracle: ulimit: 25: bad number
You can then update /u01/app/oracle/product/11.2.0/dbhome_1/bin/emctl
with #!/bin/bash to solve the problem:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
sed -i 's/^#!/bin/sh -fs*/#!/bin/bash -f/g' $ORACLE_HOME/bin/emctl

Final Notes

Next up I will install the same database on a few other Linux distributions and see how it goes. Also I will
write up a guide how to access the Database from anywhere. I haven’t completed that task yet so just
stay tuned.

HOWTO install Oracle 11g on Ubuntu Linux 12.04 (Precise Pangolin) 64bits

http://www.makina-corpus.org/blog/howto-install-oracle-11g-ubuntu-linux-1204-precise-pangolin-64bits

HOWTO install Oracle 11g on Ubuntu Linux 12.04 (Precise Pangolin) 64bits

Esta página ha sido traducida en español por Maria Ramos de Webhsotinghub.com/support/edu

Before starting

Since release 11.10 it is more difficult to install Oracle 64bits on Ubuntu.
If you need to run Oracle on a production environment, please install a supported Linux distribution.
So why installing Oracle on Ubuntu ?
  • You may manage Ubuntu servers and cannot use other linux distributions
  • You may be a developper, and clearly, ubuntu is a good choice for the desktop environment so you want to continue developing on your favorite distribution
  • You may be a student learning Oracle, and clearly, ubuntu is a good choice for the desktop environment so you want to continue learning on your favorite distribution
  • Because you want to !
Clearly, Oracle should officially support ubuntu linux !
Since version 11.10 of Ubuntu, installing Oracle as become much more complicated than already described in this previous Oracle installation guide on Ubunto 64bits how to.
This is due to, at least, the following points:
  • /dev/shm is a symbolic link to /run/shm and Oracle binaries do not properly support this, resulting in MEMORY TARGET errors
  • new configuration/compilation rules with gcc (indirect library linking) no more allow a library A referencing functions of library C linked with library B that is linked with library A. In this case, library A must be explicitly linked with library C too. So Oracle makefiles have to be updated for some libraries.
 This how to is based on the following two others and many others contributions:
So, why writing my own ?
Because they were not so easy to found, and I had started my own article before solving all the encountered issues.
Because they do not all describe or explain all errors I've encoutered and because I suggest others solutions to solve parts of encoutered as for /dev/shm.

Downloading Oracle 11g 64 bits for Linux

First, download Oracle 11gR2 Enterprise/Standard Edition for Linux x86-64 from Oracle website.
Then extract the downloaded file:

unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
A new folder named database will be extracted.

Preparing the system

Second, read the HTML documentation of the quick install guide you can found in the extracted folder at this place: database/doc/install.112/e10860/toc.htm
For the rest of this howto, we suppose Oracle will be installed at /opt/oracle Root directory in a freshly newly installed Linux Ubuntu distribution.
We will have to:
  • Create required users and groups accounts
  • Set required system parameters in /etc/sysctl.conf
  • Installing complementary packages

Creating system accounts

Creating Oracle Inventory group:
 sudo groupadd oinstall
Creating Oracle DBA group:
 sudo groupadd dba
Creating Oracle user home and account:
 sudo mkdir -p /opt/oracle
 sudo useradd -g oinstall -G dba  -d /opt/oracle -s /bin/bash oracle
 sudo passwd oracle
 sudo chown -R oracle:oinstall /opt/oracle
For Oracle 10g, it was required to add nobody user group, this is no more required with 11g as it is no more described in 11g quick installation guide.

Updating kernel parameters

This is one of the longest task of this installation. Because you will have to check your current config.
Check commands in Oracle documentation for this, section 6 Configuring Kernel Parameters.
Then, edit the file /etc/sysctl.conf as described below:
 sudo gedit /etc/sysctl.conf

Add the following lines to get minimal values required by Oracle, adjusting if required, depending of your configuration:

#
# Oracle 11g
#
kernel.sem = 250 32000 100 128
kernel.shmall = 2097152
kernel.shmmni = 4096
# Replace kernel.shmmax with the half of your memory in bytes
# if lower than 4Go minus 1
# 1073741824 is 1 GigaBytes
kernel.shmmax=1073741824

# Try sysctl -a | grep ip_local_port_range to get real values
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 = 1048576

# Max value allowed, should be set to avoid IO errors
fs.aio-max-nr = 1048576
# 512 * PROCESSES / what really means processes ?
fs.file-max = 6815744 

# To allow dba to allocate hugetlbfs pages
# 1001 is your oinstall group, id. grep oinstall /etc/group will give this value
vm.hugetlb_shm_group = 1001
About HUGE TLB.
Since Ubuntu Karmic (it was not required on Ubuntu Jaunty) kernel parameters have changed and this was required for 10g.
Without these parameters your Oracle instance won't be able to create shared memory segment and will refuse to start.
Not tested on Ubuntu 12.04 but this is now described in 11g documentation.
You have to replace the value of 1001 with the group ID of the oinstall group.
Read this great howto install Oracle on debian to know more about huge tlb parameter.
Then, run the command below to set these kernel parameters:
 sudo sysctl -p 
Now, update /etc/security/limits.conf:
 sudo gedit /etc/security/limits.conf
And add the following parameters:
# Oracle
oracle           soft    nproc   2047
oracle           hard    nproc   16384
oracle           soft    nofile  1024
oracle           hard    nofile  65536
oracle           soft    stack   10240
Check that /etc/pam.d/login contains a line like this one:
 session    required   pam_limits.so
Now, update /etc/profile:
 sudo gedit /etc/profile
And add the following lines:
if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
              ulimit -p 16384
              ulimit -n 65536
        else
              ulimit -u 16384 -n 65536
        fi
fi 

Installing additional packages

If not already done, update your distribution with the latest packages:
 sudo apt-get update
 sudo apt-get dist-upgrade
Install the following additional packages:
sudo apt-get install alien
sudo apt-get install autoconf
sudo apt-get install automake 
sudo apt-get install autotools-dev
sudo apt-get install binutils
sudo apt-get install bzip2
sudo apt-get install doxygen
sudo apt-get install elfutils
sudo apt-get install expat
sudo apt-get install gawk
sudo apt-get install gcc
sudo apt-get install gcc-multilib
sudo apt-get install g++-multilib

# This will help preventing prevent from runInstaller terrific ./runInstaller: line 54: ./install/.oui: No such file or directory error message
sudo apt-get install ia32-libs

sudo apt-get install ksh
sudo apt-get install less
sudo apt-get install lesstif2
sudo apt-get install lesstif2-dev
sudo apt-get install lib32z1
sudo apt-get install libaio1
sudo apt-get install libaio-dev
sudo apt-get install libc6-dev
sudo apt-get install libc6-dev-i386
sudo apt-get install libc6-i386 
sudo apt-get install libelf-dev
sudo apt-get install libltdl-dev
sudo apt-get install libmotif4
sudo apt-get install libodbcinstq4-1 libodbcinstq4-1:i386
sudo apt-get install libpth-dev
sudo apt-get install libpthread-stubs0
sudo apt-get install libpthread-stubs0-dev
sudo apt-get install libstdc++5
sudo apt-get install lsb-cxx
sudo apt-get install make
sudo apt-get install openssh-server
sudo apt-get install pdksh
sudo apt-get install rlwrap
sudo apt-get install rpm
sudo apt-get install sysstat
sudo apt-get install unixodbc
sudo apt-get install unixodbc-dev
sudo apt-get install unzip
sudo apt-get install x11-utils
sudo apt-get install zlibc 

Preventing from installation errors

To prevent from error genclntsh: Failed to link libclntsh.so.11.1 in make file for rdbms/lib/ins_rdbms.mk
beacause of missing library: /usr/bin/ld: cannot find /usr/lib64/libpthread_nonshared.a inside
we need to create a symlink for /usr/lib64:
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
To help preventing from error lib//libagtsh.so: undefined reference to `nnfyboot' in make: rdbms/lib/dg4odbc] Error 1
sudo ln -sf /bin/bash /bin/sh
sudo ln -s /usr/bin/awk /bin/awk
sudo ln -s /usr/bin/rpm /bin/rpm 
sudo ln -s /usr/bin/basename /bin/basename 
To prevent from # /lib64/libgcc_s.so.1: File or directory does not exists, while creating lib/liborasdkbase.so.11.1 in ins_rdbms.mk, execute the command:
cd /lib64
sudo ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 .
Oracle 11g also needs libstdc++5 in 32bits version that is not provided with Ubuntu Pangolin.
There are many ways to install it, I have followed this howto to install libstdc++5 on Ubuntu Karmic 
Below is the summary of this HOWTO:
mkdir /tmp/libstdc++5
cd /tmp/libstdc++5
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-3.3/libstdc++5_3.3....
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-3.3/libstdc++5_3.3....

sudo dpkg --force-architecture -i libstdc++5_3.3.6-17ubuntu1_i386.deb
sudo mv /usr/lib/libstdc++.so.5* /usr/lib32/

sudo dpkg -i libstdc++5_3.3.6-17ubuntu1_amd64.deb
Now reboot your system to be sure these parameters will be taken in account for the next part of the installation.

Others configurations

Connect as Oracle user and set some default startup file
 sudo su - oracle
 cd
 touch .bashrc
 ln -s .bashrc .bash_profile
Edit .bashrc file:
 vi .bashrc
And add the following line:
 umask 022
Execute the .bashrc file or restart a bash shell
 source .bashrc

Installing Oracle

Now we can start the installation of the Oracle 10g archive.
Allow others users to connect to your X session, by entering in a bash shell:
 xhost +
Then, login as oracle user:
 su - oracle
Go in the extracted database folder and run the following commands:
 export DISPLAY=:0
 ./runInstaller
Then, Oracle installer should start in graphic mode.
For the rest of the installation, we suppose you will choose the following options:
  • Installing Oracle 11g Enterprise edition in advanced mode
  • Installing server class
  • Oracle base directory: /opt/oracle/Oracle11gee
  • Oracle home: /opt/oracle/Oracle11gee/product/11.2.0/dbhome_1
  • Oracle inventory: /opt/oracle/oraInventory
  • Oracle database global name and SID: orcl
  • Character set: Unicode AL32UTF8
  • Memory: Uncheck activate automatic memory management to prevent from ORA-00845: MEMORY_TARGET not supported on this system. Antoher solution could be to remove /de/shm symbolic link and mount it as a bind to /run/shm: mount --bind /run/shm /dev/shm. But this no more seems to be an issue on 12.04, was ok as automatic with my last installation.
  • Oradata directory: /opt/oracle/Oracle11gee/oradata
Once you will reach the "pre-reqs" screen, check "Ignore all" to continue the installation.
Then, you will encounter issues.

Solving compilation/link errors

Some issues should appear during installation.
If you have not created the symbolic links above, you will have to solve error lib//libagtsh.so: undefined reference to `nnfyboot' in make: rdbms/lib/dg4odbc] Error 1. For this, create the symbolic links and execute the commands:
export ORACLE_HOME=/opt/oracle/Oracle11gee/product/11.2.0/dbhome_1
cd $ORACLE_HOME/lib
ln -s libclient11.a libagtsh.a
$ORACLE_HOME/bin/genagtsh $ORACLE_HOME/lib/libagtsh.so 1.0
Now we will encounter many errors due to indirect library linking:
To solve error # libnnz11.so: could not read symbols: Invalid operation /sysman/lib/ins_emagent.mk, enter the command:
export ORACLE_HOME=/opt/oracle/Oracle11gee/product/11.2.0/dbhome_1
sed -i 's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk
To solve error # nsglsn.c:(.text+0xc29): undefined reference to `ons_subscriber_close' /network/lib/ins_net_server.mk, enter the command:
sed -i 's/^\(TNSLSNR_LINKLINE.*\$(TNSLSNR_OFILES)\) \(\$(LINKTTLIBS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/network/lib/env_network.mk
To solve error # libocrutl11.so: undefined reference to `lfifcp' rdbms/lib/ins_rdbms.mk, enter the commands:
sed -i 's/^\(ORACLE_LINKLINE.*\$(ORACLE_LINKER)\) \(\$(PL_FLAGS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
You also need to execute the following commands to prevent from later errors:
sed -i 's/^\(\$LD \$LD_RUNTIME\) \(\$LD_OPT\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/bin/genorasdksh
sed -i 's/^\(\s*\)\(\$(OCRLIBS_DEFAULT)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/srvm/lib/ins_srvm.mk

2013年6月22日 星期六

解決Ubuntu中文輸入問題

建議gcin輸入法:

1. 打開gnome-terminal
 apt-get install gcin
2.  gnome-language-selector
 選擇gcin
3. sudo im-switch
 選擇gcin

How to restart X session :
1. ps -ef|grep dm
    可以看到系統是使用何種 desk manager
    在linux mint我找到mdm

2. /etc/init.d/mdm restart

2013年6月13日 星期四

Ubuntu下使用HAProxy和Keepalived配置Web服务器群集



Ubuntu下使用HAProxy和Keepalived配置Web服务器群集

HAProxy是一个用于4层或7层的高性能负载均衡软件,在大型网站的大型Web服务器群集中,HAProxy可用来替代专业的硬件负载均衡设备,节省大量的开支。
通常情况下,为了避免整个体系中出现单点故障,在至关重要的架构中,都需要部署备份设备,同样,负载均衡设备也不能部署单台,一旦主设备出现问题之后,备份设备可对主设备进行接管。实现不间断的服务,这便是Keepalived的作用。
于是,HAProxy和Keepalived的组合便成了省钱高效的Web服务器负载均衡架构。最近,做了一个小实验,用HAProxy和Keepalived来实现高可用的服务器群集。

haproxy_keepalived 如拓扑图所示,本实验中涉及到4台服务器,其中,两台HAProxy服务器(director1和director2)工作在主备模式下,用以对 Client的web访问请求进行分发。IP地址分别为192.168.11.11/24,192.168.11.12/24,虚拟出一个 IP:192.168.11.10/24。
两台WWW服务器(www1和www2)对Client的WWW访问请求进行响应,IP地址分别配置为192.168.11.21/24,192.168.11.22/24。
所有Client的访问请求均被网关做DNAT转换,发送到192.168.11.10上。

配置步骤:
【第一步,安装软件】
分别在director1和director2上安装keepalived和haproxy软件:
$sudo apt-get install keepalived
$sudo apt-get install haproxy
 
【第二步,配置HAProxy】
分别在director1和director2上编辑/etc/haproxy/haproxy.cfg,配置文件如下:
global

log 127.0.0.1 local0

log 127.0.0.1 local1 notice

maxconn 4096

user haproxy

group haproxy

daemon

nbproc 2

debug

defaults

log 127.0.0.1 local3

mode http

option httplog

option httpclose

option dontlognull

option forwardfor

option redispatch

retries 2

maxconn 2000

stats uri /haproxy-stats

contimeout 5000

clitimeout 50000

srvtimeout 50000

frontend 192.168.11.10

bind *:80

mode http

option httplog

log global

default_backend server_pool

backend server_pool

balance source

option httpchk HEAD /index.html HTTP/1.0

server www1 192.168.11.21:80 weight 5 check inter 2000 rise 2 fall 3

server www2 192.168.11.22:80 weight 3 check inter 2000 rise 2 fall 3
在这个配置文件中,比较重要的部分是倒数6行这些配置,stats指定的是HAProxy的一个统计页面,在配置成功之后,可以使用URL直接访问 此页面,获得负载均衡的统计结果,而frontend后边跟的是整个群集对外的IP地址,这里当然是虚拟出来的VIP,default_backend, 用于标注出负载均衡设备后边的服务器群,httpchk指出了对Real Server进行健康检查的网页地址,我这里直接写的就是index.html,就是首页地址,实际上可以在WWW服务器上写一个脚本来进行探测,这样得 到的结果更准确些。使用而server则是整个群集中的所有Real Server,在这里可以指定权重,IP地址等。
更多关于HAProxy的语法解释,可以参考这个页面:http://haproxy.1wt.eu/download/1.4/doc/configuration.txt

【第三步,配置Keepalived】
参考这篇文章:Ubuntu下Keepalived 配置

【第四步,启动haproxy】
使用如下命令启动HAProxy:
$sudo haproxy -f /etc/haproxy/haproxy.cfg
启动完成之后,可以使用netstat -lnpt命令,看一下,HAProxy是否已经在监听80端口了。

【第五步,验证】
在Client上打开浏览器,访问地址:http://172.16.2.13,看是否可以打开web服务器的页面,然后关掉一台director,看看访问是否依然正常。
在网关上访问http://192.168.11.10/haproxy-stats,看看是否可以看到负载均衡的统计结果。

【总结】
HAProxy可以完成的事情远不止这些,比如,可以在HAProxy中指定脚本的类型,把不同的访问请求分发到不同的Web服务群集上去,比如, 把所有的.htm访问请求转发到静态群集中,把所有的.php访问请求转发到动态群集中,或者使用正则表达式,实现更高级的功能。
参考这些链接,可得到更多内容:
http://network.51cto.com/art/201110/295955_1.htm
http://www.cnblogs.com/dkblog/archive/2011/07/06/2098949.html
http://saplingidea.iteye.com/blog/628716
http://wenku.baidu.com/view/dc2cde1cfc4ffe473368ab4e.html

2013年6月12日 星期三

Ubuntu 12.04 安裝 XFCE 4

http://www.arthurtoday.com/2012/08/ubuntu-install-xubuntu-desktop-xfce4.html

除了 LinuxMint 出的 Cinnamon 和 MATE 這二個桌面管理軟體之外,阿舍還有在用而且還滿喜歡的桌面管理軟體就是 XFCE,所以,阿舍有一個常用的虛擬機器所使用的桌面管理軟體就是 XFCE,這個 XFCE 的界面雖然簡單,但是,阿舍用起來還滿順手的,如果想要一個省資源又簡單的桌面軟體的話,就可以考慮看看這個  XFCE 哩 !


Xubuntu
XFCE 和 KDE 一樣,都有專用的 Ubuntu,名字就叫做「Xubuntu」,所以,也和 KDE 一樣,用下面的第一行指令就可以裝到好,不過,也有人提到用下面的第二行指令來安裝 XFCE,阿舍有去查了一下這二種指令安裝出來的差別,也在虛擬機器上,分別試裝了一下哩 !

sudo apt-get install xubuntu-desktop



subdo apt-get install xfce4

如果是使用第二個指令的話,只需要 67MB 大小的空間,而如果是用第一行的指令的話,就會需要大概 200 多MB左右,一般來說,如果是和阿舍一樣,對於 XFCE 沒有特別熟的話,阿舍是建議用第一行的指令來安裝,雖然是比較大些,可是,是有和 Ubuntu 做過些整合的,而相對的,如果對 XFCE 有比較熟,知道怎麼自定或想要做些客制的話,就可以用第二行的指令來安裝。

Xfce 4
阿舍是先安裝了 XFCE 4 之後,再接著安裝 Xubuntu Desktop 的,在裝了 Xubuntu Desktop 之後,雖然在登入的 Session 選項裡,還有「Xfce 4」項目可選,但是,登入後,就是 Xubuntu 的畫面哩 ! 原來的 XFCE 4 是會被蓋掉的。

另外,使用 Xubuntu Desktop 所安裝的 XFCE 是 4.8 版的,如果想要用安裝最新版的 XFCE 4.10 的話,就要在執行安裝指令前,先用下面兩行指令來加入  XFCE 4.10 的 PPA 並更新, 之後,再執行安裝 Xubuntu Desktop 的指令,這樣就可以安裝 XFCE 4.10 版哩 !

sudo add-apt-repository ppa:xubuntu-dev/xfce-4.10
sudo apt-get update

Ubuntu Server 12.10自行安裝Gnome桌面(Desktop)

http://www.arthurtoday.com/2012/11/ubuntu-server-install-unity-gui.html

阿舍之前都乖乖的下載 Ubuntu Desktop 來用,可是,最近,不知為何,阿舍就是喜歡安裝 Ubuntu Server 來當作桌面版的,仔細想想,大概是為可以用 64bit 版本吧 ! 不過,Ubuntu Desktop 也有出 64 bit 的版本,所以,這個理由不太成立哩 ! 呵 ! 真正的原因,應該還是因為阿舍前陣子在測一些 Sever 端的軟體的時候,用了 Ubuntu Serer 來測,才發現用 Ubuntu Server 來當日常用的作業系統,好像也不錯用哩 ! (如果想要瞭解 Server 和 Desktop 的差異的話,請參考這裡)


精簡安裝的結果

不過,拿 Ubuntu Server 來當做桌面版用的話,第一個會遇到的問題,就是沒有圖型介面可用哩 ! 阿舍之前有試著在 Ubunu Server 上安裝 LXDE 和 XFCE 這二套視窗管理軟體來用,阿舍覺得用起來還不錯,所以,後來就選了 XFCE 來用,而在 Ubuntu Server 上安裝 LXDE及 XFCE 的方式,其實和在 Ubuntu Desktop 是沒有什麼差別的哩 ! 但是,阿舍最近突然有想到,如果要安裝 Ubuntu 預設的 Unity 的話,那要怎麼裝呢 ?

阿舍上網查了一下,發現,要在 Ubuntu Server 上安裝 Unity 的話,有二種方式可以選,第一種方式是直接安裝 Ubuntu Desktop 的完整套件,操作指令如下,這種方式會需要高達 1.5GB 的容間來安裝,所以,下完指令就可以去晃晃了哩 !

sudo apt-get install ubuntu-desktop

而第二種方式則是會安裝比較精簡的 Ubuntu Desktop 套件,如果只是要在 Ubuntu Server 上有個圖型界面來方便操作的話,就可以選用這種安裝方式,安裝的指令如下,而這種方式所安裝的東西只有 500 MB 多而已,安裝起來會快不少哩 ! 不過,也不會太快就是哩 !

sudo apt-get install --no-install-recommends ubuntu-desktop

上面這二個指令都會把 Ubuntu 預設的 Unity 界面給安裝起來,安裝完成後,重開機就會出現熟悉的登人畫面,而在登入後,就會看到 Unity 了,不過,用第二個指令裝好的畫面會有點怪(如上圖),是因為少了幾個常見的軟體的圖示的關係吧 ! 但是,這樣應該會比較好吧 ! 因為之後想要用的時候再裝,就不用事先裝一堆,然後,更新的時候,也就跟著要常更新了哩 !

另外,阿舍有點小懷疑,該不會這樣安裝後,阿舍裝好的 Ubuntu Server 就被亂成 Ubunut Desktop 了吧 ! 所以,阿舍就用了下面的指令來查了一下,結果 ... 是阿舍多想了哩 ! 呵 !

dpkg --list | grep linux-image