CentOS7下安装AliSQL

1. 安装CentOS7, 可以选择U盘安装。

1.1 下载ios镜像。

1.2 安装最新版的ultraISO

1.3 ultraISO 启动->写入硬盘映像...

1.4 电脑U盘安装,注意选择U盘启动。

一般会出错,如果出错后出现提示符dracut:/# ,这时可以执行ls /dev 看一下U盘的盘符,如果一般sda表示电脑硬盘,sdb表示U盘。

dracut:/# ls /dev

然后修改默认的命令,有的是按Tab键,有的是按e键,自己看提示信息。
原命令:

>vmlinuz initrd=initrd.imginst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet

修改为:

>vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdb4 quiet

然后执行,有的是按回车键,我的执行时按ctrl+x;还是看屏幕上的提示信息。如果你电脑安装了2盘硬盘,U盘会是sdc,命令就是>vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdc4 quiet

2、安装编译环境

因为AliSQL提供的是源码,所有需要自己编译。准备最新版的gc++ 还有git吧,cmake是为了执行配置命令,git是为了从github上下载AliSQL。安装完,将新安装的devtoolset-4 启用。

2.1

yum install centos-release-scl -y
yum install devtoolset-4-gcc-c++ devtoolset-4-gcc -y
yum install cmake -y
yum install git -y
yum install openssl-devel 
yum install bison -y
yum install ncurses-devel -y
scl enable devtoolset-4 bash

2.2 下载AliSQL

因为github下面的二级域名DNS解析有问题,下载速度很慢。修改host文件可以加速下载。因为需要下载的文件数量超级多,可以下载压缩包后解压。
下载完,或者解压后切换到AliSQL目录中,

git clone https://github.com/alibaba/AliSQL.git
cd AliSQL

2.3 编译AliSQL, 需要先设置cmake变量

[root@localhost AliSQL]# ls
BUILD                    CTestTestfile.cmake   make_dist.cmake   sql
client                   dbug                  Makefile          sql-bench
cmake                    Docs                  man               sql-common
CMakeCache.txt           Doxyfile-perfschema   mysql-test        storage
CMakeFiles               extra                 mysys             strings
cmake_install.cmake      include               mysys_ssl         support-files
CMakeLists.txt           info_macros.cmake     packaging         tests
cmd-line-utils           INSTALL               plugin            unittest
config.h.cmake           install_manifest.txt  README            VERSION
configure.cmake          libevent              README.md         VERSION.dep
COPYING                  libmysql              regex             vio
CPackConfig.cmake        libmysqld             scripts           win
CPackSourceConfig.cmake  libservices           source_downloads  zlib
[root@localhost AliSQL]# cmake .                              \
>  -DCMAKE_BUILD_TYPE="Release"         \
>  -DCMAKE_INSTALL_PREFIX="/opt/alisql" \
>  -DWITH_EMBEDDED_SERVER=0             \
>  -DWITH_EXTRA_CHARSETS=all            \
>  -DWITH_MYISAM_STORAGE_ENGINE=1       \
>  -DWITH_INNOBASE_STORAGE_ENGINE=1     \
>  -DWITH_PARTITION_STORAGE_ENGINE=1    \
>  -DWITH_CSV_STORAGE_ENGINE=1          \
>  -DWITH_ARCHIVE_STORAGE_ENGINE=1      \
>  -DWITH_BLACKHOLE_STORAGE_ENGINE=1    \
>  -DWITH_FEDERATED_STORAGE_ENGINE=1    \
>  -DWITH_PERFSCHEMA_STORAGE_ENGINE=1   \
>  -DWITH_TOKUDB_STORAGE_ENGINE=1

-DCMAKE_INSTALL_PREFIX="/opt/alisql" 指定了安装位置。

make -j4 && make install

-j4 表示使用4个并发进程

2.4 添加mysql用户

useradd --help可以查看一下命令的用法

[root@localhost AliSQL]# useradd --help
Usage: useradd [options] LOGIN
       useradd -D
       useradd -D [options]

Options:
  -b, --base-dir BASE_DIR       base directory for the home directory of the   

[root@localhost AliSQL]# groupadd mysql
[root@localhost AliSQL]# useradd -M -s /sbin/nologin -g mysql -r mysql
[root@localhost AliSQL]# mkdir -p /data/alisqldb


2.5 修改数据库文件夹的所有者,初始化数据库

查看数据库文件夹位置:

[root@localhost ~]# find / -name alisql
find: ‘/run/user/1000/gvfs’: Permission denied
/opt/alisql
[root@localhost ~]# ls /opt/alisql/
bin      docs     man         README.md      share
COPYING  include  mysql-test  README-TOKUDB  sql-bench
data     lib      README      scripts        support-files
[root@localhost ~]# cd /opt/alisql/scripts/
[root@localhost scripts]# ls
mysql_install_db

添加用户,并初始化数据库

2.6

[root@localhost scripts]# chown -R mysql:mysql /opt/alisql/
[root@localhost scripts]# chown -R mysql:mysql /data/alisqldb/
[root@localhost scripts]# [root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/opt/alisql --datadir=/usr/alisql

2.7 初始化数据库会报错

因为页面管理选项transparent huge pages 开启,根据提示关闭。关闭的命令在()内给出了提示:
echo never > /sys/kernel/mm/transparent_hugepage/enabled

2017-09-14 05:37:16 9582 [ERROR] TokuDB will not run with transparent huge pages enabled.        
2017-09-14 05:37:16 9582 [ERROR] Please disable them to continue.                            
2017-09-14 05:37:16 9582 [ERROR] (echo never > /sys/kernel/mm/transparent_hugepage/enabled)  

完整信息:

[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/opt/alisql --datadir=/usr/alisql
Installing MySQL system tables...2017-09-14 05:37:16 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-14 05:37:16 0 [Note] /opt/alisql/bin/mysqld (mysqld 5.6.32) starting as process 9582 ...
Transparent huge pages are enabled, according to /sys/kernel/mm/transparent_hugepage/enabled
2017-09-14 05:37:16 9582 [ERROR] TokuDB: Huge pages are enabled, disable them before continuing

2017-09-14 05:37:16 9582 [ERROR] ************************************************************
2017-09-14 05:37:16 9582 [ERROR]                                                             
2017-09-14 05:37:16 9582 [ERROR]                         @@@@@@@@@@@                         
2017-09-14 05:37:16 9582 [ERROR]                       @@'         '@@                       
2017-09-14 05:37:16 9582 [ERROR]                      @@    _     _  @@                      
2017-09-14 05:37:16 9582 [ERROR]                      |    (.)   (.)  |                      
2017-09-14 05:37:16 9582 [ERROR]                      |             ` |                      
2017-09-14 05:37:16 9582 [ERROR]                      |        >    ' |                      
2017-09-14 05:37:16 9582 [ERROR]                      |     .----.    |                      
2017-09-14 05:37:16 9582 [ERROR]                      ..   |.----.|  ..                      
2017-09-14 05:37:16 9582 [ERROR]                       ..  '      ' ..                       
2017-09-14 05:37:16 9582 [ERROR]                         .._______,.                         
2017-09-14 05:37:16 9582 [ERROR]                                                             
2017-09-14 05:37:16 9582 [ERROR] TokuDB will not run with transparent huge pages enabled.        
2017-09-14 05:37:16 9582 [ERROR] Please disable them to continue.                            
2017-09-14 05:37:16 9582 [ERROR] (echo never > /sys/kernel/mm/transparent_hugepage/enabled)  
2017-09-14 05:37:16 9582 [ERROR]                                                             
2017-09-14 05:37:16 9582 [ERROR] ************************************************************
2017-09-14 05:37:16 9582 [ERROR] Plugin 'TokuDB' init function returned error.
2017-09-14 05:37:16 9582 [ERROR] Plugin 'TokuDB' registration as a STORAGE ENGINE failed.

执行关闭透明大页面后重新初始化,成功

[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/opt/alisql --datadir=/usr/alisql
Installing MySQL system tables...2017-09-14 06:27:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-14 06:27:41 0 [Note] /opt/alisql/bin/mysqld (mysqld 5.6.32) starting as process 10685 ...
2017-09-14 06:27:41 10685 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-09-14 06:27:41 10685 [Note] InnoDB: The InnoDB memory heap is disabled
2017-09-14 06:27:41 10685 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-09-14 06:27:41 10685 [Note] InnoDB: Memory barrier is not used
2017-09-14 06:27:41 10685 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-09-14 06:27:41 10685 [Note] InnoDB: Using CPU crc32 instructions
2017-09-14 06:27:41 10685 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-09-14 06:27:41 10685 [Note] InnoDB: Completed initialization of buffer pool
2017-09-14 06:27:41 10685 [Note] InnoDB: Highest supported file format is Barracuda.
2017-09-14 06:27:41 10685 [Note] InnoDB: 128 rollback segment(s) are active.
2017-09-14 06:27:41 10685 [Note] InnoDB: Waiting for purge to start
2017-09-14 06:27:41 10685 [Note] InnoDB: 5.6.32 started; log sequence number 1600607
2017-09-14 06:27:41 10685 [Note] Binlog end
2017-09-14 06:27:41 10685 [Note] InnoDB: FTS optimize thread exiting.
2017-09-14 06:27:41 10685 [Note] InnoDB: Starting shutdown...
2017-09-14 06:27:42 10685 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

Filling help tables...2017-09-14 06:27:43 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-14 06:27:43 0 [Note] /opt/alisql/bin/mysqld (mysqld 5.6.32) starting as process 10726 ...
2017-09-14 06:27:43 10726 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-09-14 06:27:43 10726 [Note] InnoDB: The InnoDB memory heap is disabled
2017-09-14 06:27:43 10726 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-09-14 06:27:43 10726 [Note] InnoDB: Memory barrier is not used
2017-09-14 06:27:43 10726 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-09-14 06:27:43 10726 [Note] InnoDB: Using CPU crc32 instructions
2017-09-14 06:27:43 10726 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-09-14 06:27:43 10726 [Note] InnoDB: Completed initialization of buffer pool
2017-09-14 06:27:43 10726 [Note] InnoDB: Highest supported file format is Barracuda.
2017-09-14 06:27:43 10726 [Note] InnoDB: 128 rollback segment(s) are active.
2017-09-14 06:27:43 10726 [Note] InnoDB: Waiting for purge to start
2017-09-14 06:27:43 10726 [Note] InnoDB: 5.6.32 started; log sequence number 1625987
2017-09-14 06:27:43 10726 [Note] Binlog end
2017-09-14 06:27:43 10726 [Note] InnoDB: FTS optimize thread exiting.
2017-09-14 06:27:43 10726 [Note] InnoDB: Starting shutdown...
2017-09-14 06:27:44 10726 [Note] InnoDB: Shutdown completed; log sequence number 1625997
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /opt/alisql/bin/mysqladmin -u root password 'new-password'
  /opt/alisql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

  /opt/alisql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /opt/alisql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /opt/alisql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /opt/alisql/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

[root@localhost scripts]# 

2.7 启动数据库

启动配置文件为/etc/my.cnf,根据实际情况编辑文件,主要是数据文件位置等信息,然后启动数据库。
加上客户端选项:

[mysqld]
datadir=xxx
socket=xxx
[client]
socket=xxx
[root@localhost bin]# ./mysqld --user=mysql
2017-09-14 22:57:37 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-14 22:57:37 0 [Note] ./mysqld (mysqld 5.6.32) starting as process 7777 ...
2017-09-14 22:57:37 7777 [Note] Plugin 'FEDERATED' is disabled.
2017-09-14 22:57:38 7777 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-09-14 22:57:38 7777 [Note] InnoDB: The InnoDB memory heap is disabled
2017-09-14 22:57:38 7777 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-09-14 22:57:38 7777 [Note] InnoDB: Memory barrier is not used
2017-09-14 22:57:38 7777 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-09-14 22:57:38 7777 [Note] InnoDB: Using CPU crc32 instructions
2017-09-14 22:57:38 7777 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-09-14 22:57:38 7777 [Note] InnoDB: Completed initialization of buffer pool
2017-09-14 22:57:38 7777 [Note] InnoDB: Highest supported file format is Barracuda.
2017-09-14 22:57:38 7777 [Note] InnoDB: 128 rollback segment(s) are active.
2017-09-14 22:57:38 7777 [Note] InnoDB: Waiting for purge to start
2017-09-14 22:57:38 7777 [Note] InnoDB: 5.6.32 started; log sequence number 1626007
2017-09-14 22:57:38 7777 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a1e8fdc7-99c1-11e7-82d0-4851b730248d.
2017-09-14 22:57:38 7777 [Note] Server hostname (bind-address): '*'; port: 3306
2017-09-14 22:57:38 7777 [Note] IPv6 is available.
2017-09-14 22:57:38 7777 [Note]   - '::' resolves to '::';
2017-09-14 22:57:38 7777 [Note] Server socket created on IP: '::'.
2017-09-14 22:57:38 7777 [Note] Event Scheduler: Loaded 0 events
2017-09-14 22:57:38 7777 [Note] [RDS Diagnose] ./mysqld is using 'bundled jemalloc' malloc library
2017-09-14 22:57:38 7777 [Note] ./mysqld: ready for connections.
Version: '5.6.32'  socket: '/usr/alisql/mysql.sock'  port: 3306  Source distribution

2.8 以服务的方式启动数据库,并且开机自启动:

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

启动AliSQL服务并加入开机自启动(可选)

 service mysqld start
chkconfig --level 35 mysqld on

2.9 用户初始化密码及登录数据库

./bin/mysqladmin -u root password 'new-password' 
./bin/mysqladmin -u root -h data05 password 'new-password'

mysql -u root -p 

That's all

你可能感兴趣的:(CentOS7下安装AliSQL)