本次安装环境为: 系 统: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.18cmake -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 24make install #创建数据目录mkdir -p /data/mysql/engine/innolog mkdir -p /data/mysql/datamkdir -p /data/mysql/engine/innodatamkdir -p /data/mysql/engine/undomkdir -p /data/mysql/log/mysql-binlogmkdir -p /data/mysql/log/mysql-relaylogchown 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=mysqlbasedir = /u01/app/mysql/db datadir = /data/mysql/data pid-file = /data/mysql/mysql.pidsocket=/data/mysql/mysql.sock default-storage-engine = INNODBtransaction_isolation = REPEATABLE-READbinlog_cache_size = 32Mmax_binlog_size=512Mbinlog_format=rowcharacter-set-server = utf8port=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 = truelog-error = /data/mysql/mysql-error.logslow_query_loglong_query_time = 10log_warnings#——————basic——————————-##—————directroy——————————#innodb_log_group_home_dir=/data/mysql/engine/innologinnodb_data_home_dir=/data/mysql/engine/innodatainnodb_data_file_path = ibdata1:500M;ibdata2:150M:autoextendinnodb_undo_directory=/data/mysql/engine/undolog-bin = /data/mysql/log/mysql-binlog/mysql-binloglog-bin-index = /data/mysql/log/mysql-binlog/mysql-binlog.indexexpire-logs-days=5relay_log = /data/mysql/log/mysql-relaylog/mysql-relay-binrelay_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=1innodb_api_enable_binlog=1innodb_buffer_pool_size=256Minnodb_flush_log_at_trx_commit = 1innodb_log_buffer_size = 16Minnodb_log_file_size = 512Minnodb_log_files_in_group = 4innodb_max_dirty_pages_pct = 75innodb_lock_wait_timeout = 120innodb_buffer_pool_instances=2 innodb_force_recovery=0 #recoverinnodb_purge_threads=4 #undo purgeinnodb_write_io_threads = 16innodb_read_io_threads = 16innodb_io_capacity=1200innodb_old_blocks_pct=37innodb_old_blocks_time=1000innodb_undo_tablespaces=12innodb_undo_logs=40innodb_commit_concurrency = 1000 #commit/sinnodb_thread_concurrency = 1000 #use for cpu mutexinnodb_thread_sleep_delay = 200 #ms delay time #innodb_use_native_aio=1#—————-engine——————————–## ————global cache ————————-#read_buffer_size = 32Mread_rnd_buffer_size = 128Msort_buffer_size = 64Mjoin_buffer_size = 64Mquery_cache_size = 128Mquery_cache_limit = 4Mtmp_table_size = 128M# ————global cache ————————-##—————-replicat—————————–##read_only=1relay_log_purge=0log_slave_updates=1slave_parallel_workers=4log_bin_trust_function_creators=1binlog_checksum = CRC32slave_allow_batching = 1master_verify_checksum = 1slave_sql_verify_checksum = 1binlog_rows_query_log_events = 1gtid-mode=onenforce-gtid-consistency=1sync-master-info=1relay_log_purge = 1 #relaylog的自动修复relay_log_recovery = 1master_info_repository = TABLErelay_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 descriptorthread_stack = 256K # *thead_num thread_cache_size = 128 #reuse thread in mem#—————–thread——————————##—————-network—————————–#back_log = 512#skip-networking#skip-grant-tablesskip-name-resolvemax_connections = 3000max_connect_errors = 30table_open_cache = 4096max_allowed_packet = 64Mmax_heap_table_size = 512M#—————-network—————————–##———————–timeout————————#connect-timeout = 10wait-timeout = 8000interactive-timeout = 8000slave-net-timeout = 60net_read_timeout = 30net_write_timeout = 60net_retry_count = 10net_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.7chmod +x /etc/init.d/mysql.server-5.7chkconfig –addmysql.server-5.7#设置环境变量
vim ~/.bashrc#set mysqlNHOME=/u01/app/mysql/dbPATH=$PATH:$NHOME/binsource ~/.bashrcmysql 多实例可以写两个不同的配置文件与不同的端口 初始化库时候直接更改即可
这篇文章将为大家详细讲解有关什么是DBMS中的死锁,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。在数据库中,死锁是两个或多个线程永远被阻塞(挂起),无限期地等待彼此的的条件来完成,解锁数据资源的情况。在这种情况…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。