2018年1月

升级MYSQL到5.7后赋权错误

产生原因:从低版本的mysql直接mysqldump所有的表数据,包括mysql.user,在新赋权其它IP的时候报错(ERROR 1805 (HY000): Column count of mysql.user is wrong. Expected 45, found 43. The table is probably corrupted)
解决办法:
mysql_upgrade --force -u root -p
会看到升级提示(The sys schema is already up to date (version 1.5.1).
Found 0 sys functions, but expected 22. Re-installing the sys schema.
Upgrading the sys schema)
通过比较发现
1.MySQL5.7中mysql.user表比MySQL5.6少了1个字段(Password)
2.MySQL5.7中mysql.user表比MySQL5.6多了3个字段(password_last_changed,password_lifetime,account_locked)

elasticsearch常见错误

1:安装x-pack出错

Exception in thread "main" java.nio.file.FileSystemException: /elasticsearch-6.1.2/config/x-pack: Operation not permitted
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileAttributeViews$Posix.setOwners(UnixFileAttributeViews.java:252)
    at sun.nio.fs.UnixFileAttributeViews$Posix.setOwner(UnixFileAttributeViews.java:274)
    at org.elasticsearch.plugins.InstallPluginCommand.setOwnerGroup(InstallPluginCommand.java:725)
    at org.elasticsearch.plugins.InstallPluginCommand.installConfig(InstallPluginCommand.java:698)
    at org.elasticsearch.plugins.InstallPluginCommand.install(InstallPluginCommand.java:615)
    at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:215)
    at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:204)
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
    at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:75)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
    at org.elasticsearch.cli.Command.main(Command.java:90)
    at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:48)

解决办法:切换到root安装,可以成功安装上,安装上注意,需要重新对目录chmod,我是直接给的777,然后可以直接启动es。

2:java client连接带x-pack的elasticsearch6报错的问题(在ElasticSearch中安装X-pack后,通过TransportClient进行访问时,需要实例化PreBuiltXPackTransportClient,因此需要加入相应的jar包文件来增加此类。)

Exception in thread "main" java.lang.IllegalArgumentException: unknown setting [xpack.security.user] please check that any required plugins are installed, or check the breaking changes documentation for removed settings
at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:312)
at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:276)
at org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:135)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:140)
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:262)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:128)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:114)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:104)
at com.leo.es.App.main(App.java:31)

解决办法:

<repositories>
<repository>
<id>elasticsearch-releases</id>
<url>https://artifacts.elastic.co/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
----------
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>5.2.2</version>
</dependency>

然后JAVA代码为:
TransportClient client = new PreBuiltXPackTransportClient(settings)

3:修改max_result_window出错
新版本的es不支持通过配置配置文件修改max_result_window(默认是10000),,不然会直接报错node settings must not contain any index level settings
需要通过api去修改,网上很多都没有给全命令
curl -XPUT "http://127.0.0.1:9200/dbver/_settings" -d '{"index":{"max_result_window":100000000}}'
上面这种会直接报错,{
"error": "Content-Type header [application/x-www-form-urlencoded] is not supported",
"status": 406
}
需要加上-H指定类型
curl -XPUT "http://127.0.0.1:9200/dbver/_settings" -H 'Content-Type: application/json' -d '{"index":{"max_result_window":1000000}}'
这个就可以修改成功了,其中dbver替换成你需要的索引名称。

cmder替代powershell

在windows上使用docker,用powershell不太习惯,推荐使用cmder,很好用,毕竟平时习惯了linux交互方式。
http://cmder.net/

docker使用中常见错误

1:无法链接安装在docker里面的mongodb
在docker里面正常链接,在宿主机里面无法链接,端口映射没有问题,最后问题出现在mongodb的配置文件,需要bindIp:0.0.0.0
2:docker build 无法访问网络
在build的时候run命令无法下载资源
解决方位:
vi /etc/docker/daemon.json
增加 "dns": ["119.29.29.29"]
然后重启docker服务
2:el6无法运行elasticsearch6版本
CentoOS 6 does not (as far as I can research) support SecComp, but ES tries to use it anyway, and fails to start 。
设置配置文件:bootstrap.system_call_filter: false
3:系统重启后docker无法启动
报错为:docker0: iptables: No chain/target/match by that name
解决方法重启docker服务service docker restart
4:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf里面的vm.max_map_count