同台ECS安装多个mysql

环境:

  系统:centos7.6

  mysql版本:5.7

 [root@IG-ECS-dev-mysql ~]#yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype*
# adduser mysql
# mkdir /usr/local/mysql{3306,3307}/data          
# mkdir /usr/local/mysql{3306,3307}/log
# chown -R mysql:mysql /usr/local/mysql{3306,3307}/data/
# chown -R mysql:mysql /usr/local/mysql{3306,3307}/log/
# chmod 750 /usr/local/mysql{3306,3307}/data      
# chmod 750 /usr/local/mysql{3306,3307}/log  
# mkdir -p /usr/local/mysql{3306,3307}/etc
# chown -R mysql.mysql /usr/local/mysql{3306,3307}/etc
# mkdir -p /var/run/mysqld{3306,3307}
# chown -R mysql.mysql /var/run/mysqld{3306,3307}
# mkdir -p /var/lib/mysqld{3306,3307}
# chown -R mysql.mysql /var/lib/mysqld{3306,3307}
# cp /etc/my.cnf /usr/local/mysql{3306,3307}/etc

 

[root@IG-ECS-dev-mysql mysql-5.7.14]# cmake -DCMAKE_INSTALL_PREFIX="/usr/local/mysql3307/" -DDEFAULT_CHARSET=utf8 -DSYSCONFDIR=/usr/local/mysql3307/etc/ -DMYSQL_DATADIR="/usr/local/mysql3307/data/" -DINSTALL_PLUGINDIR=plugin -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CO
LLATION=utf8_general_ci -DENABLE_DEBUG_SYNC=0 -DENABLED_LOCAL_INFILE=1 -DENABLED_PROFILING=1 -DWITH_ZLIB=system -DWITH_EXTRA_CHARSETS=none -DMYSQL_MAINTAINER_MODE=OFF -DEXTRA_CHARSETS=all -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/boost_1_59_0

  

make && make install

 

[root@IG-ECS-dev-mysql etc]# vim my.cnf 
-----------------------------------------------------------------
[client]

port = 3306

socket = /tmp/mysql3306.sock

[mysqld]

binlog_format = mixed

port = 3306
bind-address = 0.0.0.0

socket = /tmp/mysql3306.sock

basedir = /usr/local/mysql3306

datadir  = /usr/local/mysql3306/data
pid-file=/var/lib/mysqld3306/mysql.pid

#master-to-master

log-bin   = mysql1-bin

server-id = 1 

#expire-logs-days  = 30 #only 30 days binlog backup 

#replicate-do-db   =  test

binlog-ignore-db  = mysql

binlog-ignore-db  = information_schema

binlog-ignore-db  = sys

binlog-ignore-db  = performance_schema

auto-increment-increment = 5 

auto-increment-offset = 1

log-slave-updates = ON

max_connections=3000

log_timestamps=SYSTEM

   

#============================================

back_log=50

max_user_connections=2000

innodb_thread_concurrency=8

default-storage-engine=InnoDB

innodb_buffer_pool_size=16M

innodb_log_buffer_size=8M

innodb_log_file_size=48M

innodb_flush_log_at_trx_commit=2

innodb_lock_wait_timeout=50

                          

long_query_time = 1

slow_query_log=YES

slow_query_log_file=/usr/local/mysql3306/log/slow.log

                                       

log-error=/usr/local/mysql3306/log/error.log
[mysqld_safe]
log-error=/var/log/mysqld3306.log
pid-file=/var/run/mysqld3306/mysqld.pid

  

# echo "/usr/local/mysql3306/lib" >> /etc/ld.so.conf.d/mysql.conf
# ldconfig

# ln -s /usr/local/mysql3306/include/mysql /usr/include/mysql
[root@IG-ECS-dev-mysql bin]# ./mysql_install_db  --defaults-file=/usr/local/mysql3306/etc/my.cnf  --basedir=/usr/local/mysql3306  --datadir=/usr/local/mysql3306/data/ --user=mysql

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld3306


# vi /etc/init.d/mysqld3006
------------------------------------------------------------

basedir=/usr/local/mysql3306
datadir=/usr/local/mysql3306/data
conf=/usr/local/mysql3306/etc/my.cnf
$bindir/mysqld_safe --defaults-file=/usr/local/mysql3306/etc/my.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
--------------------------------------------

/etc/init.d/mysql3306 start

 

同理安装其他的mysql

 

 

坑:

当多个mysql在同一台服务器的时候,不建议使用/etc/profile  添加环境变量的方法,貌似mysql的客户端是又识别功能的,我踩的坑是把mysql3306下的bin加到了环境变量, 

 

posted @ 2020-07-08 15:50  爱热闹的杨小厨  阅读(212)  评论(0编辑  收藏  举报