标签:ext src 服务器 nbsp sock inno dump flag quick
本次实验搭建的为一台服务器上安装四个mysql实例,实现两主两从的结构;然后两个主mysql承接mycat写的操作,两个从mysql承接mycat读的操作,实现读写分离。同时,使用mycat-web连接mycat,实现对mycat性能的监控。
首先查看java版本
mycat需要jdk1.7以上版本。
我用的mysql安装包为源码包,因为用免编译包可能会出现文件路径或权限各种没有的情况,做实验推荐用mysql5.5以前的版本,比较轻量,编译速度比较快,我用的5.1.73版本,先创建需要的路径:
mkdir -p /data/3316/etc /data/3316/var /data/3316/log mkdir -p /data/3317/etc /data/3317/var /data/3317/log mkdir -p /data/3318/etc /data/3318/var /data/3318/log mkdir -p /data/3319/etc /data/3319/var /data/3319/log mkdir -p /tmp/mysql
创建mysql用户
groupadd mysql useradd -r -g mysql mysql
chown -R mysql:mysql /data/3316
chown -R mysql:mysql /data/3317
chown -R mysql:mysql /data/3318
chown -R mysql:mysql /data/3319
chown -R mysql:mysql /tmp/mysql
编译配置:
cd /data #进入安装包路径
tar -xvf mysql-5.1.73.tar.gz
cd mysql-5.1.73 ./configure --prefix=/data/3316 --sysconfdir=/data/3316/etc --with-tcp-port=3316 --localstatedir=/data/3316/var --with-unix-socket-path=/tmp/mysql/3316.sock --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312,binary --enable-thread-safe-client --with-plugins=innobase --with-mysqld-user=mysql --with-charset=utf8 --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static
make && make install
然后初始化数据库,此步骤需在mysql_install_db文件的上层目录执行,不然会报错:
(scripts有的版本在解压包目录,有的在自己选的mysql安装目录)
scripts/mysql_install_db --user=mysql --basedir=/data/3316 --datadir=/data/3316/var --defaults-file=/data/3316/etc/my.cnf scripts/mysql_install_db --user=mysql --basedir=/data/3316 --datadir=/data/3317/var --defaults-file=/data/3317/etc/my.cnf scripts/mysql_install_db --user=mysql --basedir=/data/3316 --datadir=/data/3318/var --defaults-file=/data/3318/etc/my.cnf scripts/mysql_install_db --user=mysql --basedir=/data/3316 --datadir=/data/3319/var --defaults-file=/data/3319/etc/my.cnf
然后创建各个实例的配置文件:
touch /data/3316/etc/my.cnf touch /data/3317/etc/my.cnf touch /data/3318/etc/my.cnf touch /data/3319/etc/my.cnf
打开文件
vi /data/3316/etc/my.cnf
把下列配置项复制进去
[client] port = 3316 socket = /tmp/mysql/3316.sock [mysql] no-auto-rehash [mysqld] user = mysql port = 3316 socket = /tmp/mysql/3316.sock basedir = /data/3316 datadir = /data/3316/var open_files_limit = 1024 back_log = 600 max_connections = 800 max_connect_errors = 3000 table_open_cache = 614 external-locking = FALSE max_allowed_packet =8M sort_buffer_size = 1M join_buffer_size = 1M thread_cache_size = 100 thread_concurrency = 2 query_cache_size = 2M query_cache_limit = 1M query_cache_min_res_unit = 2k #default_table_type = InnoDB thread_stack = 192K #transaction_isolation = READ-COMMITTED tmp_table_size = 2M max_heap_table_size = 2M #long_query_time = 1 #log_long_format log-error = /data/3316/log/error.log log-slow-queries = /data/3316/log/slow.log pid-file = /tmp/mysql/3316.pid log-bin = /data/3316/var/mysql-bin #binlog-do-db = db1 #relay-log = /data/3316/log/relay-bin #relay-log-info-file = /data/3316/log/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 read_rnd_buffer_size = 1M bulk_insert_buffer_size = 1M lower_case_table_names = 1 skip-name-resolve binlog_format = mixed slave-skip-errors = 1032,1062 replicate-ignore-db=mysql server-id = 3316 innodb_additional_mem_pool_size = 4M innodb_buffer_pool_size = 32M innodb_data_file_path = ibdata1: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/3316/log/oldboy_3308.err pid-file=/tmp/mysql/3316.pid
同样,把/data/3317/etc/my.cnf /data/3318/etc/my.cnf /data/3319/etc/my.cnf 也都复制相同的内容,不过要把所有的3316换成对应的端口。
然后启动mysql:
标签:ext src 服务器 nbsp sock inno dump flag quick
原文地址:https://www.cnblogs.com/yingyingdeyueer/p/10553371.html