天天看點

Cent OS7 下配置阿裡mysql

繼開源跨平台開發架構Weex之後,阿裡巴巴再次宣布另一個重大開源項目AliSQL。

該版本性能優于社群版MySQL 70%左右

阿裡mysql git位址git位址:https://github.com/alibaba/AliSQL.git

0.檢查本機是否有mysql 殘留 如果有,需要删除

rm /etc/my.cnf
yum remove mysql mysql-server mysql-libs compat-mysql51(51為版本)
rm –rf /var/lib/mysql
           

檢視是否還存在mysql軟體 并删除

rpm -qa|grep mysql
yum –y remove 查詢到的軟體名
           

1.因為阿裡MYSQL提供的是源碼,所有需要自己編譯。

yum install gcc gcc-c++ ncurses-devel perl 
           

2.安裝cmake從https://cmake.org/download/下載下傳所需版本

wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz 
 tar -zxvf cmake-2.8.10.2.tar.gz   
 cd cmake-2.8.10.2  
./bootstrap ; make ; make install 
           

3.安裝bison從http://ftp.gnu.org/gnu/bison/下載下傳所需版本(本次使用的是2.7版本)

tar -zxvf bison-2.7.tar.gz
   sudo yum install bison-2.7
           

4.設定AliSQL使用者群組及其他相關配置

groupadd mysql 
useradd -r -g mysql mysql
           

5.增加所需檔案夾

mkdir -p /usr/local/mysql
 mkdir -p /data/mysqldb
           

6.下載下傳阿裡SQL源碼 位址:https://github.com/alibaba/AliSQL

并解壓

如果unzip 沒有的話可使用以下指令建立,如果有,請忽略

yum install -y unzip zip;
           

解壓

unzip AliSQL-master.zip
           

進入解壓完的目錄

cd AliSQL-master
           

7.編譯并安裝 (注意: 重新運作配置,需要删除CMakeCache.txt檔案 rm CMakeCache.txt )

cmake\
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \  
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \  
-DDEFAULT_CHARSET=utf8 \  
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \  
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/data/mysqldb \
-DMYSQL_TCP_PORT=3306 \  
-DENABLE_DOWNLOADS=1  
           

編譯

make
           

安裝

make install
           

8.修改AliSQL目錄所有者群組

cd  /usr/local/mysql 
           
chown -R mysql:mysql.
           
cd  /data/mysqldb  
           
chown -R mysql:mysql.
           

9.初始化資料庫

cd  /usr/local/mysql           
           
scripts/mysql_install_db  --user=mysql  --datadir=/data/mysqldb
           

初始化後可能會出現錯誤:

FATAL ERROR:please install the following Perl modules before executingscripts/mysql_install_db:  Data::Dumper
           

此時安裝autoconf庫即可解決

yum –y install autoconf 
           

10.複制AliSQL服務啟動配置檔案

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
           

選擇覆寫

11.複制AliSQL服務啟動腳本及加入path路徑

cp  support-files/mysql.server  /etc/init.d/mysqld
           
vim  /etc/profile
           
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH

  export PATH

         source/etc/profile
           

12.啟動MYSQL服務

service mysqld start
           

13.加入開機自啟動

chkconfig --level 35 mysqld on
           

14.檢視mysql狀态

service mysqld status
           
SUCCESS! MySQL running (1759)
           

15.進入mysql

mysql -u root -p
           
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.6.32 Source distribution

Copyright (c) 2000, 2016, 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>