您好,登錄后才能下訂單哦!
CentOS 6.5最小化編譯安裝mysql 5.5.35配置多實(shí)例
1、關(guān)閉防火墻
[root@mysql ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@mysql ~]# chkconfig iptables off [root@mysql ~]# chkconfig iptables --list iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
2、關(guān)閉selinux
[root@mysql ~]# setenforce 0 [root@mysql ~]# vim /etc/sysconfig/selinux
修改下面這一行;
SELINUX=disabled
[root@mysql ~]# getenforce Permissive
3、安裝mysql依賴包及編譯工具;
[root@mysql ~]# yum install libaio-devel -y [root@mysql ~]# yum install -y ncurses-devel [root@mysql ~]# yum install -y gcc gcc-c++ [root@mysql ~]# yum install -y cmake
4、安裝前準(zhǔn)備;
4.1、安裝路徑:
[root@mysql ~]# mkdir /usr/local/mysql
4.2、數(shù)據(jù)庫路徑:
[root@mysql ~]# mkdir /data/mysql -p
4.3、創(chuàng)建用戶和用戶組
[root@mysql ~]# groupadd mysql [root@mysql ~]# useradd -r -g mysql -s /bin/false mysql
4.4、賦予數(shù)據(jù)存放目錄權(quán)限
[root@mysql ~]# chown mysql:mysql -R /data/mysql
5、編譯安裝mysql 5.5.35
[root@mysql ~]# yum install -y lrzsz root@mysql ~]# mkdir /package [root@mysql ~]# cd /package/ [root@mysql package]# tar xf mysql-5.5.32.tar.gz [root@mysql package]# cd mysql-5.5.32 [root@mysql mysql-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@mysql mysql-5.5.32]# make && make install
6、創(chuàng)建多實(shí)例數(shù)據(jù)庫文件存放位置;
[root@mysql ~]# mkdir -p /data/{3306,3307}/data [root@mysql ~]# tree /data /data |-- 3306 | `-- data `-- 3307 `-- data 4 directories, 0 files
7、修改配置文件(my.cnf)如下行,分別放入3306、3307目錄當(dāng)中;
[root@mysql 3306]# vim my.cnf [client] port = 3306 socket = /data/3306/mysql.sock [mysqld] port = 3306 socket = /data/3306/mysql.sock datadir = /data/3306 server-id = 3306
8、初始化數(shù)據(jù)庫;
注意:初始化數(shù)據(jù)庫時(shí)需要指定不同的數(shù)據(jù)目錄
[root@mysql mysql-5.5.32]# cd /usr/local/mysql/ [root@mysql mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/3306 [root@mysql mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/3307
9、啟動(dòng)多實(shí)例,啟動(dòng)腳本可以加入到開機(jī)自啟動(dòng)文件中。
[root@mysql mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/3306/my.cnf 2>&1 >/dev/null & [root@mysql mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf 2>&1 >/dev/null &
9.1、查看端口;
[root@mysql mysql]# netstat -tunlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 11621/mysqld tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1266/sshd tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 11338/mysqld tcp 0 0 :::22 :::* LISTEN 1266/sshd udp 0 0 0.0.0.0:68 0.0.0.0:* 969/dhclient
10、登錄多實(shí)例數(shù)據(jù)庫
[root@mysql mysql]# /usr/local/mysql/bin/mysql -u root -p -P 3306 -S /data/3306/mysql.sock [root@mysql mysql]# /usr/local/mysql/bin/mysql -u root -p -P 3307 -S /data/3307/mysql.sock
11、關(guān)閉mysql多實(shí)例方式
[root@mysql mysql]# /usr/local/mysql/bin/mysqladmin -u root -p -P 3306 -S /data/3306/mysql.sock shutdown [root@mysql mysql]# /usr/local/mysql/bin/mysqladmin -u root -p -P 3307 -S /data/3307/mysql.sock shutdown
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。