您正在查看: Other 分类下的文章

Ubuntu16.04下修改MySQL数据的默认存储位置

1.关闭 mysql 服务

/etc/init.d/mysql stop

2.创建新的数据库路径:

mkdir -p /mnt/mysql

3.复制MySQL原有的数据

cp -R /var/lib/mysql/* /mnt/mysql

4.修改权限

chown -R mysql:mysql /mnt/mysql

5.修改配置文件夹

    vi /etc/mysql/mysql.conf.d/mysqld.cnf

    //将 [mysqld] 组下的 datadir改为:
    datadir = /mnt/mysql

6.修改启动文件

    vi /etc/apparmor.d/usr.sbin.mysqld 

    把  
    /var/lib/mysql r  
    /var/lib/mysql/** rwk  
    修改成  
    /mnt/mysql r  
    /mnt/mysql/** rwk,  

7.重启服务

/etc/init.d/apparmor restart
/etc/init.d/mysql restart

参考原文

ubuntu npm 升级到新版

sudo apt-get remove nodejs ^node-* nodejs-*
sudo apt-get autoremove
sudo apt-get clean
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs

Ubuntu 安装 Mongodb 3+

方式一:从apt-get安装

  1. 添加mongodb签名到APT
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
  2. 创建/etc/apt/sources.list.d/mongodb-org-3.2.list文件并写入命令
    echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
  3. 更新软件源列表
    sudo apt-get update
  4. 安装mongodb(默认是安装稳定版)
    sudo apt-get install -y mongodb-org

    或者安装指定版本:

    sudo apt-get install -y mongodb-org=3.2.9 mongodb-org-server=3.2.9 mongodb-org-shell=3.2.9 mongodb-org-mongos=3.2.9 mongodb-org-tools=3.2.9

方式二:从 .tar.gz 二进制包安装

  1. 下载最新安装包
    官网下载地址:https://www.mongodb.com/download-center?jmp=nav#community.
    curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.2.9.tgz
  2. 解压
    tar -zxvf mongodb-linux-x86_64-ubuntu1404-3.2.9.tgz
  3. 重命名并移动到安装目录(可自定义)
    sudo mv mongodb-linux-x86_64-3.0.6/ /usr/local/mongodb   # 将解压包拷贝到指定目录进行安装
  4. 创建 mongo 的数据目录
    MongoDB 默认的数据目录是 /data/db/ ,就直接使用默认的。
    sudo mkdir -p /data/db    #创建数据存储目录
    sudo chmod 755 /data/*    #赋予目录权限
  5. 启动
    mongod    #启动服务端
    mongo    #启动客户端

    配置MongoDB

    控制的配置文件在:/etc/mongodb.conf
    控制脚本在:/etc/init.d/mongodb
    MongoDB实例会把数据存放在:/var/lib/mongodb
    日志存放在:/var/log/mongodb
    默认由mongodb用户运行。
    如果如果显示目录不存在的话,需要运行下列命令指定文件夹:

    mongod --dbpath /var/lib/mongodb

    如果想要切换用户运行MongoDB的话,需要设置 /var/lib/mongodb 、 /var/log/mongodb两个目录的权限

    启动、停止、重启

    sudo service mongodb start
    sudo service mongodb stop
    sudo service mongodb restart

    通过mongodb shell测试安装结果

    mongodb

卸载MongoDB

  1. 停止MongoDB
    sudo service mongod stop
  2. 移除包文件
    sudo apt-get purge mongodb-org*
  3. 删除存放数据的目录
    sudo rm -r /var/log/mongodbsudo rm -r /var/lib/mongodb

    参考文档

    MongoDB官方文档:https://docs.mongodb.com/getting-started/shell/tutorial/install-mongodb-on-ubuntu/
    Ubuntu下MongoDB 安装教程及简单操作:http://www.linuxidc.com/Linux/2016-07/133254.htm

Ubuntu 切换 PHP 版本

PHP5.6 -> 7.0

# 禁用 Apache 中的 PHP5

sudo a2dismod php5.6

# 启用 PHP7

sudo a2enmod php7

# 重启 Apache

sudo systemctl restart apache2.service



# 切换 CLI 

sudo update-alternatives --set php /usr/bin/php7.0

Failed to find shared library for backend ”mysql

编译好sql_db_plugin后启动nodeos

root@iZ2zea5mjpcmz9m17k56daZ:/home/surou/Documents/github/eos/build# nodeos --sql_db-uri=”mysql://db=eos user=root host=127.0.0.1 password='数据库密码' --sql_db-block-start=0  --delete-all-blocks
2018-07-25T12:39:28.628 thread-0   sql_db_plugin.cpp:81          set_program_options  ] set_program_options
2018-07-25T12:39:28.629 thread-0   chain_plugin.cpp:271          plugin_initialize    ] initializing chain plugin
2018-07-25T12:39:28.629 thread-0   chain_plugin.cpp:408          plugin_initialize    ] Deleting state database and blocks
2018-07-25T12:39:28.721 thread-0   chain_plugin.cpp:508          plugin_initialize    ] Starting up fresh blockchain with default genesis state.
2018-07-25T12:39:29.437 thread-0   http_plugin.cpp:344           plugin_initialize    ] configured http to listen on 127.0.0.1:8888
2018-07-25T12:39:29.437 thread-0   net_plugin.cpp:2941           plugin_initialize    ] Initialize net plugin
2018-07-25T12:39:29.437 thread-0   net_plugin.cpp:2966           plugin_initialize    ] host: 0.0.0.0 port: 9876 
2018-07-25T12:39:29.437 thread-0   net_plugin.cpp:3036           plugin_initialize    ] my node_id is e5f1d9687a24d343c57e7ba32913db448147a2e9e7dc1fe12797a69c082e1c9a
2018-07-25T12:39:29.437 thread-0   wallet_plugin.cpp:42          plugin_initialize    ] initializing wallet plugin
2018-07-25T12:39:29.437 thread-0   sql_db_plugin.cpp:96          plugin_initialize    ] initialize
2018-07-25T12:39:29.437 thread-0   sql_db_plugin.cpp:104         plugin_initialize    ] connecting to ”mysql://db=eos
2018-07-25T12:39:29.438 thread-0   main.cpp:141                  main                 ] Failed to find shared library for backend ”mysql

Failed to find shared library for backend ”mysql 错误。
查看EOS代码 eos\programs\nodeos\main.cpp:141

   } catch( const std::runtime_error& e ) {
      if( std::string(e.what()) == "database dirty flag set" ) {
         elog( "database dirty flag set (likely due to unclean shutdown): replay required" );
         return DATABASE_DIRTY;
      } else if( std::string(e.what()) == "database metadata dirty flag set" ) {
         elog( "database metadata dirty flag set (likely due to unclean shutdown): replay required" );
         return DATABASE_DIRTY;
      } else {
         elog( "${e}", ("e",e.what())); // :141
      }
      return OTHER_FAIL;
   } catch( const std::exception& e ) {

应该出在sql_db_plugin中的soci连接中
下载soci源代码

git clone https://github.com/SOCI/soci.git

查看错误出现在

// non-synchronized helper
void do_register_backend(std::string const & name, std::string const & shared_object)
{
    // The rules for backend search are as follows:
    // - if the shared_object is given,
    //   it names the library file and the search paths are not used
    // - otherwise (shared_object not provided or empty):
    //   - file named libsoci_NAME.so.SOVERSION is searched in the list of search paths

    soci_handler_t h = 0;
    if (shared_object.empty() == false)
    {
        h = DLOPEN(shared_object.c_str());
    }
    else
    {
        // try system paths
        h = DLOPEN(LIBNAME(name).c_str());
        if (0 == h)
        {
            // try all search paths
            for (std::size_t i = 0; i != search_paths_.size(); ++i)
            {
                std::string const fullFileName(search_paths_[i] + "/" + LIBNAME(name));
                h = DLOPEN(fullFileName.c_str());
                if (0 != h)
                {
                    // already found
                    break;
                }
             }
         }
    }

    if (0 == h)
    {
        throw soci_error("Failed to find shared library for backend " + name);
    }

发现刚才出现此问题是因为输入的参数符号错误导致,问题停止跟进,以后在遇到类似的再跟进....