安裝mysql5.5

pathfinder_cui發表於2015-08-06

1.準備工作

      作業系統     : CentOS release 6.5

      mysql軟體   :  mysql-5.5.42.tar.gz

      cmake軟體  : cmake-2.8.5.tar.gz

     安裝必要的作業系統軟體包                 :yum install tree nmap sysstat lrzsz dos2unix ncurses-devel gcc* -y

     建立mysql資料庫的系統賬號               :useradd -M mysql

     建立mysql的安裝目錄和資料目錄        :mkdir  /mysql  /data

                                                                   chown mysql.mysql /data  

     建立臨時目錄和日誌目錄                     :mkdir /mysql/tmps  /mysql/logs 

                                                                   chown mysql.mysql /mysql/logs /mysql/tmps

                                                                   chmod  -R 775 /mysql

     配置環境變數 :

                                echo "export PATH=/mysql/bin:$PATH">>/root/.bash_profile

                                tail -1 /root/.bash_profile

                               source /root/.bash_profile

                                echo $PATH;

2.安裝

     1) 先安裝cmake

         tar xf cmake-2.8.5.tar.gz  &&  cd cmake-2.8.5

         ./configure  &&  make  &&  make install

      2)安裝mysql資料庫

         cd

         tar xf mysql-5.5.42.tar.gz

         cd mysql-5.5.42
cmake . \
-DCMAKE_INSTALL_PREFIX=/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data

         make && make install

3.配置

       初始化資料庫:

          cd /mysql/scripts/

          ./mysql_install_db --user=mysql --basedir=/mysql --datadir=/data

       將啟動指令碼放置在系統的啟動目錄:

         cd /mysql/support-files/

         cp -a  mysql.server  /etc/init.d/mysqld

      配置引數檔案

       vim /etc/my.cnf    #檔案中的內容如下

      [client]

      socket=/mysql/tmps/mysql.sock

      user=root

      [mysqld]

      datadir=/data

      socket=/mysql/tmps/mysql.sock

      user=mysql

      log-error=/mysql/logs/mysqld.err

      pid-file=/mysql/tmps/mysqld.pid

4.簡單操作

    啟動mysql:           /etc/init.d/mysqld start

    進入mysql:           mysql 

100. 記憶體72G的my.cnf配置
[client]
port = 3306
socket =/mysql/tmps/mysql.sock

[mysqld]
server-id=1
port=3306
user=mysql
basedir=/mysql
datadir=/data
tmpdir=/mysql/tmps
socket =/mysql/tmps/mysql.sock
pid-file=/mysql/tmps/mysqld.pid
skip-external-locking
skip-name-resolve
default-storage-engine=innodb
character-set-server=utf8
wait_timeout=100
connect_timeout=20
interactive_timeout=100
back_log=500
event_scheduler=on

####binlog
log-bin=/mysql/logs/mysql-bin
binlog_format=row
max_binlog_size=128M
binlog_cache_size=2M
expire-logs-days=5

####replication
slave-net-timeout=10
#rpl_semi_sync_master_enabled=1
#rpl_semi_sync_master_wait_no_slave=1
#rpl_semi_sync_master_timeout=1000
#rpl_semi_sync_slave_enabled=1
skip-slave-start
log_slave_updates=1
relay_log_recovery=1

####slow_log
slow_query_log=1
slow_query_log_file=/mysql/logs/mysql.slow
long_query_time=2

####error log
log-error=/mysql/logs/log.err

#####per_thread_buffer
max_connections=1024
max_user_connections=1000
max_connect_errors=10000
#key_buffer_size=64M
#max_allowed_packet=128M
table_open_cache=4096
table_definition_cache=4096
sort_buffer_size=512K
read_buffer_size=512K
read_rnd_buffer_size=512K
join_buffer_size=512K
#tmp_table_size=64M
#max_heap_table_size=64M
query_cache_type=0
query_cache_size=0
bulk_insert_buffer_size=32M
thread_cache_size=64
thread_stack=256K

####innodb
innodb_data_home_dir=/data
#innodb_log_group_home_dir=/mysql/logs
#innodb_data_file_path=ibdata1:2G:autoextend
#innodb_buffer_pool_size=50G
innodb_buffer_pool_instances=8
innodb_additional_mem_pool_size=16M
#innodb_log_file_size=1024M
innodb_log_buffer_size=64M
###innodb_log_file_in_group=3
innodb_flush_log_at_trx_commit=2
innodb_lock_wait_timeout=10
innodb_sync_spin_loops=40
innodb_max_dirty_pages_pct=90
innodb_support_xa=1
innodb_thread_concurrency=0
innodb_thread_sleep_delay=500
innodb_file_io_threads=4
innodb_concurrency_tickets=1000
log_bin_trust_function_creators=1
innodb_flush_method=O_DIRECT
innodb_file_per_table
innodb_read_io_threads=16
innodb_write_io_threads=16
innodb_io_capacity=2000
innodb_file_format=Barracuda
innodb_purge_threads=1
innodb_purge_batch_size=32
innodb_old_blocks_pct=75
innodb_change_buffering=all
transaction-isolation = READ-COMMITTED

[mysqldump]
quick

[mysql]
no-auto-rehash

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

[mysqlhotcopy]
interactive-timeout

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29620572/viewspace-1763687/,如需轉載,請註明出處,否則將追究法律責任。

相關文章