基于centos?7的MySQL?5.7自動(dòng)化安裝,這里順便說(shuō)一下my.cnf里的一些定義的參數(shù) 比如下面兩個(gè) innodb_buffer_pool_dump_at_shutdown=1?#關(guān)閉時(shí)把熱數(shù)據(jù)dump到本地磁盤 innodb_buffer_pool_load_at_startup=1??#啟動(dòng)時(shí)把熱數(shù)據(jù)加載到內(nèi)存 因?yàn)閙ysql重啟時(shí)候會(huì)面臨一個(gè)問(wèn)題,就是如何將之前頻繁訪問(wèn)的數(shù)據(jù)重新加載回Buffer中, 也就是說(shuō)如何對(duì)InnoDB?Buffer?Pool進(jìn)行預(yù)熱來(lái)快速恢復(fù)之前的性能狀態(tài)。 增加了undo?log的自定義目錄,因?yàn)榘製ndo?log從共享表空間ibdata1里拆分出去的話,需要 在my.cnf里提前指定好,不然等數(shù)據(jù)庫(kù)啟動(dòng)好后再指定會(huì)報(bào)錯(cuò)。 innodb_undo_log_truncate=1?#開(kāi)啟在線回收 innodb_max_undo_los_size=1G?#這個(gè)就是閾值(默認(rèn)是1GB)時(shí),會(huì)觸發(fā)truncate回收動(dòng)作。 然后說(shuō)一下,下面這個(gè)配置 innodb_temp_data_file_path?=?ibtmp1:12M:autoextend:max:5G 因?yàn)閕btmp1文件是?MySQL5.7的新特性,MySQL5.7使用了獨(dú)立的臨時(shí)表空間來(lái)存儲(chǔ)臨時(shí)表數(shù)據(jù), 初始化12M,且默認(rèn)無(wú)上限,我這里設(shè)定了最高不能超過(guò)5g,釋放這個(gè)臨時(shí)表空間唯一的辦法就 是啟數(shù)據(jù)庫(kù)。 innodb_read_io_threads,?innodb_write_io_threads:?文件讀寫(xiě)的?I/O?線程數(shù) 可根據(jù)并發(fā)量和?CPU?核心數(shù)適當(dāng)調(diào)整 也不要再去糾結(jié) query_cache_size和query_cache_type這兩個(gè)參數(shù)了,這對(duì)于mysql來(lái)說(shuō)就是雞肋 而且默認(rèn)就是關(guān)閉的,建議采用默認(rèn)值,也就是設(shè)置為0,關(guān)閉 Redo?logs?記錄了所有的數(shù)據(jù)變更 恢復(fù)時(shí)間不再是一個(gè)問(wèn)題 innodb_log_file_size?=?2047M?before?5.6 innodb_log_file_size>=?2047M?from?5.6?? So?...?越大系統(tǒng)性能更穩(wěn)定 這個(gè)大家應(yīng)該都知道 innodb_buffer_pool_size 你懂的,自己物理內(nèi)存大小的50~70% 最后還有一點(diǎn),新版的mysql默認(rèn)監(jiān)聽(tīng)在IPv6上,記得關(guān)閉掉它 bind-address=0.0.0.0 當(dāng)mysql?數(shù)據(jù)庫(kù)發(fā)生死鎖時(shí),?innodb?status?里面會(huì)記錄最后一次死鎖的相關(guān)信息,但mysql?錯(cuò)誤日志里面 不會(huì)記錄死鎖相關(guān)信息,要想記錄,啟動(dòng)?innodb_print_all_deadlocks??參數(shù)?。 當(dāng)系統(tǒng)并發(fā)很高時(shí),很多的線程等待同一個(gè)行鎖,死鎖檢測(cè)可能會(huì)拖慢系統(tǒng),這個(gè)時(shí)候關(guān)閉死鎖檢測(cè)可能更好 innodb_print_all_deadlocks?=?1 最后說(shuō)一句:MySQL默認(rèn)的隔離級(jí)別不適合大部分的應(yīng)用場(chǎng)景,而且容易發(fā)生死鎖,所以我這里改成了read-committed 好了,最后就是安裝步驟了,其實(shí)都已經(jīng)腳本化了。 mkdir?-p?/home/tools cd?/home/tools yum?-y?install?numactl?libaio wget?http://god.nongdingbang.net/downloads/mysql-5.7-el7.tgz?&&?tar?zxvf?mysql-5.7-el7.tgz if?[?$??-eq?0?];then rpm?-Uvh?mysql*.rpm fi mkdir?-p?/data/{mysql_data,mysql_log,mysql_slow,mysql_undo} chown?-R?mysql.mysql?/data/* cat?>/etc/my.cnf<<EOF [client] port=3306 socket=/tmp/mysql.sock [mysql] no-auto-rehash [mysqld] port=3306 character-set-server=utf8 socket=/tmp/mysql.sock datadir=/data/mysql_data explicit_defaults_for_timestamp=true lower_case_table_names=1 sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' bind-address=0.0.0.0 back_log=103 max_connections=500 max_connect_errors=100000 table_open_cache=512 external-locking=FALSE max_allowed_packet=128M sort_buffer_size=2M join_buffer_size=2M thread_cache_size=51 query_cache_size=0 query_cache_type=0 #query_cache_limit=4M transaction_isolation=READ-COMMITTED tmp_table_size=96M max_heap_table_size=96M log-error=/data/mysql_log/error.log ###***slowqueryparameters long_query_time=2 slow_query_log=1 slow_query_log_file=/data/mysql_slow/slow.log ###***binlogparameters log-bin=/data/mysql_log/mysql-bin binlog_cache_size=1M max_binlog_cache_size=4096M max_binlog_size=1024M binlog_format=ROW binlog_row_image=full expire_logs_days=3 sync_binlog=0 ###***undolog innodb_undo_directory=/data/mysql_undo innodb_undo_logs=128 innodb_undo_tablespaces=4 innodb_undo_log_truncate=1 innodb_max_undo_log_size=1G innodb_purge_rseg_truncate_frequency #***MyISAMparameters key_buffer_size=16M read_buffer_size=1M read_rnd_buffer_size=16M bulk_insert_buffer_size=1M ###***master-slavereplicationparameters server-id=1 #read-only=1 #replicate-wild-ignore-table=mysql.% ###***Multi-Threaded?Slave #slave-parallel-type=LOGICAL_CLOCK #slave-parallel-workers=16 #master_info_repository=TABLE #relay_log_info_repository=TABLE relay_log_recovery=ON #***Innodbstorageengineparameters innodb_buffer_pool_dump_at_shutdown=1 innodb_buffer_pool_load_at_startup=1 innodb_buffer_pool_size=16G innodb_data_file_path=ibdata1:10M:autoextend innodb_temp_data_file_path?=?ibtmp1:12M:autoextend:max:5G #innodb_file_io_threads=8 innodb_thread_concurrency=0 innodb_flush_log_at_trx_commit=2 innodb_log_buffer_size=16M innodb_log_file_size=2048M innodb_log_files_in_group=2 innodb_max_dirty_pages_pct=75 innodb_buffer_pool_dump_pct=50 innodb_lock_wait_timeout=50 innodb_file_per_table=on innodb_flush_neighbors=0 innodb_flush_method=O_DIRECT innodb_read_io_threads=16 innodb_write_io_threads=16 innodb_io_capacity?=?5000 #innodb_print_all_deadlocks?=?1 wait_timeout?=?14400 interactive_timeout?=?14400 [mysqldump] quick max_allowed_packet=128M ? [myisamchk] key_buffer=16M sort_buffer_size=16M read_buffer=8M write_buffer=8M ? [mysqld_safe] open-files-limit=28192 log-error=/data/mysql_log/error.log pid-file=/data/mysql_data/mysqld.pid EOF ##?Initialize?MySQL?configuration mysqld?--defaults-file=/etc/my.cnf?--user=mysql?\ --datadir=/data/mysql_data?--initialize-insecure ##?Start?mysql systemctl?restart?mysqld?&&?systemctl?enable?mysqld ##?Setting?root's?password?for?mysql ############################################## read?-s?-p?"Enter?password?:?"?password mysql?-e?"ALTER?USER?'root'@'localhost'?IDENTIFIED?BY?'"$password"';" mysql?-uroot?-p"$password"?-Dmysql?-e?"select?user,host,authentication_string,password_expired?from?user;" mysql?-uroot?-p"$password"?-e?"flush?privileges;" echo?Your?password?is?"$password"
文章標(biāo)題:HowtoinstallMySQL5.7onCentOS7.3
鏈接分享:http://chinadenli.net/article42/poopec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、網(wǎng)站建設(shè)、網(wǎng)站收錄、品牌網(wǎng)站建設(shè)、網(wǎng)站排名、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)