【Linux运维入门】安装sonar报错:JDBCError: Specified key was too long;

安装完SonarQ ube后,输入网址http://192.168.xx.xxx:9000 可以访问Sonar的页面。但是我却出现了一个问题:

错误一:

org.jruby.rack.RackInitializationException: An error has occurred, all later migrations canceled:

ActiveRecord::JDBCError: Specified key was too long; max key length is 1000 bytes: CREATE UNIQUE INDEX `rules_repo_key` ON `rules` (`plugin_rule_key`, `plugin_name`)
    from /usr/local/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'

    from /usr/local/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401:in `up'
    from /usr/local/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383:in `migrate'
. 
.
.

ActiveRecord::JDBCError: Specified key was too long; max key length is 1000 bytes: CREATE UNIQUE INDEX `rules_repo_key` ON `rules` (`plugin_rule_key`, `plugin_name`)


错误原因:

Sonar在MySQL中对表建立索引时,key的长度超过1000 bytes了,由于MySQL默认使用MyISAM engine,而MyLSAM引擎会有key长度的限制,超过1000bytes就会报错,所以要将Mysql引擎修改为Innodb。


解决方式:

①. 查看是否有Innodb引擎

这里写图片描述

②. 查看是否支持动态载入动态链接库,yes表示支持。

这里写图片描述

③. 安装

这里写图片描述

查看是否安装成功。

这里写图片描述

⑤. 修改my.cnf配置文件:

default-storage-engine=INNODB
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /usr/local/var
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/var
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

然后删除刚才自动创建的数据库sonar,重启sonar。这次应该就没问题了。

但是,又报了个错:

错误二:

org.jruby.rack.RackInitializationException: An error has occurred, all later migrations canceled:

ActiveRecord::JDBCError: Binary logging not possible. Message: Transaction level 'READ-UNCOMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT': INSERT INTO schema_migrations (version) VALUES ('710')
    from /usr/local/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'
    from /usr/local/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
    from /usr/local/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:490:in `migrate'
    from org/jruby/RubyArray.java:1613:in `each'
    from /usr/local/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:477:in `migrate'
.
.
.
    from file:/usr/local/sonarqube/lib/server/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:25:in `load_environment'
    from file:/usr/local/sonarqube/lib/server/jruby-rack-1.1.13.2.jar!/jruby/rack/rails_booter.rb:79:in `load_environment'

错误原因:

innodb和binlog不兼容引起的,需要将binlog修改为混合模式。

解决方式:

修改my.cnf配置文件:

#binlog_format=mixed

把注释#号去掉,重启mysql,删除sonar数据库,重启sonar即可。


这次就没问题了,访问 http://192.168.xx.xxx:9000 ,就会出现sonar的界面。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值