Posts tagged ‘gentoo’

Protected: emerge 不見的救法

This post is password protected. To view it please enter your password below:


gentoo emerge command

升級系統/世界

emerge -uDN system ( world )

升級完世界 把多餘的東西砍掉

emerge --depclean

檢查 library 一致?

revdep-rebuild

用vmware , frame buffer I/O很慢 , 要加 -q

安裝被keywords mark起來的ebuild

把 ebuild 名稱加到 /etc/portage/package.keywords 就可以了

在 /etc/make.conf 加 ACCEPT_KEYWORDS=”~amd64″

裝特定版本的 package

emerge =www-servers/apache-2.x.x
cd /
mount -t proc proc /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
cp -L /etc/resolv.conf /mnt/gentoo/etc/
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile

[gentoo] 排除舊的 lib 相容問題

 * Messages for package sys-devel/libtool-2.2.6b:

 * Old versions of installed libraries were detected on your system.
 * In order to avoid breaking packages that depend on these old libs,
 * the libraries are not being removed.  You need to run revdep-rebuild
 * in order to remove these old dependencies.  If you do not have this
 * helper program, simply emerge the 'gentoolkit' package.
 *
 *   # revdep-rebuild --library libltdl.so.3
 *
 * Once you've finished running revdep-rebuild, it should be safe to
 * delete the old libraries.  Here is a copy & paste for the lazy:
 *   # rm '/usr/lib64/libltdl.so.3'

下了 revdep-rebuild –library libltdl.so.3 會

 * Configuring search environment for revdep-rebuild

 * Checking reverse dependencies
 * Packages containing binaries and libraries using libltdl.so.3
 * will be emerged.

 * Collecting system binaries and libraries
 * Generated new 1_files.rr
 * Checking dynamic linking
[ 55% ]  *   found /usr/lib64/apache2/modules/libphp5.so
[ 80% ]  *   found /usr/lib64/php5/bin/php
[ 100% ]
 * Generated new 3_broken.rr
 * Assigning files to packages
 *   /usr/lib64/apache2/modules/libphp5.so -> dev-lang/php
 *   /usr/lib64/php5/bin/php -> dev-lang/php
 * Generated new 4_raw.rr and 4_owners.rr
 * Cleaning list of packages to rebuild
 * Generated new 4_pkgs.rr
 * Assigning packages to ebuilds
 * Generated new 4_ebuilds.rr
 * Evaluating package order
 * Generated new 5_order.rr
 * All prepared. Starting rebuild
emerge --oneshot  dev-lang/php:5
..........

[monster] monster.tw 記錄 / memo / ubuntu / 裝 圖形介面 / GUI / gnome desktop / ip address / setting

昨天晚上去一位朋友公司幫忙用他們的 server , 回來就想要做幾件事:

1. 記錄一下自己的 server 某些重要檔案, 也可供其他人參考

2. 備份重要 file

3. 隨時準備好最新版的救援CD/Live CD/Live USB , 最新版的 Monster LAMP pack 也要燒好收著.

4. 準備一個 “萬用” 含各類 driver 的 linux kernel , 以供救援使用.

5. 搞懂 booting steps / GRUB setting


a93c35eaf5a0019c7f7a42f461dae3de

root@park:~# cat /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#              

proc            /proc           proc    defaults        0       0
# / was on /dev/sda1 during installation
UUID=46312252-8925-4e60-ab5f-af240b4b440f /               ext3    relatime,errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=bf9a64f1-3eb8-433c-8311-8d971be82dc2 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0

service / daemon 管理工具

sysv-rc-conf text based utility :

sudo apt-get install sysv-rc-conf

另一套 GUI

sudo apt-get install gnome-system-tools

monster.tw 是裝這個 apt-get install rcconf

列出 runlevels 的 program : chkconfig

裝 圖形介面 / GUI / gnome desktop

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

啟動 desktop manager :

/etc/init.d/gdm start

stop x server / 關掉 x window: /etc/init.d/gdm stop

改 IP address

cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 172.30.0.42
        netmask 255.255.255.0
        network 172.30.0.0
        broadcast 172.30.0.255
        gateway 172.30.0.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8
        dns-search monster.tw

重新啟動 networking
/etc/init.d/networking restart

若要使用 DHCP 的話

auto eth0
iface eth0 inet dhcp

加上 default route

gateway 1.2.3.4

或另一個 static route

up route add -net 1.2.3.0 netmask 255.255.255.0 gw 1.2.3.4

change host name:

改 /etc/hostname
改 /etc/hosts

若是用 vmware 之類的軟體導致 clone 出來的 ubuntu 網路 interface 跑掉, 可以砍掉
/etc/udev/rules.d/70-persistent-net.rules
後 reboot , 就可以解決了.

Protected: 兩個版本的 Linux ( CENTOS vs GENTOO ) 作 mysql + senna small compare

This post is password protected. To view it please enter your password below:


gentoo linux ifconfig

ifconfig eth0 ${IP_ADDR} broadcast ${BROADCAST} netmask ${NETMASK} up

查主機溫度

cat /proc/acpi/thermal_zone/THRM/temperature

kernel 要把 I2O 編進去

裝新的 www.monster.com.tw 過程記錄

2009.0724 emerge 這些 packages:

time emerge -av gentoo-sources lilo vim bind vixie-cron syslog-ng dhcpcd xfsprogs openssh samba net-fs/nfs-utils portmap postfix screen ntp cronolog  net-mail/mpack app-arch/sharutils unzip net-dns/bind net-dns/bind-tools net-ftp/ftp net-misc/netkit-telnetd net-analyzer/trafshow net-analyzer/tcpdump net-analyzer/traceroute

kernel compile options

<*> Serial ATA (prod) and Parallel ATA (experimental) drivers  —>
<*>     Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support

CONFIG_ATA_PIIX:
This option enables support for ICH5/6/7/8 Serial ATA
and support for PATA on the Intel ESB/ICH/PIIX3/PIIX4 series
host controllers.

[*]   Ethernet (1000 Mbit)  —>
<*>   Realtek 8169 gigabit ethernet support

oasis ~ # uname -a
Linux oasis 2.6.29-gentoo-r5 #3 SMP PREEMPT Mon Jul 27 11:39:51 CST 2009 x86_64 Intel(R) Atom(TM) CPU 330 @ 1.60GHz GenuineIntel GNU/Linux

oasis ~ # file /bin/bash
/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), stripped

make.conf

CFLAGS="-O2 -pipe"
CXXFLAGS="-O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

USE="mmx sse sse2 -cups -ipv6 ssl apache2 berkdb cjk cli crypt curl gd gdbm iconv mysql mysqli ncurses nls pcre readline reflection session spell spl truetype unicode xml zlib ssl hash calendar json simplexml"

hdparm -tT /dev/sda

/dev/sda:

Timing cached reads:   1080 MB in  2.00 seconds = 539.97 MB/sec

Timing buffered disk reads:  196 MB in  3.01 seconds =  65.19 MB/sec

processor       : 3
vendor_id       : GenuineIntel
cpu family      : 6
model           : 28
model name      : Intel(R) Atom(TM) CPU  330   @ 1.60GHz
stepping        : 2
cpu MHz         : 1596.135
cache size      : 512 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good pni dtes64 monitor ds_cpl tm2 ssse3 cx16 xtpr pdcm lahf_lm
bogomips        : 3192.15
clflush size    : 64
cache_alignment : 64
address sizes   : 32 bits physical, 48 bits virtual
power management:
gcc --version gcc (Gentoo 4.3.2-r3 p1.6, pie-10.1.5) 4.3.2 

php --version
PHP 5.2.10-pl0-gentoo (cli) (built: Aug  7 2009 19:23:18)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

mysql --version
mysql  Ver 14.12 Distrib 5.0.67, for unknown-linux-gnu (x86_64) using readline 5.1
with
senna-1.1.4.tar.gz
tritonn-1.0.12-mysql-5.0.67.tar.gz

裝 dev-php5/pecl-memcache 有點問題

9d15a8d72725c3ef7655c96adb685696

解決:

在 /etc/portage/package.keywords 加上

dev-php5/pecl-memcache

在 gentoo 裝 oracle sqlplus package

5a7d294f8002b7cbcefa422e9598e2cf

去 Oracle 那邊 download
05a6575d78ea1ec511646bd57e002b71

那個 instantclient-sqlplus-linux32-11.1.0.7.zip
放到 /usr/portage/distfiles

下 emerge -av dev-db/oracle-instantclient-sqlplus

gentoo NFS

在 gentoo 要裝 NFS client 要裝

emerge -av net-fs/nfs-utils portmap

/etc/init.d/portmap start

EDIT: /etc/fstab 加一行
freenas.monster.tw:/mnt/data/public     /m1 nfs rw,addr=172.30.0.xx    0 0

有 showmount 可以看 NFS 有 export 那些 directory 出來

Protected: sqlrelay server install / setup / SOP / 設定 / 啟動

This post is password protected. To view it please enter your password below:


gentoo 安裝 Oracle client 方法 step by step / remote X window display

首先要先搞定 X window , 若不想裝 X window 可以用 xming 把畫面投到 PC 端來 , 如我目前的狀況是用 putty + xming 如圖設定

feb99306dfaa54bb05f239f7165dfa82

db7449bfa59f6eb6c6c2d0d66bc82628

63745e9abc1acee38a220141a2d38615

ssh 進遠端 server 下 export DISPLAY=172.30.0.216:0.0 把 X display 到 172.30.0.216:0.0
可以下 xeyes & 測試一下 , ( xeyes 也需要另裝)

gentoo 缺一些 X 的 lib , 要 emerge -av libXp libXtst

Oracle client 會 check 經過認可的 OS , 把這個 check 取消
vi install/oraparam.ini

[Certified Versions]
# 把下面那行註解
# Linux=gentoo,redhat-3,SuSE-9,redhat-4,UnitedLinux-1.0,asianux-1,asianux-2

開始安裝
./runInstaller

e4b1f883f9542ce30b5e8140718f0d5d

vmware esx server – compile linux kernel / scsi controller/driver problem

直接在 vmware esx server 上重裝一台 gentoo linux 的 steps

在這個地方要勾 BusLogic , 在 make menuconfig 要選 BusLogic (簡直是廢話…)

9501eebd2a93f31b580498868083c8ba

開機後 dmesg | grep scsi 的結果是

scsi: ***** BusLogic SCSI Driver Version 2.1.16 of 18 July 2002 *****
scsi: Copyright 1995-1998 by Leonard N. Zubkoff <lnz@dandelion.com>
scsi0: Configuring BusLogic Model BT-958 PCI Wide Ultra SCSI Host Adapter
scsi0:   Firmware Version: 5.07B, I/O Address: 0×1060, IRQ Channel: 17/Level
scsi0:   PCI Bus: 0, Device: 16, Address: 0xF4800000, Host Adapter SCSI ID: 7
scsi0:   Parity Checking: Enabled, Extended Translation: Enabled
scsi0:   Synchronous Negotiation: Ultra, Wide Negotiation: Enabled
scsi0:   Disconnect/Reconnect: Enabled, Tagged Queuing: Enabled
scsi0:   Scatter/Gather Limit: 128 of 128 segments, Mailboxes: 211
scsi0:   Driver Queue Depth: 211, Host Adapter Queue Depth: 192
scsi0:   Tagged Queue Depth: Automatic, Untagged Queue Depth: 3
scsi0: *** BusLogic BT-958 Initialized Successfully ***
scsi0 : BusLogic BT-958
scsi 0:0:0:0: Direct-Access     VMware   Virtual disk     1.0  PQ: 0 ANSI: 2
sd 0:0:0:0: Attached scsi generic sg0 type 0

用 HAProxy 作 load balancer – 窮人的 SLB ( server load balance)

這是簡單版的架構, http flow:
cacae1dfce25d17bd8225bdcd8b7b772

其實, 裝起來並沒有想像中複雜, 只是準備一個測試環境比較麻煩些罷了–> vmware 又幫了我不少忙 :P

參考他的 online document:
http://haproxy.1wt.eu/download/1.3/doc/haproxy-en.txt

及架構圖
http://haproxy.1wt.eu/download/1.3/doc/architecture.txt

略翻完這兩個文件就可以來測試了 , 首先準備三台 web server : webA 到 webC , 然後還要一台 server 當 haproxy server 這台不用跑 apache , 安裝 haproxy 很簡單, 在 gentoo 就是 emerge –av haproxy , 設定檔要自己建 (放到 /etc/ )

我的 /etc/haproxy.cnf

listen webfarm 172.30.0.235:80
monitor-uri /haproxy_status
stats uri /stats
stats auth admin:admin
mode http
balance roundrobin
cookie SERVERID insert indirect
option httpchk HEAD /index.php HTTP/1.0
server webA 172.30.0.206:80 cookie A check
server webB 172.30.0.227:80 cookie B check
server webC 172.30.0.228:80 cookie C check

第一次連上後, haproxy 如他的 menual 寫的 , 會丟一個 cookie 給 client , 作為下次要連的實體 server 的依據 , 我把那台 apache 停掉, 果然就連到別去了 , 然後 phpinfo 中值得紀錄的是:

SERVER_NAME 就是 haproxy.cfg 中寫的 listen 的 IP , 然後 , SERVER_ADDR 就是實體連到的 apache 的 IP , haproxy 會不停的丟 HTTP/1.0 的 HEAD 取得 apache 是否還活著.

在 webA-C 的 aapache access log 中若 沒特別改的話, 就是紀錄 haproxy server 的 IP address

….

好了! 實驗完成了!

結論, HAProxy 在他的官網寫說他:

“ 提供一個免費/快速的 HA / LOAD BALANCE 方案 , 可是我覺得他僅能夠說 HA / BALANCE (並沒有很徹底的偵測 server loading) , 並且在 SPF 方面也並沒有很好的解決辦法.

不過呢, 至少 HAProxy 比 DNS roundrobin 還好.

各種 LOAD BALANCE 方案 評估表

SLB

CPU用量

轉送效率

偵測連線

roundrobin DNS

最佳,直接傳給client

NO

ipvsadm

最低

YES

mod_proxy

YES

haproxy

YES

 

過了一個晚上想了想 , 即使 Citrix / Alteon / Foundry 這些 SLB hardware device 也沒有做到真正的 loading detective , 所以就一個免費又高容量的 HAProxy 來說, 算是很好的 SLB 解決方案了.

ㄎㄎ 有做過 HAProxy 實驗的都會貼這一張:

ec6601bde1fdb02e373efc74ea97e0f1

解決 error while loading shared libraries 的方法

執行程式時, 若遇到

./update_item: error while loading shared libraries: libsqlrclientwrapper-0.40.so.1: cannot open shared object file: No such file or directory

像這樣的錯誤訊息 , 表示程式中所需的 so 檔(share library) 沒找到 , 要修改 /etc/ld.so.conf 加上這個目錄 , 改完要下 ldconfig –v 讓路徑生效

可以用 ldd 看該程式所使用到的 shared library 有那些, 及 lib 路徑

—–

以下是 gentoo 的標準解法 , 其他版本的 linux 則不太相同!!

cat /etc/ld.so.conf   這個檔是由 env-update 產生的 , 所以再繼續看一下 /etc/env.d 下 , 究竟有啥

# ld.so.conf autogenerated by env-update; make all changes to
# contents of /etc/env.d directory
/usr/local/lib
/usr/i686-pc-linux-gnu/lib
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1
/usr/local/firstworks/lib

參考資料, 這是 compile sqlrelay 列出來的 information

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

———————————————————————-

/bin/sh ../../libtool –mode=finish /usr/local/firstworks/lib

PATH=”$PATH:/sbin” ldconfig -n /usr/local/firstworks/lib

———————————————————————-

Libraries have been installed in:

/usr/local/firstworks/lib

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR’

flag during linking and do at least one of the following:

- add LIBDIR to the `LD_LIBRARY_PATH’ environment variable

during execution

- add LIBDIR to the `LD_RUN_PATH’ environment variable

during linking

- use the `-Wl,–rpath -Wl,LIBDIR’ linker flag

- have your system administrator add LIBDIR to `/etc/ld.so.conf’

在 /etc/env.d 下建立一個 90sqlrelay

內容是

LDPATH="/usr/local/firstworks/lib"

再run : env-update , 就看到 /etc/ld.so.conf 多了正確的 lib path 了

Protected: [ruten] memcache usage

This post is password protected. To view it please enter your password below:


UTF8 / BIG5 / PUTTY / SHELL / SCREEN 真難搞系列

因為工作上都要改成 UTF8 , 所以很多以前熟悉的工具都要作一番改變 , 於是順手記在這邊 , 免得又忘記了.

我的 .screenrc

caption always "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
bind b encoding big5 utf8
bind u encoding utf8 big5

我的 .bashrc

EDITOR="/usr/bin/vim"

我的 putty setting

install oracle instant client basic on gentoo linux step by step

emerge -av dev-db/oracle-instantclient-basic dev-db/oracle-instantclient-sqlplus

!!! dev-db/oracle-instantclient-basic-11.1.0.7.0 has fetch restriction turned on.
!!! This probably means that this ebuild's files must be downloaded
!!! manually.  See the comments in the ebuild for more information.

 * Please go to:
 *   http://www.oracle.com/technology/tech/oci/instantclient/index.html
 * select your platform and download the
 * Basic client package with SDK, which are:
 *   instantclient-basic-linux32-11.1.0.7.zip
 *   instantclient-sdk-linux32-11.1.0.7.zip
 * Then after downloading put them in:
 *   /usr/portage/distfiles


http://www.oracle.com/technology/tech/oci/instantclient/index.html

factory ~ # cd /usr/portage/distfiles
factory distfiles # ls -l *zip
-rw-rw-r-- 1 apache portage 34556803 Aug  6 17:17 instantclient-basic-linux32-10.2.0.3-20061115.zip
-rw-rw-r-- 1 apache portage   602897 Aug  6 17:17 instantclient-sdk-linux32-10.2.0.3-20061115.zip

emerge -av dev-db/oracle-instantclient-basic
#

USE="apache2 berkdb bzip2 calendar cjk cli crypt ctype curl gd gdbm hash iconv json mysql mysqli nls oci8-instant-client pcre reflection session simplexml sockets spl ssl tokenizer truetype unicode xml xmlreader xmlwriter zlib" emerge -av php

screenrc

caption always "MONSTER %{bw}%0C%A %Y/%m/%d %LD %{wb} %-w%{Y}[%n %t]%{w}%+w%{k}"
activity "activity in %n (%t) [%w:%s]"

bind b encoding big5 utf8
bind u encoding utf8 big5

screen -t ROOT 0 bash
screen -t NET 8 bash
screen -t TOP 9 bash
screen -t WK1 1 bash
screen -t WK2 2 bash

Protected: Senna for mysql install 安裝說明

This post is password protected. To view it please enter your password below: