CentOS7.2安装mysql-5.7.19多实例

安装多实例之前首先需要先安装mysql,这里就不介绍如何安装mysql了,参考前面的博客:https://www.cnblogs.com/hei-ma/p/9505509.html

安装多实例之前需要将之前安装好的mysql停掉。

# /etc/init.d/mysqld stop

开始正式安装mysql-5.7.19多实例

1、创建多实例目录

# mkdir -p /data/mysql{3307,3308}/data

2、编辑多实例配置文件

      3308端口的需要将3307修改为3308,server-id也需要改

# cat /data/mysql3307/my.cnf 
[client]
port            = 3307
socket          = /data/mysql3307/mysql.sock

[mysql]
no-auto-rehash

[mysqld]
secure_file_priv = 
user    = mysql
port    = 3307
socket  = /data/mysql3307/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql3307/data
open_files_limit    = 1024
back_log = 600
max_connections = 800
max_connect_errors = 3000
table_open_cache = 614
external-locking = FALSE
max_allowed_packet =8M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 100
query_cache_size = 2M
query_cache_limit = 1M
query_cache_min_res_unit = 2k
thread_stack = 192K
tmp_table_size = 2M
max_heap_table_size = 2M
pid-file = /data/mysql3307/mysql.pid
log-bin = /data/mysql3307/mysql-bin
relay-log = /data/mysql3307/relay-bin
relay-log-info-file = /data/mysql3307/relay-log.info
binlog_cache_size = 1M
max_binlog_cache_size = 1M
max_binlog_size = 2M
expire_logs_days = 7
key_buffer_size = 16M
read_buffer_size = 1M
read_rnd_buffer_size = 1M
bulk_insert_buffer_size = 1M
lower_case_table_names = 1
skip-name-resolve
slave-skip-errors = 1032,1062
replicate-ignore-db=mysql
server-id = 6
innodb_buffer_pool_size = 32M
innodb_data_file_path = ibdata1:128M:autoextend
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 4M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
[mysqldump]
quick
max_allowed_packet = 2M

[mysqld_safe]
log-error=/data/mysql3307/mysql_3307.err
pid-file=/data/mysql3307/mysqld.pid

3、创建用户并授权

# useradd -s /sbin/nologin -M mysql
# chown -R mysql.mysql /data/mysql330*

4、初始化

# cd /mysql-path/bin      #进入到你的mysql安装路径
# ./mysqld --defaults-file=/data/mysql3307/my.cnf --basedir=/usr/local/mysql --user=mysql --initialize-insecure --explicit_defaults_for_timestamp
# echo $?             #确认初始化是否成功,返回0则成功

5、启动多实例

# cd /mysql-path/bin           #mysql的安装路径
# ./mysqld_safe --defaults-file=/data/mysql3307/my.cnf &          #启动mysql

6、确认进程

# ps -ef|grep /data/mysql3307         #查看进程
root     11893  7522  0 16:19 pts/3    00:00:00 /bin/sh ./mysqld_safe --defaults-file=/data/mysql3307/my.cnf
mysql    12562 11893  0 16:19 pts/3    00:00:01 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql3307/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql3307/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql3307/mysql_3307.err --open-files-limit=1024 --pid-file=/data/mysql3307/mysqld.pid --socket=/data/mysql3307/mysql.sock --port=3307
root     12926  7522  0 16:46 pts/3    00:00:00 grep --color=auto /data/mysql3307
# netstat -lnutp|grep 3307            #查看端口
tcp6       0      0 :::3307                 :::*                    LISTEN      12562/mysqld

至此3307的多实例就配置完成了!!

3308的配置和3307一样,但是需要修改配置文件

 

posted @ 2018-08-28 16:48  欧-阳  阅读(1167)  评论(0编辑  收藏  举报