mysql5.6 centos编译部署
準備工作
創建用戶
useradd mysql
刪除老版本
rpm -qa |grep mysql
rep -e mysql包
重命名默認的mysql配置文件
mv /etc/my.cnf /etc/my.cnf.old
下載mysql
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.35.tar.gz
安裝依賴
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
安裝配置
解壓
tar -xf mysql-5.6.35.tar.gz
cd mysql-5.6.35
編譯安裝
cmake \ -DCMAKE_INSTALL_PREFIX=/home/heron/mysql-3306 \ -DMYSQL_DATADIR=/home/heron/mysql/data \ -DMYSQL_UNIX_ADDR=/home/heron/mysql-3306/mysql-3306.sock \ -DSYSCONFDIR=/home/heron/mysql-3306/etc \ -DDEFAULT_CHARSET=utf8 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DMYSQL_TCP_PORT=3306 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_cimake -j8 && make -j8 install配置啟動
cd /home/heron/mysql-3306/
mkdir logs etc tmp var
初始化
vim /home/heron/mysql-3306/etc/my.cnf
這個配置有關于復制相關的配置,不用復制的話,請忽略,需要從庫只需修改配置server-id并打開read
[client] port = 3309 socket = /home/xiaohe/mysql-3309/mysql.sock[mysql] prompt="\u@XH-TEST-01:3309>" no-auto-rehash [mysqld] user = nobody port = 3309 socket = /home/xiaohe/mysql-3309/mysql.sock basedir = /home/xiaohe/mysql-3309 datadir = /home/xiaohe/mysql-3309/data pid-file = /home/xiaohe/mysql-3309/mysql.pid log-error = /home/xiaohe/mysql-3309/logs/mysql.err tmpdir = /home/xiaohe/mysql-3309/tmp/ slave-load-tmpdir = /home/xiaohe/mysql-3309/tmp/ character-set-server = utf8mb4 skip_name_resolve = 1 open_files_limit = 65535 back_log = 1024 max_connections = 3000 max_connect_errors = 100000 table_open_cache = 2048 table_definition_cache = 2048 table_open_cache_instances = 64 thread_stack = 512K external-locking = FALSE max_allowed_packet = 32M sort_buffer_size = 16M join_buffer_size = 16M thread_cache_size = 300 query_cache_size = 0 query_cache_type = 0 tmp_table_size = 96M max_heap_table_size = 96M slow_query_log = 1 slow_query_log_file = /home/xiaohe/mysql-3309/logs/slow.log long_query_time = 0.1 server-id = 11 read-only #忽略記錄,建議不忽略 #binlog-ignore-db=mysql #binlog-ignore-db=information_schema #binlog-ignore-db=performance_schema #忽略復制,建議開啟 #replicate-ignore-db=mysql replicate-ignore-db=information_schema replicate-ignore-db=performance_schema #忽略表復制 #replicate-wild-ignore-table=mysql.% replicate-wild-ignore-table=information_schema.% replicate-wild-ignore-table=performance_schema.% log-bin = /home/xiaohe/mysql-3309/data/mysql-bin #允許的服務器 sync_binlog = 1 binlog_cache_size = 4M max_binlog_cache_size = 2G max_binlog_size = 1024M expire_logs_days = 7 master_info_repository = TABLE relay_log_info_repository = TABLE gtid_mode = on enforce_gtid_consistency = 1 log_slave_updates binlog_format = row relay_log_recovery = 1 relay-log-purge = 1 key_buffer_size = 32M read_buffer_size = 8M read_rnd_buffer_size = 16M bulk_insert_buffer_size = 64M myisam_sort_buffer_size = 128M myisam_repair_threads = 1 myisam_recover lock_wait_timeout = 300 explicit_defaults_for_timestamp = 1 metadata_locks_hash_instances = 64 innodb_thread_concurrency = 0 transaction_isolation = REPEATABLE-READ #innodb_additional_mem_pool_size = 16M innodb_buffer_pool_size = 5734M innodb_buffer_pool_instances = 8 innodb_buffer_pool_load_at_startup = 1 innodb_buffer_pool_dump_at_shutdown = 1 innodb_data_file_path = ibdata1:1024M:autoextend innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 32M innodb_log_file_size = 2G innodb_log_files_in_group = 2 innodb_data_home_dir = /home/xiaohe/mysql-3309/data/ innodb_log_group_home_dir = /home/xiaohe/mysql-3309/data/ # 根據您的服務器IOPS能力適當調整 # 一般配普通SSD盤的話,可以調整到 10000 - 20000 # 配置高端PCIe SSD卡的話,則可以調整的更高,比如 50000 - 80000 innodb_io_capacity = 4000 innodb_io_capacity_max = 8000 innodb_open_files = 384 innodb_max_dirty_pages_pct = 50 innodb_flush_method = O_DIRECT #innodb_file_format = Barracuda #innodb_file_format_max = Barracuda innodb_lock_wait_timeout = 10 innodb_rollback_on_timeout = 1 innodb_print_all_deadlocks = 1 innodb_file_per_table = 0 innodb_online_alter_log_max_size = 4G innodb_status_file = 1 #performance_schema performance_schema = 1 performance_schema_instrument = '%=on' #innodb monitor innodb_monitor_enable="module_innodb" innodb_monitor_enable="module_server" innodb_monitor_enable="module_dml" innodb_monitor_enable="module_ddl" innodb_monitor_enable="module_trx" innodb_monitor_enable="module_os" innodb_monitor_enable="module_purge" innodb_monitor_enable="module_log" innodb_monitor_enable="module_lock" innodb_monitor_enable="module_buffer" innodb_monitor_enable="module_index" innodb_monitor_enable="module_ibuf_system" innodb_monitor_enable="module_buffer_page" innodb_monitor_enable="module_adaptive_hash" [mysqldump] quick max_allowed_packet = 64M初始化
/home/heron/mysql-3306/scripts/mysql_install_db
/home/heron/mysql-3307/scripts/mysql_install_db
如果報錯
FATAL ERROR: please install the following Perl modules before executing /home/heron/mysql-3306/scripts/mysql_install_db:
安裝下面的包
yum install -y perl-Module-Install.noarch
啟動
/home/heron/mysql-3306/bin/mysqld_safe &
/home/heron/mysql-3307/bin/mysqld_safe &
建議使用supervisor管理
[program:mysql-3306] command= /home/heron/mysql-3306/bin/mysqld --defaults-file=/home/heron/mysql-3306/etc/my.cnf directory=/home/heron/mysql-3306 user=heron[program:mysql-3307] command= /home/heron/mysql-3307/bin/mysqld --defaults-file=/home/heron/mysql-3307/etc/my.cnf directory=/home/heron/mysql-3307 user=heron默認沒有密碼 設置root密碼
SET PASSWORD = PASSWORD('123456');
安裝告一段落
主從同步
創建同步賬號
登錄主庫
GRANT RELOAD, REPLICATION SLAVE, SUPER ON . TO 'slave'@'127.0.0.1' IDENTIFIED BY '123456';
flush privileges;
查看主庫狀態
root@localhost 19:25: [(none)]> show master status;
+------------------+----------+--------------+------------------+------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+------------------------------------------+
| mysql-bin.000004 | 1638 | | | c0d14e5b-f8e7-11e6-a9ed-001c42f6626e:1-7 |
+------------------+----------+--------------+------------------+------------------------------------------+
登錄從庫
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='slave', MASTER_PASSWORD='123456', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000004', MASTER_LOG_POS=1638, MASTER_CONNECT_RETRY=5, MASTER_HEARTBEAT_PERIOD=3;
開啟slave
start slave
查看slave
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
有這兩項就說明成功了。
至此 MySQL5.6的安裝、配置、啟動、主從就完成了。
轉載于:https://www.cnblogs.com/boy215/p/6992875.html
總結
以上是生活随笔為你收集整理的mysql5.6 centos编译部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python_day3作业
- 下一篇: q标签,短文本引用;blockquote