码迷,mamicode.com
首页 > 数据库 > 详细

centos7配置mariadb

时间:2018-05-23 02:13:32      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:centos7配置mariadb

一、安装及配置:
  1. 下载mariadb:
    yum -y install mariadb-server mariadb
  2. 开启mariadb服务:
    systemctl start mariadb
  3. 无密码登录mariadb:
    mysql
  4. 查看用户表:
    select * from mysql.user\G
  5. 添加远程访问用户:
    grant all on *.* to ‘root‘@‘%‘ identified by ‘123456‘
  6. 设置添加用户的授权权限:
    update mysql.user set Grant_priv=‘Y‘ where Host=‘%‘
  7. 移除匿名用户:
    delete from mysql.user where Host<>‘%‘ or User<>‘root‘
  8. 退出mariadb命令行:
    quit
  9. 重启mariadb:
    systemctl restart mariadb

    二、主从复制:

  10. 服务器列表:
    角色                ip地址
    主服务器         192.168.8.81
    从服务器         192.168.8.82
  11. 主服务器的配置(192.168.8.81):
    a. 配置:
    vim /etc/my.cnf
    技术分享图片
    b. 重启:
    systemctl  restart  mariadb
  12. 从服务器配置(192.168.8.82):
    a. 配置:
    vim /etc/my.cnf
    技术分享图片
    b. 重启:
    systemctl  restart  mariadb
  13. 主服务器设置(192.168.8.81):
    a. 进入命令行:
    技术分享图片
    b. 查看状态:
    技术分享图片
  14. 从服务器设置(192.168.8.82):
    a. 进入命令行:
    技术分享图片
    b. 配置:
    技术分享图片
    c. 开启:
    技术分享图片
    d. 查看状态:
    技术分享图片
  15. 测试:
    a. 主:
    技术分享图片
    b. 从:
    技术分享图片

    三、coreseek(sphinx):

  16. 安装依赖:
    yum  -y  install  make  gcc  gcc-c++  libtool  autoconf  automake  imake  mariadb  mariadb-server  mariadb-devel libxml2-devel expat-devel
  17. 下载软件包:
    a. 克隆:
    git  clone  https://github.com/dollarphper/soft.git

    b. 进入目录:

    cd  soft
  18. 解压缩:
    tar  -xzf  coreseek-4.1-beta.tar.gz
  19. 安装mmseg:
    a. 进入目录:
    cd  coreseek-4.1-beta/mmseg-3.2.14/

    b. 安装:

    ./bootstrap
    ./configure --prefix=/usr/local/mmseg3
    make && make install
  20. 安装coreseek:
    a. 进入目录:
    cd  ../csft-4.1

    b. 修改配置文件:
    vim configure.ac

    将
    AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    修改为
    AM_INIT_AUTOMAKE([-Wall foreign])

    c. 下载软件:

    yum  -y  install  patch

    d. 打补丁:

    patch  -p1  <  /home/lee/sphinx/sphinxexpr.cpp-csft-4.1-beta.patch
    输入:
    /home/lee/sphinx/coreseek-4.1-beta/csft-4.1/src/sphinxexpr.cpp

    技术分享图片
    e. 安装:

    sh  buildconf.sh
    ./configure  --prefix=/usr/local/coreseek  --without-unixodbc  --with-mmseg  --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/  --with-mmseg-libs=/usr/local/mmseg3/lib/  --with-mysql
    make  &&  make install
  21. 测试:
    a. 进入测试目录:
    cd  ../testpack/

    b. 查看测试文件:

    cat  var/test/test.xml

    技术分享图片
    c. 测试中文分词:

    /usr/local/mmseg3/bin/mmseg  -d  /usr/local/mmseg3/etc var/test/test.xml

    技术分享图片
    d. 创建索引:

    /usr/local/coreseek/bin/indexer  -c  etc/csft.conf  --all

    技术分享图片
    e. 搜索测试:

    /usr/local/coreseek/bin/search  -c  etc/csft.conf  李彦宏

    技术分享图片

  22. php连接sphinx:
    a. 安装扩展:
    a-1. 进入目录:
    cd  ../csft-4.1/api/libsphinxclient/

    a-2. 编译:

    aclocal
    libtoolize --force
    automake --add-missing
    autoconf
    autoheader
    make clean
    ./configure  --prefix=/usr/local/sphinxclient
    make  &&  make install

    a-3. 回到软件包目录:

    cd  ../../../../

    a-4. 解压:

    tar  -xzf  sphinx-1.3.0.tgz

    a-5. 安装php-devel:

    yum  -y  install  php  php-devel

    a-6. 进入目录:

    cd  sphinx-1.3.0

    a-7. 安装:

    phpize
    ./configure --with-php-config=/usr/bin/php-config --with-sphinx=/usr/local/sphinxclient
    make && make install

    a-8. 开启php-sphinx扩展:
    vim /etc/php.ini

    在末尾加上:
    [sphinx]
    extension=sphinx.so

    b. 测试:
    b-1. 启动mariadb服务:

    systemctl  start  mariadb

    b-2. 添加测试数据:

    mysql  -uroot  -p123456  <  /usr/local/coreseek/etc/example.sql

    b-3. 复制配置文件:

    cp  /usr/local/coreseek/etc/sphinx.conf.dist  /usr/local/coreseek/etc/csft.conf
    cp  /home/lee/sphinx/coreseek-4.1-beta/mmseg-3.2.14/data/*  /usr/local/mmseg3/etc/

    b-4. 修改配置文件:
    vim /usr/local/coreseek/etc/csft.conf

    source src1
    {
    type            = mysql
    sql_host        = localhost
    sql_user        = root
    sql_pass        = 123456
    sql_db          = test
    sql_port        = 3306  # optional, default is 3306
    sql_query_pre = SET NAMES utf8
    sql_sock = /var/lib/mysql/mysql.sock
    sql_query       =     SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content     FROM documents
    sql_attr_uint       = group_id
    sql_attr_timestamp  = date_added
    sql_ranged_throttle = 0
    sql_query_info_pre = SET NAMES utf8
    sql_query_info      = SELECT * FROM documents WHERE id=$id
    }
    source src1throttled : src1
    {
    sql_ranged_throttle = 100
    }
    index test1
    {
    source          = src1
    path            = /usr/local/coreseek/var/data/test1
    docinfo         = extern
    mlock           = 0
    morphology      = none
    min_word_len        = 1
    html_strip      = 0
    charset_dictpath = /usr/local/mmseg3/etc/
    charset_type        = zh_cn.utf-8
    }
    indexer
    {
    mem_limit       = 128M
    }
    searchd
    {
    listen          = 9312
    listen          = 9306:mysql41
    log         = /usr/local/coreseek/var/log/searchd.log
    query_log       = /usr/local/coreseek/var/log/query.log
    read_timeout        = 5
    client_timeout      = 300
    max_children        = 30
    pid_file        = /usr/local/coreseek/var/log/searchd.pid
    max_matches     = 1000
    seamless_rotate     = 1
    preopen_indexes     = 1
    unlink_old      = 1
    mva_updates_pool    = 1M
    max_packet_size     = 8M
    max_filters     = 256
    max_filter_values   = 4096
    max_batch_queries   = 32
    workers         = threads # for RT to work
    }

    b-5. :复制二进制文件:

    cp  /usr/local/coreseek/bin/*  /usr/bin/

    b-6. 生成索引:

    indexer  --rotate  --all

    b-7. 启动服务:

    searchd

    b-8. 停止服务:

    searchd  --stop

    b-9. 测试:
    b-9-1. 编写测试脚本:
    vim test.php

    <?php
    $sphinx = new SphinxClient();
    $sphinx->SetServer("127.0.0.1",9312);
    $sphinx->SetMatchMode(SPH_MATCH_ALL);
    $sphinx->SetLimits(0, 20, 1000);
    $sphinx->SetArrayResult(true);
    $result = $sphinx -> query("one","test1");
    var_dump($result);

    b-9-2. 运行脚本:
    php test.php
    技术分享图片

    四、

centos7配置mariadb

标签:centos7配置mariadb

原文地址:http://blog.51cto.com/12173069/2119307

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!