MySQL5.5安装与多实例
MySQL5.5编译安装
#1.2 cmake软件
cd /home/oldboy/tools/
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
#CMake has bootstrapped. Now run gmake.
gmake
gmake install
cd ../
#1.3依赖包
yum install ncurses-devel -y
#1.4创建用户和组
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
#1.5解压编译MySQL
tar zxf mysql-5.5.32.tar.gz
cd 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 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-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
#-- Build files have been written to: /home/oldboy/tools/mysql-5.5.32
提示,编译时可配置的选项很多,具体可参考结尾附录或官方文档:
make
#[100%] Built target my_safe_process
make install
ln -s /application/mysql-5.5.32/ /application/mysql
chown -R mysql.mysql /application/mysql/data
chmod -R 1777 /tmp
cp support-files/my-large.cnf /etc/my.cnf
cd scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
/bin/cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
如果上述操作未出现错误,则MySQL5.5.32软件cmake方式的安装就算成功了。
MySQL5.5二进制安装
useradd mysql -s /sbin/nologin -M
mkdir /data/tools/ -p
wget http://download.xuliangwei.com/mysql-5.5.32-linux2.6-x86_64.tar.gz
tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64 /data/mysql-5.5.32
ln -s /data/mysql-5.5.32/ /data/mysql
chown -R mysql.mysql /data/mysql/
/data/mysql/scripts/mysql_install_db --basedir=/data/mysql/ --datadir=/data/3306/ --user=mysql
\cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i 's#/usr/local/mysql#/data/mysql#g' /data/mysql/bin/mysqld_safe /etc/init.d/mysqld
\cp /data/mysql/support-files/my-small.cnf /etc/my.cnf
echo 'export PATH=/data/mysql/bin:$PATH' >/etc/profile.d/mysqld.sh
sh /etc/profile.d/mysqld.sh
/etc/init.d/mysqld start
mysqladmin password 123456
mysql -uroot -p123456
mysql
#二进制安装详解
1.安装mysql
ls mysql-5.5.32-linux2.6-x86_64.tar.gz
tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64 /data/mysql-5.5.32
ln -s /data/mysql-5.5.32 /data/mysql
##########相当于编译步骤的make install完成#############
2.创建用户和目录
useradd mysql -s /sbin/nologin -M
chown -R mysql.mysql /data/mysql/data/
3.初始化数据库
cd /data/mysql
./scripts/mysql_install_db --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data/
\cp support-files/my-small.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
sed -i 's#/usr/local/mysql#/data/mysql#g' /data/mysql/bin/mysqld_safe /etc/init.d/mysqld
/etc/init.d/mysqld start
netstat -lntup|grep mysql
cp -a /data/mysql/bin/* /usr/local/sbin/
mysqladmin password oldboy123
mysql -uroot -poldboy123
##mysql安装报错
Installing MySQL system tables.../application/mysql//bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决方法: yum -y install libaio
/application/mysql//bin/mysqld: Can't create/write to file '/tmp/ibIgpX1g' (Errcode: 13 - Permission denied)
2015-09-28 02:53:35 7f5cb05e6720 InnoDB: Error: unable to create temporary file; errno: 13
2015-09-28 02:53:35 1170 [ERROR] Plugin 'InnoDB' init function returned error.
2015-09-28 02:53:35 1170 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-09-28 02:53:35 1170 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-09-28 02:53:35 1170 [ERROR] Aborting
解决方法:chmod 1777 /tmp/
##mysql启动报错
Starting MySQL.The server quit without updating PID file (/[FAILED]ql/darker.pid).
InnoDB: mmap(137363456 bytes) failed; errno 12
[ERROR] InnoDB: Cannot allocate memory for the buffer pool
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
解决:vim /etc/my.cnf innodb_buffer_pool_size = 8M 修改innodb为8M,内存过小导致无法启动
MySQL5.5多实例安装
1.安装单实例MySQL
useradd mysql -s /sbin/nologin -M
mkdir /application/tools/ -p
cd /application/tools/
tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32
ln -s /application/mysql-5.5.32/ /application/mysql
chown -R mysql.mysql /application/mysql/
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
\cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
\cp /application/mysql/support-files/my-small.cnf /etc/my.cnf
echo 'export PATH=/application/mysql/bin:$PATH' >/etc/profile.d/mysqld.sh
2.配置多实例
mkdir /data/{3306,3307}/data -p 创建多实例目录
解压已经准备好的data包
[root@MySQL01 application]# find /data/ -type f -name "mysql"|xargs chmod +x
[root@MySQL01 application]# chown -R mysql.mysql /data/
[root@MySQL01 ~]# cd /application/mysql
[root@MySQL01 ~]#./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/data/3306/data --user=mysql
[root@MySQL01 ~]#./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/data/3307/data --user=mysql
3.增加一个MySQL 3309端口实例过程如下:
mkdir -p /data/3308/data
\cp /data/3306/my.cnf /data/3308/
\cp /data/3306/mysql /data/3308/
sed -i 's/3306/3308/g' /data/3308/my.cnf
sed -i 's/3306/3308/g' /data/3308/mysql
sed -i 's#server-id = 1#server-id = 8#g’ /data/3308/my.cnf
chown -R mysql:mysql /data/3308
chmod 700 /data/3308/mysql
cd /application/mysql
./scripts/mysql_install_db --datadir=/data/3308/data --basedir=/application/mysql --user=mysql
chown -R mysql:mysql /data/3308
/data/3308/mysql start
netstat -lnt|grep 3308
如果没起来看mysql错误日志,在/data/3308/my.cnf最下面有错误日志地址
echo "#mysql multi instances" >>/etc/rc.local
echo "/data/3306/mysql start" >>/etc/rc.local
echo "/data/3307/mysql start" >>/etc/rc.local
4.增加一个MySQL 3309端口实例过程如下:
mkdir -p /data/3309/data
\cp /data/3306/my.cnf /data/3309/
\cp /data/3306/mysql /data/3309/
sed -i 's/3306/3309/g' /data/3309/my.cnf
sed -i 's/3306/3309/g' /data/3309/mysql
sed -i 's#server-id = 1#server-id = 9#g' /data/3309/my.cnf
chown -R mysql:mysql /data/3309
chmod 700 /data/3309/mysql
cd /application/mysql
./scripts/mysql_install_db --datadir=/data/3309/data --basedir=/application/mysql --user=mysql
chown -R mysql:mysql /data/3309
/data/3309/mysql start
netstat -lnt|grep 3309
如果没起来看mysql错误日志,在/data/3309/my.cnf最下面有错误日志地址
echo "#mysql multi instances" >>/etc/rc.local
echo "/data/3306/mysql start" >>/etc/rc.local
echo "/data/3307/mysql start" >>/etc/rc.local
echo "/data/3309/mysql start" >>/etc/rc.local
MySQL5.5多实例主从
1.备主库
mysqldump -A -uroot -p'123456' -S /data/3306/mysql.sock --master-data=2 >/opt/alldb20161122.sql
2.把整个备份文件恢复到从库
mysql -uroot -p123456 -S /data/3307/mysql.sock < /opt/alldb20161122.sql
3.过滤出binlog位置和master_log_pos位置点
grep -i 'change master' /opt/alldb20161122.sql |head -n 1
-- CHANGE MASTER TO MASTER_LOG_FILE='binlog.000001', MASTER_LOG_POS=250;
4.主库授权
grant all on *.* to 'repl'@'%' identified by '123456';
5.配置从库
CHANGE MASTER TO MASTER_HOST=’10.8.2.78’, MASTER_USER='repl',MASTER_PASSWORD=‘123456’, MASTER_LOG_FILE='binlog.000001', MASTER_LOG_POS=250;
slave start;
6.检查从库
show slave status\G
MySQL5.5安装与多实例的更多相关文章
- 如何在Windows下安装MySQL5和MySQL8的多实例
MySQL5和MySQL8多实例安装方法: 1.首先下载MySQL5和MySQL8 官方下载链接:https://dev.mysql.com/downloads/mysql/ 下载旧版本: 下载好后 ...
- linux mysql5.5安装与配置(转帖,在网上收集,自用)
MySQL是一个关系型数据库管理系统 ,由瑞典MySQL AB公司开发,目前属于Oracle 公司.MySQL分为社区版和商业版,由于其体积小.速度快.总体拥有成本低,尤其是开放源码 这一特点,一般中 ...
- MySql5.5安装详细说明
双击MySql5.5安装文件开始: next 打勾,Next 选Custom,原因如下面所述: Typical(典型安装) Installs the most common program fea ...
- Linux平台下源码安装mysql多实例数据库
Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...
- MySQL5.5安装图解
MySQL5.5安装图解... ====================== 第一部分:去官网下载MySQL安装包... MySQL下载官网:https://dev.mysql.com/downloa ...
- MySQL5.6与MySQL5.7安装的区别
一.MySQL5.6与MySQL5.7安装的区别 1.cmake的时候加入了boost 下载boost.org 2.初始化时 cd /application/mysql/bin/mysql 使用mys ...
- SQL:安装多个实例,修改实例端口号,和IP加端口号连接实例
sql server 安装第一个实例,默认实例的端口是1433, 一个库中如果有多个实例,从第二个实例开始的端口是动态端口,需要的话,自己手工指定为静态端口,如指定第二个实例为1434 或着随意一个如 ...
- MySQL5.6安装步骤
MySQL5.6安装步骤(windows7/8_64位) 1. 下载MySQL Community Server 5.6.11 2. 解压MySQL压缩包 将以下载的MySQL压缩包解压到自定义目录下 ...
- mysql5.6安装
mysql5.6安装 #卸载原有的mysqlyum remove mysql*ls /etc/my.cnf*mv /etc/my.cnf* /tmp/ #安装依赖包yum install make c ...
随机推荐
- JNative用法注意事项
公司要做个跟设备打交道的web系统,需要java调用dll.搞java的同事说JNative看起来挺好使的,找俺帮忙调通.用的是1.3.1版本 环境设置. JNative的调试信息需要打开才能更清楚些 ...
- NFS,两台linux设置网络共享文件系统
NFS,MOUNT,UMOUNT 简介 NFS是Network File System的简写,网络文件系统.通过使用NFS,用户和程序可以像访问本地文件一样访问远端系统上的文件,根据权限的控制可以对N ...
- HihoCoder 1063 : 缩地 树形DP第二题(对象 边)
时间限制:12000ms 单点时限:1000ms 内存限制:256MB 描述 编织者是 Dota 系列中的一个伪核,拥有很强的生存能力和线上消耗能力.编织者的代表性技能是缩地.缩地带来的隐身.极限移动 ...
- 每天一个linux命令:【转载】less命令
less 工具也是对文件或其它输出进行分页显示的工具,应该说是linux正统查看文件内容的工具,功能极其强大.less 的用法比起 more 更加的有弹性.在 more 的时候,我们并没有办法向前面翻 ...
- BZOJ1510 POI2006 Kra-The Disks 【模拟】
BZOJ1510 POI2006 Kra-The Disks LINK 还是粘题面吧,但是图就算了 Description Johnny 在生日时收到了一件特殊的礼物,这件礼物由一个奇形怪状的管子和一 ...
- RNG—随机数产生器
RNG 随机数产生器 RNG g_rng(12345); /********************************************************************** ...
- Java 按行拆分txt
T028619630|@|聚二零|@|M|@|1983-01-01|@|0|@|110101198301010098|@||@||@||@|湖南省衡阳市耒阳市蔡伦步行街1005号302|@|42100 ...
- maven搭建多模块企业级项目
首先,前面几次学习已经学会了安装maven,如何创建maven项目等,最近的学习,终于有点进展了,搭建一下企业级多模块项目. 好了,废话不多说,具体如下: 首先新建一个maven项目,pom.xml的 ...
- kong k8s 安装 以及可视化管理界面
1. git clone $ git clone git@github.com:Mashape/kong-dist-kubernetes.git $ cd kong-dist-kubernetes ...
- Codeforces Round #249 (Div. 2)-D
这场的c实在不想做,sad. D: 标记一下每个点8个方向不经过黑点最多能到达多少个黑点. 由题意可知.三角形都是等腰三角形,那么我们就枚举三角形的顶点. 对于每个定点.有8个方向能够放三角形. 然后 ...