mysql-5.5.37 installation of multiple instances

Source: Internet
Author: User
Tags mixed rehash

CentOS 6.2 Installation Compile mysql-5.5.37 # #多实例 principle is to install multiple instances after installing a single instance


First Yum Installation

Yum install gcc gcc-c++ cmake ncurses-devel Bison


1 single-instance MySQL database installation

1.1 Creating a MySQL Account

[[email protected] ~]# Groupadd MySQL

[[email protected] ~]# useradd-s/sbin/nologin-g mysql-m MySQL #-m means no home directory created

After the creation is complete, look under

[[email protected] ~]# grep mysql/etc/passwd

Mysql:x:500:500::/home/mysql:/sbin/nologin


1.2 Setting up a MySQL installation directory

[email protected] ~]# mkdir-p/usr/local/mysql

[email protected] ~]# mkdir-p/data/mysql/data


1.3 Download MySQL http://dev.mysql.com/downloads/or go to Sohu image source download and upload to the server



2. Install MySQL

2,1 detect if the system has been installed MySQL

[[email protected] ~]# rpm-qa |grep MySQL

mysql-libs-5.1.61-1.el6_2.1.i686

here is not installed MySQL if there is a need to uninstall MySQL installation package rpm-e--nodeps MySQL first. x.x.x


2,2 Install the packages needed to compile the MySQL compilation

Yum-y install make gcc-c++ cmake bison-devel ncurses-devel

If these packages are installed in front of you, you can install them separately.


2,3 unzip MySQL and install

[Email protected] ~]# tar xzvf mysql-5.5.37.tar.gz

[Email protected] ~]# CD mysql-5.5.37


CMake \

-dmysql_user=mysql \

-dcmake_install_prefix=/usr/local/mysql \

-dinstall_datadir=/data/mysql/data \

-dmysql_unix_addr=/usr/local/mysql/mysql.sock \

-ddefault_charset=utf8 \

-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-dextra_charsets=all \

-dwith_embedded_server=1 \

-denabled_local_infile=1 \

-dwith_myisam_storage_engine=1 \

-dwith_innobase_storage_engine=1


-dmysql_unix_addr=/usr/local/mysql/mysql.sock \ # socket file

[[email protected] mysql-5.6.23]# make && make install



3. Initialize the database

[Email protected] mysql]# mkdir-p/data/mysql/data/{3306,3307} # #建立两个实例

/usr/local/mysql/Scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/mysql/data/ 3306--user=mysql

/usr/local/mysql/Scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/mysql/data/ 3307--user=mysql


Chown-r Mysql:mysql/usr/local/mysql

chown-r Mysql:mysql /data/mysql/data


4. Create a configuration file

3306 MY.CNF

[Client]

Port = 3306

Socket =/data/mysql/data/3306/mysql.sock

[Mysqld]

datadir=/data/mysql/data/3306

Skip-name-resolve

Lower_case_table_names=1

Innodb_file_per_table=1

Port = 3306

Socket =/data/mysql/data/3306/mysql.sock

Back_log = 50

Max_connections = 300

max_connect_errors = 1000

Table_open_cache = 2048

Max_allowed_packet = 16M

Binlog_cache_size = 2M

Max_heap_table_size = 64M

Sort_buffer_size = 2M

Join_buffer_size = 2M

Thread_cache_size = 64

Thread_concurrency = 8

Query_cache_size = 64M

Query_cache_limit = 2M

Ft_min_word_len = 4

Default-storage-engine = InnoDB

Thread_stack = 192K

Transaction_isolation = Repeatable-read

Tmp_table_size = 64M

Log-bin=mysql-bin

Binlog_format=mixed

Slow_query_log

Long_query_time = 1

Server-id = 1

Key_buffer_size = 8M

Read_buffer_size = 2M

Read_rnd_buffer_size = 2M

Bulk_insert_buffer_size = 64M

Myisam_sort_buffer_size = 128M

Myisam_max_sort_file_size = 10G

Myisam_repair_threads = 1

Myisam_recover

Innodb_additional_mem_pool_size = 16M

Innodb_buffer_pool_size = 200M

Innodb_data_file_path = Ibdata1:10m:autoextend

Innodb_file_io_threads = 8

Innodb_thread_concurrency = 16

Innodb_flush_log_at_trx_commit = 1

Innodb_log_buffer_size = 16M

Innodb_log_file_size = 512M

Innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 60

Innodb_lock_wait_timeout = 120

[Mysqldump]

Quick

Max_allowed_packet = 256M

[MySQL]

No-auto-rehash

Prompt=\\[email protected]\\d \\r:\\m>

[Myisamchk]

Key_buffer_size = 512M

Sort_buffer_size = 512M

Read_buffer = 8M

Write_buffer = 8M

[Mysqlhotcopy]

Interactive-timeout

[Mysqld_safe]

Open-files-limit = 8192


3307 my.cnf

[Client]

Port = 3307

Socket =/data/mysql/data/3307/mysql.sock

[Mysqld]

datadir=/data/mysql/data/3307

Skip-name-resolve

Lower_case_table_names=1

Innodb_file_per_table=1

Port = 3307

Socket =/data/mysql/data/3307/mysql.sock

Back_log = 50

Max_connections = 300

max_connect_errors = 1000

Table_open_cache = 2048

Max_allowed_packet = 16M

Binlog_cache_size = 2M

Max_heap_table_size = 64M

Sort_buffer_size = 2M

Join_buffer_size = 2M

Thread_cache_size = 64

Thread_concurrency = 8

Query_cache_size = 64M

Query_cache_limit = 2M

Ft_min_word_len = 4

Default-storage-engine = InnoDB

Thread_stack = 192K

Transaction_isolation = Repeatable-read

Tmp_table_size = 64M

Log-bin=mysql-bin

Binlog_format=mixed

Slow_query_log

Long_query_time = 1

Server-id = 1

Key_buffer_size = 8M

Read_buffer_size = 2M

Read_rnd_buffer_size = 2M

Bulk_insert_buffer_size = 64M

Myisam_sort_buffer_size = 128M

Myisam_max_sort_file_size = 10G

Myisam_repair_threads = 1

Myisam_recover

Innodb_additional_mem_pool_size = 16M

Innodb_buffer_pool_size = 200M

Innodb_data_file_path = Ibdata1:10m:autoextend

Innodb_file_io_threads = 8

Innodb_thread_concurrency = 16

Innodb_flush_log_at_trx_commit = 1

Innodb_log_buffer_size = 16M

Innodb_log_file_size = 512M

Innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 60

Innodb_lock_wait_timeout = 120

[Mysqldump]

Quick

Max_allowed_packet = 256M

[MySQL]

No-auto-rehash

Prompt=\\[email protected]\\d \\r:\\m>

[Myisamchk]

Key_buffer_size = 512M

Sort_buffer_size = 512M

Read_buffer = 8M

Write_buffer = 8M

[Mysqlhotcopy]

Interactive-timeout

[Mysqld_safe]

Open-files-limit = 8192


5; Define Global

[Email protected] mysql-5.5.37]# echo "Export path=/usr/local/mysql/bin/: $PATH" >>/etc/profile

[email protected] mysql-5.5.37]#source/etc/profile



6. Start MySQL

Launch of multi-instance region files MySQL Service essence:

Mysqld_safe--defaults-file=/data/mysql/data/3306/my.cnf 2>&1 >/dev/null &

Mysqld_safe--defaults-file=/data/mysql/data/3307/my.cnf 2>&1 >/dev/null &


6. Login

[Email protected] 3307]#/usr/local/mysql/bin/mysql-uroot-p-S /data/mysql/data/3306/mysql.sock

[Email protected] 3307]#/usr/local/mysql/bin/mysql-uroot-p-S /data/mysql/data/3307/mysql.sock



7. Stop MySQL

/usr/local/mysql/bin/mysqladmin-u root-p-s/data/mysql/data/3306/mysql.sock shutdown

/usr/local/mysql/bin/mysqladmin-u root-p-s/data/mysql/data/3307/mysql.sock shutdown


8; Start Script writing

[Email protected] 3306]# VI mysqld

[Email protected] 3306]# chmod mysqld


#!/bin/bash

mysql_port=3306

Mysql_username= "Root"

#if passwd the Set password

Mysql_password= "123"

Function_start_mysql ()

{

printf "Starting mysql...\n"

}

Function_stop_mysql ()

{

printf "stoping mysql...\n"

/usr/local/mysql/bin/mysqladmin-u ${mysql_username}-p${mysql_password}-s/data/mysql/data/${mysql_port}/ Mysql.sock shutdown

}

Function_restart_mysql ()

{

printf "Restarting mysql...\n"

Function_stop_mysql

Function_start_mysql

}

Function_kill_mysql ()

{

Kill-9 $ (Ps-ef | grep ' Bin/mysqld_safe ' | grep ${mysql_port} | awk ' {printf} ')

Kill-9 $ (Ps-ef | grep ' Libexec/mysqld ' | grep ${mysql_port} | awk ' {printf} ')

}

Case $ in

Start

Function_start_mysql;;

Stop

Function_stop_mysql;;

Kill

Function_kill_mysql;;

Restart

Function_stop_mysql

Function_start_mysql;;

*)

echo "Usage:/data/mysql/data/${mysql_port}/mysqld {start|stop|restart|kill}";;

Esac


#编写3307脚本

#!/bin/bash

mysql_port=3307

Mysql_username= "Root"

Mysql_password= "123"

Function_start_mysql ()

{

printf "Starting mysql...\n"

}

Function_stop_mysql ()

{

printf "stoping mysql...\n"

}

Function_restart_mysql ()

{

printf "Restarting mysql...\n"

Function_stop_mysql

Function_start_mysql

}

Function_kill_mysql ()

{

Kill-9 $ (Ps-ef | grep ' Bin/mysqld_safe ' | grep ${mysql_port} | awk ' {printf} ')

Kill-9 $ (Ps-ef | grep ' Libexec/mysqld ' | grep ${mysql_port} | awk ' {printf} ')

}

Case $ in

Start

Function_start_mysql;;

Stop

Function_stop_mysql;;

Kill

Function_kill_mysql;;

Restart

Function_stop_mysql

Function_start_mysql;;

*)

echo "Usage:/data/mysql/data/${mysql_port}/mysqld {start|stop|restart|kill}";;

Esac


Starting mode:

/data/mysql/data/3306/mysqld start

/data/mysql/data/3307/mysqld start


[Email protected] 3307]#/data/mysql/data/3306/mysqld restart

Stoping MySQL ...

Starting MySQL ...

[Email protected] 3307]#/data/mysql/data/3307/mysqld restart

Stoping MySQL ...

Starting MySQL ...



9. Boot from MySQL

[Email protected] 3307]# vi/etc/rc.local


/data/mysql/data/3306/mysqld Start >/dev/null 2>&1

/data/mysql/data/3307/mysqld Start >/dev/null 2>&1











This article is from "think one or two" blog, please be sure to keep this source http://250919938.blog.51cto.com/962010/1684584

mysql-5.5.37 installation of multiple instances

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.