mysql5.7二进制包安装过程

MySQL5.7二进制文件安装

上传软件

cd /usr/local

rz mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz

 

解压缩

tar zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz

 

 

安装准备

按照如下步骤安装,root用户执行

shell> groupadd -g 500 mysql

shell> useradd -g mysql -md /home/mysql -s /bin/bash mysql

shell> passwd mysql

shell> cd /usr/local

shell> ln -s mysql-5.7*-linux-glibc2.5-x86_64 mysql

 

shell> chmod 775 -R mysql*

shell> chown -R mysql.mysql mysql*

 

shell> mkdir -p /mysqldata/mysql_data

shell> chmod 775 /mysqldata/mysql_data

shell> chown -R mysql.mysql /mysqldata

 

shell> mkdir -p /mysql_backup

shell> chmod 775 /mysql_backup

shell> chown -R mysql.mysql /mysql_backup

 

 

编辑参数文件

用root用户编辑 

vi /etc/my.cnf

 

[client]

user = root

password  = Lisx_new_123

socket=/tmp/mysql.sock

 

[mysqld]

federated

########basic settings########

character_set_server=utf8mb4

skip_name_resolve = 1

max_connections = 8000

max_connect_errors = 10000

transaction_isolation = READ-COMMITTED

explicit_defaults_for_timestamp = 1

join_buffer_size = 134217728

tmp_table_size = 67108864

tmpdir = /tmp

max_allowed_packet = 16777216

sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"

interactive_timeout = 7200

wait_timeout = 7200

read_buffer_size = 16777216

read_rnd_buffer_size = 33554432

sort_buffer_size = 33554432

lower_case_table_names = 1

 

########log settings########

log_error = error.log

slow_query_log = 1

slow_query_log_file = slow.log

log_queries_not_using_indexes = 1

log_slow_admin_statements = 1

log_slow_slave_statements = 1

log_throttle_queries_not_using_indexes = 10

expire_logs_days = 90

long_query_time = 2

min_examined_row_limit = 100

 

########replication settings########

master_info_repository = TABLE

relay_log_info_repository = TABLE

log_bin = mysql-bin

sync_binlog = 1

innodb_flush_log_at_trx_commit = 1

binlog_format = row 

relay_log = relay.log

relay_log_recovery = 1

binlog_gtid_simple_recovery = 1

slave_skip_errors = ddl_exist_errors

 

########innodb settings########

innodb_page_size = 8192

innodb_buffer_pool_size = 2G

innodb_buffer_pool_instances = 8

innodb_buffer_pool_load_at_startup = 1

innodb_buffer_pool_dump_at_shutdown = 1

innodb_lru_scan_depth = 2000

innodb_lock_wait_timeout = 5

innodb_io_capacity = 4000

innodb_io_capacity_max = 8000

innodb_flush_method = O_DIRECT

innodb_file_format = Barracuda

innodb_file_format_max = Barracuda

#innodb_log_group_home_dir = /mysqldata/mysql_data/

#innodb_undo_directory = /mysqldata/mysql_data/

innodb_undo_logs = 128

innodb_undo_tablespaces = 3

innodb_log_file_size = 8192M

innodb_log_buffer_size = 16777216

innodb_purge_threads = 1

innodb_large_prefix = 1

innodb_thread_concurrency = 64

innodb_print_all_deadlocks = 1

innodb_strict_mode = 1

innodb_sort_buffer_size = 67108864 

innodb_flush_neighbors = 0

 

########semi sync replication settings########

plugin_dir=/usr/local/mysql/lib/plugin

plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"

loose_rpl_semi_sync_master_enabled = 1

loose_rpl_semi_sync_slave_enabled = 1

loose_rpl_semi_sync_master_timeout = 5000

 

#GTID

log-slave-updates=true

#gtid-mode=on

#enforce-gtid-consistency=true

sync-master-info=1

slave-parallel-workers=4

binlog-checksum=CRC32

master-verify-checksum=1

slave-sql-verify-checksum=1

binlog-rows-query-log_events=1

#report-host=10.45.19.179

 

socket     = /tmp/mysql.sock

port       = 3306

pid-file   = /mysqldata/mysql_data/lt-mysql01.800best.com.pid

datadir    = /mysqldata/mysql_data

innodb_log_group_home_dir = /mysqldata/mysql_data/

innodb_undo_directory = /mysqldata/mysql_data/

server-id = 64

report-port=3306

 

[mysqld-5.7]

innodb_buffer_pool_dump_pct = 40

innodb_page_cleaners = 4

innodb_purge_threads = 4

innodb_undo_log_truncate = 1

innodb_max_undo_log_size = 2G

innodb_purge_rseg_truncate_frequency = 128

binlog_gtid_simple_recovery=1

log_timestamps=system

show_compatibility_56=on

 

初始化

Mysql5.7:

shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up

 

mysql5.6:

shell> scripts/mysql_install_db --user=mysql

 

 

开启ssl连接(可选)

shell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up

 

启动mysql

启动命令

shell> bin/mysqld_safe --user=mysql &

 

第一次登录要查看错误日志里面生成的临时密码

cd /mysqldata/mysql_data

less error.log

如下:

2015-11-26T19:51:17.665692+08:00 1 [Note] A temporary password is generated for root@localhost: rXtt<j%Gr4od

 

增加远程root用户

mysql> set password='root123';

Query OK, 0 rows affected (5.05 sec)

 

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root123' WITH GRANT OPTION;

Query OK, 0 rows affected, 1 warning (0.03 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.03 sec)

 

CREATE USER 'repl'@'%' IDENTIFIED BY 'slave123' ;

GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';

flush privileges;

 

配置启动服务(7以下需设置启动级别)

shell> cp support-files/mysql.server /etc/init.d/mysqld

添加mysql到服务开机启动 chkconfig --add mysqld

chkconfig --list|grep mysql

如果启动级别不对,则执行下面命令修改,否则忽略下面命令

chkconfig --level 2345 mysqld on

 

 centos 7以上设置开机启动

touch /usr/lib/systemd/system/mysql.service
 
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf(此处请对应修改为MySQL程序所在的路径)
LimitNOFILE = 5000
#Restart=on-failure
#RestartPreventExitStatus=1
#PrivateTmp=false


systemctl enable mysqld 设置开机启动

 

posted @ 2019-05-31 08:25  再过半世纪  阅读(849)  评论(0编辑  收藏  举报