2007年12月24日 星期一
2007年12月23日 星期日
2007年12月22日 星期六
從ubuntu到Debian
Debian linux可以算是既遵守GNU精神,而又不具商業化氣息的作業系統了。
加上它效能的穩定性高,安全性夠。用來作Server是相當不錯的選擇!
雖然不比商業化的linux 版本,Red Hat來得通俗,處處看得到Hack文件。
但linux作業系統的市場運作模式,讓我們還是能找到一個規範,
去了解它,使用它,管理它。
就我目前使用ubuntu的心得看來,
Debian的套件管理,實在要較RPM系統要來得先進多了!
嘿嘿!朋友,先別和我爭孰優孰劣。用了就知道啦!
LPIC Level 1 102 考古題 之二
What command will remove a loaded kernel module?
Choose the best answer.
a.delmod
b.modrm
c.modkill
d.rmmod
e.depmod
answer:d
Question 2/33
Which file is used by modprobe to get the information, what kernel module is
needed by a particular other kernel module?
Choose the best answer.
a./etc/modules.dep
b./etc/modules.conf
c./lib/modules/$(uname -r)/modules.dep
d./lib/modules/$(uname -r)/modules.conf
e./lib/modules/$(uname -r)/modules.needed
answer:c
Question 3/33
You have just loaded a new version of the kernel source and installed it
into /usr/src/kernelnew. In /usr/src/kernelold are the
sources of your old kernel. Before configuring the new kernel you want to get as much
configuration information as possible from the old kernel to the new one.
What file will you copy from kernelold to kernelnew to archieve this?
Choose the best answer.
a.Makefile
b.kernel.dat
c.kernel.conf
d..config
e..kernelconf
answer:a
Question 4/33
Which file contains the main log of the system?
Choose the best answer.
a./var/mesg
b./var/log
c./var/log/mesg
d./var/log/messages
e./var/messages
answer:d
Question 5/33
What is the main configuration file for the init program?
Choose the best answer.
a./etc/init.conf
b./etc/system.conf
c./etc/inittab
d./etc/init/configure
e./etc/runlevel.conf
answer:c
Question 6/33
Which command will you use to send jobs to printers?
Choose the best answer.
a.lpd
b.lpr
c.lpc
d.lpq
e.print
answer:b
Question 7/33
What command will you use to submit a printjob to a remote printer on a
windows machine?
Choose the best answer.
a.wlpr
b.wprint
c.smbclient
d.samba
e.sambaprint
answer:c ?
Question 8/33
What is the command to built a new manpage index database?
Choose the best answer.
a.updatedb
b.updatemandb
c.mandb-update
d.mandb
e.mkindex
answer:e
Question 9/33
The file _____________ is displayed by getty befor the login message.
(Please enter full path and filename)
Type the answer.
answer:/etc/issue
Question 10/33
How can you assign the content of the enviroment variable PATH to the
enviroment variable MYPATH in the bash shell?
Choose the best answer.
a.MYPATH=PATH
b.MYPATH=$PATH
c.$MYPATH=PATH
d.$MYPATH=$PATH
e.let MYPATH=$PATH
answer:b
Question 11/33
You define an alias in your shell: alias cp="cp -i" but now you want to use
the original cp command. How can you remove the alias?
Choose the best answer.
a.alias cp=
b.alias cp=builtin cp
c.unalias cp
d.rmalias cp
e.delalias cp
answer:c
Question 12/33
Which statement about the following line is true?
[ -x /usr/sbin/daemon ] && /usr/sbin/daemon
Choose the best answer.
a./usr/sbin/daemon will be executed if it exists and is executable
b.The daemon will be executed with it's own path as parameter
c.This is a recursive call to daemon
d.This isn't a valid command
answer:a
Question 13/33
User foo has left our company and you want to remove his account and all his
files in his homedirectory. Which of the following commands will do this?
Choose the best answer.
a.rm -rf /home/foo
b.userdel -r foo
c.killuser foo
d.deluser -r foo
e.kill -HOME foo
answer:b
Question 14/33
What command shows you, what groups you belong to?
Choose the best answer.
a.whatgrp
b.whatgroup
c.group
d.groups
e.grps
answer:d
Question 15/33
You want to change from old /etc/passwd format to the modern and more save
shadow password system. What command can you use for that purpose?
Choose the best answer.
a.mkshadow
b.shadow
c.sh_create
d.sh-create
e.pwconv
answer:e
Question 16/33
Where can you configure the behavior of the syslog daemon?
Choose the best answer.
a./var/log/syslog.conf
b./var/log/syslogd.conf
c./etc/syslog.conf
d./etc/syslogd.conf
e./var/lib/syslogd/configure
answer:c
Question 17/33
What actions can be configured in the logrotate configuration file?
Choose every correct answer.
a.Mail old logs to a given address before deleting them
b.Compress rotated logfiles
c.Keep an amount of old messages in the newly generated logfile
d.Move rotated logs to a different location
e.Send a mail to root after every rotating
answer:b c e
Question 18/33
What file(s) can be used to permit or deny particular users to use the
cron-system?
Choose the best answer.
a./etc/hosts.allow and /etc/hosts.deny
b./etc/cron.allow and /etc/cron.deny
c./etc/cron/allow and /etc/cron/deny
d./etc/cronuser
e.Only root may use cron, so no settings are possible
answer:b
Question 19/33
What happens with the output of a command which is run by at by a
particular user?
Choose the best answer.
a.It will be written into the file /var/log/at
b.It will be written into the file /var/log/at_username
c.It will be written into the file at.out in the users home directory
d.It will be written to /dev/null
e.It will be mailed to the user
answer:e ?
Question 20/33
How many backup levels are provided by dump?
Choose the best answer.
a.2
b.3
c.5
d.10
e.20
answer:d 0-9
Question 21/33
What is a NTP server?
Choose the best answer.
a.Network Transfer Protocol - a fileserver
b.Network Time Protocol - a server which offers exact time settings
c.NT-Protocol - a Win-NT server
d.Net Talk Protocol - a chat server
answer:b
Question 22/33
Which service works usually on port 139 ?
Choose the best answer.
a.nntp
b.netbios-ssn
c.pop3
d.snmp
e.imap
answer:b
Question 23/33
Which segmentation is correct for Class C addresses ?
Choose the best answer.
a.1 byte network address, 3 byte host address
b.2 byte network address, 2 byte host address
c.3 byte network address, 1 byte host address
answer:c
Question 24/33
The CIDR mask /28 is in dotted quad notation 255.255.255._____
Type the answer.
answer:240
Question 25/33
You get the IP-address 191.123.234.168/29 from your ISP. What is your
broadcast address in dotted quad?
Type the answer.
answer:191.123.234.175
Question 26/33
The file /etc/_____________ contains the information, in which order
IP-address resolutions should be proceeded.
Type the answer.
answer:resolv.conf
Question 27/33
Which of the following protocols can be used to authenticate a ppp client to
a ppp server?
Choose every correct answer.
a.chat
b.CHAP
c.PPP-AUTH
d.PAP
e.pppd
answer:b d
Question 28/33
What is the configuration file for inetd?
Choose the best answer.
a.~/.inetd.conf
b.~/.inetdrc
c./etc/inetdrc
d./etc/inetd.conf
e./etc/inetd.options
answer:d
Question 29/33
The user bob of your local system wants to read all his local mail at home.
He now asks you to forward his mail to his regular email address. What do
you do?
Choose the best answer.
a.change /etc/mail/forward
b.change /etc/sendmail.fw
c.change /etc/sendmail.forward
d.change /home/bob/.forward or show bob how to change it
e.change /home/bob/.sendmail.cf or show bob how to change it
answer:d
Question 30/33
How can you mount a NFS share?
Choose the best answer.
a.use nfsmount hostname target
b.use mount hostname:/absolute/path target
c.use nfsmount hostname sharename target
d.use mount hostname sharename target
e.NFS shares can not be mounted
answer:b
Question 31/33
What command is used to create key pairs for the ssh daemon?
Choose the best answer.
a.sshkeygen
b.ssh-keygen
c.mksshkeys
d.makekey
e.mkkeys
answer:b
Question 32/33
What syslog facility does the linux firewall use?
Choose the best answer.
a.auth
b.authpriv
c.security
d.kern
e.firewall
answer:d
Question 33/33
What is a true statement about the file /etc/nologin?
Choose the best answer.
a.It contains a list of users who may not login
b.It contains a list of users who may login
c.If it exists no user can login
d.If it exists no user except the root user can login
answer:d
一份網路上的考古題 LPIC 102
本來是要相互切磋,討論用的,
卻因為我前一陣子工作繁忙給忽略了。
真是對不起這位有心人!
102考題複習
000.Every kernel module should exactly fit the kernel for which it is
compiled. What command can you use to change the current working
directory to the directory where the modules for the running kernel are
stored? (單選)
a. cd /lib/modules/$(getkernelid)
b. cd /lib/modules/$(uname -r)
c. cd /lib/modules/$(uname -a)
d. cd $(uname --kerneldir)
e. cd $(uname --moduledir)
Ans: b (我猜的)
没錯!uname -r 很好用,
有時你會看到有的人是用倒斜線來進行命令代換,
像是你要查你現在OS所用到的模組,其相依性如何,就是記錄在 /lib/modules/`uname -r`/modules.dep 裡頭哦。
001.You can give options to the kernel (複選)
a. using the append-command in /etc/lilo.conf
b. using the options-command in /etc/lilo.conf
c. appending the options to the kernel name while using the bootmanager
d. using the chopt command while running the system
e. writing the desired options to /proc/kernel
Ans: a . c
002.What is the effect of the command init S ? (單選)
a. The system will be rebooted
b. The system will be shut down
c. The system will change into single user mode
d. The system will change into normal multi user mode
e. There is no runlevel S, runlevels are numbers
Ans: c (我猜的)
在我比較熟悉的RedHat版本中,runlevel 1和s或S,都是進到single單人模式。
003. Which command is used to show the contents of a printer queue?
(Enter just the command, no path and options)
Ans: lpq
004. You are printing with lpr. Which parameter do you use to select a
particular printer? (單選)
a. -p
b. -P
c. --printer
d. -q
e. -Q
Ans: a
005. What command offers you information about a standard Linux-tool?
(複選)
a. man
b. info
c. help
d. whatis
e. howto
Ans: a . b (我猜的)
不會用linux,找男人(man)就對了!
man這個指令,其實是用來看壓縮過後的檔案,
不信你去看/usr/share/man/man1裡頭的檔案,都是gz結尾,没錯吧。
別以為把他們解壓縮了,就是你用man看到的內容,man還藏了機關的。
想把man到的內容存下來慢慢看的話,可以用以下指令:
man bash | col -b > bash.man.txt
那個bash.man.txt,我相信才是你要用的資料檔案,
建議還是線上看啦,印出來的話,很浪費墨水和紙的。
還有info,它是比較複雜一點的使用查詢介面。比man強大,會用的話,也是有不少參考資訊。
而linux指令的使用說明,也可以在一個指令後給 (--help) 選項查。
但help也是一個指令,主要是提供bash內建指令的簡單說明。
如果你問我,那些指令是bash內建的指令?
哇哩咧!你直接打help指令看看吧!因為我一時也說不清...
至於那些非內建的指令,可以用whatis來查它的簡單使用說明。
真的很簡單!剛開始用linux的人,也許可以看看吧!
還有一個apropos指令。可以給字串當參數,讓它去找whatis的資料庫?
但使用時機,我就不太清楚了。
另外要補充的是:
man -f 等於是指令whatis
man -k 等於是指令apropos
所以以上選項,除了howto没有用以外,都是可以用來查詢linux指令用法。
我選a b c d
006. Which file is displayed directly after logging in on a text
console? (單選)
a. /etc/issue
b. /etc/login.txt
c. /etc/motd
d. /etc/messg
e. /etc/welcome
Ans: c
要登入時,會先看到/etc/issue這個檔案內容,轉換成的提示。
登入後,看到的就是/etc/motd了。
其他的選項...不管它。
007. Writing a shellscript you want to check if the file foobar exists
and is writable by the user who runs the script. Which of
the following test commands will check this? (單選)
a. test -e foobar
b. test -r foobar
c. test -b foobar
d. test -w foobar
e. test -f foobar
Ans: d
Man TEST
-b FILE FILE exists and is block special
-c FILE FILE exists and is character special
-d FILE FILE exists and is a directory
-e FILE FILE exists
-f FILE FILE exists and is a regular file
-g FILE FILE exists and is set-group-ID
-G FILE FILE exists and is owned by the effective group ID
-h FILE FILE exists and is a symbolic link (same as -L)
-k FILE FILE exists and has its sticky bit set
-L FILE FILE exists and is a symbolic link (same as -h)
-O FILE FILE exists and is owned by the effective user ID
-p FILE FILE exists and is a named pipe
-r FILE FILE exists and read permission is granted
-s FILE FILE exists and has a size greater than zero
-S FILE FILE exists and is a socket
-t FD file descriptor FD is opened on a terminal
-u FILE FILE exists and its set-user-ID bit is set
-w FILE FILE exists and write permission is granted
-x FILE FILE exists and execute (or search) permission is granted
008. Writing a shellscript you want to check if the file foobar exists
and is writable by the user who runs the script. Which of
the following test commands will check this? (單選)
a. test -e foobar
b. test -r foobar
c. test -b foobar
d. test -w foobar
e. test -f foobar
Ans: d (我猜的)
009. What command can you use to remove an existing group named foo? (單選)
a. rmgrp foo
b. delgrp foo
c. delgroup foo
d. remove --group=foo
e. groupdel foo
群組管理指令:
gpasswd
groupadd
groupdel
groupmod
groups
newgrp
chgrp
還有嗎?我再查查...
選 e
010. You want to change from old /etc/passwd format to the modern and
more save shadow password system. What command can you use for that
purpose? (單選)
a. mkshadow
b. shadow
c. sh_create
d. sh-create
e. pwconv
Ans: e (我猜的)
没錯!回復呢?用pwunconv
011. What command can be used to moitor the file /var/log/messages, to
see newly incoming messages? (單選)
a. tail -l /var/log/messages
b. tail -f /var/log/messages
c. tail -w /var/log/messages
d. cat /var/log/messages | tail -f
e. tail -10 /var/log/messages
Ans: a (我猜的)
這題要選b,這個指令若是管理linux的話,會很常用到。要背起來。
012. Enter the command (without path and options) to display information
about a given kernel module?
Ans: modinfo
013. Which file is used by modprobe to get the information, what kernel
module is needed by a particular other kernel module? (單選)
a. /etc/modules.dep
b. /etc/modules.conf
c. /lib/modules/$(uname -r)/modules.dep
d. /lib/modules/$(uname -r)/modules.conf
e. /lib/modules/$(uname -r)/modules.needed
Ans: c (我猜的)
這題在上面有提過了,選 c 没錯。
/etc/modules.conf則是設定開機時硬體需要載入的模組。
014. After compiling a new kernel on a PentiumII System, where will you
find the new kernel file? (單選)
a. /usr/src/linux
b. /usr/src/linux/kernel
c. /usr/src/linux/arch/i386/boot
d. /usr/src/linux/arch/i486/boot
e. /usr/src/linux/arch/i586/boot
Ans: c (我猜的)
015. What command can you use to read the kernel bootup messages? (Just
the command, no options)
Ans:
016. The command ____________ -r shows the release number of the
currently working kernel
Ans:
017. You have just loaded a new version of the kernel source and
installed it into /usr/src/kernelnew. In /usr/src/kernelold are the
sources of your old kernel. Before configuring the new kernel you want
to get as much configuration information as possible from the old kernel
to the new one. What file will you copy from kernelold to kernelnew to
archieve this?
a. Makefile
b. kernel.dat
c. kernel.conf
d. .config
e. .kernelconf
Ans:
018. Which file contains the main log of the system?
a. /var/mesg
b. /var/log
c. /var/log/mesg
d. /var/log/messages
e. /var/messages
Ans:d
019. How can you get informations about all manpages concerning a
command named foo?
a. apropos foo
b. whatis foo
c. man foo
d. list foo
e. which foo
Ans:
020. Which file is displayed directly after logging in on a text
console?
a. /etc/issue
b. /etc/login.txt
c. /etc/motd
d. /etc/messg
e. /etc/welcome
Ans:
021. You get a mail from user bart, in which he tells you, that he can't
execute a self written shell-script named foo. This script is placed in
the directory /home/bart and the user's current working directory is
/home/bart, too. The ls -l command shows the script and the user has
execute permission. What would probably be the reason of the problem?
a. A user may not execute scripts inside his home-directory
b. The PATH-variable don't includes the . entry
c. A normal user may not execute shellscripts anywhere
d. The enviroment-variable EXEC is not set
e. An error inside the script
Ans:
022. Which statement about the following line is true?
[ -x /usr/sbin/daemon ] && /usr/sbin/daemon
a. /usr/sbin/daemon will be executed if it exists and is executable
b. The daemon will be executed with it's own path as parameter
c. This is a recursive call to daemon
d. This isn't a valid command
Ans:
023. You have just loaded a new version of the kernel source and
installed it into /usr/src/kernelnew. In /usr/src/kernelold are the
sources of your old kernel. Before configuring the new kernel you want
to get as much configuration information as possible from the old kernel
to the new one.
What file will you copy from kernelold to kernelnew to archieve this?
a. Makefile
b. kernel.dat
c. kernel.conf
d. .config
e. .kernelconf
Ans:d (我猜的)
024. Which command will you use to control printers?
a. lpd
b. lpr
c. lpic
d. lpc
e. plp
Ans:d (我猜的)
025. What does the following entry from /etc/printcap means?
lp|lp1:\
:sd=/var/spool/lp:\
:rm=foo:\
:rp=bar:
a. This is a local Printer known as lp or lp1 with metric foo and
postscript filter bar.
b. This is a remote printer known as lp on the local machine and as lp1
on the remote machine.
c. This is a remote printer on host foo and there known as bar
d. This is a local printer which is accessable by the hosts foo and bar
e. This is a remote printer on host bar
Ans:c (我猜的)
026. The file _____________ is displayed by getty befor the login
message.
(Please enter full path and filename)
Ans: /etc/log/message (我猜的)
027. You have written a shellscript in /usr/local/bin/myscript. The
script is executable by all users. But every time when you start it, the
following error occurs: bash: myscript: No such file or directory. What
is likely to be the reason?
a. The /usr/local/bin directory is not in the PATH variable
b. You don't have read permission to myscript
c. Shellscripts are not binaries, so don't place them in a bin directory
d. You made a mistake (typo) in the #!/bin/bash line
e. You have to compile the script
Ans:b (我猜的)
028. The file /etc/syslog.conf contains the following line: *.crit
/var/log/warn
a. The syslog daemon reads its rules for all facilities with priority
"crit" or any higher priority out of the file /var/log/warn
b. All messages of all facilities with priority "crit" are written into
the file /var/log/warn
c. The file /var/log/warn contains a list of all errors which are
defined as critical
d. The syslog daemon reads its rules for all facilities with priority
"crit" out of the file /var/log/warn
e. All messages of all facilities with priority "crit" or any higher
priority are written into the file /var/log/warn
Ans: e
029. The file /etc/syslog.conf contains the following line: *.=crit
/var/log/warn
Ans: a (同上題)
030. Which criteria can be used in the logrotate configuration file to
determine when a logfile should be rotated? (複選)
a. hourly rotating
b. daily rotating
c. weekly rotating
d. monthly rotating
e. filesize
Ans:a.b.c.d (我猜的)
031. What elements may be used in a crontab file besides the scheduling
command? (複選)
a. Declaration of shell variables
b. Declaration of aliases
c. Declaration of functions
d. Declaration of a pre-exec script
e. Declaration of a post-exec script
Ans: b.c (我猜的)
032. You downloaded a file boot.img which contains the image of a
bootdisk. How can you transfer this file to a floppy disk so the disk is
bootable?
a. Mount the floppy and copy it with cp
b. Mount the floppy and copy it with rawrite
c. Use "restore boot.img > /dev/fd0"
d. Use "dd if=boot.img of=/dev/fd0"
e. Use "dd if=/dev/fd0 of=boot.img"
Ans:d (我猜的)
033. You want to set the system time, so you use the command "date
MMDDhhmm". All seems fine but after the next reboot the system time is
wrong again. What is the reason?
a. The date-command is called by an init-script which sets the wrong
time every time you boot linux
b. The date-command just sets the system time, not the cmos clock
c. Your cmos-clock runs to slow due to low battery status
d. You have to adjust the bogomips settings of your computer
Ans: b (我猜的)
034. Which service works usually on port 119 ?
a. nntp
b. http
c. pop3
d. snmp
e. imap
Ans: a
035. What is the dotted quad address of the localnet?
Ans: 192.168.1.0
036. Your network has a network address of 172.16.170.0/23. What are
valid host addresses in your network? (複選)
a. 172.16.171.0
b. 172.16.170.255
c. 172.16.171.255
d. 172.16.171.171
e. 172.16.170.0
Ans: b.d.e (我猜的) [a.c都是特殊位址]
037. You want to set the default route of your linux box to the gateway
192.168.0.1. What command do you use?
a. route add default 192.168.0.1
b. route -add default 192.168.0.1
c. route add default gw 192.168.0.1
d. route add gw 192.168.0.1
e. route add default -gw 192.168.0.1
Ans: c (我猜的)
038. What program can be used to establish a ppp connection?
a. ppp-up
b. ppp-connect
c. ppp-dial
d. wvdial
e. dial
Ans: b (我猜的)
039. You want to change from inetd to xinetd. What is necessary to do,
so that the settings from inetd can be used by xinetd?
a. Nothing, xinetd and inetd use the same configuration file
b. Rename the file /etc/inetd.conf to /etc/xinetd.conf
c. The file syntax is totaly different, so you have to write a new configuration file
d. Use the script xconv.pl, included with xinetd
e. Use the script xindet-convert, included with xinetd
Ans: d
040. What is the name of the main apache configuration file (just the name, no path)?
Ans: httpd.conf
041. What command is used to create key pairs for the ssh daemon?
a. sshkeygen
b. ssh-keygen
c. mksshkeys
d. makekey
e. mkkeys
Ans: b
042. What search option is used by the find program to find files with
SUID bit set?
a. -suid
b. -sbit
c. -perm
d. -security
e. -bit
選 c
試試 find /bin -perm +4000 -exec ls -l {} \;
LPIC Level 1 102 考古題
我把它留下來當考古題用。
基本上,這個網站若是你可以考到80分上下,我覺得實力就算是可以了。
但是千萬不要以為這裡的題目可以用來「背多分』的話,那可就大錯特錯了。
由於LPIC考的範圍廣,觀念的題目我認為比較重要。
考題的答案,我會陸續補上來.
並加上我的一些見解.
Question1/33
What command will remove a loaded kernel module?
Choose the best answer.
a.delmod
b.modrm
c.modkill
d.rmmod (v)
e.depmod
Question2/33
Which file is used by modprobe to get the information, what kernel module is
needed by a particular other kernel module?
Choose the best answer.
a./etc/modules.dep
b./etc/modules.conf
c./lib/modules/$(uname-r)/modules.dep (v)
d./lib/modules/$(uname-r)/modules.conf
e./lib/modules/$(uname-r)/modules.needed
Question3/33
You want to built a new kernel from your own. After installing the kernel
sources the next step is to configure the kernel. What command inside the
kernel directory can you use to configure the kernel?
Choose every correct answer.
a.make config (v)
b../configure
c.make menuconfig (v)
d.make xconfig (v)
e.make configure
Question4/33
What command can you use to read the boot messages of the kernel?
Choose the best answer.
a.read boot
b.cat /var/log/kernellog
c.kmem
d.dmesg (v)
e.kmesg
Question5/33
You want to activate graphical login on your Linux box so everybody can use
a secure X11. What can you do to start this service immediatly?
Choose the best answer.
a.Switch to the displaymanager runlevel (v)
b.Start the klogin program
c.Start the xlogin program
d.Start the xdm program
e.Enter the number of the displaymanager runlevel in the entry of the default runlevel in /etc/inittab.
Question6/33
Which command will you use to look at the print queues?
Choose the best answer.
a.lpd
b.lpr
c.lpq (v)
d.qpd
e.lpic
Question7/33
You are printing with lpr. Which parameter do you use to select a particular
printer?
Choose the best answer.
a.-p
b.-P (v)
c.--printer
d.-q
e.-Q
Question8/33
How can you get informations about all manpages concerning a command named
foo?
Choose the best answer.
a.apropos foo (v)
b.whatis foo
c.man foo
d.list foo
e.which foo
Question9/33
Which file is displayed directly after logging in on a text console?
Choose the best answer.
a./etc/issue
b./etc/login.txt
c./etc/motd (v)
d./etc/messg
e./etc/welcome
Question10/33
You've defined an enviroment variable FOO with the content "bar" and now you
want to start a new shell typing "bash". What of the following is neccesary
to ensure, that the variable FOO has its content "bar" also in the new
shell?
Choose the best answer.
a.Nothing,the content of a variable is automaticly inherited to the later shells.
b.You have to open the shell with a leading dot (. bash)
c.You have to type the command "export FOO" before you start the new shell. (v)
d.It is impossible to have the same variable in different shells.
e.You have to type the command "import FOO" after you've started the new shell.
Question11/33
Which files in the users home directory are read by a login shell (bash)?
Choose every correct answer.
a.~/.bash_profile (v)
b.~/.bashrc (v)
c.~/.bash_login (v)
d.~/.profile
e.~/.bash.profile
Question12/33
Writing a shellscript you want to check if the file foobar exists and is
readable by the user who runs the script. Which of
the following test commands will check this?
Choose the best answer.
a.test -e foobar
b.test -X foobar
c.test -r foobar (v)
d.test -b foobar
e.test -f foobar
Question13/33
User foo has left our company and you want to remove his account and all his
files in his homedirectory. Which of the following commands will do this?
Choose the best answer.
a.rm -rf /home/foo
b.userdel -r foo (v)
c.killuser foo
d.deluser -r foo
e.kill -HOME foo
Question14/33
What command can you use to remove an existing group named foo?
Choosethe best answer.
a.rmgrp foo
b.delgrp foo
c.delgroup foo
d.remove --group=foo
e.groupdel foo (v)
Question15/33
What program converts old /etc/passwd files to shadow password
system?(just the name without path and options)
Type the answer.
pwconv
Question16/33
You want all messages from the kernel with a priority of "warn" or higher
to be displayed on your 10th virtual terminal. What line in /etc/syslog.conf
guarantees this?
Choose the best answer.
a.kernel.warn /dev/tty10
b.kernel.=warn /dev/tty10
c.kern.warn /dev/tty10 (v)
d.kern.=warn /dev/tty10
e.kern.warn /dev/tty9
Question17/33
What program can be used to guarantee that logfiles do not grow
indefinitely?
Choose the best answer.
a.logrotate (v)
b.logcheck
c.logger
d.syslogd
e.loglimit
Question18/33
What is the difference between cron and anacron?
Choose the best answer.
a.anacron is an old (anachronistic) version of cron
b.cron jobsget lost if the computer isn't running at the given time, anacron jobs don't get lost. (v)
c.cron can only be used by root, anacron can be used by every user
d.anacron can only be used by root, cron can be used by every user
e.there is no difference
Question19/33
The command ___________ -e will open an editor where you can add new cron jobs.
Type the answer.
crontab
Question20/33
You want to make a full backup of the /home directory with cpio. It shall be
stored in the file /var/backup.home.
What is the proper command?
Choose the best answer.
a.find /home | cpio -o > /var/backup.home (v)
b.cpio -if=/home -of=/var/backup.home
c.cpio -f /var/backup.home /home/*
d.cpio -Rf /var/backup.home /home/*
e.cpio -rf /var/backup.home /home/*
Question21/33
What is the effect of the command "date +%M" ?
Choose the best answer.
a.The system time (only minutes) is adjusted using the cmos clock.
b.The current month is written to stdout
c.The current time (only minutes) is written to stdout (v)
d.The system time is adjusted plus one minute.
e.The system date is adjusted plus one month.
Question22/33
Which service works usually on port 22 ?
Choose the best answer.
a.ftp
b.ssh (v)
c.telnet
d.smtp
e.dns
Question23/33
What is the dotted quad address of the localnet?
Type the answer.
127.0.0.0/8
Question24/33
The dotted quad netmask 255.255.255.192 is in CIDR notation
Choosethe best answer.
a./25
b./26 (v)
c./27
d./28
e./29
Question25/33
You get the IP-address 191.123.234.168/29 from your ISP. What is your
network address in dotted quad?
Type the answer.
191.123.234.168
Question26/33
What command is used to set the default route?
Choose the best answer.
a.route (v)
b.setroute
c.gw
d.gateway
e.setgw
Question 27/33
What command is run by pppd after a connection was brought down?
Choose the best answer.
a.ppp-down
b.ip-down (v)
c.ppp-disconnect
d.ppp-offline
e.pppdown
Question 28/33
You want to restrict access to your services, so that only hosts from your
local network 192.168.1.0 can use them. What entries in /etc/hosts.allow and
/etc/hosts.deny will you use?
Choose the best answer.
a."ALL:192.168.1.0" in hosts.allow and "ALL:ALL BUT 192.168.1.0" in hosts.deny (v)
b."ALL:192.168.1." in hosts.allow and "ALL:ALL" in hosts.deny
c."ALL:192.168.1." in hosts.allow and "ALL: NONLOCAL" in hosts.deny
d."ALL:ALL" in hosts.allow and "ALL:LOCAL" in hosts.deny
e."ALL:LOCAL" in hosts.allow and an empty hosts.deny
Question29/33
What is the central configuration file for sendmail?
Choos ethe best answer.
a./etc/sendmail.conf
b./etc/mail/sendmail.conf
c./etc/sendmail.cf (v)
d./etc/mail.co
e./etc/sendmail.co
Question30/33
In what file do you declare, what host may use what directory of our
local linux box using nfs?
Choose the best answer.
a./etc/nfs.conf
b./etc/nfsd.conf
c./etc/nfsexports
d./etc/exports (v)
e./etc/hosts.allow
Question31/33
What is the main configuration file of a BIND8 nameserver?
(just the name without path)
Type the answer.
named.conf
Question32/33
What are the default tables of iptables?
Choose the best answer.
a.input output and forward
a.accept,deny and reject
a.filter,nat and mangle (v)
a.postrouting and prerouting
Question33/33
If the file /etc/nologin exists, no user can login into your system. But
what happens with already logged in users if you create this file?
Choose the best answer.
a.they are automatically logged out
b.they receive a message on their screens that they should log out
c.nothing (v)
2007年12月15日 星期六
在grub開機畫面加入底圖
網路上總是有各式各樣的玩家提供許許多多的技巧,
只要你願意,linux就可以變成你想要的模樣。
也許也有更多的電腦玩家會說,
在M$ windows的世界裡,我也能改造我的windows啊!
而且更棒更炫!
啊哈!那就是青菜蘿蔔各有所好的因素了。
没什麼好爭的。
這回我想改造的玩意,
是依附在grub裡頭的東東!
grub現在己經是linux通用的開機管理軟體了,
由於功能愈改愈強大,
現在己經能把圖檔嵌入開機的畫面中了。
改造出一個專屬的grub開機畫面,
這個主題應該可以吸引你來學學怎麼做吧。
OK!Just do it.
在 grub 內要達到這個目的,有幾個規則要遵守。
1.圖檔最好限制在 640 x 480 (像素)。
2.顏色最多 14 色,而且檔案格式為是xpm。
3.需經過 gzip 壓縮為 gz 檔
4.圖檔相關設定要加在grub軟體的設定檔,menu.lst 之中
來,讓我用以上的四項規則,一步一步來完成這次的任務吧。
為了示範,我找了張全家福照片。
(看看就好,你應該不會用我的全家福照片吧!)
圖一:
你可以不用管這圖片是什麼檔案格式,但是你一定要把它改成是640 x 480 像素的圖檔!
因為我們使用linux,所以當然用GIMP來改造你的圖檔囉。
改好圖檔的大小後,先把它存成PNG檔案格式。(BMP,JPG,TIF也都行!)
完成規則一。
接著,用convert程式來轉檔,把你之前的PNG圖檔轉成XPM格式。
並且把圖檔的顏色轉到14色,這個限制以內。
指令如下:
bullock@ubuntu:~$ convert -colors 14 myfamily.png myfamily.xpm
在此要注意一點,如果你的系統没有convert指令可用的話,
那麼你就必須安裝 imagemagick 這個套件。
由於我用ubuntu的緣故,所以我安裝套件的指令如下:
bullock@ubuntu:~$ sudo apt-get install imagemagick
到此規則二完成!
bullock@ubuntu:~$ gzip myfamily.xpm
用gzip指令完成規則三!簡單吧。
最後一個規則,
設定好 grub 的 menu.lst 檔案。
由於要讓grub好管理這個新設定,以及這個壓縮過的圖檔。
我們把它放到 /boot/grub/ 和menu.lst 一起。
bullock@ubuntu:~$ sudo cp grubsplash.xpm.gz /boot/grub/
接著編輯 /boot/grub/menu.lst ,將圖檔資料加入。
bullock@ubuntu:~$ sudo vi /boot/grub/menu.lst
加入一行,內容如下:
splashimage (hd0,2)/grub/myfamily.xpm.gz
好了,重新開機檢視你的成果吧。
圖二:(我用Virtual Box抓下來的)
2007年12月4日 星期二
蝴蝶結的打法
蝴蝶結的打法?
没錯,吳大這次要記錄下來的日誌居然是如何打蝴蝶結!
吳大:
我不懂?為什麼我們資訊人員也要學包裝?
主管:
多學一項技能不是很好嗎?有時候你們也可能去賣場支援啊。
吳大:
去支援?不會吧!難道我們資訊設備有問題時,別的部門有可能來支援嗎?本來就是不同的工作內容了,怎麼會要我們去支援賣場呢?
主管:
這是店長的指示,將來你們還要學結帳哩。
反正百貨業就是這樣,包裝,結帳等,都是員工的基本技能,都至少要懂一些就是了。
上完課要考試哦!
吳大:
哇哩咧!考試...
我還没考完LPI呢。
反正就是這樣啦!
上完課,趕緊來惡補一下,怎麼把蝴蝶結搞定吧。
包裝紙的部分是學會了,但奇怪,那個蝴蝶結就是搞不定...
下面是我看過最簡單明解的圖解說明了。
轉貼過來做備忘。
來源:Bonnie & Crafts
以下引文開始:
很簡單的幾個訣竅跟大家分享~
1. 先打個結(注意正反面):
2. 左邊的緞帶抓出耳朵
3.將右邊的緞帶從耳朵前面繞過(記得翻面):
4. 接下來從耳朵後方繞上去(再次翻面):
5. 跟第3個步驟一樣繞到前面(第2個耳朵產生!):
6.把第2個耳朵從剛剛繞的圈圈塞過去:
7. 第2個耳朵也歸位啦!接下來只要拉緊調整就好了~
2007年11月11日 星期日
磁帶機使用(轉貼)
2007-10-24
環境:Ubuntu 7.04 feisty, HP DAT-72 usb外置磁帶機。
基本概念
* 磁帶是線性存放裝置,沒有什麼分區表的概念,磁頭在哪裡,就從哪裡開始讀。
* 磁帶機好像只能用root用戶操作。
* 磁帶上可以劃分存儲空間,每個存儲空間有一個file number,從0開始順序排列。
* 磁頭在存儲空間中的位置用block number來表示,0代表開始,大於0的整數代表塊,比如39代表磁頭在本file number的第39塊的位置,而-1則代表磁頭位於本file number的結尾。
* 同樣一部磁帶機,用/dev/st0時是當自動回卷設備使用,每次操作完成之後,磁頭都返回file number=0, block number=0, BOT的位置;而用/dev/nst0調用時,操作完成時磁頭就停在那個位置,不會回到開頭。
* 使用nst非回卷方式,用tar tvf列檔,只有當block number=0時才能出內容,並且列完之後block number為大於0的整數,注意這並不代表本段存儲空間的結尾(-1)。
由於磁帶機本身具有壓縮功能,所以添加檔的時候不建議指定zip或者bz2壓縮,因為如果一點點壓縮後的資料損壞,會導致全部內容不可識別;如果的確需要壓縮的話,可以壓縮成本地檔再存儲到磁帶上,減少對其他檔的影響。
自動回卷的使用方式
這種方式比較簡單,用tar直接操作即可,基本上和tar操作本地檔相同。
往新磁帶上存儲檔,注意如果磁帶上已有檔,會被覆蓋掉:
tar cvf /dev/st0 file_to_store
向磁帶上添加檔:
tar rvf /dev/st0 file_to_store
更新磁帶上的同名檔:
tar uvf /dev/st0 file_to_store
列出磁帶上的現有檔:
tar tvf /dev/st0
刪除磁帶上的檔:
tar vf /dev/st0 --delete file_to_delete
但我使用這個命令的時候總是提示錯誤,檔倒是刪掉了,可查看的時候也總有錯誤資訊,難道是無法刪除,或者只能全部xvf出來再存到磁帶上?不過我們也應當養成一個好的習慣,每次向磁帶機存儲檔的時候一定要在檔案名中帶上日期標記。
非自動回卷的使用方式
一般這樣使用,都是用到多個存儲空間file number的時候;如果還是一個存儲段,只是手工移動檔指標就沒有什麼意義了。
在操作上,檔的存儲方式和自動回卷是基本相同的,不同之處在於要注意磁頭的位置,並且手工進行必要的位移,以一個新磁帶的操作為例來說明(status我只截取有用的部分顯示):
# mt -f /dev/nst0 status
file number = 0
block number = 0
General status bits on (41010000):
BOT ONLINE IM_REP_EN
存入一個新的檔A:
# tar cvf /dev/nst0 A
A
# mt -f /dev/nst0 status
file number = 1
block number = 0
General status bits on (81010000):
EOF ONLINE IM_REP_EN
注意這時磁頭已經移動到了第二段存儲空間了,現在再存入一個新的檔B,當然B和A是不在一個存儲空間中的:
# tar cvf /dev/nst0 B
B
# mt -f /dev/nst0 status
file number = 2
block number = 0
General status bits on (81010000):
EOF ONLINE IM_REP_EN
磁頭又移動到第三段存儲空間了,如果要查看剛才存的第二段存儲空間中的內容,需要先移動磁頭:
# mt -f /dev/nst0 bsf 2
# mt -f /dev/nst0 status
file number = 0
block number = -1
General status bits on (1010000):
ONLINE IM_REP_EN
# mt -f /dev/nst0 fsf 1
# mt -f /dev/nst0 status
file number = 1
block number = 0
General status bits on (81010000):
EOF ONLINE IM_REP_EN
由於有存儲空間結束標記,所以這裡採用退2進1的方式,詳細的磁頭移動方式可以看man mt。然後查看文件列表:
# tar tvf /dev/nst0
-rw-r--r-- root/root 21194792 2007-10-24 11:37 B
# mt -f /dev/nst0 status
file number = 1
block number = 2070
General status bits on (1010000):
ONLINE IM_REP_EN
列出檔清單之後,磁頭停在了檔結束的位置,但不是存儲空間的結尾。現在移動磁頭到本段存儲空間的開始,並且添加檔C:
# mt -f /dev/nst0 bsf 1
# mt -f /dev/nst0 status
file number = 0
block number = -1
General status bits on (1010000):
ONLINE IM_REP_EN
# mt -f /dev/nst0 fsf 1
# mt -f /dev/nst0 status
file number = 1
block number = 0
General status bits on (81010000):
EOF ONLINE IM_REP_EN
# tar rvf /dev/nst0 C
C
# mt -f /dev/nst0 status
file number = 2
block number = 0
General status bits on (81010000):
EOF ONLINE IM_REP_EN
首先還是要移動磁頭,到這裡基本上可以發現mt的fsf和bsf的規律了,fsf是磁頭向前移動,並且總是停留在block number = 0的位置,而bsf是磁頭向後移動,總是停留在 block number = -1的位置。添加完成檔之後,磁頭又定位到了第三個存儲空間(下一個)的開始。現在我們依然是移動磁頭到第二段存儲空間開始,並且用覆蓋方式添加檔 D:
# mt -f /dev/nst0 bsf 2
# mt -f /dev/nst0 fsf 1
# mt -f /dev/nst0 status
file number = 1
block number = 0
General status bits on (81010000):
EOF ONLINE IM_REP_EN
# tar cvf /dev/nst0 D
D
# mt -f /dev/nst0 status
file number = 2
block number = 0
General status bits on (81010000):
EOF ONLINE IM_REP_EN
檔D是用覆蓋方式添加的,所以剛才添加的檔B和C現在應該都消失了:
# mt -f /dev/nst0 bsf 2
# mt -f /dev/nst0 fsf 1
# mt -f /dev/nst0 status
file number = 1
block number = 0
General status bits on (81010000):
EOF ONLINE IM_REP_EN
# tar tvf /dev/nst0
-rw-r--r-- root/root 34201298 2007-10-24 11:57 D
# mt -f /dev/nst0 status
file number = 1
block number = 3341
General status bits on (1010000):
ONLINE IM_REP_EN
完成,回卷磁帶,從開始一直tvf:
# mt -f /dev/nst0 rewind
# tar tvf /dev/nst0
-rw-r--r-- root/root 341054 2007-10-24 11:37 A
# tar tvf /dev/nst0
# tar tvf /dev/nst0
-rw-r--r-- root/root 34201298 2007-10-24 11:57 D
# tar tvf /dev/nst0
# tar tvf /dev/nst0
# tar tvf /dev/nst0
tar: /dev/nst0: Cannot read: Input/output error
tar: At beginning of tape, quitting now
tar: Error is not recoverable: exiting now
# mt -f /dev/nst0 status
file number = 2
block number = -1
General status bits on (9010000):
EOD ONLINE IM_REP_EN
現在,能看懂這個了麼?我用空行隔開的位置正好是block number為0的位置。還有一些其他的操作就比較簡單了:
出帶,將磁帶卷至初始位置然後從磁帶機內彈出
# mt –f /dev/nst0 offline
清除磁帶中的所有內容,特慢,還傷帶,輕易不要用
# mt –f /dev/nst0 erase
我的幾個疑問
* 如何刪除file number?
* 既然磁帶是線性存儲,如果向前面一個file number中添加檔,存儲空間不夠怎麼辦?
小結
搞明白磁帶機的存儲方式和基本操作,用起來就簡單了。個人感覺如果要存的檔數量不多,尤其是只需要存幾個大檔的情況,直接用自動回卷方式,只使用一個存儲空間就可以了,這樣操作比較簡單。如果一定要用磁帶存儲複雜結構的資料,可以考慮手工在各個存儲空間之間來回切換的方式,原理都是一樣,只是更高一點點的技巧和小心。
同時,保存一份磁帶上現有檔的索引也是非常有必要的(tvf的結果),既方便檔的查找,也可以由此推算出磁帶上的剩餘空間大小。
參考
How to use the DAT-tape with Linux
This document describes how to use the DAT-tape standing besides Gettysburg with the Linux machine cs-zz12. It asumes some familiarity with Linux or other UNIX-systems. It is itentionaly kept short, so that you can find the important information quickly. If you are in a hurry, check the typical sessions section.
Tape organisation
The tape is structured in multiple files which are in a sequential order. The individual files are usually tar-archives. You can always append new files (tar-archives) to the tape (if there is enough space left).
Handling the tape
Insert the tape softly with the arrow on the upper side, pointing in the direction of the drive.
It will then be sucked in automatically. Ejecting the tape is done with the mt-command (see below).
Important: Before the first "mt" or "tar" command, you must switch the SCSI Switch to "1". Otherwise the system will fail to recognize the SCSI devices (including the tape drive).
Tape operation
You can operate the tape with the command "mt" (magnetic tape). You use it like this: "mt -f /dev/nst0 command". For more detailed information, see the man page. Examples are given below. The most important commands are:
* stat: prints the current status of the tape such as
o file number: The number of the file where the tape currently is (where 0 is the first file, -1 is the last).
o block number: The block number in the current file (here too, 0 is the first block and -1 is the last one).
* rewind: rewind the tape to its beginning.
* fsf
* bsf
* eom: Wind to end of media. Useful to append new files to the end of the tape.
* offline: Rewind the tape and eject it.
Examples for the mt-command
* To get the status of the tape: mt -f /dev/nst0 stat
* Rewind the tape to the start: mt -f /dev/nst0 rewind
* Wind to the next file on tape: mt -f /dev/nst0 fsf 1
Transfering data to and from the tape
You usually do this with the "tar" command. "Tar" always needs the parameter "-f" with the corresponding device, in this case "/dev/nst0". The parameter "-v" (verbose) is also suggested. The other parameters you usually need are:
* -c: Create (overwrite) tar-archive. If you overwrite a tar-file which is not the last one on the tape, all files after the overwritten one are lost!
* -x: Extract from tar-archive at current position on tape.
* -t: List contents of tar-archive at current position on tape.
Examples for tar-command
* List the contents of the next tar-file on the tape: tar -tvf /dev/nst0
* Put the directory (or files and directories)
* Extract everything from the next tar-file on the tape into the current directory: tar -xvf /dev/nst0
* Extract (only)
Typical sessions
Backup / Store
1. Insert tape in tape drive and probably switch SCSI Switch to one.
2. Check status of tape: mt -f /dev/nst0 stat
3. Probably go to end of tape: mt -f /dev/nst0 eom
4. Store
5. Rewind and eject tape: mt -f /dev/nst0 offline
Restore
1. Insert tape in tape drive and probably switch SCSI Switch to one.
2. Check status of tape: mt -f /dev/nst0 stat
3. Go to the directory where you want to restore your file(s).
4. Go to the right file on the tape with the following commands:
* Check file number and position in file: mt -f /dev/nst0 stat
* Advance one file: mt -f /dev/nst0 fsf 1
* View contents of tar-file: tar -tvf /dev/nst0
* Go back one file: mt -f /dev/nst0 bsf 1
* If you are in the last block of a file and you should be at the beginning of the file, do the following:
1. mt -f /dev/nst0 bsf 1
2. mt -f /dev/nst0 fsf 1
And check with: mt -f /dev/nst0 stat
5. Extract your file(s): tar -xvf /dev/nst0 [
6. Rewind and eject tape: mt -f /dev/nst0 offline
Remote operation
If your tape drive is in another machine than the machine you want to backup from, you can use the same tar-commands as described above with one little change: Login to the machine where the data is and instead of the tar-archive filename /dev/nst0, you specify hostname:/dev/nst0 (where hostname is the name of the machine where the tape-drive is). If you need to be another user on the machine with the drive to access the tape, you can even use the filename user@hostname:/dev/nst0.
The mt command must still be executed on the machine where the tape drive is. There is no remot-mt as far as I know.
Last change: 21 February 2001
rauch@inf.ethz.ch
2007年11月8日 星期四
掛載SCSI磁帶機到HP DL380(RHEL3)上
機器:HP ProLiant DL 380 G4 安裝RHEL3(Update4)
裝置:HP storgeworks DAT72(SCSI介面)
目的:如何正確掛載磁帶機上去,好正常運作!進行備份作業。
經查詢一些網路文件後,說是HP這款機器,
若是裝Linux Kernel 2.4的話,
會有cciss controller(SCSI陣列控制器)找不到磁帶機設備的問題,
必須在開機後,手動載入。
http://www.cpqlinux.com/cciss-tape.html
這篇文章可以參考一下!
一般Rad Hat的設備配置,
磁帶機設備會是/dev/st0甚至是/dev/st1。
也就是說,當我們用磁帶機命令查詢狀況時,
[root@dbsrv root]#mt -f /dev/st0 status
應該會有一些訊息出現!
可是在没有正確載入磁帶機設備的情形下,
我看到的結果是...
[root@dbsrv root]# mt -f /dev/st0 status
/dev/st0: No such device
哇哩咧!没有這個設備...天啊!那我的磁帶機不就...
磁帶機可是備份機制不可或缺的角色耶,
當然要趕緊讓它能正常運作!OK!
先檢查一下磁帶機設備要用得到的module有没有。
#lsmod | grep st
要是没有的話,可以用modprobe指令手動載入。
#modprobe st
好,有了支援的模組,
接下來重新註冊scsi設備到cciss controller裡頭。
[root@dbsrv root]# ls -l /proc/driver/cciss
total 0
-rw-r--r-- 1 root root 0 Nov 9 12:12 cciss0
看到控制器的文件了!註冊吧。
[root@dbsrv root]#echo "engage scsi" > /proc/driver/cciss/cciss0
若是你的機器控制器文件不至一個,
可以用迴圈處理,不必笨笨的一個一個echo。
#for x in /proc/driver/cciss/cciss[0-9]*
#do
#echo "engage scsi" > $x
#done
在那個echo "engage scsi"指令之後,會在/proc/scsi目錄下產生和cciss0有關的文件。
讓我們再一次檢查硬體資訊。用dmesg。
[root@dbsrv root]# dmesg | grep st0
Attached scsi tape st0 at scsi1, channel 0, id 0, lun 0
好像有抓到st0裝置了哦!再下一次磁帶機指令確認狀況!
[root@dbsrv root]# mt -f /dev/st0 status
SCSI 2 tape drive:
File number=-1, block number=-1, partition=0.
Tape block size 0 bytes. Density code 0x0 (default).
Soft error count since last status=0
General status bits on (50000):
DR_OPEN IM_REP_EN
哈!哈!哈!任務完成!
磁帶機終於能用了。
附帶說明,網路上看到的文件是說,若還是抓不到,
還有兩個指令可強制掃描磁帶機設備。
#echo "rescan" > /proc/scsi/cciss0/1
或是
#echo "rescan" > /proc/driver/cciss/cciss0
不過由於我的狀況是只要echo "engage scsi"就可以把裝置抓到,所以不知道以上那兩個指令有没有差啦。
大家針酌用囉。
OK!狀況好像解除,但是...
只要重新開機,那個echo "engage scsi"都要手動做一次,不是很煩嗎?
所以我當然要能夠讓echo "engage scsi"可以在開機時自動執行才對。
把之前那個迴圈拿來好好運用吧。
vi一個命令稿scsiengage存到/etc/init.d/路徑下。
內容:
#!/bin/sh
# chkconfig: 345 99 01
# description: engage scsi devices to cciss controller
# /etc/rc.d/init.d/scsiengage
# This script file is created by WuKuoHoung 2007/11/09
modprobe st
for x in /proc/driver/cciss/cciss[0-9]*
do
echo "engage scsi" > $x
done
編輯好後,用chkconfig管理!
別忘了加上可執行的檔案屬性。
[root@dbsrv root]# chmod u+x /etc/init.d/scsiengage
[root@dbsrv root]#chkconfig --add scsiengage
[root@dbsrv root]#chkconfig --list scsiengage
scsiengage 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@dbsrv bk]# find /etc/ -type l | grep scsiengage
/etc/rc.d/rc0.d/K01scsiengage
/etc/rc.d/rc1.d/K01scsiengage
/etc/rc.d/rc2.d/K01scsiengage
/etc/rc.d/rc3.d/S99scsiengage
/etc/rc.d/rc4.d/S99scsiengage
/etc/rc.d/rc5.d/S99scsiengage
/etc/rc.d/rc6.d/K01scsiengage
好了!chkconfig自動幫我們建好在開關機自動執行的link了。
要注意的是,用echo "engage scsi"之後,註冊好的scsi裝置,是不能再卸除的。除非關機!
所以這個scsiengage命令稿並没有像其他在/etc/init.d/的命令稿,
有著start|stop|restart|reload|status等啓動參數可用。因為没必要!了乎。
2007年11月5日 星期一
LAMP建置下載參考用
Apache v2.0.54 官網: http://www.apache.org
http://www.apache.org/dist/httpd/httpd-2.0.54.tar.gz [7.16MB]
PHP v4.3.11 官網: http://www.php.net
http://cn.php.net/distributions/php-4.3.11.tar.gz [4.64MB]
Zend Optimizer v2.5.10 官網: http://www.zend.com
http://downloads.zend.com/optimizer/2.5.10/ZendOptimizer-2.5.10-linux-glibc21-i386.tar.gz [3.36MB]
MySQL v4.0.24 官網: http://www.mysql.com
http://ftp.stu.edu.tw/pub/Unix/Database/Mysql/Downloads/MySQL-4.0/mysql-4.0.24.tar.gz [16.1MB]
GD Library v2.0.33 官網: http://www.boutell.com/gd/
http://www.boutell.com/gd/http/gd-2.0.33.tar.gz [573KB]
FreeType v2.1.10 官網: http://www.freetype.org
http://savannah.nongnu.org/download/freetype/freetype-2.1.10.tar.gz [1.31MB]
Jpeg v6b 官網: http://www.ijg.org
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz [598KB]
LibPNG v1.2.8 官網: http://www.libpng.org/pub/png/
http://switch.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz [498KB]
OpenSSL v0.9.7g 官網: http://www.openssl.org
http://www.openssl.org/source/openssl-0.9.7g.tar.gz [2.98MB]
vsftpd v2.0.3 官網: http://vsftpd.beasts.org
ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.0.3.tar.gz [149KB]
zlib v1.2.2 官網: http://www.gzip.org/zlib/
RHEL3(update4)手動更新AMP
也就是Apache+MySQL+PHP。
一開始建置主機環境時,是安裝RHEL3(update4)Server環境,
但我現在要它能跑Apache2,MySQL5以及PHP5。
因此之前裝的套件,我都不能再用了。
也由於我們買的RHEL3並没有完成註冊,
而要更新套件我也不想去找原廠的服務,
於是只有自已來手動更新了!
網路上對RHEL3更新AMP的文件不好找,
我原本有以CentOS替代的念頭,
但想到這個改裝OS的大動作,要是主管問起一些奇奇怪怪的問題,
我可能不好回應!
還是維持OS的版本好了!
步驟大致有12個!簡述如下:
Step 1: 配合apache2,更新zlib
Step 2:安裝 OpenSSL
Step 4:安裝支援jpeg的套件
Step 5:加裝freetype
Step 6:加裝libpng
Step 7:安裝 GD Library
Step 8:安裝libiconv
Step 9:進行Apache更新
Step 10:安裝MySql5
Step 11:安裝php5
Step 12:進行 Zend Optimizer
要安裝的套件原始碼tarball
#wget http://ftp.isu.edu.tw/pub/Sun/freeware/SOURCES/zlib-1.2.3.tar.gz
#wget http://ftp.isu.edu.tw/pub/FreeBSD/ports/distfiles/openssl-0.9.7g.tar.gz
#wget http://ftp.acc.umu.se/pub/gnome/sources/libxml2/2.6/libxml2-2.6.16.tar.gz
#wget http://ftp.isu.edu.tw/pub/Unix/GNU/ftp/gnu/ghostscript/jpegsrc.v6b.tar.gz
#wget http://ftp.isu.edu.tw/pub/Sun/freeware/companioncd/sources/freetype-2.1.10.tar.gz
#wget http://ftp.isu.edu.tw/pub/Sun/freeware/SOURCES/libpng-1.2.8.tar.gz
#wget http://ftp.isu.edu.tw/pub/Sun/freeware/SOURCES/gd-2.0.33.tar.gz
#wget http://ftp.ntu.edu.tw/gnu/gnu/libiconv/libiconv-1.10.tar.gz
#wget http://apache.cdpa.nsysu.edu.tw/httpd/httpd-2.0.54.tar.gz
#wget http://downloads.zend.com/optimizer/2.5.10/ZendOptimizer-2.5.10-linux-glibc21-i386.tar.gz
OK,找到一些資料後,開始動手...
Step 1: 配合apache2,更新zlib
#wget http://ftp.isu.edu.tw/pub/Sun/freeware/SOURCES/zlib-1.2.3.tar.gz
#tar zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.3
#./configure
ps/若是以前裝過zlib,可以不指定路徑,不然建議用 ./configure --prefix=/usr/local/zlib
#make
#make install
Step 2:安裝 OpenSSL
#wget http://ftp.isu.edu.tw/pub/FreeBSD/ports/distfiles/openssl-0.9.7g.tar.gz
#tar zxvf openssl-0.9.7g.tar.gz
#cd openssl-0.9.7g
#./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl
#make
#make install
#ln -s /usr/local/ssl /usr/lib/ssl
ps/OpenSSL安裝時,也建議用以下這方式,參數略有不同。
#cd openssl-0.9.7g
#./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
#make
#make install
ln -s /usr/local/ssl /usr/lib/ssl
Stpe 3:支援xml用的libxml
#wget http://ftp.acc.umu.se/pub/gnome/sources/libxml2/2.6/libxml2-2.6.16.tar.gz
ps/我常去找套件的義守大學FTP伺服器,剛好没有這個,還好用google找到另一個載點。
#tar -zxvf libxml2-2.6.16.tar.gz
#cd libxml2-2.6.16
#./configure
ps/可不必指定路徑,看參考文件是說安裝php可能找不到它,因為PHP5只支持libxml2-2.5.10以上版本!
#make
#make install
Step 4:安裝支援jpeg的套件、### jpeg ### jpegsrc.v6b.tar.gz ###
#wget http://ftp.isu.edu.tw/pub/Unix/GNU/ftp/gnu/ghostscript/jpegsrc.v6b.tar.gz
#tar zxvf jpegsrc.v6v.tar.gz
#cd jpeg-6b
ps/接下來有點麻煩,竟然要自己手動建目錄,可能是編譯文件没定義進去吧?
#mkdir /usr/local/jpeg
#mkdir /usr/local/jpeg/bin
#mkdir /usr/local/jpeg/lib
#mkdir /usr/local/jpeg/include
#mkdir /usr/local/jpeg/man
#mkdir /usr/local/jpeg/man/man1
ps/注意,是數字一,別搞錯了。
#./configure --prefix=/usr/local/jpeg --enable-shared
ps/configure 之後的參數 一定要有--enable-shared,不然不會生成共享的函式庫。
#make
#make install 或 make install-lib
Step 5:加裝freetype
#wget http://ftp.isu.edu.tw/pub/Sun/freeware/companioncd/sources/freetype-2.1.10.tar.gz
#tar zxvf freetype-2.1.10.tar.gz
#cd freetype-2.1.10
#./configure --prefix=/usr/local/freetype
#make
#make install
Step 6:ksr 加裝libpng
若是用libpng-1.2.8.tar.gz有問題,可改用libpng-1.2.18.tar.gz。
#wget http://ftp.isu.edu.tw/pub/Sun/freeware/SOURCES/libpng-1.2.8.tar.gz
#tar -zxf libpng-1.2.18.tar.gz
#cd libpng-1.2.8
#./configure --prefix=/usr/local/libpng(可能會提示說找不到命令script)
//////////////////////////////////////////////////////////////////////////////////////////////////////////
There is no "configure" script in this distribution of
libpng-1.2.8.有錯誤時的提示內容。
Instead, please copy the appropriate makefile for your system from the
"scripts" directory. Read the INSTALL file for more details.
Update, July 2004: you can get a configure based distribution
from the libpng distribution sites. Download the file
libpng-1.2.8-config.tar.gz
////////////////////////////////////////////////////////////////////////////////////////////////
#make
#make install
ps/注意:如果提示找不到命令script則先執行以下命令。手動生成Makefile!
#cp scripts/makefile.linux makefile
Step 7:安裝 GD Library
#wget http://ftp.isu.edu.tw/pub/Sun/freeware/SOURCES/gd-2.0.33.tar.gz
#tar -zxvf gd-2.0.33.tar.gz
#cd gd-2.0.33
#./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png --with-zlib
#make
#make install
Step 8:安裝libiconv
#wget http://ftp.ntu.edu.tw/gnu/gnu/libiconv/libiconv-1.10.tar.gz
#tar -zxvf libiconv-1.10.tar.gz
#cd libiconv-1.10
#./configure --prefix=/usr/local/libiconv
#make
#make install
ps1/將iconv.h連接到php的安裝source檔的程序中,不然好像進行php 的make會有錯誤
ps2/以下命令備用
# cd /usr/src/php-5.1.2/ext/iconv/
# link /usr/local/libiconv/include/iconv.h iconv.h
Step 9:進行Apache更新
因為php5一定要用Apache2,安裝時要注意一下版本!
cd httpd-2.0.54(php5安装环境需要apache2.0.46以上版本,下载时注意!)
#wget http://apache.cdpa.nsysu.edu.tw/httpd/httpd-2.0.54.tar.gz
#tar zxvf httpd-2.0.54.tar.gz
#./configure --prefix=/usr/local/apache --enable-module=so
ps/以下那行也行,針酌用。
#./configure --prefix=/usr/local/apache --enable-so --enable-ssl
#make
#make install
Step 10:安裝MySql5
到 http://downloads.mysql.com/archives.php 下載RPM即可!
MySQL-client-standard-5.0.27-0.rhel3.i386.rpm
MySQL-devel-standard-5.0.27-0.rhel3.i386.rpm
MySQL-server-standard-5.0.27-0.rhel3.i386.rpm
MySQL-shared-standard-5.0.27-0.rhel3.i386.rpm
#rpm -ivh MySQL-*
或
#rpm -ivh --nodeps MySQL-*
ps1/有可能提示需要安裝perl-DBI-1.32-9.i386.rpm,視狀況。
ps2/若有因為原套件的衝突。可以參考用...
#rpm -e --nodeps 套件名
移除之後應該就可以順利安裝了。
安裝完後,我們測一下資料庫是否正常運作了。
#service mysql start
ps/若是用service mysqld start會有問題, 因為它是舊的版本。
出現成功啓動的訊息後,登入看看...
#mysql -u root -p
Enter password:
因為剛裝好,密碼應該是空的。直接按Enter即可登入!
Welcome to the MySQL monitor. Commands end with ; or \g.
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
mysql>select version();
+-----------------+
| version() |
+-----------------+
| 5.0.27-standard |
+-----------------+
1 row in set (0.05 sec)
OK了!exit出來吧。
Step 11:安裝php5
去php的官網找!
下載回來後解開它...
#tar -zxvf php-5.2.0.tar.gz
#cd php-5.2.0
#./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-xml \
--with-mysql \
--with-freetype-dir=/usr/local/freetype \
--with-gd=/usr/local/gd \
--with-zlib \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir=/usr/local/libpng \
--with-iconv=/usr/local/libiconv \
--with-config-file-path=/usr/local/lib \
--disable-debug \
--enable-safe-mode \
--enable-trans-sid \
--enable-memory-limit \
--enable-short-tags \
--disable-posix \
--enable-exif \
--enable-ftp \
--enable-sockets
#make
#make install
ps/如果你順利完成install了,記得複制php.ini。
#cp php.ini-dist /usr/local/php/lib/php.ini
编辑apache配置文件httpd.conf
#vi /usr/local/apache/conf/httpd.conf(注意:为安装目录下配置文件)
要改幾個地方:
AddType application/x-tar .tgz下加一行
AddType application/x-httpd-php .php
找到#LoadModule php5_module modules/libphp5.so 把註解#去掉
找到DirectoryIndex index.html 追加index.php讓index.php可以做啓始頁面。
可能安裝時没訂好參數,user和group有錯誤,需修正。
找到User Group兩行。修改如下!
User apache
Group apache
再找#ServerName 把#去掉,修正成你正確的IP值。
最後是改DocumentRoot的值。把/usr/local/apache/htdocs改成你實際要存放網頁文件的路徑。
還有若是有設AddDefaultCharset的話,把它拿掉吧。有的網頁反而這樣才顯示正常。
#/usr/local/apache/bin/apachectl start 啓動apache
因為不是用rpm安裝,所以service httpd restart指令不用再用。
除非你有動手設定修改!
Step 12:進行 Zend Optimizer
#wget http://downloads.zend.com/optimizer/2.5.10/ZendOptimizer-2.5.10-linux-glibc21-i386.tar.gz
#tar zxvf ZendOptimizer-2.5.10-linux-glibc21-i386.tar.gz
#cd ZendOptimizer-2.5.10-linux-glibc21-i386
#./install
#cp data/5_0_x_comp/ZendOptimizer.so /usr/local/lib
ps/配置相對應的php.ini目錄,修改你所需的項目。
到你的網頁目錄下,編輯index.php 內容是:
OK!找台電腦,開啓FireFox或IE ...看到php的畫面,成功完成全部的套件安裝。
2007年10月27日 星期六
ORACLE安裝環境設定script
吳大:每次裝好丢入資料,只要覺得資料庫好像有問題,我就要重裝,
老是重複key那些環境參數,煩死了!
吳大的同事:啊你不是在學怎麼寫linux的shell script嗎?就拿這個當題目,寫個script吧!
吳大:對哦!我怎麼没想到!唉呀,真是聽君一席話,勝讀十年書哪。
於是,有了以下這個檔案。
有興趣的朋友,試用看看吧!
如果對大夥有幫助的話,也算是功德一件,對吧!阿彌陀佛。
還有,要是有人覺得該怎麼改比較好,有不錯的建議,請mail給我!
mailto:bullock0425@gmail.com
對了!忘了說明一件事,我是用在CentOS4上,我用在RHEL3或RHEL4也行。
只要是用rpm的linux distribution,應該都適用吧!我想。
save as "preinstalloracle.sh"
+--------------------------------------------------------------------------------------------------------------------------------+
#!/bin/bash
# Before your installation for oracle 10g database
# make sure your OS has the packages suport to install oracle 10g database
# This script file is created by Wu KuoHoung. 2007/10/27
datevalue=`date +"%Y/%m/%d %H:%M:%S"`
echo "# oracle 10 database setting ... $datevalue"
echo -e "Check the packages:\n"
rpm -qa binutils compat-* control-center gcc* glibc* gnome-libs libstdc* make pdksh sysstat xscreensaver setarch libaio
echo ""
read -p "Use 'yum install -y packages'?(y/N): " yN
if [ "$yN" == "y" ] || [ "$yN" == "Y" ]; then
echo "OK, Continue ..."
yum install -y binutils compat-* control-center gcc* glibc* gnome-libs libstdc* make pdksh sysstat xscreensaver setarch libaio
elif [ "$yN" == "N" ] || [ "$yN" == "n" ]; then
echo "Oh, interrupt!"
exit 11
else
echo "I don't know what is your choise, byebye."
exit 22
fi
# /etc/sysctl.conf
echo -e 'Setting the sysctl.conf (kernel parameters) ...'
echo '# oracle 10 database setting ... $datevalue' >> /etc/sysctl.conf
echo 'kernel.shmall = 2097152' >> /etc/sysctl.conf
echo 'kernel.shmmax = 2147483648' >> /etc/sysctl.conf
echo 'kernel.shmmni = 4096' >> /etc/sysctl.conf
echo 'kernel.sem = 250 32000 100 128' >> /etc/sysctl.conf
echo 'fs.file-max = 65536' >> /etc/sysctl.conf
echo 'net.ipv4.ip_local_port_range = 1024 65000' >> /etc/sysctl.conf
echo 'net.core.rmem_default = 262144' >> /etc/sysctl.conf
echo 'net.core.rmem_max = 262144' >> /etc/sysctl.conf
echo 'net.core.wmem_default = 262144' >> /etc/sysctl.conf
echo 'net.core.wmem_max = 262144' >> /etc/sysctl.conf
echo '' >> /etc/sysctl.conf
echo -e 'Run the lastestly kernel parameters: \n/sbin/sysctl -p'
read -p 'Do you want to do it right now? (y/N) ' Yn
if [ "$Yn" == "y" ] || [ "$Yn" == "Y" ]; then
echo "OK, Let's do it!!"
/sbin/sysctl -p
read -p "Continue ...(y/N): " yN
if [ "$yN" == "y" ] || [ "$yN" == "Y" ]; then
echo "OK, Continue ..."
elif [ "$yN" == "N" ] || [ "$yN" == "n" ]; then
echo "Oh, interrupt!"
exit 11
else
echo "I don't know what is your choise, byebye."
exit 22
fi
elif [ "$Yn" == "N" ] || [ "$Yn" == "n" ]; then
echo "Oh, interrupt!"
exit 33
else
echo "I don't know what is your choise, byebye."
exit 44
fi
echo ""
# /etc/security/limits.conf
echo -e 'Writting the setting to /etc/security/limits.conf ...'
echo '# oracle 10 database setting ... $datevalue' >> /etc/security/limits.conf
echo '* soft nproc 2047' >> /etc/security/limits.conf
echo '* hard nproc 16384' >> /etc/security/limits.conf
echo '* soft nofile 1024' >> /etc/security/limits.conf
echo '* hard nofile 65536' >> /etc/security/limits.conf
echo '' >> /etc/security/limits.conf
tail -n 6 /etc/security/limits.conf
# /etc/pam.d/login
echo -e 'Writting the setting to /etc/pam.d/login.conf ...'
echo '# oracle 10 database setting ... $datevalue' >> /etc/pam.d/login
echo 'session required /lib/security/pam_limits.so' >> /etc/pam.d/login
echo '' >> /etc/pam.d/login
tail -n 3 /etc/pam.d/login
# /etc/pam.d/su
echo -e 'Writting the setting to /etc/pam.d/su ...'
echo '# oracle 10 database setting ... $datevalue' >> /etc/pam.d/su
echo 'session required /lib/security/pam_limits.so' >> /etc/pam.d/su
echo '' >> /etc/pam.d/su
tail -n 3 /etc/pam.d/su
# /etc/profile
echo -e "Writting the setting to /etc/profile ..."
echo "# oracle 10 database setting ... $datevalue" >> /etc/profile
echo 'if [ $USER = "oracle" ]; then' >> /etc/profile
echo ' if [ $SHELL = "/bin/ksh" ]; then' >> /etc/profile
echo ' ulimit -p 16384' >> /etc/profile
echo ' ulimit -n 65536' >> /etc/profile
echo ' else' >> /etc/profile
echo ' ulimit -u 16384 -n 65536' >> /etc/profile
echo ' fi' >> /etc/profile
echo 'fi' >> /etc/profile
echo "" >> /etc/profile
tail -n 10 /etc/profile
echo -e "Create user, groups and directories for oracle 10g database!!"
# echo -e "You can use another termnital to do that with root privilege !"
echo -e "# groupadd oinstall"
groupadd oinstall
echo -e "# groupadd dba"
groupadd dba
echo -e "# useradd -g oinstall -G dba -m oracle"
useradd -g oinstall -G dba -m oracle
echo -e "# mkdir -p /opt/u01/app/oracle/product/10.2.0/db_1"
mkdir -p /opt/u01/app/oracle/product/10.2.0/db_1
echo -e "# chown -R oracle.oinstall /opt/u01"
chown -R oracle.oinstall /opt/u01
echo -e "# chmod -R 755 /opt/u01"
chmod -R 755 /opt/u01
echo -e "# mkdir -p /opt/u02/oradata"
mkdir -p /opt/u02/oradata
echo -e "# chown -R oracle.dba /opt/u02"
chown -R oracle.dba /opt/u02
echo -e "# chmod -R 755 /opt/u02"
chmod -R 755 /opt/u02
echo ""
echo -e "Remember to set the password of oracle!!OK!!\nUse command 'passwd oracle'"
sleep 5
echo -e "Writting the setting to /home/oracle/.bash_profile ..."
echo "# oracle 10 database setting ... $datevalue" >> /home/oracle/.bash_profile
echo 'umask 022' >> /home/oracle/.bash_profile
echo 'TMP=/tmp; export TMP' >> /home/oracle/.bash_profile
echo 'TMPDIR=$TMP; export TMPDIR' >> /home/oracle/.bash_profile
echo 'ORACLE_BASE=/opt/u01/app/oracle; export ORACLE_BASE' >> /home/oracle/.bash_profile
echo 'ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME' >> /home/oracle/.bash_profile
echo 'ORACLE_SID=MISLAB; export ORACLE_SID' >> /home/oracle/.bash_profile
echo 'ORACLE_TERM=xterm; export ORACLE_TERM' >> /home/oracle/.bash_profile
echo 'PATH=/usr/local/bin:/usr/sbin:~/bin:$PATH; export PATH' >> /home/oracle/.bash_profile
echo 'PATH=$ORACLE_HOME/bin:$PATH; export PATH' >> /home/oracle/.bash_profile
echo 'LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH' >> /home/oracle/.bash_profile
echo 'CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH' >> /home/oracle/.bash_profile
echo '' >> /home/oracle/.bash_profile
tail -n 13 /home/oracle/.bash_profile
# echo redhat-4 > /etc/redhat-release
echo -e "Writting the setting to /etc/redhat-release ..."
mv /etc/redhat-release /etc/redhat-release.default
echo redhat-4 > /etc/redhat-release
cat /etc/redhat-release
echo -e "DONE..."
echo -e "**Do not forget to set the password of oracle**\nUse command 'passwd oracle'"
echo -e "Ready to install oracle 10g database!!"
還原MBR能用grub開機
搞得我想考LPIC level 1 102的計畫也跟著延宕多日。
先是公司要我接下oracle的DBA,
好不容易,有點進入狀況說。
以為可以專心準備考試了!
没想到老婆大人又給了另一個難題!
由於我的小舅子去台中工作,
怕平日無聊想弄台電腦可以上上網消遣。
又怕用台新電腦,要是宿舍出入份子複雜,
難保電腦遭竊,得不償失。
所以要求我把我以前的舊筆記型電腦拿出來,
整理一下,好借給小舅子用。
而小舅子表面上說是借用,其實我心裡有數,
這一借可能不會還了。
老實說,那部筆電也跟了我不少歳月,
就這麼奉獻出去,多少有點不捨。
而且那部電腦我裝的作業系統是ubuntu linux,
要是就這麼讓小舅子拿去用,
那他肯定說我這個姐夫小氣,
給了台「不能用」的電腦!
好在我之前有規畫雙系統在這部筆電上,
所以要用windows,還是有解的。
但是我開機試了好久,發現windows居然開不起來了!
怎麼辦?重裝windows吧!
反正筆電的windows本來就不怎麼在用,
有資料的話,應該都在linux裡頭。
於是,動手開始重裝windows!
也許老婆和小舅子會質疑?
如果要重裝,幹嘛還留著linux!
嘿嘿!原諒我耍了個小心機,
我只是心想,筆電也許還會回到我身邊的那天,
linux留著也許還用得到吧。
加上筆電的硬碟容量本來就不大,才20G。
當初分給windows用的容量也才8G而己...
這麼一來,小舅子肯定不能再亂裝軟體,或是亂抓檔案,
也能降低筆電被小舅子搞壞的風險了。
我這招不錯吧!
更也許因為不能亂搞我的筆電,
覺得不好用,就因此把筆電還我了,也說不定!
好打定主意,就這麼辦!重裝windows。
重裝的過程中,並没有太大的問題,
只是因為筆電有些過時了,
要以NTFS檔案系統裝進windows XP,好像行不通!
最後以FAT模式裝好windows XP,搞定。
好了,這下我給自己出了個題目,
如何把之前裝好ubuntu linux時裝入MBR的開機選單給還原回來?
因為重裝windows後,MBR會被清除掉,
換成windows那套開機管理程式!M$真够霸道的!
但我有linux使用的技能,不怕被M$吃定!
找了片Knoppix光碟,開始動工,
要把我的grub開機選單裝回來!
玩過雙作業統的朋友都知道,
大部份教你裝linux和windows到電腦裡時,
都會提示說:要先裝windows再裝linux!
好像要是不這麼作的話,是没辦法讓電腦有雙作業系統的。
哈!哈!哈!
其實這是不正確的觀念,
也是因為對linux技術不够了解,
才會有這樣不成文的規定出來。
但我想,也許這不是因為那些書的作者不懂linux技術,才那麼寫書!
而是想把操作的順序做個防呆措施,
好讓讀者能無痛入門進到linux的世界吧!
就像我之前提到的,你重裝windows後,
開機選單是會被M$換成它們獨有,僅能進入windows的開機選單的。
那像linux那麼無私,容許建立多作業系統的開機選單呢。
好了!有人開始不耐煩。
我己經廢話一堆了!
在摩托學園有篇文章,討論怎麼在有雙作業系統,
重裝windows之後把grub重裝,好恢復之前的開機選單?
http://moto.debian.org.tw/viewtopic.php?t=10077
回到我的主題!
先說明一下我的硬碟規劃。
我有一個windows的C磁碟,也就是linux的hda1。
再來是幾個windows不能辨識的partition,
分別是hda2也就是我安裝ubuntu linux的根目錄!(當初没規劃/boot)
和一個當初莫名奇妙分到邏輯磁碟區的hda5,做swap用的!
現在讓我先用Knoppix開機!
用sudo su -指令來使用root身份。
然後用fdisk -l檢視一下磁碟的份割...
基本上,你可以利用fdisk -l看到的資訊,來掛載那些磁碟分割。
由於我之前的linux,只有用到一個hda2,
那個hda5可不管,因為swap用的分割和安裝grub無關!
OK!Let's do it, as soon as possible.
#mkdir -p /mnt/linux
#mount -t reiserfs /dev/hda2 /mnt/linux
嘿!那個reiserfs是我好奇用的linux file system,
不是常見的ext2/ext3,別見怪。
再來!
#mount -t proc none /mnt/linux/proc
#chroot /mnt/linux
快好了!
之所以要把proc掛到/mnt/linux/proc,
是因為我們有些主機資訊在開機完成後,
都寫到/proc了,而在chroot前,若是不把/proc調動一下,
掛到之後可對應的proc虚擬分割的話,
那grub是無法正確安裝的!
在chroot指令之後,事實上!我們己經回到之前安裝的那個linux環境了。
不信你可以找一下檔案,或看一下目錄的配置。對吧!
最後...
#grub
執行grub指令進入grub命令模式後,依序執行以下敘述:
step1:
root (hd0,1)
ps1/你可以在grub指令環境下用tab鍵,可以找出一些有用的資訊。
ps2/而(hd0,1)對應的就是hda2,(hd0,0)則是對應hda1,要注意!
step2:
setup (hd0)
step3:
quit
ps1/將啟動程式寫入硬碟的MBR磁區。然後離開,完成!
重新開機,成功把我之前的grub開機選單裝回來囉!
吳大 2007/10/27
2007年10月25日 星期四
linux自動啟動及停止 Oracle 資料庫
感謝linux.org.tw的前輩們,
無私而且不辭辛勞的把linux各種技術分享出來!
在此吳大我也將遵循linux共享奉獻的精神,
把我成功設定oracle 10g資料庫,
可以在linuxOS開關機時,自動把資料庫啓動及關閉的經驗分享給大家。
希望能對那些在做oracle 10g DBA的朋友們,有所助益!
要達成在linuxOS開關機時,可以把oracle 10g資料庫啓動及關閉。
你需要對linux的runlevel運作模式有所概念,
然後運用以下三份命令稿,就能達成我們的目的了。
我正式在跑資料庫的主機作業系統是RHEL3,
但我在CentOS環境作同樣的設定也相容。
可見和RedHat有血緣關係的linux版本,應該都適用我這份文件內容才對!
以oracle帳號登入吧!
首先,要在你oracle帳號的$PATH定義中,
能找到/home/oracle/bin這個路徑,
因為我們要把兩個命令稿分別叫 dbstartup 和 dbshutdown 放在這裡!
用echo看看PATH變數,確認一下吧!
[oracle@testhost oracle]$ echo $PATH
没有的話,可能你要修改一下你的.bash_profile或是.profile檔案,
反正就是在定義使用者登入時環境變數的檔案就是了。
語法應該會是:
PATH=$PATH:~/bin
或
PATH=$PATH:/home/oracle/bin
都行!寫在你的.bash_profile或.profile的最後一行也行。
接著,以下是兩個檔案的內容,
要放在/home/oracle/bin的!
[oracle@testhost oracle]$ vi dbstartup
+-----------------------------------------------------------------------------------------------+
#dbstartup
#/home/oracle/bin
sqlplus / as sysdba <<EOF
startup
exit
EOf
:wq 離開vi ,產生dbstartup檔案!
[oracle@testhost oracle]$ vi dbshutdown
+-----------------------------------------------------------------------------------------------+
#dbshutdown
#/home/oracle/bin
sqlplus / as sysdba <<EOF
shutdown immediate
exit
EOF
:wq 離開vi ,產生dbshutdown檔案!
記得要有執行權限的檔案屬性給它們。
[oracle@testhost oracle]$chmod +x dbstartup dbshutdown
做到這裡,等於你成功一半了,
但了為保險起見,我們還是測一下這兩命令稿的效果好了。
免得高興得太早,資料庫動也不動。
[oracle@testhost oracle]$ dbshutdown
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Oct 26 13:42:23 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@testhost oracle]$
由於之前我己經把資料庫開起來了,所以執行可以dbshutdown來關資料庫。
好,那你可以再用dbstartup試試,應該也没問題的!
因為語法大同小異,其實就startup和shutdown immediate的差異而己啊!
嗯!測試成功!我們可以繼續了...
下面這個命令稿和相關設定比較複雜些,
我簡單說明一下,它以bash的case判斷式,
再運用su -l oracle -c "oracle-command"的方式,
去呼叫之前的dbstartup和dbshutdown。
來達到如我們在啓動一些服務的效果!
啓動oracle 10g 資料庫服務:
[oracle@testhost oracle]$ sudo /etc/rc.d/init.d/oracle start
關閉oracle 10g 資料庫服務:
[oracle@testhost oracle]$ sudo /etc/rc.d/init.d/oracle stop
重啓oracle 10g 資料庫服務:
[oracle@testhost oracle]$ sudo /etc/rc.d/init.d/oracle restart
我用sudo是要以root身份執行,但如何讓oracle有執行sudo,
不在這次的題目中,請另行處理吧!
OK,當/etc/rc.d/init.d/oracle這個命令稿有上述的功能後,
我們再進一步設定成linuxOS主機可以在開機關機時,
也能够把資料庫服務一併開關就完成我們這次主題的終極目標了。
[oracle@testhost oracle]$ sudo vi /etc/rc.d/init.d/oracle
+-----------------------------------------------------------------------------------------------+
#!/bin/sh
# /etc/rc.d/init.d/oracle
#linux自動啟動及停止 Oracle 資料庫和監聽程式
case "$1" in
start)
echo -n "Starting Oracle 10g Databases : "
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Starting Oracle 10g Databases as part of system start." >> /var/log/oracle
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
echo -n "Oracle 10g Databases Starting : "
su - oracle -c dbstartup >> /var/log/oracle
echo "Done."
echo -n "Oracle 10g Listeners Starting : "
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
# echo -n "Oracle 10g OEM Starting : "
# su - oracle -c "emctl start dbconsole" >> /var/log/oracle
# echo "Done."
echo ""
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
stop)
echo -n "Shutting Down Oracle 10g Listeners : "
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Shutting Down Oracle 10g Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
# echo -n "Oracle 10g OEM Stopping : "
# su - oracle -c "emctl stop dbconsole" >> /var/log/oracle
# echo "Done."
echo -n "Oracle 10g Listeners Stopping : "
su - oracle -c "lsnrctl stop" >> /var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
echo -n "Shutting Down Oracle 10g Databases : "
su - oracle -c dbshutdown >> /var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
;;
restart)
echo -n "Restarting Oracle 10g Databases: "
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Restarting Oracle 10g Databases as part of system up." >> /var/log/oracle
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
echo -n "Shutting Down Oracle 10g Databases : "
su - oracle -c dbshutdown >> /var/log/oracle
echo "Done."
echo -n "Oracle 10g Databases Starting : "
su - oracle -c dbstartup >> /var/log/oracle
echo "Done."
echo -n "Oracle 10g Listeners Stopping : "
su - oracle -c "lsnrctl stop" >> /var/log/oracle
echo "Done."
# echo -n "Oracle 10g OEM Stopping : "
# su - oracle -c "emctl stop dbconsole" >> /var/log/oracle
# echo "Done."
# echo -n "Oracle 10g OEM Starting : "
# su - oracle -c "emctl start dbconsole" >> /var/log/oracle
# echo "Done."
echo -n "Oracle 10g Listeners Starting : "
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
*)
echo "Usage: oracle {start|stop|restart}"
exit 1
esac
以上內容,僅供參考,請視狀況修訂!
像是listener開關和資料庫開關的順序,
我個人的實際經驗是認為誰先誰後,並不影響資料庫的運作!
甚至listener可以保持在一定聆聽的狀況,只要重啓資料庫即可。
還有emctl的使用,若是用不到,就像我在內容中就註解掉不啓用了,
也可以讓機器效能好一點,不過好多少我没把握。
搞定這個最後的命令稿後,
我們要進入最後一個步驟了。
我們要在適當的執行等級目錄中 (/etc/rc.d/rcX.d),
建立符號連結 (symbolic links)。
讓我們以root身份來完成這最後的工程!畫下完美的句點吧!
[oracle@testhost oracle]$ sudo su -l root
切換成root後!
[root@testhost root]#
[root@testhost root]# cd /etc/rc.d/init.d
[root@testhost init.d]# ln -s ../init.d/oracle /etc/rc.d/rc3.d/S99oracle
[root@testhost init.d]# ln -s ../init.d/oracle /etc/rc.d/rc5.d/S99oracle
[root@testhost init.d]# ln -s ../init.d/oracle /etc/rc.d/rc0.d/K01oracle
[root@testhost init.d]# ln -s ../init.d/oracle /etc/rc.d/rc6.d/K01oracle
好了!我們己經在啓動的runlevel 3和5 做開機就啓動oracle的服務設定,
而關機的runlevel 0和重開機的runlevel 6也有關掉oracle的服務設定!
大功告成!
測試一次,現在我們不必再進資料庫關閉它了。
直接關閉機器!
[root@testhost init.d]# shutdown -r now
你應該可以在開關機的過程中,看到oracle 關閉啓動的訊息。
為了再求證我們這些設定是否有用,讓我們進資料庫看看狀況吧。
用oracle帳號登入!
[oracle@testhost oracle]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Oct 26 15:56:15 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
手動啓動庫資料看看!
SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL>
哈!資料庫already running了!成功!
吳大 2007/10/26
2007年10月24日 星期三
搞定ORACLE資料庫物理備份
總算ORACLE 10g的主機備份弄出個頭緒了。
記得網路上有提到ORACLE DB資料,
可以用物理備份的方法來執行。
以為我們可以用像ghost的方式來做,
結果發現ORACLE的運作方式,
我們根本没有考慮到。
造成就算是磁區備份成了,但倒回去還是不能動。
因為資料庫的運作機制,
redofile,controlfile,datafile...
都要能對映起來,
絶對不是單純的把partition拷貝起來就OK的。
不過,只要把ORACLE的運作原理稍有了解,
還是能用SysmanTec ghost,Acronis TrueImage,Partimage等軟體,
把資料備起來的!
在linux的環境下,只要好好運用tar指令,
也是能做好oracle的備份的。
ORACLE 10g自有一套備份還原的機制,
物理備份,只是把機器掛掉的風險減少些許而己,
但資料庫運作的備份還原若不深入研究一番的話。
日後資料出問題,物理備份!只能救機器而己吧。
在linux的環境下,怎麼做ORACLE的物理備份?
坦白說,在linux環境下安裝ORACLE是比在windows環境難多了,
但你以為會用linux安裝ORACLE,就算是個DBA,就很厲害了嗎?
嘿嘿!千萬別這麼自以為是,日後可是會吃苦頭的。
來,吳大最近研究了一下ORACLE的備份機制,
什麼exp/imp,expdb/impdb的,實在不好懂,
但我趕著要把資料庫先備份一下,
免得在我這個DBA新手不當操作之下,造成資料庫損毀,
那可就準備收拾細軟,回來吃自己啦!
如果你會Partimage或是SysmanTec ghost,Acronis TrueImage等軟體的話最好!
Partimage是GPL軟體,你可以儘管試用沒關係,
但SysmanTec ghost和Acronis TrueImage就不行了,
它們是商用軟體,濫用會被罰錢甚至吃上官司的。
在此我推薦Acronis TrueImage,由於我是在linux環境進行,
據了解,它的執行效果不錯,
想像一下,若是你的資料庫己經大到幾十G的空間,
若是工具不好的話,你得等上一兩天才做好硬碟備份,
我想任何人都受不了的!
接下來,資料庫的啓動和關閉你會吧!
什麼,還不會,天哪!資料庫主機處境危險哦。
趕快去找書看吧,不然找一下google!
還好開關資料庫還下是很難,
如果你的系統建置廠商有把oracle帳號環境設好的話,
你就可以以linux主機系統認可的方式,直接進oracle DB!
指令是sqlplus "/ as sysdba",雙引號可以省去没關係。
[oracle@macrodbbk oracle]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 25 14:46:18 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
OK!看到SQL>表示成功連接資料庫系統了,
接下來要啓動資料庫,指令是startup。
SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL>
因為我們之前己經啓動好了!所以出現ORA-01081的錯誤訊息。關掉它吧!
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
看到shut down表示成功關閉,没有異常。
好,再次啓動!
SQL> startup
ORACLE instance started.
Total System Global Area 1828716544 bytes
Fixed Size 1219976 bytes
Variable Size 201327224 bytes
Database Buffers 1610612736 bytes
Redo Buffers 15556608 bytes
Database mounted.
Database opened.
SQL>
呼!Safe,啓動成功!
之前我經歷了一次資料庫幾乎損毀的狀況歷鍊,
所以現在看資料庫成功無誤的關閉或啓動,
心中總是感慨萬千啊!
注意啦!接下來才進入重點...
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u02/db/NICE/system01.dbf
/u02/db/NICE/UNDOTBS1.dbf
/u02/db/NICE/sysaux01.dbf
/u02/db/NICE/users01.dbf
/u02/db/NICE/ZGT.dbf
/u02/db/NICE/ZGTIDX.dbf
/u02/db/NICE/EIP.dbf
7 rows selected.
SQL>
看到没,那句select語法,把你的資料庫檔案放那裡給指出來了。
所以呢!我們若是要進行partition備份,/u02就是其中之一了。了解否!
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u02/db/NICE/control01.ctl
/u02/db/NICE/control02.ctl
/u02/db/NICE/control03.ctl
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u02/db/NICE/redo03.log
/u02/db/NICE/redo02.log
/u02/db/NICE/redo01.log
SQL>
再來我又用了兩句select把控制檔和還原用的日誌檔位置找出來了。
總上所述,你要想盡辦法,把那些.dbf,.ctl,.log的檔案備份下來就是了。
再加上$ORACLE_HOME裡頭所有的檔案好,那就是完整的資料庫物理備份了。
怎麼做?工具的使用,我再找時間寫吧。
還有,我之前就提到了,linux的tar指令只要用得好,那些工具軟體就不需要囉。
最後再加註一點,既然你要做物理備份,你的硬碟一定要够大,
不然備份這遊戲,你是玩不起來的。
對了,我最最後再強調一點,物理備份一定要在資料庫關閉的狀況下執行。
在資料庫還在啓動的狀態下做物理備份也是會成功,
只是你還原回去,資料庫還是會因為那些.dbf,.ctl,.log檔案,
有你執行備份的時間差,而湊不起來的。
ORACLE的DBA!!不容易啊!
搜尋此網誌
本站大事記
特別是為了工作和進修需要,搜集了不少網站連結。
希望對來這裡觀文的朋友們,有提供一些有用的資訊或文章。
但這裡的文章中,也包含個人的心情扎記和隨興言談……
若是當中沒有對上你的口味,請多包涵!
原「琳娜絲與希斯寇的邂逅」,改名為「愛上琳娜絲」!
--原序文--
就是當LINUX遇上CISCO啦!他們的結合還能作什麼事…不就是讓這個世界的網路,串…串起來啊…不然你們那能上這網站看部落格!
我的網誌清單
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
一個多月..14 年前