Académique Documents
Professionnel Documents
Culture Documents
This vm node stores your data in RDBMS such as mysql or postgresql. In this setup, I'm going to
use MySQL database server. You need to type the following commandss on vm04 having an IP
address 192.168.1.13 only.
Make sure mysql server can be accessed from your vm01 and vm02 server i.e. Apache+php5
server. Locate [mysqld] section and add/correct as follows so that mysqld can reached remotely :
# Make sure skip-networking directive is commented (or removed)
# skip-networking
# Turn on remote access
bind-address=192.168.1.13
Optimization settings
You need to optimize mysql server otherwise it is going to eat all your CPU and other resources
on vm04. You can add or correct settings as follows (see mysql manual for more info):
#######################################################################
# WARNING!!!
# Security and optimization settings
# Read mysqld and my.cnf man page for more info
# as the following settings depends upon hardware and your requirements
########################################################################
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
## Go faster and skip some stuff, YMMV
skip-name-resolve
skip-slave-start
skip-external-locking
# PER CLIENT SETTINGS #
= 1
= 1
= /var/lib/mysql/slowquery.log
=
=
=
=
=
=
=
=
=
=
# MyISAM #
key_buffer_size
myisam_recover
= 32M
= FORCE,BACKUP
# SAFETY #
max_allowed_packet
max_connect_errors
= 16M
= 1000000
# BINARY LOGGING #
log_bin
expire_logs_days
sync_binlog
= /var/lib/mysql/mysql-bin
= 14
= 1
# INNODB #
innodb_flush_method
innodb_log_files_in_group
innodb_log_file_size
innodb_flush_log_at_trx_commit
innodb_file_per_table
innodb_buffer_pool_size
=
=
=
=
=
=
12M
12M
1
2M
32M
500
50
65535
4096
1024
O_DIRECT
2
256M
1
1
10G
Save and close the file. Restart / reload the mysql server:
# chkconfig mysqld on
Make sure vm01 and vm02 can access the database server:
## open mysqld server port for the apache and lighttpd web server #
-A INPUT -m state --state NEW -s 192.168.1.10 -m tcp -p tcp --dport 3306 -j
ACCEPT
-A INPUT -m state --state NEW -s 192.168.1.11 -m tcp -p tcp --dport 3306 -j
ACCEPT
Load the changes by typing the following sysctl command to modify Linux kernel parameters at
runtime:
# sysctl -p
DB NAME : foo
DB PASSWORD : mypassword
Type the following command to create the database and required users:
# /usr/bin/mysql -u root -h localhost -p
Type the following commands at mysql> prompt. To create your database called foo, type:
mysql> CREATE DATABASE foo;
You must grant access rights for this database to the MySQL user called bar through which the
Apache+php5 application server will be connecting. Type:
mysql> GRANT ALL ON foo.* TO bar@localhost IDENTIFIED BY 'mypassword';
mysql> GRANT ALL ON foo.* TO bar@192.168.1.10 IDENTIFIED BY 'mypassword';
mysql> GRANT ALL ON foo.* TO bar@192.168.1.11 IDENTIFIED BY 'mypassword';
You can now create tables or load data using .sql files. You can automate this procedure by
writing shell or perl script to add the mysql user and database.
Test your new db and user settings from remote vm01 or vm02
Ssh into the vm01 or vm03 and type the following command to test the connectivity from the
Apache / Lighttpd web server:
$ mysql -u bar -h 192.168.1.13 -p'mypassword' foo
OR
phpMyAdmin
The phpMyAdmin program act as the web-interface for MySQL. It is used to handle the
administration of MySQL over the WWW using a browser. PhpMyAdmin can administer a
whole MySQL server or a single database. This is recommended package for all new MySQL
database users and admins.