mysql-5.5.32多实例配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql-5.5.32多实例配置相关的知识,希望对你有一定的参考价值。
一、安装依赖包
yum install ncurses-devel libaio-devel -y
二、下载cmake2.8.8和mysql.5.5.32
PS:我这里直接下载好了所以就用rz上传了
三、解压cmake-2.8.8.tar.gz
tar xf cmake-2.8.8..tar.gz
四、编译cmake
cd cmake-2.8.8
./configure
gmake && gmake install
五、解压mysql-5.5.32
tar xf mysql-5.5.32.tar.gz
六、创建mysql用户
useradd -s /sbin/nologin -M mysql
七、进入mysql-5.5.32目录并编译
cd /home/ljx/tools/mysql-5.5.32
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DEXTRA_CHARSETS=gbk.gb2312.utf8.ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
make && make install
八、复制my.cnf
cp /home/ljx/tools/mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
九、设置软链接
ln -s /application/mysql-5.5.32/ /application/mysql
十、配置环境变量并让其生效
echo ‘export PATH=/application/mysql/bin:$PATH‘>>/etc/profile
source /etc/profile
十一、授权
chown -R mysql.mysql /application/mysql/data/
chmod -R 1777 /tmp/
十二、创建mysql多实例的数据文件目录、
mkdir -p /data/{3306,3307}/data
十三、创建3306和3307的my.cnf文件
vi /data/3306/my.cnf
#############3306##############
#3307的话这里就不写了就是把3306替换成3307,server-id = 1换成server-id = 3就行了;
[client]
port =3306
socket =/data/3306/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user = mysql
port = 3306
socket = /data/3306/mysql.sock
basedir = /application/mysql
datadir = /data/3306/data
open_files_limit =1024
back_log = 600
max_connections = 800
max_connect_errors = 3000
table_cache = 614
max_allowed_packet =8M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 100M
thread_concurrency = 2
query_cache_size = 2M
query_cache_limit = 1M
query_cache_min_res_unit = 2k
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 2M
max_heap_table_size = 2M
long_query_time =1
log-error = /data/3306/error.log
log-slow-queries = /data/3306/slow.log
pid-file = /data/3306/mysql.pid
#log-bin = /data/3306/mysql.bin
relay-log = /data/3306/relay-bin
relay-log-info-file = /data/3306/relay-log.info
binlog_cache_size = 1M
max_binlog_cache_size = 1M
max_binlog_size = 2M
expire_logs_days = 7
key_buffer_size = 16M
read_buffer_size = 1M
bulk_insert_buffer_size = 1M
myisam_sort_buffer_size = 1M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
skip-name-resolve
slave-skip-errors = 1032,1062
replicate-ignore-db=mysql
server-id = 1
innodb_additional_mem_pool_size = 4M
innodb_buffer_pool_size = 32M
innodb_data_file_path = ibdatal:128M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 4M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
[mysqldump]
quick
max_allowed_packet = 2M
[mysqld_safe]
log-error=/data/3306/mysql_oldboy3306.err
pid-file=/data/3306/mysqld.pid
十四、授权data目录
chown -R mysql.mysql /data/
十五、初始化
Cd /application/mysql/scripts/
./mysql_install_db--basedir=/application/mysql --datadir=/data/3306/data --user=mysql
./mysql_install_db--basedir=/application/mysql --datadir=/data/3307/data --user=mysql
十六、启动实例3306、3307
mysqld_safe --defaults-file=/data/3306/my.cnf 2>&1 > /dev/null &
mysqld_safe --defaults-file=/data/3307/my.cnf 2>&1 > /dev/null &
十七、检查3306和3307端口是否启动
netstat -lntup|grep 330
十八、为两个实例增加帐号密码
mysqladmin -u root -S /data/3306/mysql.sock password ‘ljx1‘
mysqladmin -u root -S /data/3307/mysql.sock password ‘ljx2‘
十九、登陆实例
mysql -uroot -pljx1 -S /data/3306/mysql.sock
mysql -uroot -pljx1 -S /data/3306/mysql.sock
以上是关于mysql-5.5.32多实例配置的主要内容,如果未能解决你的问题,请参考以下文章