centos7 部署mysql-5.7.20
一、系统环境
系统:CentOS Linux release 7.5
mysqlb进制包:mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
1)依赖包安装
yum clean all
yum -y update
yum -y install gd libxml2-devel libjpeg-devel libpng-devel net-snmp-devel wget telnet vim zip unzip
yum -y install curl-devel libxslt-devel pcre-devel libjpeg libpng libcurl4-openssl-dev
yum -y install libcurl-devel libcurl freetype-config freetype freetype-devel unixODBC libxslt
yum -y install libtool openssl-devel
yum -y install perl-devel perl-ExtUtils-Embed
yum -y install ncurses-devel.x86_64 openldap-devel.x86_64 lrzsz openssh-clients gcc-g77 bison
yum -y install libmcrypt libmcrypt-devel mhash mhash-devel bzip2 bzip2-devel
yum -y install ntpdate rsync svn patch iptables iptables-services
yum -y install libevent libevent-devel cyrus-sasl cyrus-sasl-devel
yum -y install gd-devel libmemcached-devel memcached git libssl-devel libyaml-devel auto
yum -y install gcc gcc-c++ make autoconf automake ncurses-devel ncurses cmake libaio libaio-devel boost
2)关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0 3)修改系统内核参数
cat >> /etc/sysctl.conf <<EOF
fs.file-max=655360
fs.aio-max-nr = 1048576
kernel.sem = 5050 646400 5050 128
kernel.shmmax = 137438953472
kernel.shmall = 4294967296
kernel.shmmni = 4096
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_max_syn_backlog = 32768
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.accept_source_route = 0
vm.swappiness=1
EOF # 使其生效
sysctl -p
二、创建mysql目录
mkdir -pv /home/usr/local
三、解压文件并且需要改目录名
tar xf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql5.7
四、创建用户和用户组
groupadd mysql
useradd -r -g mysql mysql
五、创建mysql数据目录
mkdir -pv /home/usr/local/mysql5.7/{data,logs,tmp}
六、授权mysql目录权限
chown -R mysql:mysql mysql5.7
七、备份原始的my.cnf 配置文件
mv /etc/my.cnf /etc/my.cnf.bak 八、创建新的配置文件 cat > /etc/my.cnf <<EOF
[client]
port = 3306
socket = /home/usr/local/mysql5.7/tmp/mysql_3306.sock
[mysql]
#prompt="\u@\h:\p \R:\m:\s [\d]>"
#tee=/gomeo2o/data/mysql/mysql_3306/data/query.log
#prompt="\u@\h:\p \R:\m:\s [\d]>"
prompt = "[\u@\h][\d]>\_"
connect_timeout = 5
no-auto-rehash
[mysqld]
#misc
user = mysql
basedir = /home/usr/local/mysql5.7
datadir = /home/usr/local/mysql5.7/data
port = 3306
socket = /home/usr/local/mysql5.7/tmp/mysql_3306.sock
#timeout
interactive_timeout = 300
wait_timeout = 300
#character set
character-set-server = utf8
open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000
skip-name-resolve = 1
disable-partition-engine-check=1
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = /home/usr/local/mysql5.7/logs/mysql_3306_slow.log
log-error = /home/usr/local/mysql5.7/logs/mysql_3306_error.log
log_error_verbosity = 3
pid-file = mysql_3306.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1
#tmp
tmpdir=/home/usr/local/mysql5.7/tmp
event_scheduler = 1
performance_schema = on
max_allowed_packet = 32M
character_set_server = utf8mb4
#character_set_server = utf8
default-time-zone = system
default-storage-engine = InnoDB
#bind_address = 172.16.151.248
explicit_defaults_for_timestamp = 1
#binlog
binlog_format = row
server-id = 1813306
log-bin = /home/usr/local/mysql5.7/logs/mysql-bin
log-bin-index = /home/usr/local/mysql5.7/logs/mysql-bin.index
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 1
expire_logs_days = 90
#replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=test.%
replicate-wild-ignore-table=information_schema.%
#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062
explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M
#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
#innodb
innodb_buffer_pool_size = 10G
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 2000
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT
gtid_mode = ON
enforce_gtid_consistency = ON
master_info_repository = TABLE
relay-log-info-repository = TABLE
binlog_checksum = NONE
log_slave_updates = ON
binlog_row_image=FULL
plugin_dir = /home/usr/local/mysql5.7/lib/plugin #官方版本的路径
plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so" #官方版本的路径
loose_rpl_semi_sync_master_enabled = on
loose_rpl_semi_sync_master_wait_no_slave = on
loose_rpl_semi_sync_slave_enabled = on
loose_rpl_semi_sync_slave_trace_level = 32
loose_rpl_semi_sync_master_enabled = 1
loose_rpl_semi_sync_slave_enabled = 1
loose_rpl_semi_sync_master_timeout = 5000
loose_rpl_semi_sync_master_wait_for_slave_count=1
loose_rpl_semi_sync_master_wait_point=AFTER_SYNC
slave_preserve_commit_order = 1
slave_transaction_retries = 128
log_timestamps = system
show_compatibility_56 = on
slave_parallel_workers = 16
slave_parallel_type = LOGICAL_CLOCK
loose_innodb_numa_interleave = 1
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 16
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 2G
innodb_purge_rseg_truncate_frequency = 128
transaction_isolation = READ-COMMITTED
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,ONLY_FULL_GROUP_BY"
[mysqld_safe]
nice=-19
open-files-limit=65535
EOF
九、初始化数据库
/home/usr/local/mysql5.7/bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure
十、查看日志
tail -f /home/usr/local/mysql5.7/logs/mysql_3306_error.log
十一、启动数据库
/home/usr/local/mysql5.7/bin/mysqld_safe --defaults-file=/etc/my.cnf &
十二、查看数据进程
十三、登录数据库
十四、设置root密码
mysql>use mysql;
mysql>update mysql.user set authentication_string=password('123') where user='root' and host='localhost';
mysql>flush privileges;
十五、赋权限
mysql>use mysql;
mysql> GRANT ALL ON db_name.* TO root@'%' IDENTIFIED BY 'passwprd';
mysql> flush privileges;
centos7 部署mysql-5.7.20的更多相关文章
- 【Docker】 使用Docker 在阿里云 Centos7 部署 MySQL 和 Redis (二)
系列目录: [Docker] CentOS7 安装 Docker 及其使用方法 ( 一 ) [Docker] 使用Docker 在阿里云 Centos7 部署 MySQL 和 Redis (二) [D ...
- Centos7部署mysql
安装mysql yum install mysql mysql-server 会出现以下错误: [root@yl-web yl]# yum install mysql-server Loaded pl ...
- 在 CentOS7 上部署 MySQL 主从
在 CentOS7 上部署 MySQL 主从 通过 SecureCRT 连接至 MySQL 主服务器: 找到 my.cnf 文件所在的目录: mysql --help | grep my.cnf 一般 ...
- CentOS7.7下二进制部署MySQL多版本多实例实战
第一章 需求说明 部署MySQL5.7的三个多实例环境(端口分别为3307,3308,3309) 部署MySQL5.6和8.0版本数据库实例((端口分别为3316和3326) 第二章 环境准备 1.虚 ...
- Centos7借助docker部署mysql,提供远程链接服务
Centos7 借助docker部署mysql,并提供远程连接服务 安装docker 运行docker 注意安装docker和运行docker的步骤很简单,可以参考我学习docker的笔记 docke ...
- Centos7部署ejforum论坛(Java+tomcat+mysql)
前面搭建Java环境和tomcat环境. 下面进行实战,搭建ejforum论坛 ejforum论坛源码:https://www.lanzous.com/i45rcoh Centos7安装MySQL数据 ...
- keepalived-1.3.5+MHA部署mysql集群
MHA: MHA工作原理总结为以下几条: 从宕机崩溃的master保存二进制日志事件(binlog events): 识别含有最新更新的slave: 应用差异的中继日志(relay log)到其他sl ...
- 一键部署mysql 无修改直接cp 执行 100% 有效
一键部署mysql 无修改直接cp 执行 100% 有效 将安装包拖至/opt目录下,编一个脚本文件,然后source执行脚本,等脚本执行完成, 即可使用mysql -u root -p点击 ...
- centos7 部署 open-falcon 0.2.0
=============================================== 2019/4/29_第3次修改 ccb_warlock 更新 ...
- centos7 部署 docker、shipyard
=============================================== 2019/4/9_第3次修改 ccb_warlock 更新说 ...
随机推荐
- 使用TaskScheduler 调度器 实现跨线程的控件访问
//任务调度器 TaskScheduler UIscheduler = null; public Form1() { //获取任务调度器 UIscheduler = TaskScheduler.Fro ...
- 转: ASP.NET MVC 多语言配置
步骤1:打开VS2015新建测试项目. 步骤2:创建资源文件 App_GlobalResources下. Resource1.resx Resource1.zh-cn.resx 步骤3 ...
- fedora 开启 apache 并 开启目录浏览模式
在内网中 暂时需要一台 文件 服务器,所以准备安装一台 http服务器并开启目录访问权限.这次使用 apache 在 fedora 28 机器上: 因为 fedora 28 已经包含 httpd 软件 ...
- Django之url映射
url映射的作用 根据Django的MTV模式,url的映射是根据用户输入或传送而来的url路径,来进行区分去执行相应的view函数来响应用户的操作. url映射的方式 Django项目的创建后,会自 ...
- The 10 Best Neighborhoods in Seattle
https://www.seattlemet.com/articles/2015/4/24/the-10-best-neighborhoods-in-seattle-may-2015 By Darre ...
- Spring Boot 的 Security 安全控制
Spring Security 是一个强大且高度可定制的身份验证和访问控制框架,完全基于 Spring 的应用程序的标准,Spring Security 为基于 Java EE 的企业应用程序提供了一 ...
- Json.Net用法
基本用法 Json.Net是支持序列化和反序列化DataTable,DataSet,Entity Framework和Entity的.下面分别举例说明序列化和反序列化. DataTable: //序列 ...
- python第三十七课——模块
3.模块(m) 概念:在python中.py结尾的文件,我们就称为模块,可以将类.函数.属性...等内容定义在模块中 分类: 1).标准库模块:安装完python环境就有的模块,这些模块都是最常用的模 ...
- Invalid action class configuration that references an unknown class named [XX] .
多次遇到这个错误,难以解决,有时候出现,有时候没有,很神奇,今天发现了一点端倪,虽然说不上找到了所有导致这个bug的原因.至少,也是很主要的一种了. 其实,透过结果,如果debug用心,一行代码一行代 ...
- Shallwe学长的模拟赛
NOIP Simulated Test 这个名字一听就很高端. T1:sGCD:http://uoj.ac/problem/48 题意概述:给定一个长度为$n$的序列,求$sgcd(a_1,a_i)$ ...