mysql 5.6.25.tar.gz_msyql5.6双mysql安装以及简单优化

注意事项:

只要做到以下4点,2个mysql就可以同时安装到一台机器ps:可以举一反三,一台机器只要你的负载够的话,想安装几个都可以。下面以2个为例:

我的测试服务器配置为2个6核cpu 48g内存 4t硬盘,安装主从测试之后10w的并发基本是上限。

2个mysql安装到一台服务器

1.socket文件不同

2.data文件不同

3.配置文件不同

4.mysql端口不同

安装步骤:

第一个mysql5.6正常安装:

groupadd mysql

useradd -s /sbin/nologin -M -g mysql mysql

tar -zxvf mysql-5.6.25.tar.gz

cd mysql-5.6.25

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1

cp support-files/my-default.cnf /etc/my.cnf

vi /etc/my.cnf

#加入优化的mysql配置:

###查看mysql innodb 5.5版本 show engine innodb status\G;

###注意:innodb 一定要在初始化之前加入配置文件

###5.6版本需要去掉#log_slow_queries=/usr/local/mysql/slow-log.log

###需要chmod 777 /tmp

[client]

#password = your_password

port  = 3306

socket  = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port  = 3306

socket  = /tmp/mysql.sock

skip-external-locking

max_allowed_packet = 32M

table_open_cache = 2048

net_buffer_length = 1M

character-set-server = utf8

skip-name-resolve

ft_min_word_len = 4

####  performance  ####

open_files_limit = 10240

max_connections = 800

max_connect_errors = 6000

thread_stack = 192K

transaction_isolation = REPEATABLE-READ

tmp_table_size = 256M

max_heap_table_size = 256M

slow_query_log

long_query_time = 1

#log_slow_queries=/usr/local/mysql/slow-log.log

net_buffer_length = 1M

#### log ####

log-error=/usr/local/mysql/mysqld.err

back_log = 500

max_binlog_cache_size = 8M

max_binlog_size = 512M

binlog_format=mixed

expire_logs_days = 7

####  buffer && cache  ####

read_buffer_size = 10M

read_rnd_buffer_size = 32M

sort_buffer_size = 2M

join_buffer_size = 2M

thread_cache_size = 300

thread_concurrency = 8

query_cache_size = 64M

query_cache_limit = 4M

binlog_cache_size = 4M

key_buffer_size = 32M

bulk_insert_buffer_size = 64M

####  myisam  ####

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover

log-bin=mysql-bin

server-id = 1

innodb_data_home_dir = /usr/local/mysql/data

innodb_data_file_path = ibdata1:10M:autoextend

innodb_log_group_home_dir = /usr/local/mysql/data

innodb_buffer_pool_size = 1G

innodb_additional_mem_pool_size = 16M

innodb_log_file_size = 150M

innodb_log_buffer_size = 16M

innodb_flush_log_at_trx_commit =2

innodb_lock_wait_timeout = 60

innodb_flush_method = O_DIRECT

innodb_open_files  =   800

innodb_file_per_table=1

innodb_file_io_threads=4

[mysqldump]

quick

max_allowed_packet = 32M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 32M

sort_buffer_size = 32M

read_buffer = 8M

write_buffer = 8M

[mysqlhotcopy]

interactive-timeout

[mysqld_safe]

open-files-limit = 8196

#修改目录权限:

cd /usr/local/mysql/

chown -R mysql .

chgrp -R mysql .

初始化mysql:

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --defaults-file=/etc/my.cnf

启动mysql:

/usr/local/mysql/bin/mysqld_safe  --defaults-file=/etc/my.cnf --user=mysql&

登录:

/usr/local/mysql/bin/mysql -u root -p

/usr/local/mysql/bin/mysqladmin -u root -p shutdown

/usr/local/mysql/bin/mysqladmin --socket=/tmp/mysql1.sock -u root password  xxx 修改密码

授权远程连接:

grant all privileges on   *.* to root@"%" identified by 'xxx' with grant option;

flush privileges ;

第二个mysql:

#需要知道不同的配置文件,data文件和scoket文件名不同

tar -zxvf mysql-5.6.25.tar.gz

cd mysql-5.6.25

注意:

安装位置不能相同,这里指定为/usr/local/3307与前面的mysql区分开

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/3307 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1

make && make install

cp support-files/my-default.cnf /usr/local/3307/my.cnf

vi /usr/local/3307/my.cnf

#加入优化的mysql配置:

###查看mysql innodb 5.5版本 show engine innodb status\G;

###注意:innodb 一定要在初始化之前加入配置文件

###5.6版本需要去掉#log_slow_queries=/usr/local/mysql/slow-log.log

###需要chmod 777 /tmp

[client]

#password = your_password

port  = 3307  ##修改mysql的端口文件不要和以前那个重名

socket  = /tmp/mysql1.sock   ##修改mysql的socket文件不要和以前那个重名

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port  = 3307   ##修改mysql的端口文件不要和以前那个重名

socket  = /tmp/mysql1.sock  ##修改mysql的socket文件不要和以前那个重名

skip-external-locking

max_allowed_packet = 32M

table_open_cache = 2048

net_buffer_length = 1M

character-set-server = utf8

skip-name-resolve

ft_min_word_len = 4

####  performance  ####

open_files_limit = 10240

max_connections = 800

max_connect_errors = 6000

thread_stack = 192K

transaction_isolation = REPEATABLE-READ

tmp_table_size = 256M

max_heap_table_size = 256M

slow_query_log

long_query_time = 1

#log_slow_queries=/usr/local/mysql/slow-log.log

net_buffer_length = 1M

#### log ####

log-error=/usr/local/mysql/mysqld.err

back_log = 500

max_binlog_cache_size = 8M

max_binlog_size = 512M

binlog_format=mixed

expire_logs_days = 7

####  buffer && cache  ####

read_buffer_size = 10M

read_rnd_buffer_size = 32M

sort_buffer_size = 2M

join_buffer_size = 2M

thread_cache_size = 300

thread_concurrency = 8

query_cache_size = 64M

query_cache_limit = 4M

binlog_cache_size = 4M

key_buffer_size = 32M

bulk_insert_buffer_size = 64M

####  myisam  ####

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover

log-bin=mysql-bin

server-id = 1

innodb_data_home_dir = /usr/local/mysql/data

innodb_data_file_path = ibdata1:10M:autoextend

innodb_log_group_home_dir = /usr/local/mysql/data

innodb_buffer_pool_size = 1G

innodb_additional_mem_pool_size = 16M

innodb_log_file_size = 150M

innodb_log_buffer_size = 16M

innodb_flush_log_at_trx_commit =2

innodb_lock_wait_timeout = 60

innodb_flush_method = O_DIRECT

innodb_open_files  =   800

innodb_file_per_table=1

innodb_file_io_threads=4

[mysqldump]

quick

max_allowed_packet = 32M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 32M

sort_buffer_size = 32M

read_buffer = 8M

write_buffer = 8M

[mysqlhotcopy]

interactive-timeout

[mysqld_safe]

open-files-limit = 8196

修改权限:

cd /usr/local/mysql/

chown -R mysql .

chgrp -R mysql .

初始化mysql:

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/3307 --datadir=/usr/local/3307/data --user=mysql --defaults-file=/usr/local/3307/my.cnf

vi /usr/local/3307/my.cnf

重新加入mysql优化文件内容,初始化之后配置文件被重置

制定配置文件启动mysql:

/usr/local/mysql/bin/mysqld_safe  --defaults-file=/usr/local/3307/my.cnf --user=mysql&

登录:

/usr/local/3307/bin/mysql --socket=/tmp/mysql1.sock (无密码)

/usr/local/3307/bin/mysqladmin --socket=/tmp/mysql1.sock -u root password xxxx(设置密码为xxxx)

/usr/local/3307/bin/mysql --socket=/tmp/mysql1.sock  -u root -p (有密码登录)

/usr/local/3307/bin/mysqladmin --socket=/tmp/mysql1.sock -u root shutdown -p(关闭)

/usr/local/3307/bin/mysqld_safe --defaults-file=/usr/local/3307/my.cnf --user=mysql&

/usr/local/mysql/bin/mysqladmin --socket=/tmp/mysql1.sock -u root password  xxx 修改密码

授权远程连接:

grant all privileges on   *.* to root@"%" identified by 'xxxxx' with grant option;

flush privileges ;

附件下载:

http://down.51cto.com/data/2149472

本文转自  674591788  51CTO博客,原文链接:http://blog.51cto.com/mrdeng/1735245

mysql-5.6.25.tar 包含两个文件: - mysql-5.6.25.tar.gz Generic Linux (Architecture Independent), Compressed TAR Archive MD5: 37664399c91021abe070faa700ecd0ed -install.txt: 安装方法 首先解压mysql-5.6.25.tar: $ tar xf mysql-5.6.25.tar ------------------ Mysql 源码安装操作: 1. 创建用户 # groupadd mysql # useradd -g -r mysql mysql 2. 解压缩tar包 # tar xf mysql-5.6.25.tar.gz # cd mysql-5.6.25 3. 编译安装 # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ > -DDEFAULT_CHARSET=gbk \ > -DDEFAULT_COLLATION=gbk_chinese_ci \ > -DENABLED_LOCAL_INFILE=ON \ > -DWITH_INNOBASE_STORAGE_ENGINE=1 \ > -DWITH_FEDERATED_STORAGE_ENGINE=1 \ > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ > -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \ > -DWITH_DEBUG=0 \ > -DMYSQL_TCP_PORT=3306 # make # make install 4. 配置以及初始化MySQL # cd /usr/local/mysql 4.1 设置MySQL安装目录的权限 # chown -R mysql:mysql /usr/local/mysql 4.2 初始化MySQL # scripts/mysql_install_db --user=mysql # cp support-files/mysql.server /etc/init.d/mysqld 4.3 重新设置MySQL安装目录的权限(除data目录外,其余所有目录及文件均修改用户为root,组不变) # chown -R root . # chown -R mysql data 4.4 启动mysql_safe # bin/mysqld_safe --user=mysql & 4.5 设置MySQL的root帐号密码 - 自动设置:# ./bin/mysql_secure_installation 或 - 手动置:# ./bin/mysqladmin -u root password '' ------------------ 操作详情参看: https://github.com/Marslo/MyBlog/blob/master/Programming/MySQL/MySQLInstallationBySourceCode.md MySQL6源码安装官方手册: http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html ------------------ 资源为英文,下载请谨慎
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值