這個文檔用於基礎解釋,後面經過ansible的自動化對MySQL單實例進行安裝部署。mysql
# tar zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/local
# cd /usr/local # mv mysql-5.7.22-linux-glibc2.12-x86_64/ mysql/
# groupadd mysql # useradd -g mysql mysql
# vi /etc/security/limits.conf mysql soft nproc 65536 mysql hard nproc 65536 mysql soft nofile 65536 mysql hard nofile 65536
su - mysql ulimit -a
#cd /data/ #mkdir -p /data/mysqldata/{3306/{data,tmp,binlog,innodb_ts,innodb_log},backup,scripts} #chown -R mysql:mysql mysqldata
#su - mysql [client] port = 3306 socket = /data/mysqldata/3306/mysql.sock # The MySQL server [mysqld] port = 3306 user = mysql socket = /data/mysqldata/3306/mysql.sock pid-file = /data/mysqldata/3306/mysql.pid basedir = /usr/local/mysql datadir = /data/mysqldata/3306/data tmpdir = /data/mysqldata/3306/tmp open_files_limit = 60000 explicit_defaults_for_timestamp server-id = 1203306 lower_case_table_names = 1 character-set-server = utf8 federated #sql_mode=STRICT_TRANS_TABLES max_connections = 1000 max_connect_errors = 100000 interactive_timeout = 86400 wait_timeout = 86400 sync_binlog=0 back_log=100 default-storage-engine = InnoDB log_slave_updates = 1 #*********** buffer ********************** net_buffer_length = 8K sort_buffer_size = 2M join_buffer_size = 4M read_buffer_size = 2M read_rnd_buffer_size = 16M query_cache_size = 128M query_cache_limit = 2M query_cache_min_res_unit = 2k thread_cache_size = 300 table_open_cache = 1024 tmp_table_size = 256M #*********** Logs related settings *********** log-bin = /data/mysqldata/3306/binlog/mysql-bin binlog_format= mixed binlog_cache_size=32m max_binlog_cache_size=64m max_binlog_size=512m long_query_time = 1 log_output = FILE log-error = /data/mysqldata/3306/mysql-error.log slow_query_log = 1 slow_query_log_file = /data/mysqldata/3306/slow_statement.log #log_queries_not_using_indexes general_log = 0 general_log_file = /data/mysqldata/3306/general_statement.log expire-logs-days = 14 #binlog_expire_logs_seconds = 1728000 relay-log = /data/mysqldata/3306/binlog/relay-bin relay-log-index = /data/mysqldata/3306/binlog/relay-bin.index #****** MySQL Replication New Feature********* master-info-repository=TABLE relay-log-info-repository=TABLE relay-log-recovery #*********** INNODB Specific options *********** innodb_buffer_pool_size = 2048M transaction-isolation=READ-COMMITTED innodb_buffer_pool_instances = 4 innodb_file_per_table = 1 innodb_data_home_dir = /data/mysqldata/3306/innodb_ts innodb_data_file_path = ibdata1:2048M:autoextend innodb_temp_data_file_path = ibtmp1:2048M:autoextend innodb_thread_concurrency = 8 innodb_log_buffer_size = 16M innodb_log_file_size = 128M innodb_log_files_in_group = 3 innodb_log_group_home_dir = /data/mysqldata/3306/innodb_log innodb_flush_log_at_trx_commit = 2 innodb_max_dirty_pages_pct = 70 innodb_flush_method=O_DIRECT [mysql] no-auto-rehash default-character-set=gbk prompt = (\u@\h) [\d]>\_
$/usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --initialize-insecure --user=mysql
備註:
--initialize
生成一個隨機密碼
--initialize-insecure
不生成隨機密碼linux
$/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf --user=mysql &
[mysql@MHA-Manager ~]$ vi .bash_profile ...相關配置文件... PATH=$PATH:/usr/local/mysql/bin ...相關配置文件... [mysql@MHA-Manager ~]$ source .bash_profile [mysql@MHA-Manager ~]$ echo $PATH [mysql@MHA-Manager ~]$ mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.22-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. (root@localhost) [(none)]>