mysql-boost-5.7.18安装方法

  本次安装环境为:

         系         统:centos 6  X86_X64  

         内         存:不低于4G

         mysql 版本:MysqL-boost-5.7.18.tar.gz

                               本文主要讲解在同主机上部署MysqL多实例

门户网站应用MysqL 多实例场景

       百度搜索引擎的数据库就是多实例,一般是从库,列如某个部门的例子,IBM 48核cpu。内存96G,跑3-4个实例;sina 网也是用的多实例,内存48G左右。门户网站使用多实例的目的是配硬件好的服务器,节省idc机柜的空间,同时,跑多实例让硬件资源不浪费,针对一般的服务器最多4个实例即可,1-2两个最合适。

        多实例可以是多个配置文件对应多实例也可以一个配置文件对应多个实例 

多实例缺点:

            1、耦合度太高,一个配置文件不好管理。工作开发和运维的统一原则;降低耦合度

          MysqL 相关软件包:    

             yum -y  install  ncurses-devel libaio-devel  cmake    

          安装需要MysqL 需要创建用户和组

             useradd MysqL -s /sbin/nologin -M

           下载MysqL 5.7 安装包

            wget https://cdn.MysqL.com//Downloads/MysqL-5.7/MysqL-boost-5.7.18.tar.gz

            解压安装包         

              tar -zxf MysqL-boost-5.7.18.tar.gz && cd MysqL-5.7.18

             

cmake   \

-DCMAKE_INSTALL_PREFIX=/u01/app/MysqL/db   \

-DSYSconfdIR=/u01/app/MysqL/db/etc   \

-DWITH_BOOST=./boost/boost_1_59_0 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNODB_MEMCACHED=1 \

-DWITH_READLINE=1   \

-DENABLED_LOCAL_INFILE=1   \

-DWITH_PARTITION_STORAGE_ENGINE=1   \

-DEXTRA_CHARSETS=all   \

-DDEFAULT_CHARSET=utf8   \

-DDEFAULT_COLLATION=utf8_general_ci  

make -j 24

make install

            #创建数据目录

            mkdir -p /data/MysqL/engine/innolog

            mkdir -p /data/MysqL/data

            mkdir -p /data/MysqL/engine/innodata

            mkdir -p /data/MysqL/engine/undo

            mkdir -p /data/MysqL/log/MysqL-binlog

            mkdir -p /data/MysqL/log/MysqL-relaylog

            chown MysqL. /data -R

            #创建MysqL 配置文件目录

            mkdir /u01/app/MysqL/db/etc

            配置my.cnf

[MysqLd]

#-------------------------------------basic_my.conf-------------------------------------------------------------

#5.7

#author: duxing

#modify: 20160902

#version: 0.8

#------------------basic-------------------------------#

user=MysqL

basedir = /u01/app/MysqL/db

datadir = /data/MysqL/data

pid-file = /data/MysqL/MysqL.pid

socket=/data/MysqL/MysqL.sock

default-storage-engine = INNODB

transaction_isolation = REPEATABLE-READ

binlog_cache_size = 32M

max_binlog_size=512M

binlog_format=row

character-set-server = utf8

port=3306

server-id= 2

#sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY'

explicit_defaults_for_timestamp = true

log-error = /data/MysqL/MysqL-error.log

slow_query_log

long_query_time = 10

log_warnings

#------------------basic-------------------------------#

#---------------directroy------------------------------#

innodb_log_group_home_dir=/data/MysqL/engine/innolog

innodb_data_home_dir=/data/MysqL/engine/innodata

innodb_data_file_path = ibdata1:500M;ibdata2:150M:autoextend

innodb_undo_directory=/data/MysqL/engine/undo

log-bin =  /data/MysqL/log/MysqL-binlog/MysqL-binlog

log-bin-index = /data/MysqL/log/MysqL-binlog/MysqL-binlog.index

expire-logs-days=5

relay_log =  /data/MysqL/log/MysqL-relaylog/MysqL-relay-bin

relay_log_index= /data/MysqL/log/MysqL-relaylog/MysqL-relay-bin.index

#relay_log_info_file=/data/MysqL/log/MysqL-relaylog/relay-log.info

#---------------directroy------------------------------#

#----------------engine--------------------------------#

innodb_file_per_table=1

innodb_api_enable_binlog=1

innodb_buffer_pool_size=256M

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 16M

innodb_log_file_size = 512M

innodb_log_files_in_group = 4

innodb_max_dirty_pages_pct = 75

innodb_lock_wait_timeout = 120

innodb_buffer_pool_instances=2

innodb_force_recovery=0 #recover

innodb_purge_threads=4 #undo purge

innodb_write_io_threads = 16

innodb_read_io_threads = 16

innodb_io_capacity=1200

innodb_old_blocks_pct=37

innodb_old_blocks_time=1000

innodb_undo_tablespaces=12

innodb_undo_logs=40

innodb_commit_concurrency = 1000 #commit/s

innodb_thread_concurrency = 1000  #use for cpu mutex

innodb_thread_sleep_delay = 200 #ms delay time

#innodb_use_native_aio=1

#----------------engine--------------------------------#

# ------------global cache -------------------------#

read_buffer_size = 32M

read_rnd_buffer_size = 128M

sort_buffer_size = 64M

join_buffer_size = 64M

query_cache_size = 128M

query_cache_limit = 4M

tmp_table_size = 128M

# ------------global cache -------------------------#

#----------------replicat-----------------------------#

#read_only=1

relay_log_purge=0

log_slave_updates=1

slave_parallel_workers=4

log_bin_trust_function_creators=1

binlog_checksum = CRC32

slave_allow_batching = 1

master_verify_checksum = 1

slave_sql_verify_checksum = 1

binlog_rows_query_log_events = 1

gtid-mode=on

enforce-gtid-consistency=1

sync-master-info=1

relay_log_purge = 1                   #relaylog的自动修复

relay_log_recovery = 1

master_info_repository = TABLE

relay_log_info_repository = TABLE

#set global rpl_semi_sync_master_enabled = 1

#set global rpl_semi_sync_slave_enabled =1

#rpl_semi_sync_master_timeout=200

#----------------replicat-----------------------------#

#-----------------thread------------------------------#

table_open_cache         = 2048   #reduce open descriptor

thread_stack             = 256K   # *thead_num < useable mem

thread_cache_size        = 128    #reuse thread in mem

#-----------------thread------------------------------#

#----------------network-----------------------------#

back_log                = 512

#skip-networking

#skip-grant-tables

skip-name-resolve

max_connections         = 3000

max_connect_errors      = 30

table_open_cache        = 4096

max_allowed_packet      = 64M

max_heap_table_size     = 512M

#----------------network-----------------------------#

#-----------------------timeout------------------------#

connect-timeout          = 10

wait-timeout             = 8000

interactive-timeout      = 8000

slave-net-timeout        = 60

net_read_timeout         = 30

net_write_timeout        = 60

net_retry_count          = 10

net_buffer_length        = 16384

#-----------------------timeout------------------------#

[MysqL]

auto-rehash

[client]

socket=/data/MysqL/MysqL.sock

port=3306

                删除 /etc/my.cnf

                /u01/app/MysqL/db/etc

                初始化之前需要查看error 日志

                cat /data/MysqL/MysqL-error.log

                cd /u01/app/MysqL/db

                ./bin/MysqLd --initialize --basedir=/u01/app/MysqL/db --datadir=/data/MysqL/data  --user=MysqL
                # --initialize-insecure option 使用这个初始化数据库之后不再需要登录后进行alter user

                #cat /data/MysqL/MysqL-error.log

                

                /u01/app/MysqL/db/bin/MysqLd_safe --skip-grant-tables &

                update MysqL.user set authentication_string=password('123.com') where user='root' and Host = 'localhost';

                #启动MysqL 服务

            /u01/app/MysqL/db/support-files/MysqL.server restart

                ##需要重新更改密码否则无法正常使用库

            alter user 'root'@'localhost' identified by '123.com';

            #设置开机自启动

            cp /u01/app/MysqL/db/support-files/MysqL.server /etc/init.d/MysqL.server-5.7

            chmod +x  /etc/init.d/MysqL.server-5.7

            chkconfig --addMysqL.server-5.7

            #设置环境变量

            vim ~/.bashrc

            #set MysqL

            NHOME=/u01/app/MysqL/db

            PATH=$PATH:$NHOME/bin

            source ~/.bashrc

MysqL 多实例可以写两个不同的配置文件与不同的端口 初始化库时候直接更改即可

    

相关文章

MySQL 死锁 是指两个或多个事务互相等待对方持有的锁,从而导...
在MySQL中,InnoDB引擎通过Next-Key Locking技术来解决幻读问...
在数据库事务管理中,Undo Log 和 Redo Log 是两种关键日志,...
case when概述 sql语句中的case语句与高级语言中的switch语句...
其实很简单,只是为了忘记,做个记录,用的时候方便。 不管是...
1.进入服务,找到mysql服务,在属性里找到mysql的安装路径 2...