CentOS 6.9 基於clang3.4 編譯安裝mariadb-10.2.12

來源:互聯網
上載者:User

標籤:出錯   sha   other   listen   linu   line   bug   logging   query   

系統平台:

CentOS release 6.9 (Final)

核心 2.6.32-696.el6.x86_64

1.去官網下載適合的源碼包

http://mariadb.org/

mariadb-10.2.12.tar.gz

檢查系統內是否安裝了資料庫。

#rpm -qa|grep MariaDB#rpm -qa|grep mysql

cmake最新版本需要c++11支援,gcc4.8以下並未包含,而Centos 6.9的版本如下

#rpm -qa|grep gccgcc-4.4.7-18.el6.x86_64libgcc-4.4.7-18.el6.x86_64gcc-gfortran-4.4.7-18.el6.x86_64gcc-c++-4.4.7-18.el6.x86_64
2.採用clang編譯器進行編譯

Clang 比 GCC 編譯器的優勢:

編譯速度更快編譯產出更小出錯提示更友好
3.安裝依賴包
# yum install cmake ncurses-devel libaio-devel openssl-devel clang -y   #其中clang需要EPEL源,請自行參考https://mirrors.aliyun.com/help/centos#cmake --versioncmake version 2.8.12.2
4.解壓mariadb包至任意臨時目錄
#tar xvf mariadb-10.2.12.tar.gz -C /app/sdb/
5.編譯安裝mariadb
#mkdir /app/sdb/db-build#cd /app/sdb/db-build/以下的編譯參數,根據自己的需求定製#cmake /app/sdb/mariadb-10.2.12  -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb-10.2.12  -DSYSCONFDIR=/etc  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_EXTRA_CHARSETS=all  -DWITH_READLINE=1  -DWITH_SSL=system  -DWITH_ZLIB=system  -DWITH_EMBEDDED_SERVER=1  -DENABLED_LOCAL_INFILE=1  -DWITH_MYISAM_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_MEMORY_STORAGE_ENGINE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_DEBUG=0我使用的AUSU筆記本是 I5  1CPU 4核,4GB記憶體,20分鐘編譯安裝完成。# make -j 8 && make install編譯完成佔用空間為3.3GB
6.建立軟連結mysql指向解壓後的目錄
#cd /usr/local/#ln -s mariadb-10.2.12 mysql
7.建立用於mysql的組和帳號
#groupadd -g 500 mysql#useradd -g 500 -u 500 -s /sbin/nologin -M mysql
8.修改mysql檔案夾所屬者和所屬組
#chown -R mysql.mysql /usr/local/mysql/
9.添加PATH至環境變數中
#echo ‘PATH=/usr/local/mysql/bin:$PATH‘ >> /etc/profile.d/mysql.sh檢查檔案#cat /etc/profile.d/mysql.sh載入環境變數檔案 並檢查#source /etc/profile.d/mysql.sh#echo $PATH#mysql -Vmysql  Ver 15.1 Distrib 10.2.12-MariaDB, for Linux (x86_64) using readline 5.1
10.建立資料庫存放檔案夾並修改許可權
#mkdir -pv /data/sqldb/3306/{log,data,pid,socket,tmp}#chown -R mysql.mysql /data/sqldb/#chmod -R 770 /data/sqldb/
11.複製主設定檔my.cnf

這裡先要確認下原生記憶體多少,以便使用一個參考模板。

#grep memory support-files/*

找到適合本機記憶體的模板

本機記憶體為512M,所以選擇了my-large.cnf這個設定檔

#\cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
12.修改設定檔
# vim /etc/my.cnf[mysqld]port            = 3306socket          = /tmp/mysql.sockpid-file = /data/sqldb/3306/pid/mysql.piddatadir = /data/sqldb/3306/datatmpdir = /data/sqldb/3306/tmpinnodb_file_per_table = 1skip_name_resolve = 1log-error = /data/sqldb/3306/log/error.log
13.安裝資料庫相關檔案
#cd /usr/local/mysql/

查看下安裝程式的安裝參數

#/usr/local/mysql/scripts/mysql_install_db --help#./scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
14.複製啟動服務指令碼至/etc/init.d目錄
#cp support-files/mysql.server /etc/init.d/mysqld
15.添加開機啟動服務,並啟動mysqld服務
#chkconfig --add mysqld#service mysqld startStarting MySQL.180128 23:54:38 mysqld_safe Logging to ‘/data/sqldb/3306/log/error.log‘.180128 23:54:38 mysqld_safe Starting mysqld daemon with databases from /data/sqldb/3306/data                                                     [  OK  ]#lsof -i:3306COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAMEmysqld  2067 mysql   21u  IPv6  12603      0t0  TCP *:mysql (LISTEN)
16.進行安全配置
#/usr/local/mysql/bin/mysql_secure_installationEnter current password for root 預設為空白Set root password   設定mysql root密碼Remove anonymous users  是否移除匿名使用者登入Disallow root login remotely    是否禁止root遠程登入Remove test database and access to it?  是否移除test資料和test帳號Reload privilege tables now?    是否立即更新許可權Thanks for using MariaDB!
17.測試
#mysql -u root -pEnter password: Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 19Server version: 10.2.12-MariaDB-log Source distributionCopyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.MariaDB [(none)]> use mysql;

建立一個帳號測試遠程登入

MariaDB [mysql]> grant all on *.* to ‘hunk‘@‘%‘ identified by ‘123456‘;Query OK, 0 rows affected (0.00 sec)MariaDB [mysql]> flush privileges;Query OK, 0 rows affected (0.00 sec)#mysql -uhunk -p123456 -h192.168.5.128Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 21Server version: 10.2.12-MariaDB-log Source distributionCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.MariaDB [(none)]>

CentOS 6.9 基於clang3.4 編譯安裝mariadb-10.2.12

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.