MYSQL 5.6.27原始碼安裝

G8bao7發表於2015-11-06
1、需要安裝的工具
# gcc、make、cmake
# 5.6 gcc 41, cmake 2.6.3
yum install -y gcc make cmake
2)mysql依賴包支援語法分析的bison庫和終端類GUI支援ncurses
yum install -y  bison*
yum install -y ncurses*
yum install -y libaio

2、tcmalloc
### depend
# libunwind-1.1.tar.gz
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install

### tcmalloc  
./configure --enable-minimal --disable-cpu-profiler --disable-heap-profiler --disable-heap-checker --disable-debugalloc
make && make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig

### ERROR
# /usr/bin/ld: cannot find -ltcmalloc
ln -s /usr/local/lib/libtcmalloc_minimal.so /usr/lib/libtcmalloc.so

3、install
# 建立安裝目錄
mkdir /usr/local/mysql

# 清除
make clean

# 檢視支援的配置項 http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
# 預設包含的引擎:MyISAM, MERGE, MEMORY, and CSV 
cmake . -LH | more

# normal
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/my5627 \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci 

# LOAD DATA INFILE, 0 disable DEFAULT, 1 enable
-DENABLED_LOCAL_INFILE=1 

# with tcmalloc
-DCMAKE_EXE_LINKER_FLAGS="-ltcmalloc" -DWITH_SAFEMALLOC=OFF

# make
#加快編譯速度,使用多核並行編譯,即8為計算的核的個數
make -j 8 
make install

4、 Create a mysql User and Group
groupadd mysql
# the -r option to create a user that does not have login permissions to your server host
useradd -r -g mysql mysql

5、初始化
/usr/local/mysql/my5627/scripts/mysql_install_db --no-defaults --user=mysql --basedir=/usr/local/mysql/my5627  --datadir=/usr/local/mysql/my5627/data

6、建立 /usr/local/mysql/my5627/cnf/my.cnf
[mysqld]
datadir=/usr/local/mysql/my5627/data
socket=/tmp/mysql5627.sock3306
port=3306
user=mysql

7、啟動
# mysqld_safe
/usr/local/mysql/my5627/bin/mysqld_safe --defaults-file=/usr/local/mysql/my5627/cnf/my.cnf &

8、配置mysql服務
# 單例項
cp /usr/local/mysql/my5627/support-files/mysql.server /etc/init.d/mysqld5627
chkconfig --add mysqld5627
chkconfig mysqld5627 on

9、設定root密碼
# 由於 mysql_secure_installation 不能設定socket,只能做個軟連結
ln -s /tmp/mysql5627.sock3306 /tmp/mysql.sock
/usr/local/mysql/my5627/bin/mysql_secure_installation

### 編譯到 /usr/local/mysql_5629路徑
# mysqld_multi.server 修改
--
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
++
basedir=/usr/local/mysql_5629
bindir=$basedir/bin

#
--
$opt_mysqladmin    = "/usr/local/mysql_5629/bin/mysqladmin";
$opt_mysqld        = "/usr/local/mysql_5629/bin/mysqld";

++
push @defaults_options, "-s";
$opt_path          = "/usr/local/mysql_5629";
$default_file      = "$opt_path/my.cnf";
$opt_mysqladmin    = "$opt_path/bin/mysqladmin";
$opt_mysqld        = "$opt_path/bin/mysqld";


sub defaults_for_group{
--
my $com= join ' ', 'my_print_defaults',  @defaults_options, $group;
++
my $com= join ' ', 'my_print_defaults', " --defaults-file=$default_file ", @defaults_options, $group;
}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26250550/viewspace-1824836/,如需轉載,請註明出處,否則將追究法律責任。

相關文章