MYSQL服务进程可以同时du服务多个DATABASE,而zhi不象ORACLE,一个实例对应一dao个DATABASE。
你的意思是再启动一个MYSQL进程吗?这也是可以的,在启动命令行中修改参数。也可以在启动配置文件my.cnf中修改。
配置文件还是一个,只不过mysql的数据库存放目录需要多个,这根据你的实例来配置数据库存放目录。给个多实例配置案例:
初始化数据库
[mysql@localhost ~]$ mkdir /mydata/mysql_db/data_1001 #创建数据库存放目录
[mysql@localhost ~]$ mkdir /mydata/mysql_db/data_1002
[mysql@localhost ~]$ mkdir /mydata/mysql_db/data_1003
[mysql@localhost mysql_db]$ ./bin/mysql_install_db –basedir=/mydata/mysql_db –datadir=/mydata/mysql_db/data_1001 –user=mysql #数据库初始化
Installing MySQL system tables…
OK
Filling help tables…
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/mydata/mysql_db/bin/mysqladmin -u root password ‘new-password’
/mydata/mysql_db/bin/mysqladmin -u root -h localhost password ‘new-password’
Alternatively you can run:
/mydata/mysql_db/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /mydata/mysql_db /mydata/mysql_db/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /mydata/mysql_db/mysql-test perl mysql-test-run.pl
Please report any problems with the /mydata/mysql_db/scripts/mysqlbug script!
[mysql@localhost mysql_db]$ ./bin/mysql_install_db –basedir=/mydata/mysql_db –datadir=/mydata/mysql_db/data_1002 –user=mysql
[mysql@localhost mysql_db]$ ./bin/mysql_install_db –basedir=/mydata/mysql_db –datadir=/mydata/mysql_db/data_1003 –user=mysql
配置mysql_multi
[mysql@localhost mysql_db]$ cd /home/mysql/
[mysql@localhost ~]$ vi my.cnf
[mysqld_multi] #添加内容如下
mysqld = /mydata/mysql_db/bin/mysqld_safe
mysqladmin = /mydata/mysql_db/bin/mysqladmin
user = mysql
[mysqld1001]
port = 3306
socket = /tmp/mysql3306.sock
pid-file = /tmp/mysql3306.pid
basedir = /mydata/mysql_db
datadir = /mydata/mysql_db/data_1001
skip-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
server-id = 1
[mysqld1002]
port = 3307
socket = /tmp/mysql3307.sock
basedir = /mydata/mysql_db
datadir = /mydata/mysql_db/data_1002
pid-file = /tmp/mysql3307.pid
skip-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
server-id = 1
[mysqld1003]
port = 3308
socket = /tmp/mysql3308.sock
basedir = /mydata/mysql_db
datadir = /mydata/mysql_db/data_1003
pid-file = /tmp/mysql3308.pid
skip-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
server-id = 1
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
多实例启动
[mysql@localhost mysql_db]$ mysqld_multi –defaults-file=/home/mysql/my.cnf –user=mysql start 1001-1003 #启动mysql实例
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)