แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - golfreeze

Pages: 1 ... 66 67 [68] 69 70 ... 73
1006
tcsh , sh ใน *BSD
หาวันที่ โดยย้อนกลับไป 4 วันที่แล้ว
แทนเป็น 4d ครับ
#echo `date "-v-4d" "+%Y%m%d"`

bash shell ใน linux
หาวันที่ โดยย้อนกลับไป 4 วันที่แล้ว
date --date="4day ago" "+%Y%m%d"

หาเดือนที่ โดยย้อนกลับไป 1 เดือนที่แล้ว
date --date="1month ago" "+%Y%m%d"

: )

1007
Linux file system
- in linux don't have drive every drive is folder
- / call "root" is top of directory in linux file system
- /bin : essential binaries
- /boot : static files of boot loader
- /etc : host specific system config
- /usr : shareable and read-only data
- /var : variable data files
- /sbin : system binary
- /tmp : temporary files delete on bootup
- /dev : location of special or device files
- /home : user home directory
- /lib : library and kernel modules
- /media : mount files
- /opt : add-on application software
- /root : home of root

Command prompt
- username@hostname:~$
- "username" is user in linux system
- "hostname" is computer name
- "~" working directory
- "$" is permission (and # for root)

Command-line pattern
- [command]
- [command] [option]
- [command] [option] [file or path]
- [command] [file or path] [option]
- [command] [option] [file or path] [file or path2]

Special path
- "." is current directory
- ".." is parent directory
- "~" is home directory

File of linux system
- File
- Hidden file
- Directory
- Link

Help for linux by
- "man"
- "--help"


### File command
$ ls -la             => directory listing with hidden files
$ cd dir             => change directory to dir
$ cd|cd ~            => change to your home
$ pwd                => print work directory for show current directory
$ mkdir dir          => create directory dir
$ rm file            => remove file
$ rm -r dir          => remove directory dir
$ rm -f file         => force remove file
$ rm -rf dir         => force remove dir
$ cp file1 file      => copy file1 to file2
$ cp -r dir1 dir     => copy dir1 to dir2, create dir2 if it doesn't exist
$ mv file1 file2     => rename or move file1 to file2 if file2 is an existing directory, moves file1 into directory file2
$ ln -s file link    => create symbolic link link to file
$ touch file         => create or update file time stamp
$ cat file           => output the content of file
$ cat > file         => places standard input into file instead text editor ^^' and stop by ^c (^ is ctrl)
$ cat file1 > file2  => copy content in file1 replace to file2 if files is an existing
$ cat file1 >> file2 => copy content in file1 append to file2 if files is an existing
$ more file          => output the content of file each page
$ less file          => output the content of file and can go to next or previous page
$ head file          => output the first 10 lines of file
$ tail file          => output the last 10 lines of file
$ div file1 file2    => output difference content between file1 and file2

### Searching
$ grep pattern files     => search for pattern in files
$ grep -r pattern dir    => search recursively for pattern in dir
$ grep ^pattern files    => search begin by pattern
$ command | grep pattern => search for pattern in the output of command
$ locate file            => file all instances of file

### Process management
$ ps               => display your currently active processes
$ ps -aux          => display any your currently processes
$ top              => display all running processes and change display every 1 sec
$ htop             => third party program same 'top'
$ kill pid         => kill process id pid
$ killall program  => kill all processes named proc (use with extreme caution)
$ bg               => lists stopped or background jobs; resume a stopped job in the background
$ fg               => brings the most recent job to foreground
$ fg n             => brings job n to the foreground
$ /etc/init.d/serv start|stop|restart|reload => for start stop service

### Shortcuts
$ Ctrl+C            => halts the current command
$ Ctrl+Z            => stops the current command, resume with fg in the foreground or bg in the background
$ Ctrl+D            => log out of current session, similar to exit
$ Ctrl+W            => erases one word in the current line
$ Ctrl+U            => erases the whole line
$ Ctrl+R            => type to bring up a recent command

### System info
$ clear|reset       => clear screen
$ echo pattern      => display pattern
$ time command      => use how long work with command
$ date              => show the current date and time
$ cal               => show this month's calendar
$ uptime            => show current uptime
$ w                 => display who is online
$ whoami            => who you are logged in as
$ finger user       => display information about user
$ uname -a|r        => show kernel information
$ cat /proc/cpuinfo => cpu information
$ cat /proc/meminfo => member information
$ man command       => show the manual for command
$ df                => show disk usage
$ du                => show directory space usage
$ free              => show memory and swap usage
$ whereis app       => show possible locations of app
$ which app         => show which app will be run by default

### Compression
$ tar cf file.tar files        => create a tar named file.tar containing files
$ tar xf file.tar              => extract the files from file.tar
$ tar czf file.tar.gz files    => create a tar with Gzip compression
$ tar xzf file.tar.gz          => extract a tar using Gzip
$ tar cjf file.tar.bz2         => create a tar with Bzip2 compression
$ tar xjf file.tar.bz2         => extract a tar using Bzip2
$ tar tf|tvf file.tar|.gz|.bz2 => display content in zip file
$ gzip file                    => compresses file and rename it to file.gz
$ gzip -d file.gz              => decompresses file.gz back to file

### Network
$ ping host            => ping host and output results
$ whois domain         => get whois information for domain
$ dig domain           => get DNS information for domain
$ dig -x host          => reverse lookup host
$ wget file            => download file
$ wget -c file         => continue a stopped download
$ ssh|telnet user@host => remote host
$ ftp|sftp host|user@host => remote ftp host
$ scp file user@host:path => copy file to remote host

Example:
$ scp file1 user@somehost:/opt    => copy file1 to /opt of remote host

### Installation
$ Install from source:
./configure
make
make install

$ dpkg -i pkg.deb               => install a package (Debian)
$ dpkg -l                       => display installed package in system
$ dpkg -l program               => display program info

$ apt-cache search program      => for search program
$ apt-cache show program        => for show detail of prog and dependent library
$ sudo apt-get install program  => install program
$ sudo apt-get update           => update package repository
$ sudo apt-get upgrade          => upgrade program in system
$ sudo apt-get remove program   => remove program
$ sudo apt-get build-dep prog   => only install dependent package of program

$ rpm -Uvh pkg.rpm              => install a package (RPM)

### File permissions
$ chmod octal file         
=> change the permissions of file to octal
,which can be found separately for user,group
, and world by adding;

4 - read (r)
2 - write (w)
1 - execute (x)

Examples:
$ chmod 777              => read, write, execute for all
$ chmod 755              => rwx for owner, rx for group and world
$ chmod ugo+|-rwx        => u = owner, g = group , o = other
$ chown user.group file  => change to another user and group

For more options, see man chmod

### Forward output and something special
- ";" => run command finished can run command2 automatic by use ';'

Example:
$ chmod o+w file1 ; chmod o-rx file1

- "`" => is call 'backtrix' sinagure
Example:
$ passwd `whoami` => for change password current user logined
$ apt-get install linux-headers-lbm-`uname -r`-xen

$ !!    => repeates the last command
- "&&"  => same ";"
- "&"   => run program finished and can do any thing with that shell

Example:
$ gclctool &  => run calculator and can use that shell to any thing

- ">"   => forward output

Example:
$ ls -l > file1 => output of ls -l overwirte into file1 if exist file1

- ">>"  => forward output append

Example:
$ ls -l >> file1 => output of ls -l append into file1 if exist file1

- "\"   => use in long command

Example:
$ chmod o+w  file1 \
;chmod o-rx file1 \
;chmod o+rx file1

- "<"   => don't explain ^^' it reverse with ">"

Example:
$ mysql user < file1 =""> for check md5sum

- 0|1|2 => get type of output 1 is valid output, 2 is error output , 0 all output

Example:
$ ./configure 2> file => for get only error output into file

### Application and Utility
$ lsusb|lspci    => display device usb or pci type
$ fdisk          => display disk device
$ mount|unmount  => mount partition

Example:
$ mount -a       => mount all device in /etc/fstab

$ script file    => use record keylogger and press ^D for stop
$ ttyrec file    => third party program same 'script' it for record keylogger
$ ttyplay file   => display file so create by ttyrec
$ alias 'alias=command'  => for create alias instead long command

Example:
$ alias 'll=ls -l'

$ unalias alias  => cancel alias name

Example:
$ unalias ll

$ chroot => program for change eviroment for work

Sample chroot: when u use live cd if u must to use enviroment real system
Useful chroot: use chroot in live cd to correct real enviroment system but u must know path for config file

$ history  => for display all old command

### Administration tools
$ sudo|gksudo  => became to root and do it
note: edit permission sudo config file /etc/sudoers
$ su    => switch to root
$ sudo visudo  => can use this command only debian base

$ shutdown -h now|poweroff  => shutdown machine can can define time for shutdown by number minute instead "now"
$ shutdown -r now|reboot    => for reboot machine can define time for rebott

- setting ip /etc/network/interface
- setting dns /etc/network/resolve.conf
- cron , crontab

Example:
$ crontab -l => list task in cron of current user
$ crontab -e => for edit cron can see detail in wiki enter * 5 char , * is every day)
note: if for some command need permission root , solve by crontab -e by sudo sample 'sudo crontab -e'

Example:
$ crontab -e
* * * * * touch ~/test-cron.txt

$ sudo adduser|useradd user => add user
$ sudo deluser user1        => remove user
note: u can check exist user by "ls /home"

### Text editor
- pico , nano
- vi stantdard editor in unix system
- searching      => default mode type '/word', press n|shift+n for find next and previous
- delete line    => default mode type 'dd'
- save file      => default mode ':w file'
- exit file      => default mode ':q!'
- save and exit  => default mode ':wq file'
- go to line     => default mode n+Shift+G => n is number of line to go

Note: '=>' = mean

References:

    * Tranning 13 of ubuntuclub.com
    * Clil command picture by Teddy in ubuntuclub.com
    * and juuier a bit
    * http://www.oreillynet.com/linux/cmd/
    * http://linuxcommand.org/

1008
### Log hashing
md5sum vsftpd.log.1 > xxx.MD5
md5sum -c xxx.MD5




## Openldap + Squid + Sarg + apache

cd /usr/ports/www/apache22

make install clean

cd /usr/ports/lang/php5

make config

make install clean

cd /usr/ports/lang/php5-extension

make config เลือก gd , ldap , mysql , pcre = จำเป็นกับ phpldapadmin

----------------------------------------------


#cd /usr/ports/net/openldap23-server

#make config

#make install clean

----------------------------

#cd /usr/ports/net/openldap23-client

#make config

#make install clean

---------------------------

#cd /usr/ports/net/phpldapadmin

#make install clean

---------------------------

#cd /usr/ports/www/squid

#make config

เลือก
squid_ldap_auth
SQUID_IDENT
SQUID_REFERER_LOG
SQUID_USERAGENT_LOG
SQUID_ARP_ACL

#make install clean

-----------------------------------------
Chillispot
http://mrkohkoh.exteen.com/20061010/freebsd-6-1
http://www.howtoforge.com/forums/showthread.php?t=2441
chillispot webboard + log พรบ
http://mamboeasy.psu.ac.th/~wiboon.w/content/category/5/23/40/
Setup a proxy server with web content filtering: squid+rejik+squint+sqstat

http://www.video4admin.com/setup-a-proxy-server-with-web-content-filtering-squidrejiksquintsqstat.html





ลง ldap
http://www.bloggang.com/viewdiary.php?id=naigod&month=02-2006&date=12&group=4&gblog=34


### ลง sarg ดู stat

#Cd /usr/ports/www/sarg

#Make install clean
-----------------------------------------------------------
การปรับปรุง SARG ให้รายงานผลเป็น Daily/Weekly/Monthly
เขียนโดย kom เมื่อ อาทิตย์, 09/23/2007 - 12:21.

 
ติดตั้ง Sarg Daily (SARG แสดงผลแบบรายวัน)
1. ดาวน์โหลดไฟล์จากที่นี่http://prdownloads.sourceforge.net/sarg/sarg-2.0.9.tar.gz?download
2. ติดตั้งตามขั้นตอนดังนี้
www # gzip -cd sarg-2.0.9.tar.gz | tar xvf –
www # cd sarg-2.0.9
www # ./configure --enable-htmldir=/usr/local/www/apache22/data
www # make
www # make install
การติดตั้งนี้มันจะติดตั้งไฟล์ทั้งหมด ยกเว้น ตัวที่ใช้รัน ไปไว้ที่ /usr/local/sarg
จะเสร็จขั้นตอนการติดตั้ง ต่อไปจะเป็นการปรับแต่ง
cd /usr/local/sarg
pico sarg.conf
แก้บรรทัดต่อไปนี้ ให้มีส่วนที่ต้องตั้งค่าดังต่อไปนี้
access_log /usr/local/squid/var/logs/access.log ที่เก็บ log ของ squid
output_dir /usr/local/www/apache22/data/sarg ตรงนี้จะตั้งเป็นชื่ออะไรก็ได้ครับ
resolve_ip no ตรงนี้ถ้าต้องการให้แสดงชื่อเครื่องแทนเบอร์ ip ก็ให้เปลี่ยนเป็น yes ครับ
user_ip yes ตรงนี้สำหรับเซ็ตให้ใช้ ip แทน user id ครับ
remove_temp_files yes ตั้งค่าให้ลบไฟล์ชั่วคราวอัตโนมัติ
index yes ตั้งค่าให้ใส่ไฟล์ index.html อัตโนมัติใน sub folder
overwrite_report no ตั้งค่าให้เขียนรายงานทับอัตโนมัติ ปกติจะเป็น no (ถ้าต้องการทดสอบการทำงาน ให้ตั้งเป็น yes ครับ)
records_without_userid ip ตั้งค่าให้ใช้ ip หากไม่มี user id
use_comma yes ใช้เครื่องหมายลูกน้ำคั่นหลักพัน
mail_utility mail กำหนดโปรแกรมที่ใช้ส่งอีเมล
displayed_values abbreviation กำหนดให้ใช้หน่วย K M แทนการแสดงผลเป็นหน่วย byte ตรงๆ ครับ
www_document_root /usr/local/www/apache22/data/sarg กำหนดที่เก็บไฟล์ html ของ apache ครับ
ดาวน์โหลด Script จาก
http://www.initzero.it/products/opensource/sarg-reports/download/sarg-reports
- แก้ชื่อไฟล์เป็น sarg.report
- copy ไปไว้ที่ /usr/local/bin/sarg.reports
- chmod 755 /usr/local/bin/sarg.reports
- แก้ไข script ส่วนต่างๆ เป็นดังนี้
## English Language
SARG=/usr/local/bin/sarg # ที่อยู่ของ sarg
CONFIG=/usr/local/etc/sarg/sarg.conf # ที่อยู่ของ config file
HTMLOUT=/usr/local/www/sarg # ที่อยู่ของ sarg ใน apache
PAGETITLE="sarg-reports for $(hostname)" # Title ที่จะให้แสดงในหน้าแรกของ script
LOGOIMG=/usr/local/etc/sarg/images/sarg.png # Logo สำหรับหน้าแรกของ script
LOGOLINK=http://sarg.sourceforge.net/ # Link เมื่อคลิกที่โลโก้
DAILY=Daily # ข้อความในหน้าแรกของ script Daily ปิดได้ เมื่อไม่ใช้งาน
WEEKLY=Weekly # ข้อความในหน้าแรกของ script Weekly ปิดได้ เมื่อไม่ใช้งาน
MONTHLY=Monthly # ข้อความในหน้าแรกของ script Monthly ปิดได้ เมื่อไม่ใช้งาน
EXCLUDELOG1="SARG: Records not found."
EXCLUDELOG2="SARG: Fine"
- เพิ่มการทำงานของ script ใน crontab ตามการใช้งานที่ต้องการ
- คำสั่ง crontab-e
00 08-18/1 * * * /usr/local/bin/sarg.reports today
00 00 * * * /usr/local/bin/sarg.reports daily
00 01 * * 1 /usr/local/bin/sarg.reports weekly
30 02 1 * * /usr/local/bin/sarg.reports monthly
- ทดลองเรียก script เพื่อสร้างรายงาน
ด้วยคำสั่ง
/usr/local/bin/sarg.reports daily
- หรือรอให้ crontab ทำงานตามเวลาที่ตั้ง

1009
หลักการทำเครื่อง log server โดยใช้ syslog-ng (new-generation) ที่ใช้ตัวนี้เพราะมีลูกเล่นอะไรเยอะกว่า syslog ธรรมดามาก และมีหลาย app ที่รองรับในการเรียก log ไปดูที่หน้าเว็บ เช่นพวก cacti ไรงี้ครับ ตัวนี้ผมลง base on Freebsd6.2 น่ะครับ
สำหรับถ้าคนไหนทำโดย OS ตัวอื่นก็เอาหลักการไปประยุกต์เอาแล้วกันน่ะครับ หรือใครต้องการแชร์ประสบการณ์ก็ MSN : golfreeze@packetlove.com ได้ครับ

ก่อนอื่นทำการลงพวก apache + mysql +php ก่อนครับ ก่อนครับ
เสร็จแล้วก็เริ่มลง apache ครับ
 ลง apache 2.0.59
#cd  /usr/ports/www/apache20
#make install clean
 
ลง php5
#cd /usr/ports/lang/php5
#make config
Check box เอา Apache + mysql  แล้วก็ option อื่นที่ท่านต้องการใช้งาน
#make install clean
 
ลง php5-extension
#cd /usr/ports/land/php5-extension
#make install clean
 
Term of Junning optimize and Configuration
1.apache
#vi /usr/local/etc/apache2/httpd.conf
      Timeout 30
       KeepAlive Off
       MaxKeepAliveRequests 1024
<IfModule prefork.c>
       ServerLimit   512
       StartServers         4
       MinSpareServers      20
       MaxSpareServers     40
       MaxClients         512
       MaxRequestsPerChild  0
</IfModule>
       ServerAdmin golfreeze@packetlove.com
ServerName localhost:80
DocumentRoot "/home/test/public_html"             #เปลี่ยน directory root
<Directory /home/test/public_html>                    # กำหนด สิทธิ์ของ permission
    Options Indexes Includes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
<Directory "/home/test/public_html">                   
AddDefaultCharset tis-620                                  #ให้ support ภาษาไทย
AddType application/x-httpd-php .php .php3       #ให้ support file php
AddType application/x-httpd-php-source .phps    #ให้ support file php

ลง Mysql-server Client ก็
#cd /usr/ports/databases/myqsl50-server
#make all install clean WITH_CHARSET=tis620 WITH_XCHARSET=all WITH_OPENSSL=yes WITH_NDB=yes
โดยที่

WITH_CHARSET=tis620 เป็นการบอกให้ MySQL เลือก Charset tis620 เป้น Default

WITH_XCHARSET=all บอกให้ mySQL support ทุก charset

WITH_OPENSSL=yes compile mysql ให้ support ssl ด้วย

Tip : ในการ install packet ผ่าน ports ถ้ามันไม่มี check box ให้เลือกให้เราทำการ
#make config ก่อนแล้วจะมี check box ขึ้นมาให้เลือกครับ เมื่อเลือกเสร็จค่อยสั่ง
#make install clean ครับ
 
ตอน install package ผ่าน port ถ้าต้องการโหลด package จากไทยก็
#make print-closest-mirrors >> /etc/make.conf
 
หรือเราจะใช้เครื่องอื่นโหลด แล้ว copy มาใส่ server ที่จะลง packalge นั้นโดย copy ไปที่
/usr/ports/distfiles  ซึ่งเมื่อเราสั่ง make install มันจะไปเรียก package ในนั้นครับ

ขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขข
เสร้จแล้วมาเพิ่มให้ app เริ่มทำงานตอน boot ในไฟล์ /etc/rc.conf ครับ
#Apache
apache22_enable=”YES”
# MySQL
mysql_enable=”YES”


สั่งให้ mysql ทำงาน
# /usr/local/etc/rc.d/mysql-server.sh start
ทำการลง cacti
fetch http://golfreeze.packetlove.com/download/Linux_packets/cacti-0.8.7a.tar.gz
# จัดการ tar
tar xvf cacti-0.8.7a.tar.gz

# Put Cacti under your public web area document root
mv /usr/src/cacti-0.8.7 /home/test/public_html/cacti

# Create the MySQL database:
/usr/local/bin/mysqladmin --user=root -p create cacti

#อิมพอต database ลง cacti
/usr/local/bin/mysql --user=root -p cacti < /home/test/public_html/cacti/cacti.sql

#สร้าง ฐานข้อมูลของ cacti
/usr/local/bin/mysql --user=root -p mysql
GRANT ALL ON cacti.* TO cactiz@localhost IDENTIFIED BY 'cactipassword';
GRANT ALL ON cacti.* TO cactiz@"%" IDENTIFIED BY 'cactipassword';
flush privileges;
exit

# แก้ไข file config ให้ถูกกับ user + pass
vi /home/test/public_html/cacti/include/config.php
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiz";
$database_password = "cactipassword";
$config['url_path'] = '/cacti/';

# เพิ่ม config ให้กับ cacti บน crontab
#crontab -e
# Cacti
*/5     *       *       *       *       root    /usr/local/bin/php /home/test/public_html/cacti/poller.php > /dev/null 2>&1
# เปลี่ยนสิทธิ์ ให้กับ cacti
chown -R www:www /home/test/public_html /htdocs/cacti/
ต่อไปทำการลง plugin ของ cacti ครับ
 # Syslog
fetch http://download.cactiusers.org/downloads/haloe.tar.gz
tar xvf haloe.tar.gz -C /opt/apache/htdocs/cacti/plugins/
# ทำการ config cacti Plug-ins

/usr/local/bin/mysql --user=cactiz -p cacti < /home/test/public_html/cacti/plugins/reports/reports.sql
cactipassword

#สร้าง database ให้เรียบร้อย

/usr/local/bin/mysqladmin --user=root -p create syslog
/usr/local/bin/mysql --user=root -p syslog < /home/test/public_html/cacti/plugins/haloe/syslog.sql

#กำหนดสิทธิ์ให้กับ user
/usr/local/bin/mysql --user=root -p mysql
GRANT ALL ON syslog.* TO cactiz@localhost IDENTIFIED BY 'cactipassword';
GRANT ALL ON syslog.* TO cactiz@"%" IDENTIFIED BY 'cactipassword';
flush privileges;
exit
#แก้ไข config ของ cacti-plugin
vi /home/test/public_html/cacti/plugins/haloe/config.php
$haloedb_username = "cactiz";
$haloedb_password = "cactipassword";
# แก้ไขemail  $mail->From = "golfreeze@packetlove.com"; ตามต้องการ
vi /home/test/public_html/cacti/plugins/haloe/functions.php
# แก้ไขให้ cacti load module เข้าใช้งาน
vi /home/test/public_html/cacti/include/global.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiz";
$database_password = "cactipassword";
$database_port = "3306";
$plugins = array();
$plugins[] = 'haloe';
$config['url_path'] = '/cacti/';
๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙๙
ทำการ install syslog-ng
# Install SyslogNG
           #cd /usr/ports/sysutils/syslog-ng
           #make install clean


# Copy ไฟล์ config ไปตามนี้
cp /usr/local/etc/syslog-ng/syslog-ng.conf.sample /usr/local/etc/syslog-ng/syslog-ng.conf

# แก้ไขให้ syslog-ng ทำงานตอน boot
vi /etc/rc.conf
syslogd_program="/usr/local/sbin/syslog-ng"
syslogd_flags=""

# แก้ไข ค่า config ตามต้องการ
vi /usr/local/etc/syslog-ng/syslog-ng.conf

#
# *.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
#
log { source(src); filter(f_notice); filter(f_not_authpriv); destination(messages); };
log { source(src); filter(f_kern); filter(f_debug); destination(messages); };
log { source(src); filter(f_lpr); filter(f_info); destination(messages); };
log { source(src); filter(f_mail); filter(f_crit); destination(messages); };
log { source(src); filter(f_news); filter(f_err); destination(messages); };
# HERE IS THE NEW LINE YOU NEED TO ADD
log { source(src); filter(f_local7); destination(messages); };

# Shut down the standard FreeBSD syslogd
kill `cat /var/run/syslog.pid`

# Start the new syslog-ng:
/usr/local/sbin/syslog-ng

# Edit the Syslog-ng conf
vi /usr/local/etc/syslog-ng/syslog-ng.conf

destination d_mysql {
pipe("/var/log/mysql.pipe"
template("INSERT INTO syslog_incoming (host, date, time, message, priority, facility)
VALUES ( '$HOST', '$YEAR-$MONTH-$DAY', '$HOUR:$MIN:$SEC', '$MSG', '$PRIORITY', '$FACILITY' );\n") template-escape(yes)); };

log { source(src); destination(d_mysql); };


# Create the fifo pipe for syslog-ng to export out logs
mkfifo /var/log/mysql.pipe

# Restart syslog-ng process
killall syslog-ng
/usr/local/sbin/syslog-ng


# This script is used to pipe syslog-ng to mysql
vi /opt/apache/htdocs/cacti/plugins/haloe/syslog-ng-to-mysql.sh
 
# Make the new script executable
chmod a+x /opt/apache/htdocs/cacti/plugins/haloe/syslog-ng-to-mysql.sh

# Run the script - Syslog messages should now be dumped into the database as they come in
/opt/apache/htdocs/cacti/plugins/haloe/syslog-ng-to-mysql.sh &
 
# Create a startup script so logging to the database restarts after each reboot
vi /usr/local/etc/rc.d/syslog-ng-fifo-mysql.sh
 
# Make the new script executable
chmod a+x  /usr/local/etc/rc.d/syslog-ng-fifo-mysql.sh

ขั้นตอนสุดท้ายสั่ง syslog-ng  restart ด้วยคำสั่ง
# pkill -HUP syslog-ng

ขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขข

ฝั่ง client ที่ต้องการให้ ส่ง log มายังเครื่อง server ก็
ให้เข้าไปแก้ไข ใน
#vi /etc/syslog.conf

ยกตัวอย่างเช่น
ให้ maillog ส่ง log มาที่เครื่อง log server(xxx.yyy.zzz.100) ก็เพียงแค่

# Log all the mail messages in one place.
#mail.*                                                 -/var/log/maillog
mail.*                                                  @xxx.yyy.zzz.100

แล้วจัดการ save
แล้วสั่งให้ syslog ที่เครื่อง client restart 1 ครั้ง

#ตระกูล RH
/etc/init.d/syslog restart

แค่นั้นแล้วไปรอดูที่ cacti_syslog ครับ

ขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขขข
Lab by golfreeze@packetlove.com

สำหรับเครื่อง RH ส่ง log มายังเครื่อง log server ผ่าน syslog-ng

[root@smtp0 syslog-ng]# more syslog-ng.conf
options {
use_fqdn(no);
sync(0);
};

source s_maillog { unix-stream("/dev/log" max_connections(1000)); pipe("/proc/kmsg"); internal(); };
source s_file { unix-stream("/dev/log"); pipe("/proc/kmsg"); internal(); };

destination d_maillog { file("/var/log/maillog"); };
destination d_backup { tcp("10.20.0.252" port(20245)); };
destination d_tools { tcp("116.68.146.13" port(20245)); };
#destination d_tools_1 { tcp("116.68.146.13" port(21245)); };


log { source(s_maillog); destination(d_backup); };
log { source(s_maillog); destination(d_tools); };
#log { source(s_file); destination(d_tools_1); };
log { source(s_maillog); destination(d_maillog); };
สั่งให้ start ดังนี้
#/usr/local/sbin/syslog-ng
ที่ฝั่ง syslog-ng server
OS Freebsd 6.2
#vi /usr/local/etc/syslog-ng/syslog-ng.conf

source s_maillog_smtp { tcp(ip(116.68.146.13) port(20245)); };
#source s_maillog_file { tcp(ip(116.68.146.13) port(21245)); };
#source s_maillog_pop0 { tcp(ip(116.68.146.13) port(20247)); };
########total#########
destination d_maillog_total { file("/var/log/customer-maillog/maillog-total"); };
#log { source(info_src); destination(d_maillog_total); };
log { source(s_maillog_smtp); destination(d_maillog_total); };
######################
### nttdata.co.th ####
#filter nttdata { match("nttdata.co.th"); };
#destination d_maillog_nttdata { file("/var/log/customer-maillog/maillog-nttdata.co.th"); };
#log { source(s_maillog_smtp); filter(nttdata); destination(d_maillog_nttdata); };

######################
########queue#########
#destination d_maillog_queue { file("/var/log/customer-maillog/maillog-queue"); };
#log { source(s_maillog_file); destination(d_maillog_queue); };
######################
########pop0#########
#destination d_maillog_pop0 { file("/var/log/customer-maillog/maillog-pop0"); };
#log { source(s_maillog_pop0); destination(d_maillog_pop0); };

สั่ง start ดังนี้
#/usr/local/etc/rc.d/syslog-ng restart
install syslog-ng + cacti on Freebsd

1010
ก่อนอื่นก็ ลืมให้รู้ว่าลืม อิอิ
มีสติก่อน
ไม่ยากไรครับ เดินไปหน้าเครื่อง
รีบูตเข้า grub เมื่อมาถึงให้กด ตัว e เลื่อนลงมาที่
คำว่า kernel แล้วพิมพ์ต่อท้าย เป็น

???? ro linux single init=/bin/sh

แล้วกด ตัว "b" ให้ boot

เมื่อมาถึง sh:3.1#
ก็ทำการ #mount -n -o remount,rw /
#cd /etc/
#cp passwd passwd.ori
#cp shadow shadow.ori
#nano shadow
จะเห็น root:weeWRSF!sfDFs:12581:0:99999:7:::
ลบ ตั้งแต่ ::ที่หนึ่ง ไปคือลบ weeWRSF! ไปจนถึง : ที่สอง
แล้วทำการ safe

แล้วรีบูต หนึ่งครั้ง เมื่อมาถึงหน้า login ก็ user = root ,
enter

1011
For many user that forget or can not access to
mysql root by command can fix problem by step like
golfreeze[at]packetlove.com

1. # Login as root to the Windows or Unix-like (Unix, Linux or BSD) machine with the MySQL server.

2.# Stop the MySQL server by using either of the following command:

Linux: /etc/rc.d/init.d/mysql stop
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh stop

3.# Open the mysql server startup script (i.e. mysql-server.sh - the file executed to start or stop
MySQL server.
4.# Add "skip-grant-tables" to the end of the line that contains the mysqld_safe command as
its parameter.
5.# Start MySQL server with the following command:

Linux: /etc/rc.d/init.d/mysql start
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh start
6.# Alternatively, start the MySQL server directly and skip the editing with the following command:

mysqld_safe --skip-grant-tables &

Depending on your path environment, you may need to point to the correct directory where mysqld_safe
is instead.
7. # Run the following commands to login as the mysql user and connect to mysql user/permission
database:

8. # mysql -u root mysql
9.# Run the update queries to change the MySQL password:

mysql> UPDATE user SET Password=PASSWORD('newrootpassword') WHERE
User='root';
mysql> FLUSH PRIVILEGES;

10. complete try to delete skip-grant-tables from
/usr/local/etc/rc.d/mysqld and then start mysql server and login to check.

1012
พอดีวันนี้ มีเพื่อนๆ มาถามเรื่อง radius ครับ

พอดีตัวนี้ ผมได้ลอง imp ให้ที่ office ซึ่งจะเค้าอยากได้ app สักตัวที่เอาไว้ authen ของการเข้าไป
ในอุปกรณ์ไว้หน่อย เพื่อเอาไว้เก็บ log หรือ เราสามารถประยุกต์ไปใช้กับพวก authen wireless
เพื่อบริการลูกค้า ร้านเน็ตไรงี้ ก็ได้ ...
"ไหนๆ เขาอยากได้มา เราก็จัดให้เลย"

สำหรับผมใช้กับ freebsd 6.2 ลงพวก apache + php +mysql ก่อนโดย

1.ติดตั้ง cvsup ใช้ในการอัฟเดท port ของ packageครับ โดยผมจะติดตั้งผ่าน pkg_add
#pkg_add -r cvsup-without-gui

รอสักพักครับเมื่อ
#rehash ให้ Freebsd ทำการsearch โปรแกรม ที่อยู่ใน $PATH ใหม่ครับ

เริ่มสั่งให้ update port

#cvsup -g -L 2 /usr/share/examples/cvsup/stable-supfile -h cvsup.th.freebsd.org

ซึ่ง -g คือทำงานในโหมดของ Test Mode
-L 2 คือให้แสดง ข้อความออกมาทาง monitor เป็นแบบ verbose ด้วยถ้าจะไม่ให้แสดงก็ใส่เป็น 0 ครับ
-h คือ Host ที่เราต้องการไป sync update port ด้วยครับ ถ้าของไทยก็ cvsup.th.freebsd.org
ของเว็บ freebsd ก็ cvsup4.FreeBSD.org ครับ

หรือ มีอีกวิธีคือการใช้ ตัว
portsnap ครับ ก็จะใช้วิธีโหลดตัว package มาเป็นก้อนเดียว แล้วเมื่อโหลดเสร็จก็จะทำการ install
ให้ครับ
โดยใช้ คำสั่ง 2 คำสั่งนี้เมื่อเริ่มต้น
#portsnap fetch
#portsnap extract

แล้วใช้คำสั่งนี้ในการ update port ในครั้งต่อไป
#portsnap fetch
#portsnap update

หรือเราจะให้ระบบ update อัตโนมัติก็ไปเขียนใส่ crontab ไว้

0 3 * * * root portsnap -I cron update && pkg_version -vIL=

แค่นี้ก็เรียบร้อย

เสร็จแล้วก็ทำการ Compile kernel ใหม่ครับเพื่อให้เหมาะสมกับทรัพยากรใน server ของเราครับ
และเพื่อความเสถียรและปลอดภัย และใช้งาน ipfw ได้ครับ

ทำการ แก้ไข config ของ kernel เรา โดยใช้ คำสั่ง

#vi /usr/src/sys/i386/conf/PACKETLOVE

เพิ่มข้อลูกเข้าไป ดั่งนี้ครับ
ident PACKETLOVE # ตั้งชื่อ Kernel ของเรา
options SMP # ทำใ้ห้ kernel support
options IPFIREWALL # ทำให้ Kernel support ipfw
options IPFIREWALL_VERBOSE #enable logging to syslogd(
options IPFIREWALL_FORWARD #enable transparent proxy support
options IPFIREWALL_VERBOSE_LIMIT=100 #limit verbosity
options IPFIREWALL_DEFAULT_TO_ACCEPT#allow everything by default
options IPDIVERT #divert sockets
options IPSTEALTH #support for stealth forwarding

หลังจากแก้ไขเสร็จ ให้ backup kernel เก่าและเข้าไปยัง /usr/src และสั่ง compile kernel ครับ

#cp -Rp /usr/src/sys/i386/GENERIC /usr/src/sys/i386/GENERIC.ori
#cd /usr/src
#make -j4 kernel KERNCONF=PACKETLOVE
รอสักพักครับเมื่อเสร็จแล้วให้ทำการเพิ่ม Rule ของ ipfw ดังนี้
#vi /etc/rc.conf
เพิ่ม
ipfw add 100 allow ip from any to any
เพื่อให้สามารถ ออกเน็ตได้ครับ
เสร็จแล้วก็ reboot ไป 1 ครั้งครับแล้ว

แล้วลอง
#uname -a ดูครับ
FreeBSD PooPay.Cute 6.2-STABLE FreeBSD 6.2-STABLE #1: Fri Jun 22 08:11:35 ICT 2007
golf@PooPay.Cute:/usr/obj/usr/src/sys/PACKETLOVE i386

เสร็จแล้วก็เริ่มลง Openssl กับ apache ครับ
ลง apache 2.0.59
#cd /usr/ports/www/apache20
#make install clean

ลง php5
#cd /usr/ports/lang/php5
#make config
Check box เอา Apache + mysql แล้วก็ option module ที่ไม่ต้องเอา ก็ dbm dba เพราะจะทำให้ตัว dialup
ที่ใช้งานเป็น webUI management มีปัญหาครับ เสร็จแล้วก็สั่งเลย
#make install clean

ลง php5-extension
#cd /usr/ports/land/php5-extension
#make install clean

Term of Junning optimize and Configuration
1.apache
#vi /usr/local/etc/apache2/httpd.conf
Timeout 30
KeepAlive Off
MaxKeepAliveRequests 1024
<IfModule prefork.c>
ServerLimit 512
StartServers 4
MinSpareServers 20
MaxSpareServers 40
MaxClients 512
MaxRequestsPerChild 0
</IfModule>
ServerAdmin golfreeze@packetlove.com
ServerName localhost:80
DocumentRoot "/home/test/public_html" #เปลี่ยน directory root
<Directory /home/test/public_html> # กำหนด สิทธิ์ของ permission
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/home/test/public_html">
AddDefaultCharset tis-620 #ให้ support ภาษาไทย
AddType application/x-httpd-php .php .php3 #ให้ support file php
AddType application/x-httpd-php-source .phps #ให้ support file php

ลง Mysql-server Client ก็
#cd /usr/ports/databases/myqsl50-server
#make all install clean WITH_CHARSET=tis620 WITH_XCHARSET=all WITH_OPENSSL=yes WITH_NDB=yes

โดยที่

WITH_CHARSET=tis620 เป็นการบอกให้ MySQL เลือก Charset tis620 เป้น Default

WITH_XCHARSET=all บอกให้ mySQL support ทุก charset

WITH_OPENSSL=yes compile mysql ให้ support ssl ด้วย
------------------------------------------------------------------------
เสร็จแล้วก็เริ่มลง freeradius ครับเป็น application radius ใน reebsd ครับ

#cd /usr/ports/net/freeradius
#make config
เอา snmp , ldap , kerboros,mysql

#make install clean

เสร็จแล้วก็เอา dialup_admin.tar.gz มาใช้งานเป็น user interface ผ่านเว็บได้เลย โดย install ไว้ที่
DocumentRoot
ที่ apache เรียกใช้น่ะครับ

#tar zxf dialup_admin.tar.gz

แก้ไข ใน httpd.conf ด้วยครับ
<Directory /home/golf/public_html>
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
#RedirectMatch ^/$ /dialup/htdocs/
Allow from all
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/golf/.htpasswd
require valid-user
</Directory>

ต่อไปสร้างไฟล์ .htpasswd ที่ /home/golf โดย
#htpasswd -c /home/golf/.htpasswd usergolf
ใส่ pass ลงไป

ต่อไป import ฐานข้อมูลต้องไปทำใน phpmyadmin เท่านั้น ไม่งั้นจะทำให้ ตารางมีปัญหา ได้ครับ
ของ radius จะมี radius.sql = nas , radacct, radcheck , radgroupcheck , radgroupreply ,radpostauth ,
radreply , usergroup
ของ dialup_admin จะมี 4 ตาราง = badusers , mtotacct ,totacct , userinfo

เท่านี้ก็เรียบร้อย เวลาเข้าเว็บก็
http://xxx.xxx.xxx.xxx/dialup/htdocs
ครับ login เข้าไปก็จะจัดการ radius ได้หมดครับ

1013
#mysql -p

>use db_name;

>check table table_name;

เวลาจะซ่อม table ที่เสียก็
>repair table table_name;

แค่นี้ก็เรียบร้อยครับ

1014
Change IP VHCS ครับ

วิธีการมีดังต่อไปนี้

1. ปิด vhcs2_daemon
#/etc/init.d/vhcs2_daemon stop

2. แก้ไขค่า ต่าง ๆ ของ ip

#vi /etc/network/interfaces
#vi /etc/resolv.conf
#vi /etc/vhcs2/vhcs2.conf

3. แก้ไขค่าต่าง ๆ ใน Database

#mysql -u root -p

>USE vhcs2;
>UPDATE `server_ips` SET `ip_number` = '203.146.129.142' WHERE `ip_id` = 1;
>UPDATE `domain` SET `domain_status` = 'change' WHERE`domain_status`='ok';
>UPDATE `domain_aliasses` SET `alias_status` = 'change' WHERE `alias_status` = 'ok';
>UPDATE `subdomain` SET`subdomain_status` = 'change' WHERE `subdomain_status`='ok';
>UPDATE `mail_users` SET `status` = 'change' WHERE `status` = 'ok';
>quit

4. สั่งให้เริ่มทำการ update อีกครั้ง

#/var/www/vhcs2/engine/vhcs2-rqst-mngr

5. ทำการ สั่ง start vhcs2_daemon อีกครั้ง

#/etc/init.d/vhcs2_daemon start

สำเร็จจนได้ครับ

1015
all application on unix knowledges by golfreeze / add php module to php in directadmin
« on: มกราคม 24, 2011, 12:17:15 PM »
cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2
cp -fp configure/ap2/configure.php5 custom/ap2/configure.php5
#เพิ่ม module ที่ต้องการโดยใส่ --with-module เข้าไปในไฟล์ custom/ap2/configure.php5 ,
# อย่าลืมเครื่องหมาย \ ปิดท้ายด้วยนะครับ จากนั้นสั่ง

#ใช้สำหรับเป็น php5
./build php 5

#ใช้สำหรับเป็น php4
./build php 4


##Linux
/sbin/service httpd restart

##FreeBSD
/usr/local/etc/rc.d/httpd restart

1016
สำหรับผมได้ลองเล่น SAN มา
ซึ่งเป็นที่รู้กันว่า OS ที่เป็น opensource ที่ support san นั้น
ก็มี RHEL กับ Suse จึงค่อยข้างผูกขาดทางด้าน driver สำหรับ
distro อื่นๆ เหลือเกิน ซึ่งปกติ ผมจะชอบใช้ debian

ซึ่งก็ต้องออกแรง หา driver หน่อย

เริ่มจาก

การ boot ที่ผิดพลาดของตัว server ซึ่งเมื่อต่อกับ san แล้วทำให้
kernel ไปอ่าน driver ตัว QLE2460 ก่อนซึ่งเป็นการ์ด HBA ของทาง Qlogic ซึ่งเอาไว้ส่งผ่านข้อมูลไปยังตัว
SAN

ทำให้มันไปมองหา partition root (sda1) ใน HDD ใน server ไม่เจอ เราก็เลยต้อง map เข้ากับ LABEL
เพื่อแก้ไขปัญหานี้ครับ
Boot เข้า Server โดยไม่ต้องต่อ SAN ก่อน
จัดการแปลง label
#tune2fs -L root /dev/sda1
เสร็จแล้วเปลี่ยนค่าใน ไฟล์
/etc/fstab
ให้เป็น
#
# /etc/fstab - static file system information.
#
LABEL=root / ext3 defaults,errors=remount-ro 0 1
/dev/sda2 none swap sw 0 0
----------------------------------------------------------------------
อีกไฟล์ที่แก้ไข ก็คือ /boot/grub/menu.lst
จาก
# kopt=root=/dev/sda1 ro acpi=off noapic
ไปเป็น

# kopt=root=LABEL=root ro acpi=off noapic

แล้วทำการ restart เครื่องซะ คราวนี้ก็ boot ผ่านไปอย่างไร้ปัญหาครับ

เด๋วมาต่อเรื่อง SAN น่ะครับ

1017
ขั้นตอนแรกเข้าไป ยัง folder ที่เป็น folder ที่จะเปลี่ยน
#chgrp ชื่อgroup -R * &
เสร็จแล้วสั่ง
#find . -mindepth 1 -maxdepth 1 -type d | while read DIR; do chown -R $(basename"$DIR") "$DIR"; done

แค่นี้ก็เรียบร้อย ครับ

1018
MySQL Slave:

Now extract mysql-4.1.12.tar.gz at different dir,

cd /opt/mysql-4.1.12

./configure --prefix=/usr/local/mysql-slave

make

make install

cd /usr/local/mysql-slave

cd bin

./mysql_install_db
(it will create a var folder )

cd ../var

cp /opt/mysql-4.1.12/support-files/my-medium.cnf my.cnf

cd ..

groupadd mysql

useradd -g mysql mysql

chown -R root .

chown -R mysql var

chgrp -R mysql .

Edit my.cnf in the var folder

[mysqld]

port = 3307

socket = /usr/local/mysql-slave/var/mysql.sock



#skip-networking



server-id = 2



# The replication master for this slave - required

master-host = localhost

master-user = slavedb

master-password = q1w2e3r4t5

master-port = 3306


Now starts the mysql server by:

cd /usr/local/mysql-slave/bin

./mysqld_safe --defaults-file=/usr/local/mysql-slave/var/my.cnf &
Configure Replication:

connect to mysql master by:

mysql --sock=/usr/local/mysql-master/mysql.sock

Create account at master for slave:

mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO
slavedb@"192.168.1.27/255.255.255.0";;; identified by 'q1w2e3r4t5'; Query OK, 0
rows affected (0.28 sec)

connect to mysql slave by:

mysql --sock=/usr/local/mysql-slave/mysql.sock

mysql> slave start;
Query OK, 0 rows affected, 1 warning (0.04 sec)

Testing:

mysql connect at master:

mysql> show master status\G;

*************************** 1. row ***************************

File: adam-bin.000001

Position: 227

Binlog_Do_DB:

Binlog_Ignore_DB:

1 row in set (0.01 sec)



ERROR:

No query specified

connect mysql at slave

mysql> show slave status\G;

*************************** 1. row ***************************
Slave_IO_State: Connecting to master

Master_Host: localhost

Master_User: slavedb

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: adam-bin.000001

Read_Master_Log_Pos: 4

Relay_Log_File: adam-relay-bin.000001

Relay_Log_Pos: 4

Relay_Master_Log_File: adam-bin.000001

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 4

Relay_Log_Space: 4

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: NULL

1 row in set (0.00 sec)



ERROR:

No query specified

binlog file at masterand its position must be same in mysql slave by show slave status\G;

If every things fine, you are running a working copy of one-one master and slave relation on same
system.


Some Issues:

Replication may be fail because of number of issues. I share some of my experience with
replication.

issue: replication fails, master got down.

Master could be down due to many of the reasons. Do CHECK the FILE LIMITS IN DATABASE, SQL QUERIES
AND DISK USAGE. If any of the reason shows, fix that, restart mysqld and check master status:

mysql> show master status\G;
*************************** 1. row ***************************

adam-bin.000003

Position: 227
Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.01 sec)


now check slave: by show slave status:

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: localhost
Master_User: slavedb
Master_Port: 3306
Connect_Retry: 60

Master_Log_File: adam-bin.000001

Read_Master_Log_Pos: 4

Relay_Log_File: adam-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: adam-bin.000001

Slave_IO_Running: No

Slave_SQL_Running: Yes

Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 4
Relay_Log_Space: 4
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
1 row in set (0.00 sec)

as above values shows that master has incremented to 3rd binlog while slave is still pointed to
binlog1. so change this value by connecting at mysql slave

mysql>; stop slave;

mysql> change master to master_log_file='adam-bin.000003', master_log_pos=227;

mysql> start slave;

Now check with show slave status\G; its working fine.

Issue 2: At Slaves if duplicate error key appear
i.e
At slave

Mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.0.0.152
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: adam-bin.000048
Read_Master_Log_Pos: 317714810
Relay_Log_File: db4-relay-bin.000001
Relay_Log_Pos: 290512385
Relay_Master_Log_File: adam-bin.000048
Slave_IO_Running: Yes

Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1062

Last_Error: Error 'Duplicate entry 'dekq5g820avnfdmar5qi9dkhv3' for key 1' on query.
Default database:'session_sql'. Query: 'INSERT INTO sessi ons5 VALUES
('dekq5g820avnfdmar5qi9dkhv3', UNIX_TIMESTAMP(NOW()) + 18000, 'redir ect|i:1;')'
Skip_Counter:0
Exec_Master_Log_Pos: 290512419
Relay_Log_Space: 317714776
Until_Condition: None
Until_Log_File:
Until_Log_Pos:0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
1 row in set (0.00 sec)

That means that by unavailablilty of master, slave was read, or unavailability of slave, master was
updated, so a query got two primary keys found for one entry which is a mess up.
So fixing it is by:
At slave:

Mysql> set global sql_slave_skip_counter=1;

Mysql> start slave;

Mysql> show slave status\G;

1019
all application on unix knowledges by golfreeze / install clipshare packetlove.com
« on: มกราคม 24, 2011, 12:00:20 PM »
Packetlove.com

==== Web Hosting support ffmpeg ====

เริ่มต้น ก็
#tar zxf video_packetlove.tar.gz
#cd cgi-bin
#mv * ../cgi-bin

#แก้ไข cgi-bin/configs/uu_default_config.pm ไฟล์ที่เป็น config รอง
#vi uu_default_config.pm

#แก้ไข file config หลักที่ใช้แสดง ไฟล์ video ใน
#vi include/config.php

#แก้ไข file ที่ติดต่อ db
#vi include/dbconfig.php

ทำการ chown ให้ถูกต้อง

ทำการ chmod 777 กับ folder
video
flvideo
chimg
tmp
thumb
templates
templates_c
photo
images

เรียบร้อย วิธีลง ffmpeg สไตล์ golfreeze@packetlove.com

1020
#cd /usr/ports/net/ntp
#make install clean

vi /etc/ntp.conf

#server ntplocal.example.com prefer
#server timeserver.example.org
#server ntp2a.example.net
server clock.nectec.or.th
server 127.127.1.0
server xxx.xxx.com
fudge 127.127.1.0 stratum 13
restrict 202.142.213.0 mask 255.255.255.0

driftfile /var/db/ntp.drift

------------------------------------------------------
#vi /etc/rc.conf
ntpd_enable="YES"
------------------------------------------------------
สั่งให้ service ทำงาน
/etc/rc.d/ntpd stop
/etc/rc.d/ntpd start

###test
#ntpq -p
#ntpdate 202.142.213.172

Pages: 1 ... 66 67 [68] 69 70 ... 73