Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2900261
  • 博文数量: 793
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 11121
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(793)

文章存档

2018年(140)

2017年(75)

2016年(48)

2015年(48)

2014年(152)

2013年(49)

2012年(157)

2011年(93)

2010年(30)

分类: Mysql/postgreSQL

2017-06-01 14:57:57

1.解压缩并创建相应目录
[root@izwz9gxsbwybwg9n5xdi47z opt]# tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
[root@izwz9gxsbwybwg9n5xdi47z opt]# mv mysql-5.7.18-linux-glibc2.5-x86_64 mysql5718
[root@izwz9gxsbwybwg9n5xdi47z opt]# cd mysql5718
[root@izwz9gxsbwybwg9n5xdi47z mysql5718]# mkdir db1
[root@izwz9gxsbwybwg9n5xdi47z mysql5718]# mkdir db2

[root@izwz9gxsbwybwg9n5xdi47z mysql5718]# cd db1
[root@izwz9gxsbwybwg9n5xdi47z db1]# mkdir data
[root@izwz9gxsbwybwg9n5xdi47z db1]# mkdir conf
[root@izwz9gxsbwybwg9n5xdi47z db1]# mkdir redolog
[root@izwz9gxsbwybwg9n5xdi47z db1]# mkdir -p mysqllog/relaylog
[root@izwz9gxsbwybwg9n5xdi47z db1]# mkdir -p mysqllog/logfile
[root@izwz9gxsbwybwg9n5xdi47z db1]# mkdir -p mysqllog/binlog

[root@izwz9gxsbwybwg9n5xdi47z mysql5718]# cd db2
[root@izwz9gxsbwybwg9n5xdi47z db2]# mkdir data
[root@izwz9gxsbwybwg9n5xdi47z db2]# mkdir conf
[root@izwz9gxsbwybwg9n5xdi47z db2]# mkdir redolog
[root@izwz9gxsbwybwg9n5xdi47z db2]# mkdir -p mysqllog/relaylog
[root@izwz9gxsbwybwg9n5xdi47z db2]# mkdir -p mysqllog/logfile
[root@izwz9gxsbwybwg9n5xdi47z db2]# mkdir -p mysqllog/binlog

2.db1的参数文件
[root@izwz9gxsbwybwg9n5xdi47z conf]# more my.cnf
[mysqld]
port=3306
server-id=1
datadir=/opt/mysql5718/db1/data
character-set-server=utf8
max_connections = 1500
skip-external-locking
key_buffer_size=16M
max_allowed_packet=16M
myisam_sort_buffer_size=16M
query_cache_size=32M
read_buffer_size=2M
sort_buffer_size=2M
#table_cache=512
#thread_cache=20
#thread_concurrency=4
interactive_timeout=86400
wait_timeout=86400
#log_slow_queries=1
innodb_file_per_table=1
#innodb_additional_mem_pool_size=16M
innodb_buffer_pool_size=16M
innodb_flush_log_at_trx_commit=0
innodb_lock_wait_timeout=50
innodb_log_buffer_size=128M
innodb_log_file_size=128M
innodb_log_files_in_group=5
innodb_log_group_home_dir=/opt/mysql5718/db1/redolog
innodb_thread_concurrency=8
log_bin_trust_function_creators=1
event_scheduler=1
max_binlog_size=100M
log-bin=/opt/mysql5718/db1/mysqllog/binlog/binlog.bin
slow_query_log_file=/opt/mysql5718/db1/mysqllog/logfile/slow-query.log
long_query_time=1
log-error=/opt/mysql5718/db1/mysqllog/logfile/mysql-err.log
binlog_format=mixed
expire_logs_days=7
binlog_cache_size=4MB
skip-host-cache
#skip-name-resolve
#read-only
skip-slave-start
relay-log-index=/opt/mysql5718/db1/mysqllog/relaylog/slave-relay-bin.index
relay-log=/opt/mysql5718/db1/mysqllog/relaylog
replicate-ignore-db=information_schema,performance_schema
slave_net_timeout=60
log_slave_updates=1
##lower_case_table_names=1
language=/opt/mysql5718/share/english
early-plugin-load=""
explicit_defaults_for_timestamp=true

[client]
port = 3306
socket=/opt/mysql5718/db1/mysql.sock
default-character-set = utf8

[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

3.db2的参数文件
[root@izwz9gxsbwybwg9n5xdi47z conf]# more my.cnf
[mysqld]
port=3307
server-id=1
datadir=/opt/mysql5718/db2/data
socket=/opt/mysql5718/db2/mysql.sock
character-set-server=utf8
max_connections = 100
skip-external-locking
key_buffer_size=8M
max_allowed_packet=8M
myisam_sort_buffer_size=8M
query_cache_size=16M
read_buffer_size=2M
sort_buffer_size=2M
#table_cache=512
#thread_cache=20
#thread_concurrency=4
interactive_timeout=86400
wait_timeout=86400
#log_slow_queries=1
innodb_file_per_table=1
#innodb_additional_mem_pool_size=16M
innodb_buffer_pool_size=8M
innodb_flush_log_at_trx_commit=0
innodb_lock_wait_timeout=50
innodb_log_buffer_size=32M
innodb_log_file_size=128M
innodb_log_files_in_group=5
innodb_log_group_home_dir=/opt/mysql5718/db2/redolog
innodb_thread_concurrency=8
log_bin_trust_function_creators=1
event_scheduler=1
max_binlog_size=100M
log-bin=/opt/mysql5718/db2/mysqllog/binlog/binlog.bin
slow_query_log_file=/opt/mysql5718/db2/mysqllog/logfile/slow-query.log
long_query_time=1
log-error=/opt/mysql5718/db2/mysqllog/logfile/mysql-err.log
binlog_format=mixed
expire_logs_days=7
binlog_cache_size=4MB
skip-host-cache
#skip-name-resolve
#read-only
skip-slave-start
relay-log-index=/opt/mysql5718/db2/mysqllog/relaylog/slave-relay-bin.index
relay-log=/opt/mysql5718/db2/mysqllog/relaylog
replicate-ignore-db=information_schema,performance_schema
slave_net_timeout=60
log_slave_updates=1
##lower_case_table_names=1
language=/opt/mysql5718/share/english
early-plugin-load=""
explicit_defaults_for_timestamp=true

[client]
port = 3306
default-character-set = utf8

[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

4.修改文件权限
[root@izwz9gxsbwybwg9n5xdi47z opt]# chown -R mysql:mysql ./mysql5718

5.创建软连接
[root@host01 db]# mkdir -p /usr/local/mysql/bin
[root@host01 db]# ln -s /opt/mysql5718/bin/mysqld /usr/local/mysql/bin/mysqld

6.安装db1
./mysqld --initialize --user=mysql --basedir=/opt/mysql5718 --datadir=/opt/mysql5718/db1/data --lc_messages_dir=/opt/mysql5718/share --lc_messages=en_US

7.安装db2
./mysqld --initialize --user=mysql --basedir=/opt/mysql5718 --datadir=/opt/mysql5718/db2/data --lc_messages_dir=/opt/mysql5718/share --lc_messages=en_US

8.db1、db2安装ssl_rsa
[mysql@host01 bin]$ ./mysql_ssl_rsa_setup --user=mysql --basedir=/db/mysqlmha --datadir=/opt/mysql5718/db1/data
[mysql@host01 bin]$ ./mysql_ssl_rsa_setup --user=mysql --basedir=/db/mysqlmha --datadir=/opt/mysql5718/db2/data


9.启动db1和db2
(在mysql用户下执行)
启动db1
[mysql@host01 bin]$ ./mysqld_safe --defaults-file=/opt/mysql5718/db1/conf/my.cnf --user=mysql
启动db2
[mysql@host01 bin]$ ./mysqld_safe --defaults-file=/opt/mysql5718/db2/conf/my.cnf --user=mysql

启动db2的时候报如下错误,因为我机器内存比较小,无法分配内存导致的,调整db2的my.cnf参数再次启动。
2017-06-01T06:15:00.128396Z 0 [ERROR] InnoDB: Cannot allocate 268435992 bytes of memory after 60 retries over 60 seconds. OS error: 
Cannot allocate memory (12). Check if you should increase the swap file or ulimits of your operating system. Note that on most 32-bi
t computers the process memory space is limited to 2 GB or 4 GB.

key_buffer_size=16777216
read_buffer_size=2097152
max_used_connections=0
max_threads=1500
thread_count=0
connection_count=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 6180399 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

再次启动报如下错误:
2017-06-01T06:36:27.010905Z 0 [ERROR] Another process with pid 30006 is using unix socket file.
2017-06-01T06:36:27.010920Z 0 [ERROR] Unable to setup unix socket lock file.
2017-06-01T06:36:27.010932Z 0 [ERROR] Aborting
原因是db1和db2公用一个socket,默认是/tmp/mysql.sock,修改db2的参数文件在mysqld下指定另外一个socket,如下:

[mysqld]
port=3307
server-id=1
datadir=/opt/mysql5718/db2/data
socket=/opt/mysql5718/db2/mysql.sock

再次启动db2,成功启动,这样就完成了一个mysql同时部署多个实例.
阅读(253) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

hxl2018-02-07 08:43:01

kaizi1992:第6.安装db1 第7 安装db2 描述不够详细。不行

谢谢,我完善下。

回复 | 举报

kaizi19922018-02-06 16:57:41

第6.安装db1 第7 安装db2 描述不够详细。不行

评论热议
请登录后评论。

登录 注册