Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching, Zero-Downtime Upgrade, GoldenGate

Oracle Exadata ,Oracle ODA, Oracle ZDLRA


当前位置: 首页 » 技术文章 » MySQL

MySQL配置文件my.cnf

我们有多种方式安装MySQL,通过YUM/rpm包,通过源码安装,或通过二进制文件安装,安装方式多样。MySQL的配置文件为my.cnf/my.ini,这个配置文件和Oracle数据库的初始化参数很像,她配置的好坏,决定这你系统的性能。下面附带了AliSQL小型、中型、大型MySQL的配置文件my.cnf,仅供参考。


通过YUM或rpm包安装

配置yum
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
安装MySQL
yum install mysql-community-server
Installing : mysql-community-common-5.7.16-1.el6.x86_64
Installing : mysql-community-libs-5.7.16-1.el6.x86_64  
Installing : mysql-community-client-5.7.16-1.el6.x86_64
Installing : mysql-community-server-5.7.16-1.el6.x86_64

启动MySQL
service mysqld start     #Linux7以下
systemctl start mysqld   #Linux7以上
service mysqld status
mysqld (pid 3066) is running.

获取root临时密码
grep 'temporary password' /var/log/mysqld.log

通过源码安装或二进制文件安装
这两种方式的区别是:
通过源码安装需要编译,我们可以根据自己的需要,配置安装选项,然后再编译。
通过二进制的方式安装,这些文件是已经编译好的,我们无需再编译。
这两者后续步骤操作一样
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chmod 750 mysql-files
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql    # Before MySQL 5.7.6
shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
shell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up
shell> chown -R root .
shell> chown -R mysql data mysql-files
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
通过源码安装更多选项可以参考下面的链接
https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html

通过Docker安装
docker run --name my-container-name -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql/mysql-server:tag
my-container-name是指你指定的容器的名字
my-secret-pw是指为root设置的密码
tag是指你想要安装的版本
这种方式应该算是最简单的了,更多细节请参考
https://hub.docker.com/r/mysql/mysql-server/

MySQL的配置文件my.cnf/my.ini
这个是默认的my.cnf [root@mysql ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@mysql ~]#


AliSQL my.cf配置文件

AliSQL-8C-16G.cnf
AliSQL-large.cnf
AliSQL-middle.cnf
AliSQL-small.cnf

他们之间的区别在于连接数的配置,内存分配的大小,Innodb的设置等,详情请参考https://github.com/alibaba/AliSQL/wiki


Reference

https://dev.mysql.com/doc/refman/5.7/en/installing.html

https://github.com/alibaba/AliSQL/wiki



关键词:docker mysql 

相关文章

OGG from MySQL to Oracle
MySQL数据库高可用实践
Terraform,docker,wercker,k8s
Install oracle products on docker
MySQL Cookbook for Oracle DBA
MySQL HA - Innodb Cluster
腾讯微信的PhxSQL数据库
MySQL Group Replication(MGR)
MySQL and Oracle Enterprise Manager
MySQL Tools for performance, backup, monitor
MySQL Multi-Master Single-Slave Replication
MySQL and GPL
Top