change According to single instance, the main change file is my.cnf files and MySQL file
Multiple instances with Port distinction
Note the changes to the ports in the following files, and the user password changes
my.cnf
[client]port = 3306socket =/data/3306/mysql.sock [mysql]no-auto-rehash [ Mysqld]user = mysqlport = 3306socket =/data /3306/mysql.sockbasedir = /application/mysqldatadir = /data/3306/dataopen_files_limit = 1024back_log = 600max_connections = 800max_connect_errors = 3000table_open_cache = 614external-locking = falsemax_allowed_packet = 8msort_buffer_size = 1mjoin_buffer_size = 1mthread_cache_size = 100thread_ Concurrency = 2query_cache_size = 2mquery_cache_limit = 1mquery_cache_min_res_ Unit = 2k#default_table_type = innodbthread_stack = 192k#transaction_isolation = read-committedtmp_table_size = 2mmax_heap_table_size = 2mlong_query_time = 1#log_long_format# log-error = /data/3306/error.log#log-slow-queries = /data/3306/slow.logpid-file = /data/3306/mysql.pidlog-bin = /data/3306/mysql-binrelay-log = /data/3306/ Relay-binrelay-log-info-file = /data/3306/relay-log.infobinlog_cache_size = 1mmax_binlog_ cache_size = 1mmax_binlog_size = 2mexpire_logs_days = 7key_buffer_size = 16mread_buffer_size = 1mread_rnd_buffer_size = 1mbulk_insert_buffer_size = 1m#myisam_sort_buffer_size = 1m#myisam_max_sort_file_size = 10g#myisam_max_extra_ Sort_file_size = 10g#myisam_repair_threads = 1#myisam_recover lower_case_table_names = 1skip-name-resolveslave-skip-errors = 1032,1062replicate-ignore-db=mysql server-id = 1 innodb_additional_mem_pool_size = 4minnodb_buffer_pool_size = 32minnodb_data_file_path = ibdata1:128m: Autoextendinnodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_ Commit = 2innodb_log_buffer_size = 2minnodb_log_file_size = 4minnodb_log_files_ In_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120innodb_ file_per_table = 0[mysqldump]quickmax_allowed_packet = 2m [mysqld_safe]log-error=/ Data/3306/mysql_oldboy3306.errpid-file=/data/3306/mysqld.pid
mysql file
#!/bin/sh################################################ #this scripts is created by oldboy at 2007-06-09#oldboy qq:31333741#site:http://www.etiantian.org#blog:http:// oldboy.blog.51cto.com#oldboy trainning qq group: 208160987 226199307 44246017################################################ #initport =3306mysql_user= "root" mysql_pwd= "Oldboy "Cmdpath="/application/mysql/bin "mysql_sock="/data/${port}/mysql.sock "#startup functionfunction_start_ MySQL () { if [ ! -e "$mysql _sock" ];then printf "startingmysql...\n" /bin/sh${cmdpath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2>&1 >/dev/null & else printf "mysql isrunning...\n" exit fi} #stop functionfunction_stop_mysql () { if [ ! -e "$mysql _sock" ];then printf "mysql isstopped...\n" exit else printf "stopingmysql...\n" ${cmdpath}/mysqladmin-u ${mysql_user} -p${mysql_pwd} -S /data/${port}/mysql.sock shutdown fi} #restart functionfunction_restart_mysql () { printf "restartingmysql...\n" function_stop_mysql sleep 2 function_start_ Mysql} case $1 instart) function_start_mysql;; Stop) function_stop_mysql;; Restart) function_restart_mysql;; *) printf "usage:/data/${pOrt}/mysql {start|stop|restart}\n "Esac
1.Delete/application/mysql/data/of Data
[[email protected] data]# RM-RF *[[email protected] data]# pwd/application/mysql/data[[email protected] Data]#[[email PR Otected] data]# ls
2.Create a multi-instance directory (Port-differentiated)
Mkdir/data/{3306,3307}/data-p
3.CreateMY.CNF MySQLfile
[Email protected] 3306]# lsdata my.cnf mysql[[email protected] 3306]#
4.Copying related filesMy.cnf,Mysqlto each directory
\CP/DATA/3306/MY.CNF mysql/data/3307/#保证是下面形式 [[email protected] data]# tree.├──3306│├──data│├──my.cnf│└──my Sql├──3307├──data├──my.cnf└──mysql
5.Modify the port number andId
#修改3307sed-i ' s/3306/3307/g '/data/3307/my.cnfsed-i ' S/server-id = 1/server-id = 7/g '/data/3307/my.cnfsed-i ' s/3306/33 07/g '/data/3307/mysql
6.Initialize
cd/application/mysql/scripts./mysql_install_db--datadir=/data/3306/data--basedir=/application/mysql--user= mysql./mysql_install_db--datadir=/data/3307/data--basedir=/application/mysql--user=mysql
7.Authorized
Chown-r mysql.mysql/data/find/data-type f-name Mysql|xargs chmod 700
8.OpenMysql
/data/3306/mysql Start/data/3307/mysql Start
9.Check Port
[[email protected] scripts]# netstat-lnt|grep 330tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN TCP 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN
10.adding environment variables and booting from
[[Email protected] ~] #PATH = "$PATH:/application/mysql/bin" [[email protected] ~]# echo ' path= ' $PATH:/application/mysql /bin "' >>/etc/profile[[email protected] ~]#. /etc/profile[[email protected] ~]#
11.join Power-on self-boot
echo "/data/3306/mysql start" >>/etc/rc.localecho "/data/3307/mysql start" >>/etc/rc.local[[email Protected] ~]# tail-2/etc/rc.local/data/3306/mysql start/data/3307/mysql start[[email protected] ~]#
Thank Oldboy Teacher for teaching!
This article is from "Song Someone C" blog, please be sure to keep this source http://syaving.blog.51cto.com/5614476/1879039
MySQL Installation-multi-instance Installation "3"