CentOS 6.5最小化编译安装MysqL 5.5.35配置多实例
1、关闭防火墙
[root@MysqL~]#serviceiptablesstop iptables:SettingchainstopolicyACCEPT:filter[OK] iptables:Flushingfirewallrules:[OK] iptables:Unloadingmodules:[OK] [root@MysqL~]#chkconfigiptablesoff [root@MysqL~]#chkconfigiptables--list iptables0:off1:off2:off3:off4:off5:off6:off
2、关闭selinux
[root@MysqL~]#setenforce0 [root@MysqL~]#vim/etc/sysconfig/selinux
修改下面这一行;
SELINUX=disabled
[root@MysqL~]#getenforce Permissive
3、安装MysqL依赖包及编译工具;
[root@MysqL~]#yuminstalllibaio-devel-y [root@MysqL~]#yuminstall-yncurses-devel [root@MysqL~]#yuminstall-ygccgcc-c++ [root@MysqL~]#yuminstall-ycmake
4、安装前准备;
4.1、安装路径:
[root@MysqL~]#mkdir/usr/local/MysqL
4.2、数据库路径:
[root@MysqL~]#mkdir/data/MysqL-p
[root@MysqL~]#groupaddMysqL [root@MysqL~]#useradd-r-gMysqL-s/bin/falseMysqL
4.4、赋予数据存放目录权限
[root@MysqL~]#chownMysqL:MysqL-R/data/MysqL
5、编译安装MysqL 5.5.35
[root@MysqL~]#yuminstall-ylrzsz root@MysqL~]#mkdir/package [root@MysqL~]#cd/package/ [root@MysqLpackage]#tarxfMysqL-5.5.32.tar.gz [root@MysqLpackage]#cdMysqL-5.5.32 [root@MysqLMysqL-5.5.32]#cmake.-DCMAKE_INSTALL_PREFIX=/usr/local/MysqL-DMysqL_UNIX_ADDR=/data/MysqL/MysqL.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DMysqL_DATADIR=/data/MysqL/-DMysqL_USER=MysqL-DMysqL_TCP_PORT=3306 [root@MysqLMysqL-5.5.32]#make&&makeinstall
[root@MysqL~]#mkdir-p/data/{3306,3307}/data [root@MysqL~]#tree/data /data |--3306 |`--data `--3307 `--data 4directories,0files
7、修改配置文件(my.cnf)如下行,分别放入3306、3307目录当中;
[root@MysqL3306]#vimmy.cnf [client] port=3306 socket=/data/3306/MysqL.sock [MysqLd] port=3306 socket=/data/3306/MysqL.sock datadir=/data/3306 server-id=3306
8、初始化数据库;
注意:初始化数据库时需要指定不同的数据目录
[root@MysqLMysqL-5.5.32]#cd/usr/local/MysqL/ [root@MysqLMysqL]#scripts/MysqL_install_db--user=MysqL--basedir=/usr/local/MysqL--datadir=/data/3306 [root@MysqLMysqL]#scripts/MysqL_install_db--user=MysqL--basedir=/usr/local/MysqL--datadir=/data/3307
9、启动多实例,启动脚本可以加入到开机自启动文件中。
[root@MysqLMysqL]#/usr/local/MysqL/bin/MysqLd_safe--defaults-file=/data/3306/my.cnf2>&1>/dev/null& [root@MysqLMysqL]#/usr/local/MysqL/bin/MysqLd_safe--defaults-file=/data/3307/my.cnf2>&1>/dev/null&
9.1、查看端口;
[root@MysqLMysqL]#netstat-tunlp ActiveInternetconnections(onlyservers) ProtoRecv-QSend-QLocalAddressForeignAddressStatePID/Programname tcp000.0.0.0:33070.0.0.0:*LISTEN11621/MysqLd tcp000.0.0.0:220.0.0.0:*LISTEN1266/sshd tcp000.0.0.0:33060.0.0.0:*LISTEN11338/MysqLd tcp00:::22:::*LISTEN1266/sshd udp000.0.0.0:680.0.0.0:*969/dhclient
[root@MysqLMysqL]#/usr/local/MysqL/bin/MysqL-uroot-p-P3306-S/data/3306/MysqL.sock [root@MysqLMysqL]#/usr/local/MysqL/bin/MysqL-uroot-p-P3307-S/data/3307/MysqL.sock
[root@MysqLMysqL]#/usr/local/MysqL/bin/MysqLadmin-uroot-p-P3306-S/data/3306/MysqL.sockshutdown [root@MysqLMysqL]#/usr/local/MysqL/bin/MysqLadmin-uroot-p-P3307-S/data/3307/MysqL.sockshutdown