May 2, 2008
Configure network in CentOS5
for Static
DEVICE=eth0
ONBOOT=yes
HWADDR=00:0c:29:c3:90:85
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
IPADDR=172.16.1.3
NETMASK=255.255.0.0
GATEWAY=172.16.10.1
for dhcp
DEVICE=eth0
ONBOOT=yes
HWADDR=00:0c:29:c3:90:85
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
BOOTPROTO=dhcp
Mar 5, 2008
ldd command - shared libraries
Feb 29, 2008
Remove .svn
$ find . -name .svn -print0 | xargs -0 rm -rf
*Note
using zip to compress file/folder in Unix/Linux
$ zip -r FCH.zip FCH
$ upzip FCH.zip
Oct 12, 2007
Proxy
http://sourceforge.net/projects/proxy/
Installation
$ tar xzvf proxy.tar.gz
$ cd proxy
$ make
$ ./proxy -s 8080 -S 192.168.1.39 -d 80 -D nhungnguoibantot.net
Oct 9, 2007
Delete Linux User
Firstly
$ find / -user username
Manually delete or
$ find / -user username > log.txt
$ rm -rf `cat log.txt`
Finally
$ userdel username
Aug 1, 2007
Subversion command line
Some basic command should remember
svn add — Add files and directories.
$ svn add testdir
svn checkout — Check out a working copy from a repository.
$ svn co http://mangmaytinh.biz.tm/repos/
svn commit — Send changes from your working copy to the repository.
$ svn ci -m "commit"
svn cleanup — Recursively clean up the working copy.
svn delete — Delete an item from a working copy or the repository.
svn diff — Display the differences between two paths.
svn update — Update your working copy.
Install Subversion with Apache
yum install httpd
yum install subversion
yum install mod_dav_svn
Now we need to create the directory for the repository:
mkdir /usr/local/svn
Now we need to create the repository
svnadmin create --fs-type fsfs /usr/local/svn
svn import /tmp/webqs/ file:///usr/local/svn/webqs/ -m "Initial import"
We need to configure apache
vi /etc/httpd/conf/httpd.conf
add
<location /repos>
DAV svn
SVNPath /usr/local/svn
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/svn-auth-file
# For any operations other than these, require an authenticated user.
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</Location>
Create a user and password (if you want to create more users leave out the -c switch, just use -m)
htpasswd -cm /etc/svn-auth-file huusan
New password: *****
Re-type new password: *****
Adding password for user huusan
Restart httpd service
# service httpd restart
After it boots back up open a web browser to your subversion machine (http://127.0.0.1/repos) it will prompt you for your user name and password and there you go.
Jul 18, 2007
Directory Server
What is a Directory Server?
A directory server provides a centralized directory service for your intranet, network, and extranet information. Directory Server integrates with existing systems and acts as a centralized repository for the consolidation of employee, customer, supplier, and partner information. You can extend Directory Server to manage user profiles and preferences, as well as extranet user authentication.
How is a Directory Server different from a Relational Database?
An LDAP directory server stores information in a tree-like heirarchical structure.
The characteristics of an LDAP server are:
very fast read operations
fairly static data
hierarchical
clients use standard LDAP protocol
loosely coupled replication
The characteristics of an RDMBS are:
very fast write operations (think TPS)
dynamic data
tables with rows and columns, with key relations between tables
no standard on the wire protocol - vendors must provide ODBC or JDBC drivers
What is LDAP?
LDAP provides a common language that client applications and servers use to communicate with one another.
What is Fedora Directory Server?
A secure, highly scalable, robust LDAP server.
Install Fedora-ds
$ wget http://directory.fedoraproject.org/download/fedora-ds-1.0.4-1.FC6.i386.opt.rpm
$ rpm -ihv *.rpm
$ cd /opt/fedora-fs
$ ./setup/setup
Installation guide in
(http://directory.fedoraproject.org/wiki/Install_Guide)
Run
$ ./startconsole -u admin -a http://domain.com:28365/
Jul 8, 2007
Install VNCserver in Fedora Core 7
$ yum -y install vnc*
- Starting with no configuration file
$ vncserver :1
Only xterm interface
$ vncserver -kill :1
to kill display 1
- Configuration
$ vi ~/.vnc/xstartup
Comment
twm &
And append
init 5
startkde &
Note: init 5 is necessary only when your server start with runlevel other than 5
Installing inadyn as afraid.org Dynamic DNS client
# yum -y install inadyn.i386
Configure
# vi /etc/inadyn.conf
dyndns_system default@freedns.afraid.org
username userpublic
password passpublic
alias mangmaytinh.biz.tm,Um9ALVNVTVRTTUlBQUNzb21ZMDoyMTcwNTE0
update_period 60000
log_file /var/log/inadyn.log
background
with "Um9ALVNVTVRTTUlBQUNzb21ZMDoyMTcwNTE0" is hash(Direct URL http://freedns.afraid.org/dynamic/update.php?Um9ALVNVTVRTTUlBQUNzb21ZMDoyMTcwNTE0) that you can get it from http://freedns.afraid.org/dynamic/ after you regist a subdomain
Configure start up daemon
# chkconfig --level 345 inadyn on
Start service
# service inadyn start
Check daemon run
# vi /var/log/inadyn.log
Debug
# inadyn --dyndns_system default@freedns.afraid.org -a mangmaytinh.biz.tm,Um9ALVNVTVRTTUlBQUNzb21ZMDoyMTcwNTE0 -u userpublic -p passpublic --verbose 5
add --verbose 5 to see detail error
Jun 18, 2007
Managing Storage
Managing Storage
Overview of Storage Hardware
Device files
the device files for disk drives appear in the /dev/ directory.
Device type
sd – the device is SCSI-based
hd – the device is ATA-based
The first hard drive on system may appear as hda or sda
Unit
Following the two-letter device type are one or two letters denoting the specific unit
Partition
the partition on the device is represented by number in the end of device name
/dev/hda1 (ATA drive)
/dev/sdad4 (SCSI device)
Mounting file system
Mounting point
Basically, mounting points are where you mount your file systems or devices.
Seeing What is Mounted
Viewing /etc/mtab
# vi /etc/mtab
The /etc/mtab file is meant to be used to display the status of currently-mounted file systems only. It should not be manually modified.
Viewing /proc/mounts
# vi /proc/mounts
(The Proc psuedo file system is a real time, memory resident file system that tracks the processes running on your machine and the state of your system.)
df – command
Lets we know what file systems are currently mounted and the amount of free space on them.
Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
/dev/mapper/VolGroup00-LogVol00
99636632 10652432 83841264 12% /
/dev/sda1 101086 16258 79609 17% /boot
/dev/mapper/VolGroup00-LogVol02
49611460 1517004 45533640 4% /data
tmpfs 511684 0 511684 0% /dev/shm
Network-Accessible Storage Under Linux
NFS (Network File System)
is a file system that may be accessed via a network connection.
The file systems an NFS server makes available to clients is controlled by the configuration file /etc/exports.
SMB (Server Message Block)
is the name for the communications protocol used by various operating systems produced by Microsoft.
Red Hat Linux supports SMB via the Samba server program.
Mounting File systems automatically with /etc/fstab
#vi /etc/fstab
Mornitoring Disk Space
df – command
# df
-h option for understand by human
Automated Monitoring Using diskcheck
Automatically check disk and send email to administrator.
Adding/Removing Storage
Adding Storage
Partitioning
Using the command-line fdisk utility program
Using parted, another command-line utility program
Formatting the partition(s)
# mkfs
Updating /etc/fstab
to automatically mount to system.
Removing Storage
Remove the disk drive's partition from /etc/fstab
Unmount the disk drive's active partitions.
# umount path
Erase the contents of the disk drive.
# badblocks -ws
Disk Quotas
Disk quotas under Red Hat Linux have the following features:
Per-file-system implementation
Per-user space accounting
Per-group space accounting
Tracks disk block usage
Tracks disk inode usage
Hard limits
Soft limits
Grace periods
Physical and Virtual Memory
Storage Access Patterns
Access tends to be sequential
If address N is accessed by the CPU, it it highly likely that address N+1 will be accessed next.
Access tends to be localized
If address X is accessed, it is likely that other addresses surrounding X will also be accessed in the future.
The Storage Spectrum
Storage technologies:
CPU registers
Cache memory
Ram
Hard drives
Off-line backup storage (tape, optical disk, etc.)
Virtual Memory
Virtual memory is a portion of the hard disk that operation system uses to application programs to meet the require exceeds the amount of physical memory available.
Paging occurs when an active process requires more memory than what is accessible in physical memory. Portions of the process are moved to disk so the physical memory can be used for something else.
Swapping is done by the kernel. When memory space is running low the kernel looks for a process that isn't likely to run in the near future. That process is written entirely to disk, and the newly-freed memory is reassigned to another process or job.
Virtual Memory in Redhat Linux
Using free to get a concise overview of memory and swap utilization.
$ free
total used free shared buffers cached
Mem: 1023368 1004148 19220 0 14544 277328
-/+ buffers/cache: 712276 311092
Swap: 2031608 198436 1833172
System has 1G of RAM, about ~1004 MB is actually in use. ~198 MB of swap is in use.
sar [-a] [-A] [-b] [-c] [-d] [-g] [-k] [-m] [-p] [-q] [-r] [-u] [-v] [-w] [-y ] [ -o filename ] t [ n ]
Viewing result of sar -r
09時17分12秒 LINUX RESTART
09時20分02秒 kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad
09時30分02秒 35432 987936 96.54 30024 523368 2031444 164 0.01 0
09時40分01秒 33080 990288 96.77 37776 512900 2031444 164 0.01 0
09時50分01秒 13600 1009768 98.67 45868 516460 2031444 164 0.01 0
10時00分01秒 57096 966272 94.42 52216 469420 2031444 164 0.01 0
平均値: 34802 988566 96.60 41471 505537 2031444 164 0.01 0
kb: Kilobytes of memory allocated to
sar -W
09時17分12秒 LINUX RESTART
09時20分02秒 pswpin/s pswpout/s
09時30分02秒 0.00 0.07
09時40分01秒 0.00 0.00
09時50分01秒 0.00 0.00
10時00分01秒 0.00 0.00
平均値: 0.00 0.02
page swap in per second (pswpin/s)
page swap out per second (pswpout/s)
Jun 13, 2007
Resource Monitoring
- CPU power
- Bandwidth
- Memory
- Storage
+ System have problem, can we improve its performence? (system performence monitoring)
+ System run well now, can we keep it later? (monitoring system capacity)
- System performence monitoring
- Determine the cause of problem
- Analyze the the data that produced from monitoring, to solve the problem
- Ensure the performence problem has been resolved
- Monitoring system capacity
Monitoring Bandwidth
Monitoring Memory
Monitoring Storage
Tools for resource monitoring
free
Display amount of free and used memory in the system
# free
total used free shared buffers cached
Mem: 1023368 966064 57304 0 24704 247628
-/+ buffers/cache: 693732 329636
Swap: 2031608 164 2031444
Mem row: displays the physical memory utilization.
Swap row: displays the utilization of the system swap space.
+/- buffers/cache row: display the amount of physical memory currently devoted to system buffers.
to view it change with time using
#watch free
#watch -n 1 -d free
-n to set delay time, -d to highline the change
top
Display a lot of things.
#top
#gnome-system-monitor
vmstat
To get an overview of process, memory, swap, I/O, system, and CPU activity in one line of numbers:
# vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 164 68416 10204 251848 0 0 47 38 1121 1038 8 2 89 1 0
Procs
r: The number of runnable processes waiting for access to the CPU
b: The number of processes in an uninterrupible sleep state
Memory
swpd: The amount of virtual memory used
free: The amount of free memory
buff: The amount of memory used for buffers
cache: The amount of memory used as page cache
Swap
si: The amount of memory swapped in from disk
so: The amount of memory swapped out to disk
IO
bi: Blocks sent to a block device
bo: Blocks received from a block device
System
in: The number of interrupts per second
cs: The number context switches per second
CPU
us: The percentage of the time the CPU ran user-level code
sy: The percentage of the time of CPU ran system-level code
id: The percentage of the time the CPU was idle
wa: The percentage of the time spent running non-kernel code
st: The percentage of the time stolen from a virtual machine
The Sysstat Suite of Resource Monitoring Tools
#yum -y install sysstat.i386
iostat
Display an overview of CPU utilization, along with I/O statistics for one or more disk devices
mpstat
Display more in-depth CPU statistics.
sadc (/usr/lib/sa/sadc), sar generate the reports interactively.
1. The Philosophy of System Administration
- Automate everything
- Document everything
- Communicate as much as possible
- Know your resources
- Know your users
- Know your business
- Security cannot be an afterthought
- Plan ahead
- Expect the unexpected
- crontab(1) and crontab(5) man pages — Command and file format documentation for using cron.
- at(1) man page — Schedule commands and scripts for execution at a later time with this utility.
- bash(1) man page — Learn more about the default shell (and shell script writing) with this documentation.
- perl(1) man page — View pointers to the many man pages that make up perl’s online documentation.
- gedit(1) man page and Help menu entry — Learn how to edit text files with this graphical text editor.
- emacs(1) man page — Information (including instructions for running an online tutorial) on how to use this text editor.
- vim(1) man page — Learn how to use this text-based editor.
- mozilla(1) man page and Help Contents menu entry — Learn how to edit HTML files, read mail, and browse the Web.
- Quanta Handbook menu entry — Learn how to edit HTML files with this graphical HTML editor.
- evolution(1) man page and Help menu entry — Learn how to manage your email with this graphical email client.
- pine(1) man page and ? menu entry — Learn how to manage your email with this text-based email client.
- mutt(1) man page and files in /usr/share/doc/mutt-¤ version — Learn how to manage your email with this text-based email client.
- pam(8) man page and files in /usr/share/doc/pam-¤ version — Learn how authentication takes place under Red Hat Linux.
- tripwire(8) man page — Learn how to configure and run this intrusion detection software.
[Red Hat Linux System Administration Primer book]