본문 바로가기
FreeBSD

FreeBSD 10.0, MariaDB 10.0 컴파일

by 이르가체페 2014. 8. 5.



1. 개요

FreeBSD 10.0-RELEASE-p7 에서 MariaDB 10은 아직 ports 지원이 안되어 소스를 다운로드받아 컴파일하여 설치한다.

xtrabackup 은 패키지에서 설치한다.

[ ~# ] pkg install -y xtrabackup


2. 파일 다운로드

아래 링크에서 mariadb-10.0.12.tar.gz 를 다운로드한다.

참고로 10.1.x는 개발버전, 10.0.10 이후부터 스테이블버전이다.

https://mariadb.com/kb/en/mariadb/development/release-notes/mariadb-10012-release-notes/


3. 설치

다운로드 받은 파일을 압축해제한다.

[ ~# ] tar xvfz mariadb-10.0.12.tar.gz

[ ~# ] ls -l

drwxr-xr-x  35 admin  1001         59  8  5 18:13 mariadb-10.0.12/

-rw-r--r--   1 root      wheel  51100726  8  5 18:06 mariadb-10.0.12.tar.gz


mariadb-10.0.12/BUILD/ 디렉토리에 보면 autorun.sh 파일 있는데, 실행하면 mariadb-10.0.12/ 에 configure 실행 스크립트가 생성된다. 

[ ~# ] cd mariadb-10.0.12/BUILD/

[ ~/mariadb-10.0.12/BUILD # ] ./autorun.sh


configure 를 실행한다.

아래는 풀옵션인데 필요에 따라 선택하면 된다.

옵션별 상세내용은 mariadb-10.0.12/BUILD/build_mccge.sh 에 있으니 참고 하면 된다.

[ ~/mariadb-10.0.12/BUILD/ # ] cd ..

[ ~/mariadb-10.0.12/ # ] ./configure --prefix=/usr/local/mysql \

--enable-assembler \

--with-extra-charsets=complex  \

--enable-thread-safe-client  \

--with-big-tables \

--with-plugin-maria \

--with-aria-tmp-tables \

--without-plugin-innodb_plugin \

--with-mysqld-ldflags=-static \

--with-client-ldflags=-static \

--with-readline \

--with-ssl \

--with-plugins=max-no-ndb \

--with-embedded-server \

--with-libevent \

--with-mysqld-ldflags=-all-static  \

--with-client-ldflags=-all-static \

--with-zlib-dir=bundled \

--enable-local-infile



빌드 시작.

시간이 오래 걸리므로 time 으로 시간을 측정해본다.

참고로 10KRPM 600GB HDD 4개를 ZFS에서 RAID6로 묶은 디스크에서 34분 소요되었다.

(FreeBSD 10.0, Xeon E5420 *2, RAM 16GB)

[ ~/mariadb-10.0.12/ # ] time make install


빌드 및 인스톨이 완료되었으니 데이터 디렉토리를 만들고 데이터디렉토리를 초기화한다.

콘솔을 많이 이용한다면 PATH에 /usrl/local/mysql/bin 을 추가해주는것이 좋다.

[ ~/ # ] mkdir /db/data

[ ~/ # ] /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/db/data



/etc/rc.conf 파일 편집

mysql_enable="YES"
mysql_limits="YES"
mysql_dbdir="/db/data"
mysql_optfile="/db/my.cnf"



첨부한 실행스크립트를 다운로드받아 해당 디렉토리로 이동 후 실행권한을 부여한다.

일단 my.cnf 기본제공되는것 복사.

MariaDB 실행.

[ ~/ # ] fetch http://withserver.tistory.com/attachment/cfile3.uf@2341494B53E18D920EB227

3E0B2401CDFD4              100% of 4289  B   16 MBps 00m00s

[ ~/ # ] mv cfile3.uf@2341494B53E18D920EB227  /usr/local/etc/rc.d/mysql-server

[ ~/ # ] chmod +x /usr/local/etc/rc.d/mysql-server

[ ~/ # ] cp /usr/local/mysql/support-files/my-innodb-heavy-4G.cnf /db/


fetch http://withserver.tistory.com/attachment/cfile9.uf@272A744653E0B2401CDFD4
mv cfile9.uf\@272A744653E0B2401CDFD4 /usr/local/etc/rc.d/mysql-server
chmod +x /usr/local/etc/rc.d/mysql-server
cp /usr/local/mysql/support-files/my-innodb-heavy-4G.cnf /db/my.cnf


mysql-server 스크립트 다운로드


mysql-server




* my.cnf 참고

메모리크기에 따라 따라 아래 링크의 설정파일을 참조 할 수 있다.



* configure 옵션
( mariadb-10.0.12/BUILD/build_mccge.sh 참조)

  This script is intended to make it easier to build

  performance-optimised MariaDB versions from source on these

  platforms/compilers: Linux/x86 (32-bit and 64-bit) (either using gcc

  or icc), Linux Itanium, Solaris 8,9,10 and 11 x86 and SPARC using

  gcc or SunStudio and MacOSX/x86/gcc.


  The script automatically detects CPU type and operating system; The

  default compiler is always gcc.


  To build on other platforms you can use the --print-only option on a

  supported platform and edit the output for a proper set of commands on

  the specific platform you are using.


  Using the --package option, it is also possible to build a "classic"

  version of MariaDB having only the MyISAM storage engine, a "Pro"

  package including all storage engines and other features except MariaDB

  Cluster, and an "extended" package including these features plus MariaDB

  Cluster (this is the default if the --developer option is used).


  Different MariaDB storage engines are included in the build, depending

  on which --package option is used. The comment and version strong

  suffix are also set according to the package selected.


  --package=pro

    storage engines:

      ARCHIVE, BLACKHOLE, CSV, FEDERATED, INNODB, MYISAM

      (All storage engines except NDB)

    comment: Pro versions

    version string suffix: [none]


  --package=classic

    storage engines: CSV, MYISAM

    comment: Version without InnoDB and Maria

    version string suffix: [none]


  All packages except Classic include support for user-defined

  partitioning. All packages include support for Performance

  Schema.


  If --with-debug is used, an additional "-debug" is appended to the

  version string.


  --with-debug[=full]

    This option will ensure that the version is built with debug

    information enabled; the optimisation level is decreased to -O.


  --developer

    This option changes a number of things to make the version built

    more appropriate to the debugging and testing needs of developers. 

    It changes the default package to "extended". It also changes the 

    default warning mode from "none" to "normal", which allows an 

    extensive list of warnings to be generated.


  --error-inject

    This flag is used only when the --developer option is also used, and

    enables error injection in both the MySQL Server and in MySQL

    Cluster data nodes.


  The following is a list of the default configure options used for all

  packages:


  --prefix: /usr/local/mysql (can be overridden)


  --libexecdir: <prefix>/bin (can be overridden)


  --localstatedir: <prefix>/data, unless --datadir is used, in which

    case it defaults to <datadir>/data (can be overridden by setting

    --localstatedir explicitly).


  --enable-local-infile: Enable use of the LOAD DATA FROM  LOCAL INFILE

    command (cannot be overridden).


  --enable-thread-safe-client: Enable the multi-threaded mysql client

    library (cannot be overridden).


  --with-big-tables: Enable use of tables with more than 4G rows (cannot  be overridden).


  --with-extra-charsets=all: Enable use of all character sets supported

    by MySQL (cannot be overridden).


  --with-ssl: Enable use of yaSSL library included in the MySQL source

    if possible (GCC and same CC and CXX).

    (cannot be overridden).


  --with-pic: Build all binaries using position independent assembler

    to avoid problems with dynamic linkers (cannot be overridden).


  --without-example-engine: Ensure that the example engine isn't built,

    it cannot do any useful things, it's merely intended as documentation.

    (cannot be overridden)


  --with-csv-storage-engine: Ensure that the CSV storage engine is

    included in all builds. Since CSV is required for log tables in

    MySQL 5.1, this option cannot be overridden.


    (Note that MyISAM support is always built into the MySQL Server; the

    server *cannot* be built without MyISAM.)


  --with-mysqld-ldflags=-static

  --with-client-ldflags=-static

    Ensures that binaries for, respectively, the MySQL server and client

    are built with static libraries except for the system libraries,

    which use dynamically loaded libraries provided by the operating

    system. Building with --developer sets these to all-static instead, 

    to build everything statically.


  In addition there are some configure options that are specific to

  Linux operating systems:


  --enable-assembler

    Include assembler code optimisations for a number of mostly string

    methods. Used for x86 processors only.


  Neither of the preceding options can be disabled.


  MySQL Cluster Carrier Grade edition also adds the following options

  (also used by the extended package):


  --with-ndbcluster

    Include the NDB Cluster storage engine, its kernel, management

    server, and client, as well as support for the NDB and MGM APIs.


  --without-ndb-debug

    Do not include specific NDB debug code, not even in debug versions

    (cannot be overridden).


  Package-specific options:

  -------------------------

  --with-innodb

    Specifically included in the "pro" package.


  --with-comment

    Sets the comment for the MySQL version, by package, as described

    above.


  --with-server-suffix

    Sets the server suffix on the MySQL version, by package, as

    described above.


  Other options used:

  -------------------

  --with-readline

    Use the GPL readline library for command editing functions.


  --with-libedit

    Use the BSD licensed library for command editing functions.


  --with-zlib-dir=bundled

    Use the zlib package bundled with MySQL.


  --with-mysqld-libs=-lmtmalloc

    Used on Solaris to ensure that the proper malloc library is used.

    Investigations have shown mtmalloc to be the best choice on Solaris,

    also umem has good performance on Solaris but better debugging

    capabilities.


  Compiler options:

  -----------------


    This section describes the compiler options for each of the different

    platforms supported by this script.


    The --fast option adds -mtune=cpu_arg to the C/C++ flags (provides

    support for Nocona, K8, and other processors), this option is valid

    when gcc is the compiler.


    Use of the --debug option adds -g to the C/C++ flags.


    In all cases it is possible to override the definition of CC and CXX

    by calling the script as follows:

    CC="/usr/local/bin/gcc" CXX="/usr/local/bin/gcc" BUILD/build_mccge.sh


  Feedback profiler on gcc

  ------------------------

  Using gcc --generate-feedback=path causes the following flags to be added

  to the compiler flags.


  --fprofile-generate

  --fprofile-dir=path


  Using gcc with --use-feedback=path causes the following flags to be added

  to the compiler flags. --fprofile-correction indicates MySQL is a multi-

  threaded application and thus counters can be inconsistent with each other

  and the compiler should take this into account.


  --fprofile-use

  --fprofile-dir=path

  --fprofile-correction


  Feedback compilation using Open64

  ---------------------------------


  Using Open64 with --generate-feedback=path causes the following flags to

  be added to the compiler flags.


  -fb-create path/feedback


  Using Open64 with --use-feedback=path causes the following flags to be

  added to the compiler flags.


  --fb-opt path/feedback


  Linux/x86+Itanium/gcc

  -------------

    For debug builds -O is used and otherwise -O3 is used.Discovery of a

    Nocona or Core 2 Duo CPU causes a 64-bit binary to be built;

    otherwise, the binary is 32-bit. To build a 64-bit binary, -m64 is

    added to the C/C++ flags. (To build a 32-bit binary on a 64-bit CPU,

    use the --32 option as described previously.)


    When gcc 4.5 is used and the user set --with-link-time-optimizer then

    also --flto is added to compiler flags and linker flags.


  Linux/x86+Itanium/icc

  -------------

    Flags used:

    CC  = icc -static-libgcc -static-intel

    C++ = icpc -static-libgcc -static-intel

    C/C++ flags = -mp -restrict


    On Itanium we also add -no-ftz and to CC and C++ flags.


    Note that if the user of this script sets CC or CXX explicitly then

    also -static-libgcc and -static-intel needs to be set in the CC and

    CXX.


    The non-debug versions also add the following:

      C/C++ flags += -O3 unroll2 -ip


    The fast version adds (if --with-link-time-optimizer is used):

      C/C++ flags += -ipo


    On discovery of a Core 2 Duo architecture while using icc, -xT is also 

    added to the C/C++ flags; this provides optimisations specific to Core 

    2 Duo. This is added only when the --fast flag is set.


  Linux/x86/Open64

  ----------------

    For normal builds use -O3, when fast flag is set one also adds

    --march=auto to generate optimized builds for the CPU used. If

    --with-link-time-optimizer is set also -ipa is set. There is also

    a special flag --with-mso which can be set to get --mso set which

    activates optimisation for multi-core scalability.


  FreeBSD/x86/gcc

  ---------------

    No flags are used. Instead, configure determines the proper flags to 

    use.


  Solaris/x86/gcc

  ---------------

    All builds on Solaris are by default 64-bit, so -m64 is always used in

    the C/C++ flags. LDFLAGS is set to -m64 -O/-O2/-O3. If for

    some reason a 32-bit Solaris is used it is necessary to add the flag

    --32 to the script invocation. Due to bugs in compiling with -O3 on

    Solaris only -O2 is used by default, when --fast flag is used -O3 will

    be used instead.


    Sets -m64 (default) or -m32 (if specifically set) in LDFLAGS and

    C/C++ flags.


  Solaris/Sparc/Forte

  -------------------

    Uses cc as CC and CC as CXX

    Note that SunStudio uses different binaries for C and C++ compilers.


    Set -m64 (default) or -m32 (if specifically set) in ASFLAGS,

    LDFLAGS and C/C++ flags.


    Sets ASFLAGS=LDFLAGS=compiler flags=xarch=sparc, so that we compile

    Sparc v9 binaries, also -mt is set in all those since we're always

    building a multithreaded program.


    C flags   = -xstrconst    This flag is set only on SPARC

    C++ flags = -noex


    Set the following C/C++ flags:

    -fsimple=1

    -ftrap=%none

    -nofstore          This flag is set only on x86

    -xbuiltin=%all

    -xlibmil

    -xlibmopt


    Set the C++ flag:

    -noex

    -features=no%except    This flag is set only on x86


    When compiling with fast we set (-ipo only used if we have

    set --with-link-time-optimizer):

    C/C++ flags: -xtarget=native -xunroll=3 -xipo

    LDFLAGS: -xipo


    When not compiling with fast we always set -xtarget=generic


    When compiling with fast on SPARC we also set:

    C/C++ flags: -xbinopt=prepare

    LDFLAGS: -xbinopt=prepare


    When compiling with fast on x86 we also set:

    C/C++ flags: -xregs=frameptr

    When not compiling with fast we set on x86

    C/C++ flags: -xregs=no%frameptr


    On SPARC we set

    ASFLAGS = LDFLAGS = C/C++ flags = -xarch=sparc


    The optimisation level is

    -xO         Debug builds

    -xO2        Production build on SPARC

    -xO3        Production build on x86

    -xO4        Fast builds on SPARC/x86


  MacOSX/x86/gcc

  --------------

    C/C++ flags include -fno-common -arch i386.

    When 64-bits builds then i386 is replaced by x86_64.


    Non-debug versions also add -Os -felide-constructors, where "-Os"

    means the build is space-optimised as long as the space optimisations

    do not negatively affect performance. Debug versions use -O.

  

    Mac OS X builds will always be 32-bit by default, when --64 is added

    the build will be 64 bit instead. Thus the flag --m64 is added only

    when specifically given as an option.

EOF

}


with_usage()

{

  cat <<EOF


  To obtain extended help on the --with-* options available, run this

  script with --configure-only to create a configuration file. Then

  issue the command ./configure --help to get an extensive list of

  possible configure options.


  The remainder of this text focuses on those options which are useful

  in building binaries for MySQL Cluster Carrier Grade Edition.


  --with-ndb-sci=/opt/DIS

    Used to build a MySQL Cluster Carrier Grade Edition that can use the

    SCI Transporter. The Dolphin SCI installation must be completed

    first (see 

    http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-interconnects.html

    for more information).


  --with-ndb-test

    Compile the MySQL Cluster test programs.


  --with-ndb-port=PORT

    Change the default port for the MySQL Cluster management server.


  --with-ndb-port-base=PORT

    Change the default port base for MySQL Cluster data nodes.


  --without-query-cache

    Build the MySQL Server without the query cache, which is often not

    of value in MySQL Cluster applications.


  --with-atomic-ops=rwlocks|smp|up

                          Implement atomic operations using pthread

                          rwlocks or atomic CPU instructions for

                          multi-processor (default) or single-processor

                          configurations.


  --without-geometry      Do not build geometry-related portions of the

                          MySQL Server. Seldom used in MySQL Cluster

                          applications.


  --with-ndb-cc-flags=FLAGS

    This option can be used to build MySQL Cluster with error injection

    on the data nodes. It can be used to pass special options to

    programs in the NDB kernel for special test builds.

    The option for enabling data node error injection is -DERROR_INSERT.





반응형

'FreeBSD' 카테고리의 다른 글

freebsd 서버(파티션)이전  (0) 2014.11.07
V2P/P2V 시 파티션 크기조절  (0) 2014.09.12
FreeBSD 시스템정보 확인  (0) 2014.02.11
ZFS 디스크 복구방법 (FreeBSD)  (0) 2013.09.11
ZFS Tuning Guide  (0) 2013.08.30

댓글