mysql5.6.20二進位安裝部署文檔

來源:互聯網
上載者:User

標籤:mysql   二進位   安裝部署   

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的業務產生任何影響的

本文出自 “10931853” 部落格,請務必保留此出處http://wujianwei.blog.51cto.com/10931853/1959711

mysql5.6.20二進位安裝部署文檔

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.