A brief short linux how to and problem solving. This blog is intended to be a reference by summarizing from reliable data source and my experience. Readers should have a basic understanding about linux.
วันศุกร์ที่ 14 ตุลาคม พ.ศ. 2554
(link) Nginx "how to" - Fast and Secure webserver
https://calomel.org/nginx.html
วันศุกร์ที่ 30 กันยายน พ.ศ. 2554
mysql commonly use statement
mysql> CREATE table if not exists tblname like old_tblname;
INSERT ... SELECT
mysql> INSERT INTO tblname1 SELECT * from tblname2 where ...;
Empty table
mysql> TRUNCATE table story_longcon_40;
Delete/Drop table
mysql> DROP TABLE tblname;
Delete/Drop database
mysql> DROP {DATABASE | SCHEMA} [IF EXISTS] db_nameOptimize Table
mysql> OPTIMIZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE tbl_name [, tbl_nam
Delete binary logs
This will delete the binary log till master.000080
mysql> purge binary logs to 'master-bin.000081';
Start slave
mysql> START SLAVE [thread_type [, thread_type] ... ]or
mysql> START SLAVE [SQL_THREAD] UNTIL
MASTER_LOG_FILE = 'log_name', MASTER_LOG_POS = log_pos
วันพฤหัสบดีที่ 29 กันยายน พ.ศ. 2554
[MySQL] Backing up data
1) Logical backup
* SQL dumps
#mysqldump dbname tblnameNot suitable for huge backup. Both table structure and the data are stored together.(option available)
* Delimited file backups
backing up :
mysql> SELECT * INTO OUTFILE '/tmp/t1.txt'
-> FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
-> LINES TERMINATED BY '\n'
-> FROM test.t1
restore :
mysql> LOAD DATA INFILE '/tmp/t1.txt'*parallel dump: maatkit(mk-parallel-dump)
-> INTO TABLE test1.t1
-> FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
-> LINES TERMINATED BY '\n';
2) File system snapshot (LVM)
not covered here.
mysql backup/dump/export table schema, definition
1) use mysqldump
server# mysqldump -uroot -p dbname tblname -dwith this method you will get sql statement. You can use this for backing up table definition as well.
2) create table from another table
mysql> create table if not exists tblname like old_tblname;with this method you get a copy of table. It is useful if you want to have a another table with the same structure for backing up, testing.
วันศุกร์ที่ 5 สิงหาคม พ.ศ. 2554
Postfix วิธีการ pipe mail ที่ได้รับ ไปยัง command ต่างๆ
Environment ที่ใช้ทดสอบนะครับ ใช้ Ubuntu 10.04.3, Postfix, Dovecot เป็นหลัก สิ่งที่ต้องการคือ เมื่อมีคนส่ง e-mail มาที่ test@example.com แล้ว ให้ postfix ทำการ pipe email นั้นเข้าสู่โปรแกรม /home/myuser/testperl ซึ่งเป็น perl script ที่ผมเขียนรอไว้ก่อนหน้านี้แล้ว
ทั้งนี้ ตัว postfix ผม config ตัว virtual domains, virtual mailbox ที่ติดต่อกับ mysql server เอาไว้ด้วยนะครับ
เริ่มจาก
- เข้าไปแก้ไข /etc/postfix/main.cf
ที่บรรทัด smtpd_recipient_restrictions เพิ่มคำสั่ง check_recipient_access เข้าไป
smtpd_recipient_restrictions =# bypass checks on outgoing mailpermit_mynetworks# reject if not full email addressreject_non_fqdn_recipient# next line rejects if the account/domain does not exist# ALSO prevents OPEN RELAY - if missing RELAY is OPEN!!# MUST appear before the check_recipient_accessreject_unauth_destination# perform filter access by recipient namecheck_recipient_access hash:/usr/local/etc/postfix/script_filter
- เพิ่ม /etc/postfixscript_filter
test@example.com FILTER support:dummy
- # postmap script_filter จะมีไฟล์ script_filter.db เพิ่มขึ้นมา
- เข้าไปแก้ master.cf
support unix - n n - - pipe flags=Rq user=www argv=/home/myuser/testperl $(sender)$(recipient)
โดยใน perl script จะได้ argument 1 = sender และ argument 2 = receiver
แค่นี้ ระบบก็เรียบร้อยพร้อมใช้งานแล้ว ![]()
วันพฤหัสบดีที่ 16 มิถุนายน พ.ศ. 2554
How to Setup Canon MX350 Series on Ubuntu 11.04 Natty
sudo add-apt-repository ppa:michael-gruz/canon
sudo apt-get update
apt-get install cnijfilter-mx350series
and now you can add printer by
1. Go to search -> printing
2. Add -> Network Printer
3. Canon MX350 Series will appear in left panel
4. Follow the instruction
5. Finish installation