2009年3月5日 星期四

Installing VNC on Fedora

Installing VNC on Fedora:

1.Open a Terminal Window, and type the following to install the VNC Server Package, if NOT already installed:

su -c 'yum -y install vnc-server」

Setting the VNC Password:

1.Type the following command to set the password for your user. This must be repeated for each user in which you would like to provide access for:

vncpasswd

2.You will now be prompted for a password, enter your desired password, then press . You will now be prompted to verify the password you just entered. Verify, then press to move one.

3.After you enter the password for your user, it will create the default configuration files and place them in the /home//.vnc directory. It will also start the VNC Server for your user for the first time. We are NOT ready to log in yet, so type the following to terminate the VNC Server for your user.

vncserver -kill : // Desktop Number will most likely be 「1」

vncserver -kill :1


Customizing VNC Start-up (To Start KDE or Gnome Desktop, instead of default Grey 「rootweave」 Desktop):

NOTE: The VNC Server allows the user to configure various settings specific to them through the use 「xstartup」 file located in the 「.vnc」 directory found in the user's home directory.

1.Change directory to $HOME/.vnc/

2.Open the 「xstartup」 file using the VI editor (my preference) or whatever editor you prefer.

3.Jump to the end of the file. Here you will notice a line similar to the following:

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

*** Here you MUST replace the 「twm」 with either 「startkde」 or 「gnome-session」, to start the GUI Desktop that you are use to.

like this

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &


Add more user for VNC connection:

su - user1
vncserver :1 -geometry 1024x768
Password: xxxxx


Desktop Selection

Default desktop being GNOME.

To change desktop used to KDE, create or edit /etc/sysconfig/desktop:

DESKTOP=GNOME
# DESKTOP=KDE



Make sure xstartup access mode is -rwxr-xr-x (755), if not

chmod 755 ~/.vnc/xstartup

Configuring your Firewall to Allow Access:


1.The following command will open port 5901 (:1) only for access. This is typically the 1st VNCDESKTOP number that gets setup.

su -c '/sbin/iptables -I INPUT -p tcp --destination-port 5901 -j ACCEPT'

This command would open the port range 5901 to 5903 (To allow the first 3 VNCDESKTOP's):

su -c '/sbin/iptables -I INPUT -p tcp --destination-port 5900:5903 -j ACCEPT'

*** If you are unsure which port(s) your VNC Servers are listening on, type the following command; (Assumes Defaults were in place)

netstat -lnt | grep 590* //This will check ports 5900-5901

If all goes well, and you have VNC Server's listening, you should see a response similar to the following:


$ netstat -lnt | grep 590*
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN

*** This tells me ports 5901 and 5902 are listening.

2.Next, save the new rules with the following command:

su -c '/sbin/iptables-save > /etc/sysconfig/iptables'

3.Confirm the settings were successful with the following command:

su -c '/sbin/iptables -L'

*** You should see an output line similar to the following:

ACCEPT tcp -- anywhere anywhere tcp dpts:5900:5903


Manually Starting VNC Desktops:

This is a very simple step, once you have configured the desired settings for your user. Type the following:

vncserver

*** You should now get a response, telling you which Desktop Number you just started. Be Careful that you don't start Multiple Desktops by accident. This can be done very easily, if you don't properly kill old desktops before opening new ones.


Automating VNC on Startup:


1.The following command is used to start VNC Server at system boot, for runlevel 5 (Multi-User X);

su -c 'chkconfig --level 5 vncserver on'

*** The default VNC start-up file can be found in the following location, and can be opened/edited with VI or your favorite editor:

/etc/init.d/vncserver

*** However if you are simply wanting to add which VNC Desktops you would like started, edit the following file:

/etc/sysconfig/vncservers

2009年2月26日 星期四

Make Symbolic link for mirror Rsync

Symbolic link : atmail
Real Directory : atmaildata

atmail -> atmaildata

1. rename the existing directory name (main and mirror server).
mv atmail atmaildata


2. modify the rsync.sh in the main server.
vi rsync.sh
change /usr/local/atmail --> /usr/local/atmaildata


3. change own for the symbolic link (main and mirror server).
chown -h atmail:atmail atmail


2009年2月18日 星期三

MySQL Commands

http://www.pantz.org/software/mysql/mysqlcommands.html

This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. To use MySQL with Perl you will need to use the Perl modules DBI and DBD::mysql.

Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.

To login (from unix shell) use -h only if needed.

# [mysql dir]/bin/mysql -h hostname -u root -p

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in the db.

mysql> show tables;


To see database's field formats.

mysql> describe [table name];

To delete a db.

mysql> drop database [database name];

To delete a table.

mysql> drop table [table name];

Show all data in a table.

mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];

Show certain selected rows with the value "whatever".

mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";

Show all records containing the name "Bob" AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';

Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;

Show all records starting with the letters 'bob' AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';

Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;

Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";

Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];

Sum column.

mysql> SELECT SUM(*) FROM [table name];

Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;

Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Set a root password if there is on root password.

# mysqladmin -u root password newpassword

Update a root password.

# mysqladmin -u root -p oldpassword newpassword

Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;

Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

or

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

To update info already in a table.

mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';

Delete a row(s) from a table.

mysql> DELETE from [table name] where [field name] = 'whatever';

Update database permissions/privilages.

mysql> flush privileges;

Delete a column.

mysql> alter table [table name] drop column [column name];

Add a new column to db.

mysql> alter table [table name] add column [new column name] varchar (20);

Change column name.

mysql> alter table [table name] change [old column name] [new column name] varchar (50);

Make a unique column so you get no dupes.

mysql> alter table [table name] add unique ([column name]);

Make a column bigger.

mysql> alter table [table name] modify [column name] VARCHAR(3);

Delete unique from table.

mysql> alter table [table name] drop index [colmn name];

Load a CSV file into a table.

mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);

Dump all databases for backup. Backup file is sql commands to recreate all db's.

# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql

Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql

Dump a table from a database.

# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql

Restore database (or database table) from backup.

# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql

Create Table Example 1.

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

Create Table Example 2.

mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');


Change own for Symbolic Link

To change the group ownership of symbolic link, simply use the -h or –no-dereference flag to the chgrp command.

Example:

chgrp -h new_group symbolic_link_name

chown -h sam:sam link_name

2009年2月12日 星期四

Fedora 10 - Plymouth Graphical Boot


http://www.my-guides.net/en/content/view/125/26/1/12/#plymouth

Plymouth Graphical Boot

Plymouth is the new Graphical Boot of Fedora 10 which replaces the old RHGB. It requires kernel modesetting (KMS) support to work properly. KMS is currently supported on most ATI Radeon chips; anything from the Radeon 9500 and newer should work. Intel KMS support is in development, but is not yet supported. For all other graphics hardware, the text plugin is used. If you see only a scrolling bar when booting to Fedora you can try to force your Hardware into graphics mode without using KMS support. To do so reat below at the Graphical Boot Problem. However you could first try and change this theme to another one to see if it works without any changes to your grub.conf.

* Plymouth Themes

By default only the solar and text themes are installed. To add additional plymouth themes type:


yum install plymouth-plugin-{fade-in,pulser,spinfinity}


Now you can try any theme you want like this. Just replace pluginname with one of the following: solar, fade-in, pulser, spinfinity, text.


plymouth-set-default-plugin pluginname
/usr/libexec/plymouth/plymouth-update-initrd


After that just reboot your computer.

* Graphical Boot Problem

While booting in Fedora 10 you might have seen a blue scrolling bar loading instead of the grub's graphical boot screen. This has happened because of the modesetting option of the kernel that Fedora 10 uses. In order to see the graphical boot you must edit grub.conf and add a vga resolution to it. Here it is how:


gedit /boot/grub/grub.conf



Here you must add your framebuffer resolution at the end of the kernel line. Something like this:


title Fedora (2.6.27.5-117.fc10.i686)
root (hd0,9)
kernel /boot/vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=a61c8338-e373-4389-ae00-32942185f7c2 rhgb quiet vga=792
initrd /boot/initrd-2.6.27.5-117.fc10.i686.img


vga=792 stands for 1024x768 resolution with 24-bit colours. You can find the resolution you like from here . Just look at the second table.

2009年2月10日 星期二

Install VBoxLinuxAdditions and set full screen

1. install VBoxLinuxAdditions

type bellow in terminal.


yum install kernel
yum install kernel-devel


cd /media/VirtualBox_1.5.6_Guest_Additions

sh ./VBoxLinusAdditions.run / sudo ./VBoxLinusAdditions.run



reboot

2. set full screen

make sure the VirtualBox Linux resolution is same as Windows.

- change the Linux monitor to "monitor 1200*1024"

a. in linux, System -> Administration -> Display
b. in Display windows -> Hardware -> Monitor -> "Generic ..." -> "1280*1024"
c. after reboot, press "host key(e.g. alt) + F" to switch the full screen.

2009年1月28日 星期三

坐騎巨集

http://wowbox.tw/bbs/viewtopic.php?f=57&t=13375
/跑 local m=GetZoneText() if (m=="達拉然" or m=="冬握湖"or m=="奧核之眼") and (GetSubZoneText()~="卡薩斯平臺") then CallCompanion("mount",45);end
/使用 [swimming]水棲形態;[flyable,nomounted]迅捷飛行形態; [nomounted]大型白色科多獸
/dismount [mounted]

這是目前我在使用的坐騎巨集。

一、在達拉然、冬握湖等不能用飛行坐騎的地方,會自動使用 CallCompanion("mount",45) 的坐騎。※紅色的45是坐騎頁面中第45隻坐騎,玩家可以自行改成自己喜歡的陸地坐騎編號。
二、在可以飛的地方,會自動用迅捷飛行形態。(可以改成自己愛用的飛行座騎)
三、在不能飛的艾澤拉斯,則用大型白色科多獸。(可以改成自己愛用陸地座騎)
四、非小德玩家,請把「[swimming]水棲形態;」刪除,程式改為:

/跑 local m=GetZoneText() if (m=="達拉然" or m=="冬握湖"or m=="奧核之眼") and (GetSubZoneText()~="卡薩斯平臺") then CallCompanion("mount",45);end
/使用 [flyable,nomounted]迅捷飛行形態; [nomounted]大型白色科多獸
/dismount [mounted]

2009年1月22日 星期四

cron job for zip last 7 days files

1. set schedule for run cronjob every hr
crontab -e

0 */1 * * * (. archive.sh > archiveJob.log 2>&1)


2. prepare a job for backup and zip the file last 7 days ( not include today ! )

archive.sh

#!/bin/sh

logpath=/usr/local/jboss/server/default/log
fname=`echo a b c d e f g h`
bday=7

cd $logpath

echo -e "\n$logpath\n"

for (( i=$bday;i>=1;i=i-1 ))
do
ddate=`/bin/date +%Y-%m-%d -d -"$i"day`

if [ -e "$logpath"/server.log."$ddate" ]; then
gzip server.log."$ddate"
mv server.log."$ddate".gz archive/
echo server.log."$ddate" moved.
fi

for f in $fname
do
if [ -e "$logpath"/server.log."$ddate$f" ]; then
gzip server.log."$ddate$f"
mv server.log."$ddate$f".gz archive/
echo server.log."$ddate$f" moved.
fi
done

done

#cd /usr/local/jboss/bin
#sh run.sh &

echo -e "
----------------------------------------
Server Log Backup and Archive Finished.
----------------------------------------
"

2009年1月13日 星期二

Changing the default message/header encoding

http://atmail.com/kb/2006/changing-the-default-messageheader-encoding/

@Mail uses a strict header parsing for displaying messages via Webmail. Encoding issues can occur if messages are received by @Mail without specifying the encoding of the message or headers.For example, a user sending Thai or characters with accents in the Subject header without specifying the character-set can cause rendering problems ( e.g TIS-620 for Thai, iso-8859-1 for normal latin characters )


The Iconv library used by @Mail converts all messages & headers to UTF-8 to be displayed via Webmail. This allows @Mail to display messages from any charset within the browser.

A sample subject header that contains “Message with åäöÅÄÖ”

The correct encoding for the header is:

Subject: =?ISO-8859-1?Q?Message with =E5=E4=F6=C5=C4=D6?=

An incorrect header is:

Subject: Message with åäöÅÄÖ

Where the characters are raw, but should be encoded into 7-bit as per the MIME RFC.

Some old legacy systems or misconfigured clients can send the message with the incorrect encoding.

Now comes the question: “How can @Mail be modified to correctly parse headers that are not correctly encoded?”


By modifying GetMail.pm & ReadMsg.pm, the two modules used to parse messages. The default encoding can be set to ISO-8859-1 if the header does not contain the correct encoding:


# Fix a header and take away unnessasary characters
sub quote_header {
my ( $self, $header ) = @_; $header =~ s{s*=?([^?]+)?[Qq]?([^?]+)??=}{$self->decode_language($1, $self->decode_mime_head ($1, $2)); }eg;

$header =~ s{s*=?([^?]+)?[Bb]?([^?]+)??=}{$self->decode_language($1, $self->generic_base64_decode ($2));}eg;


Replace with:

# Fix a header and take away unnessasary characters
sub quote_header {
my ( $self, $header ) = @_;


if($header =~ /s*=?([^?]+)?[Qq]?([^?]+)??=/) {
$header =~ s{s*=?([^?]+)?[Qq]?([^?]+)??=}{$self->decode_language($1, $self->decode_mime_head ($1, $2)); }eg;
} elsif($header =~ /s*=?([^?]+)?[Bb]?([^?]+)??=/) {
$header =~ s{s*=?([^?]+)?[Bb]?([^?]+)??=}{$self->decode_language($1, $self->generic_base64_decode ($2));}eg;
} else {
$header = $self->decode_language(”iso-8859-1“, $header );
}


——————————


Then modify /usr/local/atmail/webmail/libs/Atmail/ReadMsg.pm and locate:


$self->{$_} =~ s{s*=?([^?]+)?[Qq]?([^?]+)??=}{$self->decode_language($self->{Encoding}, $self->decode_mime_head ($1, $2)); }eg;
$self->{$_} =~ s{s*=?([^?]+)?[Bb]?([^?]+)??=}{$self->decode_language($self->{Encoding}, $self->generic_base64_decode($2));}eg;


Change to:


# Check all encoding, use iso-8859-1 for default otherwise
if($self->{$_} =~ /s*=?([^?]+)?[Qq]?([^?]+)??=/ ) {
$self->{$_} =~ s{s*=?([^?]+)?[Qq]?([^?]+)??=}{$self->decode_language($self->{Encoding}, $self->decode_mime_head ($1, $2)); }eg;
} elsif($self->{$_} =~ /s*=?([^?]+)?[Bb]?([^?]+)??=/ ) {
$self->{$_} =~ s{s*=?([^?]+)?[Bb]?([^?]+)??=}{$self->decode_language($self->{Encoding}, $self->generic_base64_decode($2));}eg;
} else {
$self->{$_} = $self->decode_language(”iso-8859-1“, $self->{$_} );
}


——————————


After making the changes restart Apache to reload the mod-perl cache.


service httpd restart


2009年1月12日 星期一

MySQL數據庫如何實現雙機熱備的配置

來源:54master.com 作者:佚名

大 中 小

1。mysql數據庫沒有增量備份的機制,當數據量太大的時候備份是一個很大的問題。還好mysql數據庫提供了一種主從備份的機制,其實就是把主數據庫的所有的數據同時寫到備份數據庫中。實現mysql數據庫的熱備份。

2。要想實現雙機的熱備首先要了解主從數據庫服務器的版本的需求。要實現熱備mysql的版本都要高於3.2,還有一個基本的原則就是作為從數據庫的數據庫版本可以高於主服務器數據庫的版本,但是不可以低於主服務器的數據庫版本。

3。設置主數據庫服務器:

a.首先查看主服務器的版本是否是支持熱備的版本。然後查看my.cnf(類unix)或者my.ini(windows)中mysqld配置塊的配置有沒有log-bin(記錄數據庫更改日志),因為mysql的復制機制是基於日志的復制機制,所以主服務器一定要支持更改日志才行。然後設置要寫入日志的數據庫或者不要寫入日志的數據庫。這樣只有您感興趣的數據庫的更改才寫入到數據庫的日志中。


QUOTE:
server-id=1 //數據庫的id這個應該默認是1就不用改動
log-bin=log_name //日志文件的名稱,這裏可以制定日志到別的目錄 如果沒有設置則默認主機名的一個日志名稱
binlog-do-db=db_name //記錄日志的數據庫
binlog-ignore-db=db_name //不記錄日志的數據庫

以上的如果有多個數據庫用","分割開

然後設置同步數據庫的用戶帳號
QUOTE:
mysql> GRANT REPLICATION SLAVE ON *.*
-> TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';

4.0.2以前的版本, 因為不支持REPLICATION 要使用下面的語句來實現這個功能
QUOTE:
mysql> GRANT FILE ON *.*
-> TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';

設置好主服務器的配置文件後重新啟動數據庫

b.鎖定現有的數據庫並備份現在的數據

鎖定數據庫
QUOTE:
mysql> FLUSH TABLES WITH READ LOCK;

備份數據庫有兩種辦法一種是直接進入到mysql的data目錄然後打包你需要備份數據庫的文件夾,第二種是使用mysqldump的方式來備份數據庫但是要加上"--master-data " 這個參數,建議使用第一種方法來備份數據庫

c.查看主服務器的狀態
QUOTE:
mysql> show master status\G;
+---------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+----------+--------------+------------------+
| mysql-bin.003 | 73 | test | manual,mysql |
+---------------+----------+--------------+------------------+

記錄File 和 Position 項目的值,以後要用的。

d.然後把數據庫的鎖定打開
QUOTE:
mysql> UNLOCK TABLES;

4。設置從服務器

a.首先設置數據庫的配置文件
QUOTE:
server-id=n //設置數據庫id默認主服務器是1可以隨便設置但是如果有多臺從服務器則不能重復。
master-host=db-master.mycompany.com //主服務器的IP地址或者域名
master-port=3306 //主數據庫的端口號
master-user=pertinax //同步數據庫的用戶
master-password=freitag //同步數據庫的密碼
master-connect-retry=60 //如果從服務器發現主服務器斷掉,重新連接的時間差
report-host=db-slave.mycompany.com //報告錯誤的服務器

b.把從主數據庫服務器備份出來的數據庫導入到從服務器中

c.然後啟動從數據庫服務器,如果啟動的時候沒有加上"--skip-slave-start"這個參數則進入到mysql中
QUOTE:
mysql> slave stop; //停止slave的服務

d.設置主服務器的各種參數
QUOTE:
mysql> CHANGE MASTER TO
-> MASTER_HOST='master_host_name', //主服務器的IP地址
-> MASTER_USER='replication_user_name', //同步數據庫的用戶
-> MASTER_PASSWORD='replication_password', //同步數據庫的密碼
-> MASTER_LOG_FILE='recorded_log_file_name', //主服務器二進制日志的文件名(前面要求記住的參數)
-> MASTER_LOG_POS=recorded_log_position; //日志文件的開始位置(前面要求記住的參數)

e.啟動同步數據庫的線程
QUOTE:
mysql> slave start;

查看數據庫的同步情況吧。如果能夠成功同步那就恭喜了!

查看主從服務器的狀態
QUOTE:
mysql> SHOW PROCESSLIST\G //可以查看mysql的進程看看是否有監聽的進程

如果日志太大清除日志的步驟如下

1.鎖定主數據庫
QUOTE:
mysql> FLUSH TABLES WITH READ LOCK;

2.停掉從數據庫的slave
QUOTE:
mysql> slave stop;

3.查看主數據庫的日志文件名和日志文件的position
QUOTE:
show master status;
+---------------+----------+--------------+------------------+
| File | Position | Binlog_do_db | Binlog_ignore_db |
+---------------+----------+--------------+------------------+
| louis-bin.001 | 79 | | mysql |
+---------------+----------+--------------+------------------+

4.解開主數據庫的鎖
QUOTE:
mysql> unlock tables;

5.更新從數據庫中主數據庫的信息
QUOTE:
mysql> CHANGE MASTER TO
-> MASTER_HOST='master_host_name', //主服務器的IP地址
-> MASTER_USER='replication_user_name', //同步數據庫的用戶
-> MASTER_PASSWORD='replication_password', //同步數據庫的密碼
-> MASTER_LOG_FILE='recorded_log_file_name', //主服務器二進制日志的文件名(前面要求記住的參數)
-> MASTER_LOG_POS=recorded_log_position; //日志文件的開始位置(前面要求記住的參數)

6.啟動從數據庫的slave
QUOTE:
mysql> slave start;