mysql5.6.20二进制安装部署文档

一、业务需求:

单台服务器线上运行着mysql5.5.48

现在是不影响线上的业务,不停止线上的mysql5.5数据库来部署另外一个mysql5.6.20的实例

二、安装部署过程:

2.1安装部署过程注意事项:

在初始化mysql数据库时,是会寻找my.cnf配置文件的,是有顺序的,默认的顺序是:

[[email protected] ~]# mysql --help | grep ‘Default options‘ -A 1

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

查看当前mysql运行采用的是哪个配置文件:

[[email protected] ~]# cat /proc/$(pidof mysqld)/cmdline | tr ‘\0‘ ‘\n‘

/usr/local/mysql5.6/bin/mysqld

--defaults-file=/usr/local/mysql5.6/my.cnf

--basedir=/usr/local/mysql5.6

--datadir=/data/mysql3307/data

--plugin-dir=/usr/local/mysql5.6/lib/plugin

--user=mysql

--log-error=/data/mysql3307/log/error.log

--open-files-limit=65535

--pid-file=/data/mysql3307/log/git-server.pid

--socket=/tmp/mysql3307.sock

--port=3307

提示:上面的命令只适合查看单实例mysql

参考:https://www.electrictoolbox.com/mysql-my-cnf/

https://www.psce.com/en/blog/2012/04/01/how-to-find-mysql-configuration-file/

2.2开始部署:

注意:要把现在线上运行的mysql5.5.48采用的my.cnf配置文件mv为另外一个名称,否则在初始化mysql5.6的时候会报错。原因是:初始化mysql5.6时,默认是先寻找/etc/my.cnf这个文件的。但是这个文件正在被mysql5.5.48在采用,所以要把这个文件改名,然后把mysql5.6.20的my.cnf的配置文件移到/usr/local/mysql5.6/下面,然后在初始化mysql5.6.20

mv /etc/my.cnf /etc/my.cnf.bak

如果不把线上mysql5.5.48的my.cnf配置文件改名的话,初始化mysql5.6.20会报如下错误:

[[email protected] scripts]# ./mysql_install_db --datadir=/data/mysql3307/data --basedir=/usr/local/mysql5.6 --user=mysql --explicit_defaults_for_timestamp

Installing MySQL system tables...2017-08-27 14:04:28 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.

2017-08-27 14:04:28 0 [Note] /usr/local/mysql5.6/bin/mysqld (mysqld 5.6.36-log) starting as process 7379 ...

2017-08-27 14:04:28 7379 [Note] InnoDB: Using atomics to ref count buffer pool pages

2017-08-27 14:04:28 7379 [Note] InnoDB: The InnoDB memory heap is disabled

2017-08-27 14:04:28 7379 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2017-08-27 14:04:28 7379 [Note] InnoDB: Memory barrier is not used

2017-08-27 14:04:28 7379 [Note] InnoDB: Compressed tables use zlib 1.2.3

2017-08-27 14:04:28 7379 [Note] InnoDB: Using Linux native AIO

2017-08-27 14:04:28 7379 [Note] InnoDB: Using CPU crc32 instructions

2017-08-27 14:04:28 7379 [Note] InnoDB: Initializing buffer pool, size = 1.0G

2017-08-27 14:04:28 7379 [Note] InnoDB: Completed initialization of buffer pool

2017-08-27 14:04:28 7379 [ERROR] InnoDB: Unable to lock /usr/local/mysql/var/ibdata1, error: 11

2017-08-27 14:04:28 7379 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

2017-08-27 14:04:28 7379 [Note] InnoDB: Retrying to lock the first data file

2017-08-27 14:04:29 7379 [ERROR] InnoDB: Unable to lock /usr/local/mysql/var/ibdata1, error: 11

2017-08-27 14:04:29 7379 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

2017-08-27 14:04:30 7379 [ERROR] InnoDB: Unable to lock /usr/local/mysql/var/ibdata1, error: 11

2017-08-27 14:04:30 7379 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

2017-08-27 14:04:31 7379 [ERROR] InnoDB: Unable to lock /usr/local/mysql/var/ibdata1, error: 11

2017-08-27 14:04:31 7379 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

2017-08-27 14:04:32 7379 [ERROR] InnoDB: Unable to lock /usr/local/mysql/var/ibdata1, error: 11

2017-08-27 14:04:32 7379 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

2017-08-27 14:04:33 7379 [ERROR] InnoDB: Unable to lock /usr/local/mysql/var/ibdata1, error: 11

2017-08-27 14:04:33 7379 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

所以要先把线上的mysql5.5.48的my.cnf配置文件改名(切记此期间不要对mysql5.5.48有任何的修改启动服务操作),等mysql5.6.20成功部署好后记得再把改名后的mysql5.5.48的配置文件改回原来的/etc/my.cnf

Mysql二进制包下载地址

http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/

useradd mysql

mkdir /data1/mysql5.6/{data,var} -p

chown -R mysql.mysql /data1/mysql5.6/

tar xf /tmp/mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

cd /usr/local/

mv mysql-5.6.20-linux-glibc2.5-x86_64 mysql5.6

chown -R mysql.mysql /usr/local/mysql5.6

cp my.cnf(mysql5.6.20的配置文件) /usr/local/mysql5.6/

cd /usr/local/mysql5.6/scripts

[[email protected] scripts]# ./mysql_install_db --datadir=/data/mysql5.6/data --basedir=/usr/local/mysql5.6 --user=mysql --explicit_defaults_for_timestamp

Installing MySQL system tables.../usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

解决:

yum -y install libaio-devel 或者yum install libaio*

./mysql_install_db --datadir=/data1/mysql5.6/data --basedir=/usr/local/mysql5.6 --user=mysql --explicit_defaults_for_timestamp

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql5.6

sed -i ‘s#/usr/local/mysql5.6#/usr/local/mysql#g‘ /etc/init.d/mysql5.6

chkconfig mysql5.6 on

echo "export PATH=$PATH:/usr/local/mysql5.6/bin" > /etc/profile.d/mysql.sh

source /etc/profile

2.3启动mysql5.6.20设置密码:

第一种方式启动mysql

/etc/init.d/mysql5.6 start

第二种方式启动mysql

mysqld_safe --defaults-file=/usr/local/mysql5.6/my.cnf &

ps -ef|grep mysql

给mysql5.6.20设置密码:

/usr/local/mysql5.6/bin/mysqladmin -u root password ‘Zydfg55726‘ -S /tmp/mysql3307.sock

mysql -uroot -p -S /tmp/mysql3307.sock

平滑关闭mysql5.6.20:

mysqladmin -uroot -p‘Zydfg55726‘ -S /tmp/mysql3307.sock  shutdown

/etc/init.d/mysql5.6 stop

2.4 mysql5.6.20的my.cnf配置文件:

[[email protected] ~]# cat /etc/my.cnf

[client]

#password = your_password

port = 3307

socket = /tmp/mysql3307.sock

[mysqld]

port = 3307

socket = /tmp/mysql3307.sock

datadir = /data1/mysql5.6/data

skip-external-locking

key_buffer_size = 32M

max_allowed_packet = 50M

table_open_cache = 1024

sort_buffer_size = 4M

net_buffer_length = 8K

read_buffer_size = 4M

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 64M

thread_cache_size = 128

#query_cache_size = 128M

tmp_table_size = 64M

max_join_size=3G

#skip-networking

skip-name-resolve

max_connections = 500

max_connect_errors = 1000

open_files_limit = 65535

#log-bin=mysql-bin

#binlog_format=row

server-id = 1

#expire_logs_days = 1

#default_storage_engine = InnoDB

innodb_data_home_dir = /data1/mysql5.6/var

innodb_data_file_path = ibdata1:300M:autoextend

innodb_log_group_home_dir = /data1/mysql5.6/var

innodb_buffer_pool_size = 1024M

innodb_additional_mem_pool_size = 2M

innodb_log_file_size = 256M

innodb_log_buffer_size = 8M

innodb_flush_log_at_trx_commit = 0

innodb_lock_wait_timeout = 50

#innodb_force_recovery = 2

[mysqldump]

quick

max_allowed_packet = 256M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 16M

sort_buffer_size = 4M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

到此单台服务器上开启另外一个实例mysql5.6.20成功完成。而且不会对线上mysql5.5.48的业务产生任何影响的

时间: 2024-12-28 12:44:49

mysql5.6.20二进制安装部署文档的相关文章

Sqlserver2008安装部署文档

Sqlserver2008部署文档 注意事项: 如果你要安装的是64位的服务器,并且是新机器.那么请注意,你需要首先需要给64系统安装一个.net framework,如果已经安装此功能,请略过这一步.   具体安装.net framework的方法是:在图标<我的电脑>上右击选择<管理>,打开以后选择<功能>选项卡,如下图所示,然后点击添加功能,勾选..net framework,然后一直点击下一步安装即可. 安装的过程中,需要注意如果你要安装的服务器有外挂或者附加的

LVS+Heartbeat安装部署文档

LVS+Heartbeat安装部署文档 发表回复 所需软件: ipvsadm-1.24-10.x86_64.rpmheartbeat-2.1.3-3.el5.centos.x86_64.rpmheartbeat-pils-2.1.3-3.el5.centos.x86_64.rpmheartbeat-stonith-2.1.3-3.el5.centos.x86_64.rpmPyXML-0.8.4-4.x86_64.rpm 系统环境:CentOS 5.4 64-bit HA1            

zabbix3.0安装部署文档

zabbix v3.0安装部署 摘要: 本文的安装过程摘自http://www.ttlsa.com/以及http://b.lifec-inc.com ,和站长凉白开的<ZABBIX从入门到精通v3.0.1 - 运维生存时间(2016)>一书. 关于zabbix及相关服务软件版本: Linux:centos 6.6 nginx:1.9.15 MySQL:5.5.49 PHP:5.5.35 一.安装nginx: 安装依赖包: yum -y install gcc gcc-c++ autoconf

mysql5.6.20二进制安装

1把105的/usr/local/mysql拷过去 2. 把105的/etc/my.cnf拷过去 3. mkdir /data/mysql/{data,tmp,binlog,log}-p 4. 初始化 rpm -qa mysql yum remove mysql-5.1.73-8.el6_8.x86_64 /etc/my.cnf /etc/my.cnf.bak yum install libaio* useradd mysql mkdir /data/mysql/{data,tmp,binlog

mysql-5.7.20 二进制安装 | 备份恢复

###### 二进制自动安装数据库脚本root密码123456将脚本和安装包放在/usr/local/src目录即可############### ######数据库目录/usr/local/mysql############ ######数据目录/data/mysql############ ######慢日志目录/data/slowlog############ ######端口号默认3306其余参数按需自行修改############ #!/bin/bash cd /usr/local/s

OpenVPN2.4.3 安装部署文档(实战)

VPN概述: VPN(Virtual Private NetWork,虚拟专用网络)架设在公共共享的基础设施互联网上,在非信任的网络上建立私有的安全的连接,把分布在不同地域的办公场所.用户或者商业伙伴互联起来. 在目前的实践中,常见的VPN构建技术: PPTP(Point-to-Point Tunneling Protocol,点到点的隧道协议)VPN IPSec(Internet Protocol Security,互联网协议安全)VPN SSL/TLS(Secure Sockets Laye

redmine安装部署文档

############################################################################## 官网:http://www.redmine.org/ Redmine是一个开源的,基于Web的项目管理和缺陷跟踪工具.它用日历和甘特图辅助项目及进度可视化显示.同时它又支持多项目管理.Redmine是一个自由开放源码软件解决方案,它提供集成的项目管理功能,问题跟踪,并为多个版本控制选项的支持.虽说像IBM Rational Team Con

haproxy 安装部署文档

HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.HAProxy特别适用于那些负载特大的web站点,这些站点通常又需要会话保持或七层处理.HAProxy运行在当前的硬件上,完全可以支持数以万计的并发连接.并且它的运行模式使得它可以很简单安全的整合进您当前的架构中,同时可以保护你的web服务器不被暴露到网络上. haproxy 配置中分成五部分内容,分别如下:1.global:参数是进程级的,通常是和操作系统相关.这些参数一

Oracle RAC安装部署文档

1.    部署环境步骤 1.1 软件环境 操作系统:CentOS release 6.5(推荐使用5.*的系统)192.168.1.151    racnode1 192.168.1.152    racnode2 oracle安装包:p10404530_112030_Linux-x86-64_1of7.zipp10404530_112030_Linux-x86-64_2of7.zipp10404530_112030_Linux-x86-64_3of7.zipkmod-oracleasm-2.