1. 程式人生 > >MySQL-8.0.12原始碼安裝例項

MySQL-8.0.12原始碼安裝例項

1、通過官網下載對應的版本後,通過FTP上傳至雲伺服器的/usr/local/src 目錄

2、解壓縮檔案

[[email protected] src]# ls
mysql-boost-8.0.12.tar.gz
[[email protected] src]# tar zxvf mysql-boost-8.0.12.tar.gz
[[email protected] src]# ls
mysql-8.0.12  mysql-boost-8.0.12.tar.gz

3、重新命名資料夾

[[email protected] src]# mv mysql-8.0.12  mysql
[
[email protected]
src]# ls mysql mysql-boost-8.0.12.tar.gz [[email protected] src]# cd mysql [[email protected] mysql]# ls boost config.h.cmake Doxyfile.in libbinlogevents man plugin sql testclients win client configure.cmake doxygen_resources libbinlogstandalone mysql-test README sql-common unittest cmake dbug extra libmysql mysys run_doxygen.cmake storage utilities CMakeLists.txt Docs include libservices mysys_ssl scripts strings VERSION components Doxyfile-ignored INSTALL LICENSE packaging share support-files vio

4、安裝cmake工具 yum install -y cmake

5、cmake構建編譯環境

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/src/mysql  -DMYSQL_DATADIR=/usr/local/src/mysql/var  -DSYSCONFDIR=/usr/local/src/mysql/etc -DWITH_DEBUG=0  -DWITH_INNODB_MEMCACHED=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DENABLED_PROFILING=0  -DCMAKE_C_FLAGS="-O3"  -DCMAKE_CXX_FLAGS="-O3"

6、cmake報錯彙總:

錯誤1、 CMake Warning at CMakeLists.txt:185 (MESSAGE):
  Could not find devtoolset gcc

解決方案:yum install -y gcc

再次執行cmake編譯

錯誤2、**-- Could NOT find Git (missing:  GIT_EXECUTABLE) **

解決方案:yum install -y git

錯誤3、-- The CXX compiler identification is unknown
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.

解決方案:yum install -y gcc gcc-c++

再次執行cmake編譯

錯誤4、CMake Error at cmake/boost.cmake:101 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

解決方案:編譯選項中增加
-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/mysql
回車後,系統會自動下載並解壓縮該檔案

錯誤5、Cannot find appropriate system libraries for WITH_SSL=system.
Make sure you have specified a supported SSL version. 
Valid options are : 
system (use the OS openssl library), 
yes (synonym for system), 
</path/to/custom/openssl/installation>, 
wolfssl (use wolfSSL. See extra/README-wolfssl.txt on how to set this up)

錯誤6、CMake Error at cmake/ssl.cmake:68 (MESSAGE):
  Please install the appropriate openssl developer package.

解決方案5:編譯選項中增加 -DWITH_SSL=system

解決方案6:yum install ncurses-devel 和 yum install openssl-devel

7、執行編譯 make -j N(N為執行緒數,一般為伺服器中CPU的個數)

檢視Linux系統CPU資訊:

cat /proc/cpuinfo

檢視Linux系統CPU物理個數:

cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

8、cmake -j 編譯過程中的錯誤資訊

[ 56%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/handler/i_s.cc.o
錯誤  c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/handler/handler0alter.cc.o] Error 4
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
make: *** [all] Error 2

解決方案:根據錯誤資訊提示 internal compiler error: Killed (program cc1plus) 判斷為編譯過程中記憶體耗盡, 導致了編譯中斷,解決辦法就是增加一個交換分割槽:

[[email protected] mysql]# dd if=/dev/zero of=/swapfile bs=1k count=2048000    //建立分割槽檔案, 大小 2G
2048000+0 records in
2048000+0 records out
2097152000 bytes (2.1 GB) copied, 16.9483 s, 124 MB/s
[[email protected] mysql]# mkswap /swapfile   //生成 swap 檔案系統
Setting up swapspace version 1, size = 2047996 KiB
no label, UUID=5c0b0fa8-7396-4b89-998f-29b6b269a938
[[email protected] mysql]# swapon /swapfile   //啟用 swap 檔案
swapon: /swapfile: insecure permissions 0644, 0600 suggested.