CentOS下mysql資料庫data目錄遷移和配置最佳化

來源:互聯網
上載者:User

標籤:參數   大連   開啟   logs   buffer   最佳化   body   select   sse   

目錄遷移
  1. 關閉資料庫服務

    service mysqld stop
  2. 複製資料庫

    mv  /var/lib/mysql /data/mysql# 或者使用cp -a複製# 這兩個命令都會帶許可權到新目錄去
  3. 修改設定檔 /etc/my.cnf

    [mysqld]#datadir=/var/lib/mysql                      ------原系統預設路徑datadir=/data/mysql      ------現有路徑#socket=/var/lib/mysql/mysql.sock            ------原socket路徑現socket=/data/mysql/mysql.sock                ------現有路徑[mysqld_safe]socket=/data/mysql/mysql.sock                 -----現有路徑[client]socket=/data/mysql/mysql.sock                 -----現有路徑[mysql.server]socket=/data/mysql/mysql.sock                 -----現有路徑
  4. 重新啟動服務

    service mysqld start
  5. 遇到遷移目錄之後無法啟動的問題,有可能是selinux搞的鬼,可以設定成Permissive模式

    # getenforceEnforcing# setenforce 0# getenforcePermissive# setenforce 1 設定SELinux 成為enforcing模式# setenforce 0 設定SELinux 成為permissive模式

    或者之間關閉selinux,vi /etc/selinux/config 修改 SELINUX=disabled

    # This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#     enforcing - SELinux security policy is enforced.#     permissive - SELinux prints warnings instead of enforcing.#     disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these two values:#     targeted - Targeted processes are protected,#     mls - Multi Level Security protection.SELINUXTYPE=targeted
配置最佳化

yum安裝的mysql預設配置似乎是不能滿足要求的,主要修改以下配置

# 批量執行語句包的大小max_allowed_packet = 16M# innodb緩衝,設定為伺服器記憶體的 80%左右innodb_buffer_pool_size = 2048M# 鎖等待逾時時間innodb_lock_wait_timeout = 30# 0時表示關閉,1時表示開啟,2表示只要select 中明確指定SQL_CACHE才緩衝query_cache_type = 0# 最大串連數max_connections = 1024# 下面兩個參數一起設定innodb_flush_log_at_trx_commit = 2sync_binlog = 1000# 表不區分大小寫lower_case_table_names = 1

CentOS下mysql資料庫data目錄遷移和配置最佳化

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.