phpMyAdmin can be used to export or backup MySQL databases easily. However, if the database size is very big, it probably won’t be a good idea. phpMyAdmin allows users to save database dump as file or display on screen, which involves exporting SQL statements from the server, and transmitting the data across slower network connection or Internet to user’s computer. This process slow the exporting process, increase database locking time and thus MySQL unavailability, slow the server and may simply crash the Apache HTTPD server if too many incoming web connections hogging the system’s resources.
Monday, September 27, 2010
Saturday, June 19, 2010
Hướng dẫn Reset password root mysql (Windows & Linux )
Hướng dẫn rest password root mysql:
* Server Windows:
B1:
- Stop service mysql
+ C:\>net stop mysql
or:
+ Start -> Run -> services.msc. Tìm đến service mysql -> Stop.
B2:
- Vào thư mục Bin của mysql, Thông thường là C:\Program Files\MySQL\MySQL Server 5.0\bin. Gõ như sau:
+ C:\Program Files\MySQL\MySQL Server 5.0\bin>mysqld-nt –skip-grant-tables
Mọi người cứ để shell DOS đấy. Mở một shell DOS mới.
B3:
- Mở shell DOS mới, gõ:
+C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot
Ok, mọi người đã login vào root rồi đấy. Giờ thực hiện change password mới thôi.
B4:
mysql>use mysql;
mysql>update user set Password=PASSWORD(’new_pass’) WHERE User=’root’;
mysql>flush privileges;
Ok done.
+mysql>exit
Xong mọi người kill process mysql-nt.exe nhé. Rồi mới start lại service mysql.
* server Linux:
B1: Stop mysql:
#service mysql stop
B2:Chạy mysql ở mode safe_mode
# mysqld_safe --skip-grant-tables &
Mọi người cứ để command nay, dung close nhe', Mở một Telnet mới( O day toi dung telnet)
B3:Vào mysql với user root.
# mysql -u root
B4:Reset passwd:
#mysql>use mysql;
#mysql>update user set Password=PASSWORD(’new_pass’) WHERE User=’root’;
#mysql>flush privileges;
# /etc/init.d/mysql stop
B6: Start mysql:
#service mysql start
* Server Windows:
B1:
- Stop service mysql
+ C:\>net stop mysql
or:
+ Start -> Run -> services.msc. Tìm đến service mysql -> Stop.
B2:
- Vào thư mục Bin của mysql, Thông thường là C:\Program Files\MySQL\MySQL Server 5.0\bin. Gõ như sau:
+ C:\Program Files\MySQL\MySQL Server 5.0\bin>mysqld-nt –skip-grant-tables
Mọi người cứ để shell DOS đấy. Mở một shell DOS mới.
B3:
- Mở shell DOS mới, gõ:
+C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot
Ok, mọi người đã login vào root rồi đấy. Giờ thực hiện change password mới thôi.
B4:
mysql>use mysql;
mysql>update user set Password=PASSWORD(’new_pass’) WHERE User=’root’;
mysql>flush privileges;
Ok done.
+mysql>exit
Xong mọi người kill process mysql-nt.exe nhé. Rồi mới start lại service mysql.
* server Linux:
B1: Stop mysql:
#service mysql stop
B2:Chạy mysql ở mode safe_mode
# mysqld_safe --skip-grant-tables &
Mọi người cứ để command nay, dung close nhe', Mở một Telnet mới( O day toi dung telnet)
B3:Vào mysql với user root.
# mysql -u root
B4:Reset passwd:
#mysql>use mysql;
#mysql>update user set Password=PASSWORD(’new_pass’) WHERE User=’root’;
#mysql>flush privileges;
# /etc/init.d/mysql stop
B6: Start mysql:
#service mysql start
Labels:
LINUX-UNIX,
ThuThuatPC
Friday, June 18, 2010
Command backup thuong dung
Create a backup folder:
mkdir /home/backup chmod 700 /home/backup cd /home/backup
Backup the database
mysqldump -u root -p dbispconfig > dbispconfig.sql
Ex: Backup Folder
tar pcfz software.tar.gz /usr/local/software
Backup the configuration files in /etc
tar pcfz etc.tar.gz /etc
Uznip:
tar xvzf software.tar.gz
Labels:
LINUX-UNIX,
ThuThuatPC
Tuesday, June 8, 2010
Tạo file âm thanh tương thích Asterisk
Asterisk chỉ hỗ trợ định dạng wav 8Khz, còn số bit thì từ 8 đến 16bit, tùy theo độ nén.
Nếu bạn muốn dùng file wav nào đó, ví dụ example.wav hoặc foo-in.wav với asterisk, dùng các lệnh sau từ console linux để convert sang chuẩn tương thích Asterisk (thường là ulaw hoặc wav):
Nếu bạn muốn dùng file wav nào đó, ví dụ example.wav hoặc foo-in.wav với asterisk, dùng các lệnh sau từ console linux để convert sang chuẩn tương thích Asterisk (thường là ulaw hoặc wav):
Labels:
LINUX-UNIX,
VoIP-FreePBX
Cach kiem tra ổ cứng đầy trong Linux
Trixbox/Asterisk sẽ hoạt động hiệu quả và ổn định cho đến khi ổ cứng bị đầy. Một trong những nguyên nhân có thể do các file logs sinh ra quá lớn (/var/log/asterisk).
Để biết thư mục nào chiếm dung lượng nhiều, hãy dùng lệnh đơn giản sau:
Để biết thư mục nào chiếm dung lượng nhiều, hãy dùng lệnh đơn giản sau:
Labels:
LINUX-UNIX,
VoIP-FreePBX
Phân biệt Asterisk, FreePBX.Trixbox, Elastix, PIAF
Nhiều bạn vẫn còn thắc mắc FreePBX là gì, rồi Asterisk và Trixbox có khác gì nhau không? Lại còn Elastix hay PIAF (PBX in a Flash). Bài viết này giúp bạn có cái nhìn tổng quát và rõ ràng cho các khái niệm trên.
Asterisk là phần mềm mã nguồn mở, khởi điểm chạy trên Hệ điều hành linux (hiện có thể chạy trên Windows & Macintosh), đảm nhiệm vai trò làm tổng đài nội bộ.
Để dựng server Asterisk, bạn có thể cài linux (thường dùng CentOS5), xong download gói Asterisk về, compile, cấu hình(*) và chạy. Nếu muốn Asterisk giao tiếp với điện thoại analog hoặc line bưu điện PSTN thì phải download, compile và cấu hình thêm gói ZAPTEL/DAHDI (**). Tất cả các bước trên đòi hỏi phải có kiến thức sâu về linux và asterisk.
(*): việc cấu hình Asterisk sẽ thao tác trực tiếp trên các file .conf, và rất mất thời gian + dễ sai sót. Bạn có thể phải viết hàng trăm, thậm chí hàng nghìn dòng để cấu hình các tính năng cơ bản và khai báo số extension.
(**): ZAPTEL là tên gọi lúc trước, do trùng với tên một công ty nên sau này driver đã được đổi lại thành DAHDI.
Để tránh việc cấu hình Asterisk bằng tay, FreePBX ra đời. Với giao diện WEB dễ dùng, tự động sinh mã code, miễn phí, FreePBX đã được đón nhận nồng nhiệt và trở thành giao diện chuẩn cấu hình Asterisk.
Tuy nhiên, khi triển khai nguyên cụm CentOS, Asterisk, FreePBX, Zaptel... cho nhiều máy thì phải cấu hình lại từ đầu, hoặc import/export các settings lại.
Do đó, để thuận tiện, người ta đã cài sẵn CentOS, Asterisk, FreePBX, Zaptel cùng một số gói hỗ trợ khác, cấu hình đầy đủ, xong đóng gói lại thành các distro của asterisk, gọi là Trixbox, Elastix, PIAF... Mọi người chỉ cần download một trong các phiên bản này về, cài đặt là xong. Muốn cấu hình thêm thì dùng FreePBX có sẵn trong các phiên bản.
Có thể nói nôm na là Trixbox/Elastix/PIAF giống như bản "Ghost" (asterisk+linux+FreePBX+zaptel+các gói hỗ trợ khác) vậy cho dễ hiểu.
(Copy & Paste)
Asterisk là phần mềm mã nguồn mở, khởi điểm chạy trên Hệ điều hành linux (hiện có thể chạy trên Windows & Macintosh), đảm nhiệm vai trò làm tổng đài nội bộ.
Để dựng server Asterisk, bạn có thể cài linux (thường dùng CentOS5), xong download gói Asterisk về, compile, cấu hình(*) và chạy. Nếu muốn Asterisk giao tiếp với điện thoại analog hoặc line bưu điện PSTN thì phải download, compile và cấu hình thêm gói ZAPTEL/DAHDI (**). Tất cả các bước trên đòi hỏi phải có kiến thức sâu về linux và asterisk.
(*): việc cấu hình Asterisk sẽ thao tác trực tiếp trên các file .conf, và rất mất thời gian + dễ sai sót. Bạn có thể phải viết hàng trăm, thậm chí hàng nghìn dòng để cấu hình các tính năng cơ bản và khai báo số extension.
(**): ZAPTEL là tên gọi lúc trước, do trùng với tên một công ty nên sau này driver đã được đổi lại thành DAHDI.
Để tránh việc cấu hình Asterisk bằng tay, FreePBX ra đời. Với giao diện WEB dễ dùng, tự động sinh mã code, miễn phí, FreePBX đã được đón nhận nồng nhiệt và trở thành giao diện chuẩn cấu hình Asterisk.
Tuy nhiên, khi triển khai nguyên cụm CentOS, Asterisk, FreePBX, Zaptel... cho nhiều máy thì phải cấu hình lại từ đầu, hoặc import/export các settings lại.
Do đó, để thuận tiện, người ta đã cài sẵn CentOS, Asterisk, FreePBX, Zaptel cùng một số gói hỗ trợ khác, cấu hình đầy đủ, xong đóng gói lại thành các distro của asterisk, gọi là Trixbox, Elastix, PIAF... Mọi người chỉ cần download một trong các phiên bản này về, cài đặt là xong. Muốn cấu hình thêm thì dùng FreePBX có sẵn trong các phiên bản.
Có thể nói nôm na là Trixbox/Elastix/PIAF giống như bản "Ghost" (asterisk+linux+FreePBX+zaptel+các gói hỗ trợ khác) vậy cho dễ hiểu.
(Copy & Paste)
Labels:
VoIP-FreePBX
Friday, June 4, 2010
Thay đổi giá trị max_allowed_packet của MySQL
Thay đổi giá trị max_allowed_packet của MySQL
Trong quá trình thao tác với cơ sở dữ liệu, đặc biệt là khi phải restore các database lớn mình thường gặp phải vấn đề với max_allowed_packet của server. Tranh thủ hôm nay động lại món này mình ghi vào đây để sau này có thể tra cứu :)
Có nhiều cách để thay đổi giá trị của biến max_allowed_packet trong MySQL, mình sẽ nói các cách mình đã dùng nhé :D
1. Chỉnh sửa trực tiếp giá trị của biến max_allowed_packet trong file /etc/my.cnf . Sửa dòng này có nội dung thế này:
[mysqld]
max_allowed_packet=16M => điều chỉnh giá trị theo ý bạn muốn. Đừng để lớn quá nhé ;)
2. Điều chỉnh tại chế độ dòng lệnh nhưng không làm khởi động lại (giá trị max_allowed_packet chỉ được áp dụng trong phiên làm việc đó).
mysql> show variables like ‘max_allowed_packet%’ ;
+——————–+———+
| Variable_name | Value |
+——————–+———+
| max_allowed_packet | 1048576 |
+——————–+———+
1 row in set (0.00 sec)
mysql> set max_allowed_packet = 1073741824;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like ‘max_allowed_packet%’ ;
+———————————–+———————+
| Variable_name | Value |
+———————————-+———————+
| max_allowed_packet | 1073741824 |
+——————–+————+———————-+
3. Khởi động lại MySql server với giá trị của biến –max_allowed_packet do bạn chọn.
/etc/init.d/mysqld restart –max_allowed_packet=1024M (hoặc giá trị bạn muốn thay đổi khác).
Trong quá trình thao tác với cơ sở dữ liệu, đặc biệt là khi phải restore các database lớn mình thường gặp phải vấn đề với max_allowed_packet của server. Tranh thủ hôm nay động lại món này mình ghi vào đây để sau này có thể tra cứu :)
Có nhiều cách để thay đổi giá trị của biến max_allowed_packet trong MySQL, mình sẽ nói các cách mình đã dùng nhé :D
1. Chỉnh sửa trực tiếp giá trị của biến max_allowed_packet trong file /etc/my.cnf . Sửa dòng này có nội dung thế này:
[mysqld]
max_allowed_packet=16M => điều chỉnh giá trị theo ý bạn muốn. Đừng để lớn quá nhé ;)
2. Điều chỉnh tại chế độ dòng lệnh nhưng không làm khởi động lại (giá trị max_allowed_packet chỉ được áp dụng trong phiên làm việc đó).
mysql> show variables like ‘max_allowed_packet%’ ;
+——————–+———+
| Variable_name | Value |
+——————–+———+
| max_allowed_packet | 1048576 |
+——————–+———+
1 row in set (0.00 sec)
mysql> set max_allowed_packet = 1073741824;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like ‘max_allowed_packet%’ ;
+———————————–+———————+
| Variable_name | Value |
+———————————-+———————+
| max_allowed_packet | 1073741824 |
+——————–+————+———————-+
3. Khởi động lại MySql server với giá trị của biến –max_allowed_packet do bạn chọn.
/etc/init.d/mysqld restart –max_allowed_packet=1024M (hoặc giá trị bạn muốn thay đổi khác).
Labels:
Database
Saturday, May 22, 2010
Home Increase max_connections in mysql without restarting mysqld service.
By default in mysql database server max_connections is set to 100. This value indicates how many maximum concurrent connections mysql server can handle. If mysql reaches to it maximum (max) limit then you can see errors like "too many connections". I assume that you have enough hardware resources (Mainly RAM )to handle more connections, here with this article I will share a TIP to increase max_connections in mysql.
As we know my.cnf is default configuration file for mysqld service and by default it is located in /etc directory unless and until you have changed it.
To find out how many max_connections are allowed currently on your mysql server use following command from mysql prompt.
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 100 |
+-------------------+
1 row in set (0.00 sec)
max_connections is a GLOBAL variable. we can increase it on the fly without restarting mysqld service.
To do so use following command.
mysql> set global max_connections = 200;
Query OK, 0 rows affected (0.00 sec)
Now, If you check again you will see that limit of max_connections is increased.
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 200 |
+-------------------+
1 row in set (0.00 sec)
Note:
It is important that you edit your /etc/my.cnf to add max_connections = 200 otherwise when you restart mysqld service in future, It will complain again after it hits the old max_connections limit.
As we know my.cnf is default configuration file for mysqld service and by default it is located in /etc directory unless and until you have changed it.
To find out how many max_connections are allowed currently on your mysql server use following command from mysql prompt.
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 100 |
+-------------------+
1 row in set (0.00 sec)
max_connections is a GLOBAL variable. we can increase it on the fly without restarting mysqld service.
To do so use following command.
mysql> set global max_connections = 200;
Query OK, 0 rows affected (0.00 sec)
Now, If you check again you will see that limit of max_connections is increased.
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 200 |
+-------------------+
1 row in set (0.00 sec)
Note:
It is important that you edit your /etc/my.cnf to add max_connections = 200 otherwise when you restart mysqld service in future, It will complain again after it hits the old max_connections limit.
Labels:
LINUX-UNIX,
WindowsServer
Setup and Running Glassfish as a service on CentOS
1/ Setup Glassfish (GUI Cai dat o che do Graphics)
Download: http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1-unix.sh
Phải đăng nhập vào mode Graphics mới setup Glassfish duoc.
init 5
- Làm theo hướng dẫn step by step
http://docs.sun.com/app/docs/doc/820-7690
2/ Setup Glassfish (Zip)
Huong dan setup
http://docs.sun.com/app/docs/doc/821-1756
- Tao Folder :
mkdir /usr/GF_OSSO_AS
cd /usr/GF_OSSO_AS
wget http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1.zip
unzip glassfish-3.0.1.zip
cd glassfish
chmod 777 chmod 777 /usr/GF_OSSO_AS/glassfishv3/glassfish/bin/asadmin
cd /usr/GF_OSSO_AS/glassfishv3/glassfish/bin
./asadmin start-database --dbhome ../javadb/
Database already started on host 0.0.0.0, port 1527.
Command start-database executed successfully.
[root@webhosting bin]# ./asadmin start-domain
Waiting for DAS to start ...........
Started domain: domain1
Domain location: /usr/GF_OSSO_AS/glassfishv3/glassfish/domains/domain1
Log file: /usr/GF_OSSO_AS/glassfishv3/glassfish/domains/domain1/logs/server.log
Admin port for the domain: 4848
Command start-domain executed successfully.
Test: http://localhost:4848 & http://localhost:8080
3/ Tạo file Script service
cd etc/init.d/
nano glassfish
copy đoạn script o dưới vào
#!/bin/bash
#
# glassfish: Startup script for Glassfish Application Server.
#
# chkconfig: 3 80 05
# description: Startup script for domain1 of Glassfish Application Server.
GLASSFISH_HOME=/root/glassfishv3/glassfish;
export GLASSFISH_HOME
GLASSFISH_OWNER=root;
export GLASSFISH_OWNER
start() {
echo -n "Starting Glassfish: "
echo "Starting Glassfish at `date`" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
su $GLASSFISH_OWNER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
sleep 2
echo "done"
}
stop() {
echo -n "Stopping Glassfish: "
echo "Stopping Glassfish at `date`" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
su $GLASSFISH_OWNER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
echo "done"
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: glassfish {start|stop|restart}"
exit
esac
3/ Install the service
#chmod +x /etc/init.d/glassfish
#chkconfig --add glassfish
#chkconfig --level 3 glassfish on
4/ # Start glassfish.
#/etc/init.d/glassfish start
Download: http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1-unix.sh
Phải đăng nhập vào mode Graphics mới setup Glassfish duoc.
init 5
- Làm theo hướng dẫn step by step
http://docs.sun.com/app/docs/doc/820-7690
2/ Setup Glassfish (Zip)
Huong dan setup
http://docs.sun.com/app/docs/doc/821-1756
- Tao Folder :
mkdir /usr/GF_OSSO_AS
cd /usr/GF_OSSO_AS
wget http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1.zip
unzip glassfish-3.0.1.zip
cd glassfish
chmod 777 chmod 777 /usr/GF_OSSO_AS/glassfishv3/glassfish/bin/asadmin
cd /usr/GF_OSSO_AS/glassfishv3/glassfish/bin
./asadmin start-database --dbhome ../javadb/
Database already started on host 0.0.0.0, port 1527.
Command start-database executed successfully.
[root@webhosting bin]# ./asadmin start-domain
Waiting for DAS to start ...........
Started domain: domain1
Domain location: /usr/GF_OSSO_AS/glassfishv3/glassfish/domains/domain1
Log file: /usr/GF_OSSO_AS/glassfishv3/glassfish/domains/domain1/logs/server.log
Admin port for the domain: 4848
Command start-domain executed successfully.
Test: http://localhost:4848 & http://localhost:8080
3/ Tạo file Script service
cd etc/init.d/
nano glassfish
copy đoạn script o dưới vào
#!/bin/bash
#
# glassfish: Startup script for Glassfish Application Server.
#
# chkconfig: 3 80 05
# description: Startup script for domain1 of Glassfish Application Server.
GLASSFISH_HOME=/root/glassfishv3/glassfish;
export GLASSFISH_HOME
GLASSFISH_OWNER=root;
export GLASSFISH_OWNER
start() {
echo -n "Starting Glassfish: "
echo "Starting Glassfish at `date`" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
su $GLASSFISH_OWNER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
sleep 2
echo "done"
}
stop() {
echo -n "Stopping Glassfish: "
echo "Stopping Glassfish at `date`" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
su $GLASSFISH_OWNER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
echo "done"
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: glassfish {start|stop|restart}"
exit
esac
3/ Install the service
#chmod +x /etc/init.d/glassfish
#chkconfig --add glassfish
#chkconfig --level 3 glassfish on
4/ # Start glassfish.
#/etc/init.d/glassfish start
Labels:
LINUX-UNIX
Setup and Running Glassfish as a service on CentOS
1/ Setup Glassfish
Phải đăng nhập vào mode Graphics mới setup Glassfish duoc.
init 5
- Làm theo hướng dẫn step by step
http://docs.sun.com/app/docs/doc/820-7690
Phải đăng nhập vào mode Graphics mới setup Glassfish duoc.
init 5
- Làm theo hướng dẫn step by step
http://docs.sun.com/app/docs/doc/820-7690
Labels:
LINUX-UNIX
Subscribe to:
Posts (Atom)