centos6.5 mysql5.6.24 单实例二进制包安装

线上部署考虑因素:
版本选择,5.1、5.5还是5.6?

5.1官方已不再维护,不建议
5.5是现在线上使用最多的版本
5.6最新的稳定版,已发布3年多,现在使用的也很多

分支选择,官方社区版?persona server ? Mariadb ?

官方版 推荐使用
persona server 管理性能上有改进,并且完全兼容mysql
Mariadb 是mysql原班人马开发的

安装方式,包安装?二进制包安装源码安装?

线上推荐使用二进制包安装

路径配置,参数配置(尽量模板化、标准化)

一个实例多个库或多个实例单个库?

如果只部署一个实例,因为mysql是单进程的,对多核的利用不充分,导致资源浪费
多实例的方式,是现在主流的线上部署方式

检查系统是否含有mysql相关组件

# rpm -qa |grep mysql
mysql-libs-5.1.71-1.el6.x86_64

移除相关组件

# yum remove mysql-libs*

下载mysql二进制包

# wget http://120.52.72.24/cdn.mysql.com/c3pr90ntc0td/archives/mysql-5.6/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz

安装依赖包

# yum install libaio

创建mysql用户、组

# groupadd mysql
# useradd -g mysql mysql

解压二进制包

# tar xzf mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
# pwd
/opt/mysql-5.6.24-linux-glibc2.5-x86_64

创建软连接

# pwd
/usr/local
# ln -s /opt/mysql-5.6.24-linux-glibc2.5-x86_64/ mysql

指定文件拥有者为mysql

# chown -R mysql:mysql /opt/mysql-5.6.24-linux-glibc2.5-x86_64
# chown -R mysql:mysql /usr/local/mysql

创建相关目录

配置文件目录
# mkdir -p /etc/mysql
# chown -R mysql:mysql /etc/mysql
数据文件目录
# mkdir -p /data1/db3306
临时文件目录
# mkdir -p /data1/tmp

# chown -R mysql:mysql /data1

设置环境变量(追加)

# vi /etc/profile
...
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
export C_INCLUDE_PATH=$MYSQL_HOME/include
export LIBDIR=/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/lib:$MYSQL_HOME/lib
export LD_RUN_PATH=/usr/local/lib

# source /etc/profile
# mysql --version
mysql  Ver 14.14 Distrib 5.6.24, for linux-glibc2.5 (x86_64) using  EditLine wrapper

编辑配置文件

# vi /etc/mysql/mysql3306.cnf
[mysqld]
# GENERAL #
user = mysql
port = 3306
socket = /data1/db3306/my3306.sock
pid_file = /data1/db3306/mysql.pid
datadir = /data1/db3306/
tmpdir = /data1/tmp
log_bin = /data1/db3306/3306-mysql-bin
relay-log = /data1/db3306/3306-relay-bin
log_error = /data1/db3306/error.log
slow_query_log_file = /data1/db3306/slow-queries.log
long_query_time=1
sync_binlog = 0
expire_logs_days = 7
back_log=1024
skip-name-resolve
skip-slave-start
skip-external-locking
skip-character-set-client-handshake
explicit_defaults_for_timestamp=true
default_storage_engine = InnoDB
bind-address=0.0.0.0
#lower_case_table_names  = 0
myisam_recover = FORCE,BACKUP
transaction-isolation = READ-COMMITTED
table_definition_cache = 4096
table_open_cache = 4096

# connection #
max_connections = 1100
max_user_connections = 1000
max_connect_errors = 1000

# timeout #
wait_timeout = 100
interactive_timeout = 100
lock_wait_timeout = 3
connect_timeout = 20
slave-net-timeout = 30

# character #
character-set-server=utf8
init-connect='SET NAMES utf8'

# disabled query cache #
query_cache_type = 0
query_cache_size = 0

# replication #
server_id=71493306
gtid_mode=ON
enforce-gtid-consistency
log-slave-updates
binlog-format=row
slave-parallel-workers=6
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync_master_info = 10000
slave_sql_verify_checksum=1
skip-slave-start

# session #
key_buffer_size = 128M
tmp_table_size = 32M
max_heap_table_size = 32M
max_allowed_packet = 32M
bulk_insert_buffer_size = 32M
sort_buffer_size = 128K
read_buffer_size = 1M
read_rnd_buffer_size = 1M
join_buffer_size = 128K
myisam_sort_buffer_size = 32M
tmp_table_size = 32M
max_heap_table_size = 64M
thread_cache_size = 64
#thread_concurrency = 32
thread_stack = 192K

# INNODB #
innodb_flush_method = O_DIRECT
innodb_data_home_dir = /data1/db3306/
innodb_data_file_path = ibdata1:10M:autoextend
#redo log
innodb_log_group_home_dir=/data1/db3306/
innodb_log_files_in_group = 3
innodb_log_file_size = 1G
#innodb performance
innodb_flush_log_at_trx_commit = 0
innodb_file_per_table = 1
innodb_buffer_pool_instances = 8
innodb_io_capacity = 2000
innodb_lock_wait_timeout = 30
binlog_error_action = ABORT_SERVER
innodb_buffer_pool_size = 256M
innodb_max_dirty_pages_pct=90
innodb_file_format=Barracuda
innodb_support_xa = 0
innodb_buffer_pool_dump_at_shutdown = 1
innodb_buffer_pool_load_at_startup = 1

初始化

# pwd
/usr/local/mysql/scripts
查看帮助(列出部分重要的参数)
# ./mysql_install_db -h
--basedir=path       The path to the MySQL installation directory.
--datadir=path       The path to the MySQL data directory.
                       If missing, the directory will be created, but its
                       parent directory must already exist and be writable.
--defaults-file=name Only read default options from the given file name.
--user=user_name     The login username to use for running mysqld.  Files
                       and directories created by mysqld will be owned by this
                       user.  You must be root to use this option.  By default
                       mysqld runs using your current login name and files and
                       directories that it creates will be owned by you.
看到两个ok
# ./mysql_install_db --defaults-file=/etc/mysql/mysql3306.cnf --basedir=/usr/local/mysql
Installing MySQL system tables...2016-07-19 07:36:49 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.24-log) starting as process 3499 ...
OK

Filling help tables...2016-07-19 07:37:09 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.24-log) starting as process 3521 ...
OK
...

启动mysql

# mysqld_safe --defaults-file=/etc/mysql/mysql3306.cnf &

# ps -ef |grep mysql
root       3551   2818  0 07:39 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/mysql/mysql3306.cnf
mysql      4604   3551  3 07:39 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/mysql/mysql3306.cnf --basedir=/usr/local/mysql --datadir=/data1/db3306/ --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data1/db3306/error.log --pid-file=/data1/db3306/mysql.pid --socket=/data1/db3306/my3306.sock --port=3306

账号安全设置

# mysql -uroot --socket=/data1/db3306/my3306.sock
mysql> select user,host,password from mysql.user;
+------+-----------+----------+
| user | host      | password |
+------+-----------+----------+
| root | localhost |          |
| root | miles     |          |
| root | 127.0.0.1 |          |
| root | ::1       |          |
|      | localhost |          |
|      | miles     |          |
+------+-----------+----------+
6 rows in set (0.01 sec)

mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.01 sec)

mysql> delete from mysql.user where host <>'localhost';
Query OK, 3 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;
+------+-----------+----------+
| user | host      | password |
+------+-----------+----------+
| root | localhost |          |
+------+-----------+----------+
1 row in set (0.00 sec)

mysql> set password for root@'localhost' = password('XXXXXX');
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 可以看到test数据库存在安全隐患,任何用户都可以在test进行操作
mysql> select * from mysql.db \G
*************************** 1. row ***************************
                 Host: %
                   Db: test
                 User:
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: Y
            Drop_priv: Y
           Grant_priv: N
      References_priv: Y
           Index_priv: Y
           Alter_priv: Y
Create_tmp_table_priv: Y
     Lock_tables_priv: Y
     Create_view_priv: Y
       Show_view_priv: Y
  Create_routine_priv: Y
   Alter_routine_priv: N
         Execute_priv: N
           Event_priv: Y
         Trigger_priv: Y
*************************** 2. row ***************************
                 Host: %
                   Db: test\_%
                 User:
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: Y
            Drop_priv: Y
           Grant_priv: N
      References_priv: Y
           Index_priv: Y
           Alter_priv: Y
Create_tmp_table_priv: Y
     Lock_tables_priv: Y
     Create_view_priv: Y
       Show_view_priv: Y
  Create_routine_priv: Y
   Alter_routine_priv: N
         Execute_priv: N
           Event_priv: Y
         Trigger_priv: Y
2 rows in set (0.00 sec)

mysql> delete from mysql.db;
Query OK, 2 rows affected (0.00 sec)

mysql> drop database test;
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
时间: 2024-10-31 14:10:21

centos6.5 mysql5.6.24 单实例二进制包安装的相关文章

《OpenStack实战指南》—— 2.1 在Ubuntu上使用二进制包安装

2.1 在Ubuntu上使用二进制包安装 笔者写本书的时候,OpenStack已经发展到Havana版本,几大主流的Linux发行版本都会将OpenStack的源代码做成各自平台的二进制安装包,以供用户使用.随着OpenStack使用的人越来越多,发行版本对Linux的支持力度也越来越大,就目前来看,Ubuntu(Debian).RedHat.OpenSUSE都有相应的包和开发定制的安装程序.当然,各个Linux平台上的包制作发布的时间各有快慢,同时支持的版本更新也有快有慢.Ubuntu是更新最

centos6.5 mysql5.6.24 单机多实例安装

单实例安装请参照该文档,本文在此基础上进行安装 多实例部署优势: 充分利用系统资源 mysql为单进程多线程的模型,它对多核的利用不是很好,无法充分利用系统资源.所以服务器上可以考虑多实例部署 资源隔离 如果不同的业务,部署在一个实例里,那么连接数.缓存等资源都是共享的.如果某个业务压力很大的话,很可能影响另一个业务的正常运行 业务.模块隔离 例如,A业务需要支持移动端,那么就需要升级数据库以支持utf8mb4字符集.而B业务则不需要.如果A.B是部署在一起的话,升级数据库必然会对B的业务造成影

单实例ASM无法创建磁盘组问题处理

问题现象:         在单实例数据库上安装好了Oracle GridInfrastructure 11gR2用于standby数据库创建ASM使用,但是在通过grid用户登录执行ASMCA命令后出来Create ASM GUI界面,简单配置后执行create ASM 的过程中报错:Oracle Grid Infrastructure is not configured properly.ASMCA needOracle Grid Infrastructure to configure AS

mysql-MySQL5.6.24的JDBC驱动包用哪个版本的能连接?

问题描述 MySQL5.6.24的JDBC驱动包用哪个版本的能连接? 这是两个版本的貌似都不行,每次重新导入我都重启tomcat 解决方案 http://download.csdn.net/detail/zzzzzqf/8269609 解决方案二: 5.1 就行了 可以支持的 解决方案三: 解决方案四: 用下载的mysql对应的版本啊 解决方案五: mysql-connector-java-5.1.5-bin.jar

MySQL 5.5升级5.6 单实例操作

 MySQL 5.5升级5.6 单实例 同类可参考: 环境:RHEL 6mysql旧版本:mysql-5.5.28mysql新版本:mysql-5.6.26安装方式:源码编译 不习惯用rpm包来安装mysql,所以此处仍然使用用源码安装编译mysql.若为rpm包安装,操作过程大体一致,当然路径和安装方法有出入. 因为是实验环境,首先安装mysql5.5.basedir : /home/sano1y/mysql5.5datadir : /home/sano1y/mysql5.5/datasock

Oracle中如何恢复rac db(raw)到单实例下

os:redhat as 4 oracle:oracle10gR2 客户提出了这样一个要求,演示一下rac db到单实例的恢复,他们的目的是检验生产环境的备份有效性 下面是思路和主要步骤: 1.先在rac db下生成一个init参数文件 2.修改参数,cluster_database为false以及屏蔽local_listener等和集群相关的参数 3.通过rman备份rac db(为了简单我使用了catalog) 4.拷贝参数文件和rac db备份到单实例机器上 5.在单实例机器上创建bdum

奕新集团--单实例到RAC节点 GG同步

Install and Configure Goldengate on RAC 10g 以前写过几篇关于OGG(Oracle GlodenGate)部署的文章,是关于单实例到单实例,具体内容可参考:Install and simple configure Oracle GoldenGateConfigure Oracle GoldenGate Active-to-Active 今天测试了一下从RAC 到 单实例的简单部署,做简要记录如下: 测试环境: source 端: 操作系统版本:rhel4

oracle单实例数据库转换为RAC数据库

测试目的: 单实例数据库转换为RAC数据库 测试环境:Oracle 11.2.0.4 测试方法:手工转换 . 首先,安装一套RAC环境,并把单实例数据库通过通过rman还原到这个环境(通常如果是生产环境,我们会搭建从RAC到单实例数据库的ADG,以减少停机时间). 然后生成一个源库(单实例数据库)spfile: startup pfile=/home/oracle/lunar/spfile.lunardb.tmp 08:07:25 sys@lunardb>show parameter spfil

单实例单向rac搭建gg流

1. m1 m2 m3  source端   2. 在m1 m2 m3 上   /etc/hosts 172.16.10.140     source   source上 添加 #public network 172.16.15.101 m1 172.16.15.102 m2 172.16.15.103 m3   #private network 10.11.11.1 m1-pri 10.11.11.2 m2-pri 10.11.11.3 m3-pri 29 #VIP network 172.1