设为首页 收藏本站
查看: 639|回复: 0

[经验分享] MySQL版本介绍和安装---JC MySQL系列(二)

[复制链接]

尚未签到

发表于 2018-9-30 10:06:32 | 显示全部楼层 |阅读模式
  (一)MYSQL版本介绍:
  MySQL 4.1/5.0/5.1/5.5/5.6各版本的主要区别
  1.mysql-server-4.1
  增加了子查询的支持,字符集增加UTF-8,GROUP BY语句增加了ROLLUP,mysql.user表采用了更好的加密算法,innodb开始支持单独的表空间。
  2.mysql-server-5.0
  增加了Stored procedures、Views、Cursors、Triggers、XA transactions的支持,增加了INFORATION_SCHEMA系统数据库。
  3.mysql-server-5.1
  增加了Event scheduler,Partitioning,Pluggable storage engine API ,Row-based replication、Global级别动态修改general query log和slow query log的支持。
  小版本的重要特性:
  4.mysql-5.1.2 开始支持微秒级的慢查询。关于慢查询相关信息请参考 http://linuxguest.blog.51cto.com/195664/721042
  5.mysql-server-5.5
  1)默认存储引擎更改为InnoDB
  2)提高性能和可扩展性
  a. 提高了默认线程并发数(innodb_thread_concurrency)
  b. 后台输入/输出线程控制(innodb_read_io_threads、innodb_write_io_threads)
  c. 主线程输入/输出速率控制(innodb_io_capacity)
  d. 操作系统内存分配程序使用控制(innodb_use_sys_malloc)
  e. 适应性散列索引(Hash Index)控制,用户可以关闭适应性散列功能。
  f. 插入缓冲(Insert Buffering)控制,用户可以关闭innodb的插入缓冲功能。
  g. 通过快速加锁算法提高可扩展性,innodb不在使用代理(posix)线程,而是使用原生的独立操作来完成互斥和读写锁定。
  h. 恢复组提交(Restored Group Commit)
  i. 提高恢复性能
  j. 多缓冲池实例
  k. 多个回滚段(Multiple Rollback Segments),之前的innodb版本最大能处理1023个并发处理操作,现在mysql5.5可以处理高达128K的并发事物,
  l. Linux系统固有的异步输入/输出,mysql5.5数据库系统也提高了linux系统的输入输出请求的并发数。
  m. 扩展变化缓冲:添加了删除缓冲和清除缓冲
  n. 改善了日志系统互斥和单独刷新(Flush)列表互斥
  o. 改善清除程序进度,在mysql5.5中清楚操作线程是独立的线程,并支持并发,可以使用innodb_purge_treads配置。
  p. 改善事务处理中的元数据锁定。例如,事物中一个语句需要锁一个表,会在事物结束时释放这个表,而不是像以前在语句结束时释放表。
  3)提高实用性
  a. 半同步复制(Semi-synchronous Replication)
  b. 复制Heartbeat

  c. 中继日志自动恢复(Automatic>  d. 根据服务器过滤项复制(Replication Per Server Filtering)
  e. 从服务器复制支持的数据类型转换(Replication Slave Side Data Type Conversions)
  4)提高易管理性和效率
  a. 建立快速索引(Faster Index Creation)
  b. 高效的数据压缩(Efficient Data Compression)
  c. 为大物件和可变长度列提供高效存储
  d. 增加了INFORMATION_SCHEMA表,新的表提供了与InnoDB压缩和事务处理锁定有关的具体信息。
  5)提高可用性
  a. 针对SIGNAL/RESIGNAL的新SQL语法
  b. 新的表/索引分区选项。MySQL5.5将表和索引RANG和LIST分区范围扩展到了非整数列和日期,并增加了在多个列上分区的能力。
  6)改善检测和诊断
  Mysql5.5引入了一种新的性能架构(performancn_shema,P_S),用于监控mysql监控服务器运行时的性能。
  小版本的重要特性:
  percona-server-5.5.18.23支持group commit 参考:http://www.orczhou.com/index.php/2011/12/time-to-group-commit-2/
  mysql-server-5.6
  1)InnoDB现在可以限制大量表打开的时候内存占用过多的问题(比如这里提到的)(第三方已有补丁)
  2)InnoDB性能加强。如分拆kernel mutex;flush操作从主线程分离;多个perge线程;大内存优化等
  3)InnoDB死锁信息可以记录到 error 日志,方便分析
  4)MySQL5.6支持延时复制,可以让slave跟master之间控制一个时间间隔,方便特殊情况下的数据恢复。
  5)表分区功能增强
  6)MySQL行级复制功能加强,可以降低磁盘、内存、网络等资源开销(只记录能确定行记录的字段即可)
  7)Binlog实现 crash-safe
  8)复制事件采用crc32校验,增强master/slave 复制数据一致性
  9)新增 log_bin_basename (以前variables里面没有binlog位置信息,对数据库的监管很不方便)
  (二)安装MySQL
  备注:mysql安装有2种方式:
  1)编译安装
  2)yum安装
  #我这里采用的是编译安装MYSQL,系统环境是:
  [root@dba01 ~]# cat /etc/redhat-release

  CentOS>  [root@dba01 ~]# uname -i
  x86_64
  #这里采用Centos6.2 X86_64位操作系统.
  #先yum安装依赖:
  [root@dba01 ~]# yum -y install gcc* make libXp* gcc-c++ autoconf  bison  ncurses ncurses-devel openssl openssl-devel
  [root@dba01 ~]# [ ! -d /tools ] && mkdir -p /tools
  #什么是bison?
  BISON用于语法分析器的自动生成,实际上可用于所有常见的操作系统。Bison把LALR形式的上下文无关文法描述转换为可做语法分析的C或C++程序。
  [root@dba01 ~]# wget -P /tools/ -c http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz && echo "bison-2.5.tar.gz download is OK"
  [root@dba01 ~]# tar -zxvf /tools/bison-2.5.tar.gz -C /tools/
  [root@dba01 ~]# cd /tools/bison-2.5
  [root@dba01 bison-2.5]# ./configure && make && make install
  #什么是cmake?
  CMake是一个比make更高级的编译配置工具,它可以根据不同平台、不同的编译器,生成相应的Makefile或者vcproj项目.
  #安装Cmake
  [root@dba01 ~]# wget -P /tools/ -c http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz && echo "cmake-2.8.4.tar.gz download is OK"
  [root@dba01 bison-2.5]# tar -zxvf /tools/cmake-2.8.4.tar.gz -C /tools/
  [root@dba01 bison-2.5]# cd /tools/cmake-2.8.4
  [root@dba01 cmake-2.8.4]# ./configure && gmake && gmake install
  #安装MySQL5.5.19
  [root@dba01 cmake-2.8.4]# wget -P /tools/ -c http://down1.chinaunix.net/distfiles/mysql-5.5.19.tar.gz && echo "mysql-5.5.19.tar.gz download is OK"
  [root@dba01 cmake-2.8.4]# tar -zxvf /tools/mysql-5.5.19.tar.gz -C /tools/
  [root@dba01 cmake-2.8.4]# cd /tools/mysql-5.5.19
  [root@dba01 mysql-5.5.19]# groupadd mysql
  [root@dba01 mysql-5.5.19]# useradd -g mysql mysql
  [root@dba01 mysql-5.5.19]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STOPAGE_ENGINE=1 -DWITH_BLACKHOLE_STOPAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP-PORT=3306
  参数说明:
  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录
  -DMYSQL_DATADIR=/var/mysql/data数据库存放目录
  -DWITH_MYISAM_STORAGE_ENGINE=1 //安装myisam存储引擎
  -DWITH_INNOBASE_STORAGE_ENGINE=1 //安装innodb存储引擎
  -DWITH_ARCHIVE_STORAGE_ENGINE=1 //安装archive存储引擎
  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 //安装blackhole存储引擎
  -DENABLED_LOCAL_INFILE=1 //允许从本地导入数据
  -DDEFAULT_CHARSET=utf8   //使用utf8字符
  -DDEFAULT_COLLATION=utf8_general_ci //校验字符
  -DEXTRA_CHARSETS=all   //安装所有扩展字符集
  -DMYSQL_TCP_PORT=3306 //MySQL监听端口
  -DMYSQL_USER=mysql //MySQL用户名
  其他参数:
  -DWITH-EMBEDDED_SERVER=1 //编译成embedded MySQL library (libmysqld.a)
  -DSYSCONFDIR=/etc //MySQL配辑文件
  -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock //Unix socket 文件路径
  -DWITH_READLINE=1 //快捷键功能
  -DWITH_SSL=yes //SSL
  -DWITH_MEMORY_STORAGE_ENGINE=1 //安装memory存储引擎
  -DWITH_FEDERATED_STORAGE_ENGINE=1 //安装frderated存储引擎
  -DWITH_PARTITION_STORAGE_ENGINE=1 //安装数据库分区
  -DINSTALL_PLUGINDIR=/usr/local/mysql/plugin //插件文件及配置路径
  [root@dba01 mysql-5.5.19]# make && make install
  [root@dba01 mysql-5.5.19]# chmod +w /usr/local/mysql
  [root@dba01 mysql-5.5.19]# chown -R mysql:mysql /usr/local/mysql
  [root@dba01 mysql-5.5.19]# ln -s /usr/local/mysql/lib/libmysqlclient_r.so.18.0.0 /usr/
  [root@dba01 mysql-5.5.19]# mkdir -p /var/mysql/
  [root@dba01 mysql-5.5.19]# mkdir -p /var/mysql/data/
  [root@dba01 mysql-5.5.19]# mkdir -p /var/mysql/log/
  [root@dba01 mysql-5.5.19]# chown -R mysql:mysql /var/mysql/
  [root@dba01 mysql-5.5.19]# cd support-files/
  [root@dba01 support-files]# cp my-large.cnf /var/mysql/my.cnf
  [root@dba01 support-files]# cp mysql.server /etc/init.d/mysqld
  #初始化安装
  [root@dba01 support-files]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/var/mysql/my.cnf --basedir=/usr/local/mysql/ --datadir=/var/mysql/data/ --user=mysql
  [root@dba01 support-files]# chmod +x /etc/init.d/mysqld
  [root@dba01 support-files]# vim /etc/init.d/mysqld +46
  在 basedir=/usr/local/mysql  #(添加)mysql安装目录
  datadir=/var/mysql/data   #(添加)mysql数据存储目录
  #设置mysql开机启动
  [root@dba01 support-files]# chkconfig --add mysqld
  [root@dba01 support-files]# chkconfig --level 345 mysqld on
  #启动mysql服务进程
  [root@dba01 ~]# vim /var/mysql/my.cnf +28
  #注释skip-federated
  [root@dba01 support-files]# rm -f /etc/my.cnf
  [root@dba01 support-files]# /etc/init.d/mysqld restart
  [root@dba01 support-files]# ln -s /usr/local/mysql/bin/* /bin/
  [root@dba01 support-files]# cd
  [root@dba01 ~]# mysqladmin -uroot password '123456'                         #设置mysql初始密码
  [root@dba01 ~]# mysql -uroot -p
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.

  Your MySQL connection>  Server version: 5.5.19 Source distribution
  Copyright (c) 2000, 2011, 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.
  mysql> show engines;                     #InnoDB是MYSQL5.5系列默认的存储引擎.
  +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
  | Engine             | Support | Comment                                                    | Transactions | XA   | Savepoints |
  +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
  | MyISAM             | YES     | MyISAM storage engine                                      | NO           | NO   | NO         |
  | InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |

  | MRG_MYISAM         | YES     | Collection of>  | PERFORMANCE_SCHEMA | YES     | Performance Schema                                         | NO           | NO   | NO         |
  | CSV                | YES     | CSV storage engine                                         | NO           | NO   | NO         |
  | MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
  +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
  6 rows in set (0.00 sec)
  mysql> \q                                                                     #退出mysql数据库.
  Bye
  ######修改MYSQL密码#########
  [root@dba01 ~]# mysqladmin -uroot -p123456 password '23456'                   #把初始设置的密码123456更改为23456
  #####如果本地的mysql.sock(UNIX)套接字丢失,可以使用TCP协议进程登陆MYSQL数据库#####
  [root@dba01 ~]# mysql -uroot -p                                                #
  Enter password:
  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)  #错误提示不能通过/tmp/mysql.sock连接mysql server
  [root@dba01 ~]# netstat -lntp|grep mysqld                                                     #mysqld进程是存在和启动的,问题的引起是mysql.sock丢失了。
  tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      14940/mysqld
  #备注:从MySQL 4.1 开始,通过--protocol= TCP |SOCKET | PIPE | MEMORY}选项,你可以显示地指定连接协议.
  [root@dba01 ~]# mysql --protocol=TCP -uroot -p -P3306
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.

  Your MySQL connection>  Server version: 5.5.19 Source distribution
  Copyright (c) 2000, 2011, 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.
  mysql> show engines;
  +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
  | Engine             | Support | Comment                                                    | Transactions | XA   | Savepoints |
  +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
  | MyISAM             | YES     | MyISAM storage engine                                      | NO           | NO   | NO         |
  | InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |

  | MRG_MYISAM         | YES     | Collection of>  | PERFORMANCE_SCHEMA | YES     | Performance Schema                                         | NO           | NO   | NO         |
  | CSV                | YES     | CSV storage engine                                         | NO           | NO   | NO         |
  | MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
  +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
  6 rows in set (0.00 sec)
  mysql> \q
  Bye
  #查看MySQL的日志文件:日志文件一般是这样的格式:*.err.
  [root@dba01 ~]# cd /var/mysql/data/
  [root@dba01 data]# tail -f dba01.err
  130525  5:02:12 InnoDB: Mutexes and rw_locks use GCC atomic builtins
  130525  5:02:12 InnoDB: Compressed tables use zlib 1.2.3

  130525  5:02:12 InnoDB: Initializing buffer pool,>  130525  5:02:12 InnoDB: Completed initialization of buffer pool
  130525  5:02:12 InnoDB: highest supported file format is Barracuda.
  130525  5:02:12  InnoDB: Waiting for the background threads to start
  130525  5:02:13 InnoDB: 1.1.8 started; log sequence number 1595675
  130525  5:02:13 [Note] Event Scheduler: Loaded 0 events
  130525  5:02:13 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
  Version: '5.5.19'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
  #从以上的日志信息,我们可以得知Mysql的启动程序主配置文件在/usr/local/mysql/bin/mysqld下面。MySQL版本是:5.5.19,端口号是3306,并已启动,和默认的存储引擎是InnoDB等信息。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-606602-1-1.html 上篇帖子: Microsoft Azure部署MYSQL-MMM(1)安装MYSQL 下篇帖子: MySQL压测--注意事项和FAQ
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表