码迷,mamicode.com
首页 > 数据库 > 详细

Mysql5.7.17安装部署

时间:2018-05-30 19:26:47      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:ace   grep   sla   tables   pad   yum   两台   file   ali   

技术分享图片

1.创建mysql用户

groupadd mysql
useradd -r -g mysql -s /bin/false mysql 

2.安装MySQL依赖包下载5.7.17包

yum install -y libaio
cd /usr/local/src/
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
tar -zxf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mkdir -p /data/app/

  

3.拷贝解压文件到安装目录并授权

cp -rf mysql-5.7.17-linux-glibc2.5-x86_64 /data/app/mysql-3306
cp -rf mysql-5.7.17-linux-glibc2.5-x86_64 /data/app/mysql-3307
cp -rf mysql-5.7.17-linux-glibc2.5-x86_64 /data/app/mysql-3308
cp -rf mysql-5.7.17-linux-glibc2.5-x86_64 /data/app/mysql-3309
chown -R mysql:mysql /data/app/mysql-3306
chown -R mysql:mysql /data/app/mysql-3307
chown -R mysql:mysql /data/app/mysql-3308
chown -R mysql:mysql /data/app/mysql-3309

4.初始化程序

/data/app/mysql-3306/bin/mysqld --initialize-insecure --user=mysql --basedir=/data/app/mysql-3306 --datadir=/data/app/mysql-3306/data
/data/app/mysql-3307/bin/mysqld --initialize-insecure --user=mysql --basedir=/data/app/mysql-3307 --datadir=/data/app/mysql-3307/data
/data/app/mysql-3308/bin/mysqld --initialize-insecure --user=mysql --basedir=/data/app/mysql-3308 --datadir=/data/app/mysql-3308/data
/data/app/mysql-3309/bin/mysqld --initialize-insecure --user=mysql --basedir=/data/app/mysql-3309 --datadir=/data/app/mysql-3309/data

5.配置my.cnf

修改my.cnf需要修改的参数:server-id:保证每个配置文件唯一,两台master的自增长ID必须不同

linux-node2
cat
> /data/app/mysql-3306/my.cnf<<EOF [client] port = 3306 socket = /data/app/mysql-3306/mysql.sock [mysqld] port = 3306 user = mysql server-id = 1 bind-address = 0.0.0.0 basedir = /data/app/mysql-3306 datadir = /data/app/mysql-3306/data socket = /data/app/mysql-3306/mysql.sock pid-file = /data/app/mysql-3306/mysql.pid log-error = /data/app/mysql-3306/mysqld.log skip-name-resolve log_bin = mysql-bin log-slave-updates sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES EOF chown mysql.mysql /data/app/mysql-3306/my.cnf ---------------------------------------------------------- cat > /data/app/mysql-3307/my.cnf<<EOF [client] port = 3307 socket = /data/app/mysql-3307/mysql.sock [mysqld] port = 3307 user = mysql server-id = 11 bind-address = 0.0.0.0 basedir = /data/app/mysql-3307 datadir = /data/app/mysql-3307/data socket = /data/app/mysql-3307/mysql.sock pid-file = /data/app/mysql-3307/mysql.pid log-error = /data/app/mysql-3307/mysqld.log skip-name-resolve log_bin = mysql-bin sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES EOF chown mysql.mysql /data/app/mysql-3306/my.cnf

6.配置启动mysql服务

touch /data/app/mysql-3306/mysqld.log && chown mysql.mysql /data/app/mysql-3306/mysqld.log
sed -i s#/usr/local/mysql#/data/app/mysql-3306#g /data/app/mysql-3306/bin/mysqld_safe
touch /data/app/mysql-3307/mysqld.log && chown mysql.mysql /data/app/mysql-3307/mysqld.log
sed -i s#/usr/local/mysql#/data/app/mysql-3307#g /data/app/mysql-3307/bin/mysqld_safe
touch /data/app/mysql-3308/mysqld.log && chown mysql.mysql /data/app/mysql-3308/mysqld.log
sed -i s#/usr/local/mysql#/data/app/mysql-3308#g /data/app/mysql-3307/bin/mysqld_safe
touch /data/app/mysql-3309/mysqld.log && chown mysql.mysql /data/app/mysql-3309/mysqld.log
sed -i s#/usr/local/mysql#/data/app/mysql-3309#g /data/app/mysql-3309/bin/mysqld_safe

 

启动修改:第一种:

vim /data/app/mysql-3306/support-files/mysql.server
mysqld_pid_file_path=/data/app/mysql-3306/
basedir=/data/app/mysql-3306/
datadir=/data/app/mysql-3306/data
cp -a /data/app/mysql-3306/support-files/mysql.server /etc/init.d/
mv /etc/init.d/mysql.server  /etc/init.d/mysql3306
chmod +x  /etc/init.d/mysql.server
server mysql3306 start
启动:3306
/data/app/mysql-3306/bin/mysqld_safe --defaults-file=/data/app/mysql-3306/my.cnf --basedir=/data/app/mysql-3306 --datadir=/data/app/mysql-3306/data --user=mysql &
启动:3307
/data/app/mysql-3307/bin/mysqld_safe --defaults-file=/data/app/mysql-3307/my.cnf --basedir=/data/app/mysql-3307 --datadir=/data/app/mysql-3307/data --user=mysql &
启动:3308
/data/app/mysql-3308/bin/mysqld_safe --defaults-file=/data/app/mysql-3308/my.cnf --basedir=/data/app/mysql-3308 --datadir=/data/app/mysql-3308/data --user=mysql &
启动:3309
/data/app/mysql-3309/bin/mysqld_safe --defaults-file=/data/app/mysql-3309/my.cnf --basedir=/data/app/mysql-3309 --datadir=/data/app/mysql-3309/data --user=mysql &

启动修改:第二种:

检查启动端口:

ss -lntup |egrep 3306|3307|3308|3309
yum install -y mysql
mysql -uroot -S /data/app/mysql-3306/mysql.sock
yum install -y mysql
mysql -uroot -S /data/app/mysql-3307/mysql.sock

 参考博文:http://www.cnblogs.com/kevingrace/p/5685511.html

Mysql5.7.17安装部署

标签:ace   grep   sla   tables   pad   yum   两台   file   ali   

原文地址:https://www.cnblogs.com/wylhome/p/9112397.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!