目前分類:freebsd (6)

瀏覽方式: 標題列表 簡短摘要

Upgrading mysql 5.1 to 5.5 on FreeBSD
Hi there! I just completed our upgrade of mysql so I thought I'd let people know how to do it the correct way as I can see alot of people missing some vital steps to have everything running smoothly afterwards. I managed to do the upgrade with 15 seconds of downtime (when you install 5.5 it will shutdown mysql-server so while installing mysql will be offline). 1. The first thing you have to do is check what ports depends on your current version of mys...

Hi there!

I just completed our upgrade of mysql so I thought I'd let people know how to do it the correct way as I can see alot of people missing some vital steps to have everything running smoothly afterwards. I managed to do the upgrade with 15 seconds of downtime (when you install 5.5 it will shutdown mysql-server so while installing mysql will be offline).

1. The first thing you have to do is check what ports depends on your current version of mysql-client, this can be done by issuing
portupgrade -frn mysql-client

if you're using portmaster you obvisously have to change the flags to whatever the portmaster equivalent is, but as im a portupgrade kind of guy I wont get into that. What this command does is that it tries to force rebuild all ports that depends on mysql-client, but as we also used the "n" flag, it wont start doing anything (only a test). So you should now have a huuuuge list of ports that requires the mysql-client port to work correctly, save this list to a safe location because you will need it later (you can remove mysql-client and mysql-server from this list as your going to reinstall those anyway)

2. Now before you start doing anything stupid, after issuing the below stated commands, do NOT restart apache/php-fpm afterwards until you have rebuilt apache/php because you will then get downtime due to that because those softwares will stop working until rebuilt. If you're using postfix for mail, it will stop working at the moment you deinstall mysql51-server, so if you're using postfix for your mailaccounts, you want to rebuild that port the first thing you do in step 3 and then restart postfix.

So start by uninstalling mysql51-client and mysql51-server
cd /usr/ports/databases/mysql51-client
make deinstall
cd /usr/ports/databases/mysql51-server
make deinstall

Now install mysql 5.5 server (will install mysql 5.5 client automatically)
cd /usr/ports/databases/mysql55-server
make install clean

Now that you've got the new shit installed, fire it up and also run mysql_upgrade afterwards
/usr/local/etc/rc.d/mysql-server start
mysql_upgrade -u root -p

After mysql_upgrade is done I usually restart mysql again (just in case)

3. You now have mysql 5.5 installed and running, however, all your software are still using the 5.1 client, so at this point, DO NOT RESTART ANY SOFTWARE. As most software keeps a copy of it's libraries in memory so everything should be working just fine until restart.

If you're running postfix, the first thing you want to do is this
portupgrade -fO postfix
# If your using mysql as userdatabase
portupgrade -fO p5-DBD-mysql
# If your using spamassassin
portupgrade -fO p5-Mail-SpamAssassin

There is probably more p5- ports that you have in your list, rebuild all those and then restart postfix and you should be good to go.

Now, take the list of ports you saved in step 1 and rebuild every single one of them. You probably have alot of php ports in it if you're using php, heres an easy way of getting that stuff rebuilt without problems
portupgrade -fO php5*
# If your also using pecl modules and eaccelerator
# issue the below command
portupgrade -fO pecl* eaccelerator

If you're using apache you probably have apache22, mod_perl and apr1 in the list
portupgrade -fO www/apache22 www/mod_perl2 devel/apr1

The most basic webstuff is now done and it's safe to restart apache, however, you will have to rebuild all ports you have in your list for them to work correctly. So before restarting a software, make sure you have rebuilt that port and those ports that it depends on. When you think your done, meaning you have rebuilt all ports in your list, you can run pkgdb -F to remove all the dependencies to the old mysql-client. After that you can run portversion just to check that there is no dependency warning, if there is no warning, well done!

Thats all from me this time, hope this helped someone out.

Cya!
- See more at: http://www.203creative.se/blogg/upgrading-mysql-5-1-to-5-5-on-freebsd.html#sthash.xD80sq78.dpuf

bluenature0904 發表在 痞客邦 留言(0) 人氣()


Installing OpenBSD 5.3 i386 / amd64 using softraid (also works on OpenBSD 5.1 and 5.2)

Posted on July 19, 2012     by Spirited Blowfish
Please note currently only the i386 and amd64 kernels allow booting directly from a softraid array.  Other supported architectures require the kernel to be located on a small (100MB) non-softraid partition.

I recently purchased a HP Proliant MicroServer N40L, and a couple of Western Digital RE4 enterprise drives to use in a RAID 1 array.  The process of configuring the softraid RAID array was as simple as follows:

Boot off the 5.3 media as per usual, but choose (S)hell instead of (I)nstall.

(I)nstall, (U)pgrade or (S)hell? s
# cd /dev
# sh /dev/MAKEDEV sd1 sd2
# fdisk -iy sd0
Writing MBR at offset 0.
# fdisk -iy sd1
Writing MBR at offset 0.
# disklabel -E sd0
Label editor (enter ‘?’ for help at any prompt)
> a a
offset: [64] [ENTER]
size: [976768001] [ENTER]
FS type: [4.2 BSD] RAID
> q
Write new label?: [y] y
# cd /tmp
# disklabel sd0 > protofile
# disklabel -R sd1 protofile
# bioctl -c 1 -l /dev/sd0a,/dev/sd1a softraid0
sd2 at scscibus2 targ 1 lun 0: SCSI2 0/direct fixed
sd2: 476937MB, 512 bytes/sector, 976767473 sectors
softraid0: SR RAID 1 volume attached as sd2
# dd if=/dev/zero of=/dev/rsd2c bs=1m count=1
1+0 records in
1+0 recours out
1048576 bytes transferred in 0.031 secs (32996916 bytes/sec)
# exit

That will place you back at the (I)nstall, (U)pgrade or (S)hell? prompt and you can install as per normal.  Just be sure to  install to the newly created sd2 array.  Partitions on the array can be configured as per usual, using 4.2 BSD/swap FS types.  Once you’re done reboot as per usual and you’ll be up and running with softraid.  To make sure you can check your array status with the bioctl command.

# bioctl softraid0
Volume        Status                             Size  Device

#

It’s also worth noting that softraid can handle RAID 0, 5 and more.  To configure a RAID 0 stripe you would follow the guide for RAID 1 but change the bioctl command:

# bioctl -c 0 -l /dev/sd0a,/dev/sd1a softraid0

A quick example for configuring 3 drives in RAID 5 would be as follows:

(I)nstall, (U)pgrade or (S)hell? s
# cd /dev
# sh /dev/MAKEDEV sd1 sd2 sd3
# fdisk -iy sd0
# fdisk -iy sd1
# fdisk -iy sd2
# disklabel -E sd0
> a a
offset: [64] [ENTER]
size: [976768001] [ENTER]
FS type: [4.2 BSD] RAID
> q
Write new label?: [y] y
# cd /tmp
# disklabel sd0 > protofile
# disklabel -R sd1 protofile
# disklabel -R sd2 protofile
# bioctl -c 5 -l /dev/sd0a,/dev/sd1a,/dev/sd2a softraid0
# dd if=/dev/zero of=/dev/rsd3c bs=1m count=1
# exit

You would then install to the newly created sd3 array.

As always be sure to check the man pages if you’re not sure what a command does.

softraid (4)
bioctl (8)
fdisk (8)
disklabel (8)

bluenature0904 發表在 痞客邦 留言(0) 人氣()


Installing OpenBSD 5.3 i386 / amd64 using softraid (also works on OpenBSD 5.1 and 5.2)

Posted on July 19, 2012     by Spirited Blowfish
Please note currently only the i386 and amd64 kernels allow booting directly from a softraid array.  Other supported architectures require the kernel to be located on a small (100MB) non-softraid partition.

I recently purchased a HP Proliant MicroServer N40L, and a couple of Western Digital RE4 enterprise drives to use in a RAID 1 array.  The process of configuring the softraid RAID array was as simple as follows:

Boot off the 5.3 media as per usual, but choose (S)hell instead of (I)nstall.

(I)nstall, (U)pgrade or (S)hell? s
# cd /dev
# sh /dev/MAKEDEV sd1 sd2
# fdisk -iy sd0
Writing MBR at offset 0.
# fdisk -iy sd1
Writing MBR at offset 0.
# disklabel -E sd0
Label editor (enter ‘?’ for help at any prompt)
> a a
offset: [64] [ENTER]
size: [976768001] [ENTER]
FS type: [4.2 BSD] RAID
> q
Write new label?: [y] y
# cd /tmp
# disklabel sd0 > protofile
# disklabel -R sd1 protofile
# bioctl -c 1 -l /dev/sd0a,/dev/sd1a softraid0
sd2 at scscibus2 targ 1 lun 0: SCSI2 0/direct fixed
sd2: 476937MB, 512 bytes/sector, 976767473 sectors
softraid0: SR RAID 1 volume attached as sd2
# dd if=/dev/zero of=/dev/rsd2c bs=1m count=1
1+0 records in
1+0 recours out
1048576 bytes transferred in 0.031 secs (32996916 bytes/sec)
# exit

That will place you back at the (I)nstall, (U)pgrade or (S)hell? prompt and you can install as per normal.  Just be sure to  install to the newly created sd2 array.  Partitions on the array can be configured as per usual, using 4.2 BSD/swap FS types.  Once you’re done reboot as per usual and you’ll be up and running with softraid.  To make sure you can check your array status with the bioctl command.

# bioctl softraid0
Volume        Status                             Size  Device

#

It’s also worth noting that softraid can handle RAID 0, 5 and more.  To configure a RAID 0 stripe you would follow the guide for RAID 1 but change the bioctl command:

# bioctl -c 0 -l /dev/sd0a,/dev/sd1a softraid0

A quick example for configuring 3 drives in RAID 5 would be as follows:

(I)nstall, (U)pgrade or (S)hell? s
# cd /dev
# sh /dev/MAKEDEV sd1 sd2 sd3
# fdisk -iy sd0
# fdisk -iy sd1
# fdisk -iy sd2
# disklabel -E sd0
> a a
offset: [64] [ENTER]
size: [976768001] [ENTER]
FS type: [4.2 BSD] RAID
> q
Write new label?: [y] y
# cd /tmp
# disklabel sd0 > protofile
# disklabel -R sd1 protofile
# disklabel -R sd2 protofile
# bioctl -c 5 -l /dev/sd0a,/dev/sd1a,/dev/sd2a softraid0
# dd if=/dev/zero of=/dev/rsd3c bs=1m count=1
# exit

You would then install to the newly created sd3 array.

As always be sure to check the man pages if you’re not sure what a command does.

softraid (4)
bioctl (8)
fdisk (8)
disklabel (8)

bluenature0904 發表在 痞客邦 留言(0) 人氣()

UNIX / Linux: HowTo Use unison File Synchronizer

by nixCraft on August 16, 2010 · 2 comments· last updated at August 16, 2010

I know how to use rsync for Unix systems which synchronizes files and directories from one location to another while minimizing data transfer. However, I would like to synchronizing files between two directories, either on one computer, or between a computer and another server. How do I maintain the same version of files on multiple servers?

Unison is a file-synchronization tool for Unix and Windows.

It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other. This is useful for:

  1. Backups.
  2. Web server cluster.
  3. Sync home and office files.

Install unison

Type the following command under RHEL / CentOS Linux (make sure you turn on EPEL repo):
# yum install unison
Type the following command under Debian / Ubuntu Linux:
# apt-get update && apt-get install unison
Type the following command under FreeBSD:
# cd /usr/ports/net/unison/ && make install clean

How Do I Use unison?

In this example, sync /tmp/test1 to /tmp/test2 as follows:
# mkdir /tmp/test{1,2}
# cd /tmp/test1
# touch file{1,2,3}
# ls -l

Sample outputs:

total 12
-rw-r--r-- 1 root root 0 Aug 16 12:09 file1
-rw-r--r-- 1 root root 0 Aug 16 12:09 file2
-rw-r--r-- 1 root root 0 Aug 16 12:09 file3

Now, try to sync it:
# unison /tmp/test1 /tmp/test2
Sample outputs:

Contacting server...
Connected [//vivek-desktop//tmp/test1 -> //vivek-desktop//tmp/test2]
Looking for changes
Warning: No archive files were found for these roots, whose canonical names are:
	/tmp/test1
	/tmp/test2
This can happen either
because this is the first time you have synchronized these roots,
or because you have upgraded Unison to a new version with a different
archive format.
Update detection may take a while on this run if the replicas are
large.
Unison will assume that the 'last synchronized state' of both replicas
was completely empty. This means that any files that are different
will be reported as conflicts, and any files that exist only on one
replica will be judged as new and propagated to the other replica.
If the two replicas are identical, then no changes will be reported.
If you see this message repeatedly, it may be because one of your machines
is getting its address from DHCP, which is causing its host name to change
between synchronizations. See the documentation for the UNISONLOCALHOSTNAME
environment variable for advice on how to correct this.
Donations to the Unison project are gratefully accepted:
http://www.cis.upenn.edu/~bcpierce/unison
Press return to continue.[ ] Reconciling changes
test1     test2
file   ---->      file1 [f]
file   ---->      file2 [f]
file   ---->      file3 [f]
Proceed with propagating updates? [] y
Propagating updates
UNISON 2.27.57 started propagating changes at 12:11:18 on 16 Aug 2010
[BGN] Copying file1 from /tmp/test1 to /tmp/test2
[END] Copying file1
[BGN] Copying file2 from /tmp/test1 to /tmp/test2
[END] Copying file2
[BGN] Copying file3 from /tmp/test1 to /tmp/test2
[END] Copying file3
UNISON 2.27.57 finished propagating changes at 12:11:18 on 16 Aug 2010
Saving synchronizer state
Synchronization complete (3 items transferred, 0 skipped, 0 failures)

The -batch (batch mode) option ask no questions at all, enter:
# rm /tmp/test1/file3
# echo 'foo' >> /tmp/test2/file2
# unison -batch /tmp/test1 /tmp/test2

Sample outputs:

Contacting server...
Connected [//vivek-desktop//tmp/test1 -> //vivek-desktop//tmp/test2]
Looking for changes
Reconciling changes
     <---- changed  file2
test1    : unchanged file   modified on 2010-08-16 at 12:11:18 size 0     rw-r--r--
test2    : changed file    modified on 2010-08-16 at 12:14:59 size 4     rw-r--r--
deleted ---->      file3
test1    : deleted
test2    : unchanged file   modified on 2010-08-16 at 12:09:31 size 0     rw-r--r--
Propagating updates
UNISON 2.27.57 started propagating changes at 12:15:11 on 16 Aug 2010
[BGN] Updating file file2 from /tmp/test2 to /tmp/test1
[END] Updating file file2
[BGN] Deleting file3 from /tmp/test2
[END] Deleting file3
UNISON 2.27.57 finished propagating changes at 12:15:11 on 16 Aug 2010
Saving synchronizer state
Synchronization complete (2 items transferred, 0 skipped, 0 failures)

Remote Server Synchronizer

First, make sure you use the same version on local and remote server. Use the following command to test that the local unison client can start and connect to the remote server:
# unison -testServer /tmp/test1 ssh://server1.cyberciti.com//tmp/test1
Sample outputs:

Contacting server...
Connected [//vivek-desktop//tmp/test1 -> //server1.cyberciti.com//tmp/test1]

To sync, enter:
# unison -batch /tmp/test1 ssh://server1.cyberciti.com//tmp/test1
Delete or add a new file from or to server1.cyberciti.com//tmp/test1 directory and try again:
# unison -batch /tmp/test1 ssh://server1.cyberciti.com//tmp/test1

Sample Shell Scripts

Create a sample shell script as follows (sync.dirs.sh):

#!/bin/bash
# set paths / dirs
_paths="/var/www/html/ \
/etc/ \
/home/vivek/ \
/projects/scripts/*.pl"
 
# binary file name
_unison=/usr/bin/unison
 
# server names 
# sync server1.cyberciti.com with rest of the server in cluster
_rserver="server2.cyberciti.com server3.cyberciti.com"
 
# sync it
for r in ${_rserver}
do
	for p in ${_paths}
	do
    	${_unison} -batch "${p}" "ssh://${r}/${p}"
	done
done
 

Save and close the file. Setup a cronjob as follows:

*/30 * * * * /path/to/sync.dirs.sh &>/tmp/sync.dirs.sh.log

Make sure you setup ssh keys or use keychain to avoid the password prompt.

How Do I Call unison On Demand?

You need to use the incrond (inotify cron daemon) is a daemon which monitors filesystem events (such as add a new file, delete a file and so on) and executes commands or shell scripts. It’s use is generally similar to cron. In this example, call sync.dirs.sh whenever files uploaded or deleted from /var/www/html (see inotify FAQ for more info):
/var/www/html IN_CLOSE_WRITE,IN_CREATE,IN_DELETE /path/to/sync.dirs.sh

bluenature0904 發表在 痞客邦 留言(0) 人氣()

chmod: 改變檔案模態


檔案的許可權乃根據模態改變. 模態可以分為 絕對模態 與 符號模態 , 絕對模態是一個由下列模態位元的邏輯 OR 構 成的八進位數:

各種模態位元:

	  + ---------- 4000 將使用者識別碼設定於執行 (檔案)
	  |		 或隱藏目錄 
	  | + ----- 2000 將使用群識別碼設定於執行
	  | | + -- 1000 固著位元
	  | | |
	  s s t

許可權模態位元:
	 + ------------------ 0400 可由所有者讀出
	 | + ---------------- 0200 可由所有者寫入
	 | | + -------------- 0100 可由所有者執行 (在目錄中搜尋)
	 | | | + ------------ 0040 可由所有群成員讀出
	 | | | | + ---------- 0020 可由所有群成員寫入
	 | | | | | + -------- 0010 可由所有群成員執行或搜尋
	 | | | | | | + ------ 0004 可由其他人讀出
	 | | | | | | | + ---- 0002 可由其他人寫入
	 | | | | | | | | + -- 0001 可由其他人執行或搜尋
	 | | | | | | | | |
	 r w x r w x r w x
符號模態的形式如下:
	 [ who ] op permission [ op permission ]
其中 who 的部份由三個字母組成: u 代表使用者許可權, g 為 使用群許可權, o 為其他人的許可權. 如果其中沒有 who, 則 以字母 a 代表 ugo 的內定值.

op 的值若為 +, 表示增加該檔案模態的許可權項目, - 為取 消許可權項目; 若為 =, 則為指派絕對許可權 (即重設其餘位 元).

許可權部份可由下列表示許可項目的任何字母組成: r (讀出), w (寫入), x (執行), s (設定所有者和所有群識別碼), H ( 隱藏檔案), 以及 t (儲存內文或固著); u g 或 o 代表現行 模態擁有的許可權. 若省略許可權部份, 只有配合 = 才能剝 奪全部的許可權.

其中也可以加入由逗點分隔的多重符號模態. 作業時則以使用 者指定的順序執行. s 只對 u 或 g 作用, t 則只對 u 作用.

只有所有者 (或高階使用者) 才能改變檔案的模態. 但是只有 高階使用者可以設定固著位元. 要能夠設定使用群識別碼, 檔 案的使用群必須與你目前的使用群識別碼相同.

若在符號鏈中使用 chmod 命令, 則符號鏈所指檔案的模態就會 改變.

例子:

  • 不允許其他人寫入:
    	 chmod o-w file
    
  • 將檔案變為可執行檔:
    	 chmod +x file
    
  • 允許每個人讀出和執行, 以及設定 set-user-ID 位元:
    	 chmod 4555 file
    
  • 允許所有者讀出和寫入, 並允許其他人讀出:
    	 chmod 644 file

bluenature0904 發表在 痞客邦 留言(0) 人氣()

你只要利用WebStress軟體就可以讓你瞭解到你網站上的 Server 性能表現的情形。 WebStress 可以模擬出許多人數在同一時間內進站或是順序進站時你的 Server 的反映情形。你只要輸入網站的 URL 網址以及所要模擬出的進站人數即可,接下來你就可以看到 Server 在這種壓力測試下的評比,它以調解圖行明白地表現出 Server的反映時間、傳輸速率等相關資料。

bluenature0904 發表在 痞客邦 留言(1) 人氣()