CentOS 6.5 Minimized compilation install MySQL 5.5.35 configuration multi-instance
1. Turn off the firewall
[[email protected] ~]# service iptables stopiptables: setting chains to policy accept: filter [ OK ]iptables: Flushing firewall rules: [ OK ]iptables: Unloading modules: [ OK ][[email protected] ~]# chkconfig iptables off[[email protected] ~]# chkconfig iptables -- Listiptables 0:off 1:off 2:o ff 3:off 4:off 5:off 6:off
2. Turn off SELinux
[Email protected] ~]# setenforce 0[[email protected] ~]# Vim/etc/sysconfig/selinux
Modify the following line;
Selinux=disabled
[Email protected] ~]# Getenforce Permissive
3, install MySQL dependency package and compiling tools;
[[email protected] ~]# yum install libaio-devel-y[[email protected] ~]# yum install-y ncurses-devel[[email protected] ~] # yum install-y gcc gcc-c++ [[email protected] ~]# Yum install-y cmake
4, preparation before installation;
4.1. Installation path:
[Email protected] ~]# Mkdir/usr/local/mysql
4.2. Database path:
[Email protected] ~]# mkdir/data/mysql-p
4.3. Create users and user groups
[[email protected] ~]# groupadd mysql[[email protected] ~]# useradd-r-g mysql-s/bin/false MySQL
4.4. Assigning permissions to the data store directory
[Email protected] ~]# chown mysql:mysql-r/data/mysql
5. Compile and install MySQL 5.5.35
[[email protected] ~]# yum install-y lrzsz[email protected] ~]# mkdir/package[[email protected] ~]# Cd/package/[roo[ema Il protected] package]# tar xf mysql-5.5.32.tar.gz [[email protected] package]# CD Mysql-5.5.32[[email protected] mysql-5. 5.32]# CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_unix_addr=/data/mysql/mysql.sock-ddefault_charset=utf8-ddefault _collation=utf8_general_ci-dwith_extra_charsets:string=utf8,gbk-dwith_innobase_storage_engine=1-dwith_readline =1-denabled_local_infile=1-dmysql_datadir=/data/mysql/-dmysql_user=mysql-dmysql_tcp_port=3306[[email protected] mysql-5.5.32]# make && make install
6, create multi-instance database file storage location;
[Email protected] ~]# mkdir-p/data/{3306,3307}/data[[email protected] ~]# tree/data/data|--3306| '--data '--3307 '--data4 directories, 0 files
7, modify the configuration file (MY.CNF) the following line, respectively, into the 3306, 3307 directories;
[Email protected] 3306]# vim my.cnf [client]port = 3306socket =/data/3306/mysql.sock[mysqld]port = 3306socket =/data/3306/mysql.sockdatadir =/data/3306server-id = 3306
8, initialize the database;
Note: You need to specify a different data directory when initializing the database
[Email protected] mysql-5.5.32]# cd/usr/local/mysql/[[email protected] mysql]# scripts/mysql_install_db--user=mysql --basedir=/usr/local/mysql--datadir=/data/3306[[email protected] mysql]# scripts/mysql_install_db--user=mysql-- Basedir=/usr/local/mysql--datadir=/data/3307
9, start a multi-instance, the startup script can be added to the boot file.
[Email protected] mysql]#/usr/local/mysql/bin/mysqld_safe--defaults-file=/data/3306/my.cnf 2>&1 >/dev/ Null & [[email protected] mysql]#/usr/local/mysql/bin/mysqld_safe--defaults-file=/data/3307/my.cnf 2>&1 & Gt;/dev/null &
9.1, check the port;
[[email protected] mysql]# netstat -tunlpactive internet connections (only servers) proto recv-q send-q local address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 11621/mysqld tcp 0 0 0.0.0.0:22 0.0.0.0:* listen 1266/sshd tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 11338/mysqld tcp 0 0 :: :22 :::* LISTEN 1266/sshd udp 0 0 0.0.0.0:68 0.0.0.0:* 969/dhclient
10. Log in to multi-instance database
[[email protected] mysql]#/usr/local/mysql/bin/mysql-u root-p-P 3306-s/data/3306/mysql.sock[[email protected] MySQL #/usr/local/mysql/bin/mysql-u Root-p-P 3307-s/data/3307/mysql.sock
11. Turn off MySQL multi-instance mode
[Email protected] mysql]#/usr/local/mysql/bin/mysqladmin-u root-p-P 3306-s/data/3306/mysql.sock shutdown [[email] Protected] mysql]#/usr/local/mysql/bin/mysqladmin-u root-p-p 3307-s/data/3307/mysql.sock shutdown
CentOS 6.5 Minimized compilation install MySQL 5.5.35 configuration multi-instance