1. 程式人生 > >[MySQL]-二進制版安裝-手冊版

[MySQL]-二進制版安裝-手冊版

定向 ora ted 是否 tmp pen spa 服務 sta

1.MySQL安裝方式選擇

  1.1 yum直接安裝

    安裝非常簡單,適合對MySQL沒有什麽要求時使用.

   正常基本不考慮yum安裝(開發本地裝個客戶端可以用),不能修改安裝路徑,導致一臺服務器上只能安裝一個MySQL,要安裝新的需要先卸載

  1.2 rpm包安裝

    可以選擇MySQL版本進行下載. 與yum基本類似,不同只在於自己去下rpm安裝包

    同yum

  1.2 二進制安裝(免編譯版)

    安裝簡單(相對源碼安裝而言,不用定向編譯),相當於源碼編譯出一個通用版,對MySQL系統有基本的控制力,至少可以同時存在多個MySQL版本

    性能不如源碼編譯,因為源碼編譯可以定制編譯參數,使得最後版本定向在某種環境或者某個操作系統而言有額外的運行效率提升.

  1.3 源碼安裝

    性能最高(統一的環境下),對MySQL系統幹預力度最大(甚至可以自行分解組件等)

    編輯參數配置復雜,編譯時間長,

  這裏選擇二進制安裝,yum,rpm基本不考慮.也達不到需要定制編譯來提高性能的程度

2.準備安裝包

  mysql-5.6.23-linux-glibc2.5-x86_64.tar

上傳到服務器

3.安裝

3.1安裝到這裏

  #mkdir /usr/local

  #mv /opt/software/mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz /usr/local/

  #cd /usr/local

3.2檢查是否存在

  #ps -ef|grep mysqld

  #rpm -qa |grep -i mysql

3.3解壓&&改名

  #tar xzvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz

  #mv mysql-5.6.23-linux-glibc2.5-x86_64 mysql

3.4創建用戶組

  #groupadd -g 101 dba

3.5創建管理員

#useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin

  如果mysqladmin 已經存在#usermod -u 514 -g dba -G root -d /usr/local/mysql mysqladmin #

  檢查一下 #id mysqladmin

  技術分享圖片

  設置管理員密碼#passwd mysqladmin

3.6 異步非阻塞接口組件

  #yum -y install libaio

3.7配置單獨環境變量

  #cp /etc/skel/.* /usr/local/mysql

  #vi /etc/my.cnf

  覆蓋以下內容

  

[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock

[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock

skip-external-locking
key_buffer_size = 256M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
query_cache_size= 32M
max_allowed_packet = 16M
myisam_sort_buffer_size=128M
tmp_table_size=32M

table_open_cache = 512
thread_cache_size = 8
wait_timeout = 86400
interactive_timeout = 86400
max_connections = 600

# Try number of CPU‘s*2 for thread_concurrency
thread_concurrency = 32

#isolation level and default engine
default-storage-engine = INNODB
transaction-isolation = READ-COMMITTED

server-id = 1
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/hostname.pid

#open performance schema
log-warnings
sysdate-is-now

binlog_format = MIXED
log_bin_trust_function_creators=1
log-error = /usr/local/mysql/data/hostname.err
log-bin=/usr/local/mysql/arch/mysql-bin
#other logs
#general_log =1
#general_log_file = /usr/local/mysql/data/general_log.err
#slow_query_log=1
#slow_query_log_file=/usr/local/mysql/data/slow_log.err

#for replication slave
#log-slave-updates
#sync_binlog = 1

#for innodb options
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:500M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/arch
innodb_log_files_in_group = 2
innodb_log_file_size = 200M

innodb_buffer_pool_size = 2048M
innodb_additional_mem_pool_size = 50M
innodb_log_buffer_size = 16M

innodb_lock_wait_timeout = 100
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 1
innodb_locks_unsafe_for_binlog=1

#innodb io features: add for mysql5.5.8
performance_schema
innodb_read_io_threads=4
innodb-write-io-threads=4
innodb-io-capacity=200
#purge threads change default(0) to 1 for purge
innodb_purge_threads=1
innodb_use_native_aio=on

#case-sensitive file names and separate tablespace
innodb_file_per_table = 1
lower_case_table_names=1

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[mysqlhotcopy]
interactive-timeout

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

3.8環境配置文件提權

  #chown mysqladmin:dba /etc/my.cnf

  #chmod 640 /etc/my.cnf

  檢查一下#ll /etc/my.cnf

  技術分享圖片

3.9變更獨立環境配置文件給MySQL管理員

  #chown -R mysqladmin:dba /usr/local/mysql

  #chmod -R 755 /usr/local/mysql

4.MySQL初始化

  4.1 切換到MySQL管理員賬戶

  #su - mysqladmin

  看看 #pwd

    #mkdir arch 

  4.2 初始化

  #scripts/mysql_install_db --user=mysqladmin --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

5.設置開機自啟動

  # cd /usr/local/mysql

  服務文件拷貝到init.d下,並重命名為mysql # cp support-files/mysql.server /etc/rc.d/init.d/mysql

  賦予可執行權限 # chmod +x /etc/rc.d/init.d/mysql

  刪除服務 # chkconfig --del mysql

  添加服務 # chkconfig --add mysql

  # chkconfig --level 345 mysql on

  

6.啟動MySQL

  還是切到MySQL管理員 # su - mysqladmin

  # rm -rf my.cnf

  # bin/mysqld_safe &

  技術分享圖片

  

[MySQL]-二進制版安裝-手冊版