單台[DELL R720]伺服器部署多個MySQL執行個體

來源:互聯網
上載者:User

單台[DELL R720]伺服器部署多個MySQL執行個體

單台[DELL R720]伺服器部署多個MySQL執行個體

一、安裝mysql準備

1.1 下載mysql軟體包

mkdir -p /home/xuekun/mysql

cd /home/xuekun/tools/mysql

wgethttp://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.10.tar.gz

1.2安裝mysql軟體

yum-y install make gcc-c++ cmake bison bison-devel ncurses-devel

tarxvf mysql-5.6.16.tar.gz

cdmysql-5.6.16

cmake\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DMYSQL_DATADIR=/data\

-DSYSCONFDIR=/etc\

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_MEMORY_STORAGE_ENGINE=1\

-DWITH_READLINE=1\

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock\

-DMYSQL_TCP_PORT=3306\

-DENABLED_LOCAL_INFILE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DEXTRA_CHARSETS=all\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci

 

make&& make install

 

1.3建立mysql使用者

groupadd mysql

useradd -g mysql -M -s /sbin/nologin mysql

1.4建立mysql資料檔案目錄

mkdir -p/data/3306/data

mkdir -p/data/3307/data

tree /data/

/data/

|-- 3306

| `-- data

`-- 3307

`-- data

4 directories, 0 files

1.5 授權mysql使用者及組訪問資料檔案目錄

chown -Rmysql:mysql /data/3306

chown -Rmysql:mysql /data/3307

1.6 建立3306,3307my.cnf設定檔

vim /data/3306/my.cnf

vim  /data/3307/my.cnf

需要添加的my.cnf內容見附錄B:或本文檔目錄下的my.cnf檔案

#授權mysql使用者及組訪問my.cnf

chown -Rmysql:mysql /data/3306/my.cnf

chown -Rmysql:mysql /data/3307/my.cnf

1.7 建立mysql啟動指令碼

vim  /data/3306/mysql

vim  /data/3307/mysql

 

需要添加的mysql 內容見附錄C:或本文檔目錄下的mysql檔案

chmod 700/data/3306/mysql

chmod 700/data/3307/mysql

1.8初始化資料庫

vim/etc/profile

PATH=/usr/local/mysql/bin:$PATH

exportPATH

#關閉檔案,運行下面的命令,讓配置立即生效

source/etc/profile

cd/usr/local/mysql

scripts/mysql_install_db--datadir=/data/3306/data

InstallingMySQL system tables...

OK

Filling helptables...

OK

To start mysqldat boot time you have to copy

support-files/mysql.serverto the right place for your system

PLEASE REMEMBERTO SET A PASSWORD FOR THE MySQL root USER !

To do so, startthe server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin-u root password 'new-password'

/usr/local/mysql/bin/mysqladmin-u root -h A password 'new-password'

Alternativelyyou can run:

/usr/local/mysql/bin/mysql_secure_installation

which will alsogive you the option of removing the test

databases andanonymous user created by default. This is

stronglyrecommended for production servers.

See the manualfor more instructions.

You can startthe MySQL daemon with:

cd/usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can testthe MySQL daemon with mysql-test-run.pl

cd/usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please reportany problems with the /usr/local/mysql/bin/mysqlbug script!

 

scripts/mysql_install_db--datadir=/data/3307/data

InstallingMySQL system tables...

OK

Filling helptables...

OK

同上面3306的內容,因此,此處省略。

 

chown -Rmysql:mysql /data

1.9 啟動資料庫

啟動mysql執行個體的命令為

/data/3306/mysqlstart

StartingMySQL...

/data/3307/mysqlstart

StartingMySQL...

檢查啟動情況:

netstat-lnt|grep 330[6-7]

tcp 0 00.0.0.0:3306 0.0.0.0:* LISTEN

tcp 0 00.0.0.0:3307 0.0.0.0:* LISTEN

並加入/etc/rc.local,設定為開機自啟動

echo"/data/3306/mysql start" >>/etc/rc.local

echo"/data/3307/mysql start" >>/etc/rc.local

cat/etc/rc.local

#!/bin/sh

#

# This scriptwill be executed *after* all the other init scripts.

# You can putyour own initialization stuff in here if you don't

# want to dothe full Sys V style init stuff.

touch/var/lock/subsys/local

/data/3306/mysqlstart

/data/3307/mysql start

提示:如果此步中的資料庫啟動不了,請稍微等待下,如果還不行請查看錯誤記錄檔,路徑在my.cnf的最下面。

 

--------------------------------------分割線 --------------------------------------

Ubuntu 14.04下安裝MySQL

《MySQL權威指南(原書第2版)》清晰中文掃描版 PDF

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主從伺服器

Ubuntu 12.04 LTS 構建高可用分布式 MySQL 叢集

Ubuntu 12.04下原始碼安裝MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二進位安裝

--------------------------------------分割線 --------------------------------------

更多詳情見請繼續閱讀下一頁的精彩內容:

  • 1
  • 2
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.