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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,717评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,501评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,311评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,417评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,500评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,538评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,557评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,310评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,759评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,065评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,233评论 1 343
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,909评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,548评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,172评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,420评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,103评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,098评论 2 352

推荐阅读更多精彩内容

  • Ubuntu的发音 Ubuntu,源于非洲祖鲁人和科萨人的语言,发作 oo-boon-too 的音。了解发音是有意...
    萤火虫de梦阅读 99,233评论 9 467
  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 12,156评论 2 33
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 171,980评论 25 707
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,646评论 18 139
  • 刚刚结束的这个春节假期,人们依旧在微信眼花缭乱的群里或是一对一的发了、收了N个红包。 我也脱离不了事俗,虽下载了个...
    木木辰辰阅读 355评论 0 1