MYSQL数据库多实例配置步骤详解
2019/10/10/17:32:28 阅读:1963 来源:谷歌SEO算法 标签:
夫唯SEO视频教程
多实例是一个比较有单的东西了,小编今天来为各位介绍mysql单多实例的配置方法,希望下文可以帮助到各位朋友.
- [root@Mysql~]#yuminstallvimgccgcc-c++wgettreelsofncurses-develcmakelibaio*-y#依赖库
- [root@Mysql~]#/usr/sbin/useraddmysql-s/sbin/nologin-M#mysql用户
- [root@Mysql~]#cd/byrd/tools/
- [root@Mysqltools]#wgethttp://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.37.tar.gz
- [root@Mysqltools]#tarzxfmysql-5.5.37.tar.gz
- [root@Mysqltools]#cdmysql-5.5.37/
- [root@Mysqlmysql-5.5.37]#cmake.-DCMAKE_INSTALL_PREFIX=/byrd/server/mysql-5.5.37-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DENABLED_LOCAL_INFILE=ON-DWITH_READLINE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1
- [root@Mysqlmysql-5.5.37]#make&&makeinstall
- [root@Mysqlmysql-5.5.37]#ln-s/byrd/server/mysql-5.5.37//usr/local/mysql
- [root@Mysql~]#cd/usr/local/mysql/
- [root@Mysql~]#mkdir-p/data/{3306,3307}/data
- [root@Mysql~]#chown-Rmysql.mysql/data
- [root@Mysqlmysql-5.5.37]#/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/--datadir=/data/3306/data/--user=mysql
- [root@Mysqlmysql-5.5.37]#ll/data/3306/data/
- total12
- drwx------.2mysqlroot4096Jun1522:09mysql
- drwx------.2mysqlmysql4096Jun1522:36performance_schema
- drwx------.2mysqlroot4096Jun1522:09test
- [root@Mysqlmysql]#/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/--datadir=/data/3307/data/--user=mysql
- [root@Mysqlmysql-5.5.37]#ll/data/3307/data/
- total12
- drwx------.2mysqlroot4096Jun1522:37mysql
- drwx------.2mysqlmysql4096Jun1522:37performance_schema
- drwx------.2mysqlroot4096Jun1522:37test
- [root@Mysqlmysql-5.5.37]#cp/byrd/tools/mysql-5.5.37/support-files/my-medium.cnf/data/3307/my.cnf
- [root@Mysqlmysql-5.5.37]#cp/byrd/tools/mysql-5.5.37/support-files/my-medium.cnf/data/3306/my.cnf
- [root@Mysqlmysql-5.5.37]#sed-i's#/tmp/mysql.sock#/data/3306/mysql.sock#g'/data/3306/my.cnf
- [root@Mysqlmysql-5.5.37]#sed-i's#3306#3307#g'/data/3307/my.cnf
- [root@Mysqlmysql-5.5.37]#sed-i's#=1#=2#g'/data/3307/my.cnf
- [root@Mysql~]#cat>>/data/3306/my.cnf<<BYRD
- >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
- >log-error=/data/3306/mysql_3306.err
- >BYRD
- [root@Mysql~]#cat>>/data/3307/my.cnf<<BYRD
- >[mysqld_safe]
- >pid-file=/data/3307/mysql.pid
- >log-bin=/data/3307/mysql-bin
- >relay-log=/data/3307/relay-bin
- >relay-log-info-file=/data/3307/relay-log.info
- >log-error=/data/3307/mysql_3307.err
- >BYRD
- [root@Mysqlmysql]#/usr/local/mysql/bin/mysqld_safe--defaults-file=/data/3306/my.cnf2>&1>/dev/null&--phpfensi.com
- [root@Mysqlmysql]#/usr/local/mysql/bin/mysqld_safe--defaults-file=/data/3307/my.cnf2>&1>/dev/null&
- [root@Mysql3307]#netstat-tunlp
- ActiveInternetconnections(onlyservers)
- ProtoRecv-QSend-QLocalAddressForeignAddressStatePID/Programname
- tcp00:::3307:::*LISTEN8046/mysqld
- tcp00:::3306:::*LISTEN4943/mysqld
- [root@Mysql3307]#
my.cnf配置文件内容:
- [client]
- port=3306
- socket=/data/3306/mysql.sock
- [mysql]
- no-auto-rehash
- [mysqld]
- user=mysql
- port=3306
- socket=/data/3306/mysql.sock
- basedir=/usr/local/mysql
- datadir=/data/3306/data
- open_files_limit=1024
- back_log=600
- max_connections=800
- max_connect_errors=3000
- 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
- thread_stack=192K
- tmp_table_size=2M
- max_heap_table_size=2M
- long_query_time=1
- 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
- read_rnd_buffer_size=1M
- bulk_insert_buffer_size=1M
- lower_case_table_names=1
- skip-name-resolve
- slave-skip-errors=1032,1062
- replicate-ignore-db=mysql
- server-id=1
- [mysqldump]
- quick
- max_allowed_packet=2M
- [mysqld_safe]
- log-error=/data/3306/mysql_oldboy3306.err
- pid-file=/data/3306/mysqld.pid
测试登陆:
- [root@Mysql3306]#/usr/local/mysql/bin/mysql-S/data/3306/mysql.sock
- mysql>createdatabased3306;
- QueryOK,1rowaffected(0.53sec)
- mysql>showdatabases;
- +--------------------+
- |Database|
- +--------------------+
- |information_schema|
- |d3306|
- |mysql|
- |performance_schema|
- |test|
- +--------------------+
- 5rowsinset(0.13sec)
- [root@Mysql3306]#/usr/local/mysql/bin/mysql-S/data/3306/mysql.sock
- mysql>showdatabases;
- +--------------------+
- |Database|
- +--------------------+
- |information_schema|
- |mysql|
- |performance_schema|
- |test|
- +--------------------+
- 4rowsinset(0.04sec)
热门评论