设为首页 收藏本站
查看: 1177|回复: 0

[经验分享] 安装多个mysql实例(debian版本)

[复制链接]
累计签到:2 天
连续签到:1 天
发表于 2018-5-14 13:38:15 | 显示全部楼层 |阅读模式
我的博客已迁移到xdoujiang.com请去那边和我交流
前言:领导要求在1台DELL R710上安装多个mysql实例
一、安装第1个实例
1、当前系统
cat /etc/debian_version
6.0.10
2、查看安装包
apt-cache search mysql-server|grep "mysql-server"
mysql-server-5.1 - MySQL database server binaries and system database setup
mysql-server-core-5.1 - MySQL database server binaries
mysql-server - MySQL database server (metapackage depending on the latest version)
3、安装mysql(会安装mysql相关的一系列的包)
apt-get -y install mysql-server --force-yes
二、安装第二个实例
1、创建目录(我这边将第二个实例安装在/opt下)
cd /opt/
mkdir mysql3307
2、复制mysql表和配置文件
cd /var/lib/mysql/
cp -a mysql /opt/mysql3307/
cp /etc/mysql/my.cnf /opt/mysql3307/
3、修改配置(一般就是改下port和sock和pid和datadir路径)
port            = 3307
socket          = /var/run/mysqld/mysqld3307.sock
pid-file        = /var/run/mysqld/mysqld3307.pid
datadir         = /opt/mysql3307
4、给mysql权限
chown -R mysql.root /opt/mysql3307/
5、启mysql(这里使用mysql用户启)
修改/etc/passed文件
mysql:x:102:104:MySQL Server,,,:/var/lib/mysql:/bin/bash
su - mysql
/usr/sbin/mysqld --defaults-file=/opt/mysql3307/my.cnf --basedir=/usr --datadir=/opt/mysql3307/ --user=mysql --pid-file=/var/run/mysqld/mysqld3307.pid --skip-external-locking --port=3307 --socket=/var/run/mysqld/mysqld3307.sock &
[1] 2484
150505  9:30:06 [Note] Plugin 'FEDERATED' is disabled.
150505  9:30:07  InnoDB: Initializing buffer pool, size = 8.0M
150505  9:30:07  InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
150505  9:30:07  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
150505  9:30:07  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
150505  9:30:07  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
150505  9:30:07  InnoDB: Started; log sequence number 0 0
150505  9:30:07 [Note] Event Scheduler: Loaded 0 events
150505  9:30:07 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.73-1'  socket: '/var/run/mysqld/mysqld3307.sock'  port: 3307  (Debian)
6、最后查看2个mysql实例是否正常运行着
ps aux|grep mysql
root      2152  0.0  0.0   3956   616 ?        S    08:53   0:00 /bin/sh /usr/bin/mysqld_safe
mysql     2276  0.0  3.6 182456 37560 ?        Sl   08:53   0:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
root      2277  0.0  0.0   5348   688 ?        S    08:53   0:00 logger -t mysqld -p daemon.error
mysql     2480  0.0  0.1  36884  1232 pts/0    S    09:29   0:00 su - mysql
mysql     2481  0.0  0.1  19220  1976 pts/0    S    09:29   0:00 -su
mysql     2484  5.5  3.6 174064 37004 pts/0    Sl   09:30   0:00 /usr/sbin/mysqld --defaults-file=/opt/mysql3307/my.cnf --basedir=/usr --datadir=/opt/mysql3307/ --user=mysql --pid-file=/var/run/mysqld/mysqld3307.pid --skip-external-locking --port=3307 --socket=/var/run/mysqld/mysqld3307.sock
mysql     2495  0.0  0.1  16340  1136 pts/0    R+   09:30   0:00 ps aux
mysql     2496  0.0  0.0   7548   820 pts/0    S+   09:30   0:00 grep mysql
7、登陆2个mysql实例看下
mysql -uroot -predhat -S /var/run/mysqld/mysqld.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 54
Server version: 5.1.73-1 (Debian)
Copyright (c) 2000, 2013, 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> quit
Bye
mysql -uroot -predhat -S /var/run/mysqld/mysqld3307.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-1 (Debian)
Copyright (c) 2000, 2013, 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> quit
Bye
mysql@10:~$
三、引擎
当前版本引擎
mysql -uroot -predhat -S /var/run/mysqld/mysqld.sock -e "show engines;"
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                        | Transactions | XA   | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| BLACKHOLE  | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| FEDERATED  | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| ARCHIVE    | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
配置修改默认引擎为innodb
是在[mysqld]这个里面
default_table_type = innodb
5.5的话默认引擎直接是innodb了 不需要修改

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-460085-1-1.html 上篇帖子: 搭建内网centos+epel源(debian) 下篇帖子: 【翻译】如何删除debian jessie 的systemd
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表