MariaDB与MySQL在一台服务器同时运行
[root@HE3 ~]#groupadd mariadb -g 513
[root@HE3 ~]#useradd-u 513 -gmariadb
-s /sbin/nologin -d /home/mariadbmariadb
从MariaDB官网下载二进制安装包至/root目录,本文采用的是目前最新稳定版mariadb-10.1.16
[root@HE3 ~]# tarxvf mariadb-10.1.16-linux-x86_64.tar.gz
[root@HE3 ~]# mv/root/mariadb-10.1.16-linux-x86_64 /usr/local/mariadb
[root@HE3 ~]#mkdir -p/data/mariadb
[root@HE3 ~]#chown -Rmariadb. /data/mariadb
[root@HE3 ~]#mkdir -p/log/mariadb
[root@HE3 ~]#chown -Rmariadb. /log/mariadb
[root@HE3 ~]#vi /usr/local/mariadb/my.cnf
[client]
port = 3307
socket = /tmp/mariadb.sock
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld]
port = 3307
socket = /tmp/mariadb.sock
basedir = /usr/local/mariadb
datadir = /data/mariadb
open_files_limit = 3072
back_log = 103
max_connections = 800
max_connect_errors = 100000
table_open_cache = 512
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 51
query_cache_size = 32M
tmp_table_size = 96M
max_heap_table_size = 96M
slow_query_log = 1
slow_query_log_file = /log/mariadb/slow.log
log-error = /log/mariadb/error.log
long_query_time = 1
server-id = 2503307
log-bin = /log/mariadb/mysql-bin
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 8M
max_binlog_size = 1024M
expire_logs_days = 60
key_buffer_size = 32M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
character-set-server = utf8
default-storage-engine = InnoDB
binlog_format = row
innodb_buffer_pool_dump_at_shutdown = 1
innodb_buffer_pool_load_at_startup = 1
#binlog_rows_query_log_events = 1
explicit_defaults_for_timestamp = 1
transaction_isolation = REPEATABLE-READ
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 512M
#innodb_data_home_dir =
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_locks_unsafe_for_binlog = 0
wait_timeout = 14400
interactive_timeout = 14400
skip-name-resolve
[mysqldump]
quick
max_allowed_packet = 32M
初始化数据库
[root@HE3 ~]#/usr/local/mariadb/scripts/mysql_install_db--basedir=/usr/local/mariadb --datadir=/data/mariadb--defaults-file=/usr/local/mariadb/my.cnf
--user=mariadb
拷贝启停模板至/etc/init.d/下
[root@HE3 ~]#cp -rp /usr/local/mariadb/support-files/mysql.server /etc/init.d/mariadb
编辑该启停脚本变更第46、47、58行为mariadb相关目录,本文示例如下
[root@HE3 ~]#vi /etc/init.d/mariadb
46 basedir=/usr/local/mariadb
47 datadir=/data/mariadb
48
49 # Default value, in seconds, afterwhich the script should timeout waiting
50 # for server start.
51 # Value here is overriden by value in my.cnf.
52 # 0 means don't wait at all
53 # Negative numbers mean to wait indefinitely
54 service_startup_timeout=900
55
56 # Lock directory for RedHat / SuSE.
57 lockdir='/var/lock/subsys'
58 lock_file_path="$lockdir/mariadb"
第311行添加唯一参数路径,本文为--defaults-file=/usr/local/mariadb/my.cnf
311 $bindir/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" >/dev/null 2>&1 &
[root@HE3 ~]# ps -ef|grep mysql
root 28996 2226 0 16:50 pts/2 00:00:00 grep mysql
[root@HE3 ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@HE3 ~]# ps -ef|grep mysql
root 29008 1 0 16:51 pts/2 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/HE3.pid
mysql 29754 29008 13 16:51 pts/2 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/log/mysql/error.log --open-files-limit=3072 --pid-file=/data/mysql/HE3.pid --socket=/tmp/mysql.sock --port=3306
root 29778 2226 0 16:51 pts/2 00:00:00 grep mysql
[root@HE3 ~]# /usr/local/mysql/bin/mysql -uroot -p -P3306
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+------------+
| version() |
+------------+
| 5.6.25-log |
+------------+
1 row in set (0.01 sec)
mysql>
[root@HE3 ~]# /etc/init.d/mariadb start
Starting MySQL SUCCESS!
[root@HE3 ~]# ps -ef|grep mysql
root 29008 1 0 16:51 pts/2 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/HE3.pid
mysql 29754 29008 0 16:51 pts/2 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/log/mysql/error.log --open-files-limit=3072 --pid-file=/data/mysql/HE3.pid --socket=/tmp/mysql.sock --port=3306
root 29802 1 0 16:52 pts/2 00:00:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mariadb --pid-file=/data/mariadb/HE3.pid
mariadb 30041 29802 7 16:52 pts/2 00:00:00 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mariadb --plugin-dir=/usr/local/mariadb/lib/plugin --user=mariadb --log-error=/log/mariadb/error.log --open-files-limit=3072 --pid-file=/data/mariadb/HE3.pid --socket=/tmp/mariadb.sock --port=3307
root 30070 2226 0 16:52 pts/2 00:00:00 grep mysql
[root@HE3 ~]# /usr/local/mariadb/bin/mysql -uroot -p -P3307
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.25-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select version();
+-----------------+
| version() |
+-----------------+
| 10.1.16-MariaDB |
+-----------------+
1 row in set (0.00 sec)
也可以手动启停
启动命令
[root@HE3~]# /usr/local/mariadb/bin/mysqld_safe --defaults-file=/etc/mariadb.cnf--ledir=/usr/local/mariadb/bin --datadir=/data/mariadb&
停止命令
[root@HE3 ~]#/usr/local/mariadb/bin/mysqladmin --defaults-file=/usr/local/mariadb/my.cnf-hlocalhost -P3307 shutdown
本文出自 “岁伏” 博客,请务必保留此出处http://suifu.blog.51cto.com/9167728/1834417
MariaDB与MySQL在一台服务器同时运行的更多相关文章
- mysql在一台服务器搭建主从
注:本环境事先执行rm -rf /usr/local/mysql 以方便实验. 1. 主与从,类似于A机器和B机器的连接,通过bin_log和rpel_log 进行数据连接 2. 如图所示: 3. ...
- mysql在一台服务器搭建主从1
1. 登录mysq的方法: mysql-S /tmp/mysql.sock 登录3306 mysql -S /tmp/mysql_slave.sock 登录3307 mysql -h 127.0. ...
- 【MySQL】一台服务器上搭建两个mysql节点
环境: CentOS 6.8 memory:1G Mysql 5.7 二进制安装包 1.安装相关的环境包 yum -y install gcc glibc libaio libstdc++ libs ...
- Apache实现一台服务器上运行多个网站
总共有三种方法:通过不同的IP地址 通过不同的域名 通过不同的端口号 (1).通过不同的IP地址实现 例如一台CentOS7有两个IP:192.168.5.101和192.168.5.103 [roo ...
- 同一台服务器(电脑)运行多个Tomcat
同一台电脑运行不能同时运行多个未修改过配置tomcat的原因在于:一台电脑的一个端口只能被一个程序使用,多个tomcat启动会因为端口号号被占用的原因而启动失败. 如果想要在一台电脑上同时运行多个to ...
- 如何实现一台服务器同时运行两个php版本
有需要学习交流的友人请加入交流群的咱们一起,有问题一起交流,一起进步!前提是你是学技术的.感谢阅读! 点此加入该群jq.qq.com 假设您已经安装了Apache,为这两个项目创建了虚拟主机,并添加 ...
- Capistrano:自动完成多台服务器上新版本的同步更新,包括数据库的改变
https://baike.baidu.com/item/Capistrano/6844928?fr=aladdin Capistrano是一种在多台服务器上运行脚本的开源工具,它主要用于部署we ...
- 如何在同一台服务器上安装多套通达OA
本人最近研究了在同一服务器安装多套通达OA的方法:发现网上关于这个话题的文章比较少,于是录制成视频,在此发布,希望对有这方面需求的朋友有所帮助: http://blog.163.com/zhuwei_ ...
- Redis集群搭建,伪分布式集群,即一台服务器6个redis节点
Redis集群搭建,伪分布式集群,即一台服务器6个redis节点 一.Redis Cluster(Redis集群)简介 集群搭建需要的环境 二.搭建集群 2.1Redis的安装 2.2搭建6台redi ...
随机推荐
- webapp之路--百度手机前端经验(转)
看了之后收获很大,分享一下: 本文将围绕我半年来在移动前端工程化做的一些工作做的总结,主要从localstorage缓存和版本号管理,模块化,静态资源渲染方式三个方面总结手机百度前端一年内沉淀的解决方 ...
- 用apache配置多个tomcat webapp
The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for m ...
- 最短路 HDU 2544
最短路 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- Python 100例(上)
如果你已经把基础看完,可以尝试一下看看以下例子了,如果不会做也不要紧,你要尝试手动把所有的代码都敲一边.别嫌麻烦,因为都是从麻烦到简单的. 实例1: 题目:有1.2.3.4个数字,能组成多少个相互不同 ...
- sencha touch环境搭建
引入touch文件,包括resources和sencha-touch-debug.js文件 index.html文件内容如下: <!DOCTYPE HTML> <html> & ...
- The 2014 ACM-ICPC Asia Regional Anshan Online
[A]无向图的双联通子图计数.DP+状态压缩 [B]计算几何(点的旋转) [C]DP+状态压缩 [D]离散数学+DP (感觉可出) [E]概率DP [F]LCT模板题(-_-///LCT是啥!!!!) ...
- IOS中集合视图UICollectionView中DecorationView的简易使用方法
转载自: http://www.it165.net/pro/html/201312/8575.html Decoration View是UICollectionView的装饰视图.苹果官方给的案例 ...
- 11.10document对象练习
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- jstl-按照html的形式输出至页面
一.按照html的形式输出至页面 <c:out value="${xxx}" default="默认值" escapeXml="false&qu ...
- 【POJ2104】【HDU2665】K-th Number 主席树
[POJ2104][HDU2665]K-th Number Description You are working for Macrohard company in data structures d ...