debian中vim显示中文出现乱码

在/etc/vim/vimrc中添加配置
set termencoding=utf-8
set encoding=utf-8

 

Host '10.0.2.2' is not allowed to connect to this MariaDB server

Host '10.0.2.2' is not allowed to connect to this MariaDB server
mysql的root用户,默认只允许本地访问。当使用客户端连接远程mysql服务器,出现上面错误。只要在mysql.user表添加远程用户即可.
  • 进入mysql命令行界面
➜  ~  mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  • 执行下面insert
insert into mysql.user(Host,User,Password) values("%","root",password("root"));insert into mysql.user(Host,User,Password) values("%","root",password("root"));
 

内外网同时访问阿里rds数据库

阿里对它的rds数据库作了访问限制,内外网不能同时使用,并且切到外网访问,会收取流量费。每次更新数据库时,要先切到外网模式,再链接rds进行操作,太麻烦了. 怎么做可以让内网、外网同时访问? 想到了将rds的端口映射到ecs,再访问ecs,即可访问rds.
 
在ecs主机上,运行下面命令,将rds映射到外网
ssh -NfgT  -L 3306:rds地址:3306 用户名@localhost
 
更新完之后,再kill掉上面命令.
 

debian创建用户没有宿主目录

在debian系统中,以useradd创建用户,默认不会创建密码和宿主目录. debian建议用adduser创建用户,它会提示创建初始密码和目录.
root@xxxx:/home# adduser wyq
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "zh_CN.UTF-8",
LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Adding user `pkadmin' ...
Adding new group `wyq' (1003) ...
Adding new user `wyq' (1002) with group `wyq' ...
Creating home directory `/home/wyq' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for wyq
Enter the new value, or press ENTER for the default
Full Name []:       
Room Number []: 
Work Phone []: 
Home Phone []: 
Other []: 
Is the information correct? [Y/n] y
 

chkconfig用法

chkconfig是一种简单的命令行工具,用于帮助管理员对/etc/rc[0-6].d目录层次下的众多的符号链接进行直接操作。

语法

chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name <on|off|reset>
chkconfig [--level levels] name
 
--list 显示系统服务的运行状态(on或off)  
--add  增加系统服务  
--del  删除系统服务  
--level 指定系统服务在哪个执行等级中开启或关闭  
      等级0表示:表示关机  
      等级1表示:单用户模式  
      等级2表示:无网络连接的多用户命令行模式  
      等级3表示:有网络连接的多用户命令行模式  
      等级4表示:不可用  
      等级5表示:带图形界面的多用户模式  
      等级6表示:重新启动  

基本用法

  • 查询当前所有自动启动的服务
chkconfig --list 
chkconfig --list [name] //查询特定服务
  • 开机启动开启/关闭
chkconfig httpd on/off
  • 指定服务运行等级
chkconfig --level 35 httpd on/off
设定httpd在等级3和5为开机运行服务.
  • 新增服务
chkconfig --add httpd
加入到chkconfig列表
  • 删除服务
chkconfig --del httpd
从chkconfig列表移除服务
 

chkconfig配置开机启动

  • 新建脚本
touch /etc/init.d/echo_msg
  • 添加内容
#!/bin/zsh
#chkconfig:2345 61 61
#description:runing echo
echo "I am runing"  > /home/wyq/start.txt
前三行是chkconfig的格式,不可以省略,否则会出现"服务echo_msg,chkconfig不支持".
  • 赋予执行权限
chmod a+x echo_msg
  • 加入chkconfig列表
chkconfig --add echo_msg
  • 设置开机启动
chkconfig echo_msg on
重启系统之后, 在/home/wyq目录下发现start.txt文件,表示启动成功.
 

$('a').click()无法触发页面跳转

描述

在用$("a").click()方法, 触发a元素点击事件,进行页面跳转效果. 结果发现页面未发生跳转.

示例

<html>
<meta charset='utf-8'>
<body>
<button id="btn">按钮</button>
<a href="http://www.baidu.com" target="_blank" id="link">链接</a>
</body>
<script src="/jquery1.91.js" type="text/javascript"></script>
<script>
$(function(){
    $("#btn").click(function(e){
        //触发点击事件
        $("a").click();
    });
</script>
</html>

解决方法

  • 第一种: 用原生的a对象触发事件
$("a")[0].click();
  • 第二种: 通过事件冒泡触发事件
<a href="http://www.baidu.com" target="_blank" id="link"><span id="link">链接</span></a>

$(function(){
    $("#btn").click(function(e){
        //触发点击事件
        $("#link").click();
    });
</script>
 

git免密码(https方式)

    使用git push提交时,每次都要输入密码,次数多了,感觉挺麻烦. 如果git以ssh协议通讯,免密码可以用ssh公钥设置免登录。如果git时以https方式访问呢,该怎么办?下面方式可以解决这个问题.

 
* 新建文件并保存密码
touch ~/.git-credentials
vim ~/.git-credentials
添加内容
https://{username}:{passwd}@github.com
 
* 添加git配置
 
执行下面命令添加配置
git config --global credential.helper store
 
* 查看~/.gitconfig文件变化
 
~/.gitconfig文件多出下面配置项
[credential]
    helper = store
 
再尝试git push不再需要输入密码.
 

《若要佛法兴唯有僧赞僧》

    改善命运的方法中,有一个很重要的秘诀,就是改善人际关系,如何改善人际关系,方法很简单,就是“礼敬赞叹”,祖师大德有一句话:“若要佛法兴,唯有僧赞僧”,所以,僧赞僧时佛法兴,人赞人时事业旺!“赞叹”是改善命运的秘诀。此书汇集了当今高僧净空老法师与各宗派大德高僧的互相赞叹,读完此书,你就会明白,为什么净空老法师能把原来贫穷短命的命运转变为富有、长寿、令全世界尊敬的命运,原因之一就是“赞叹”!得此秘诀,您的命运亦将从此改变。

http://pan.baidu.com/s/1ntICwLb

在运行jetty-maven-plugin时,出现错误

在运行jetty-maven-plugin出现错误
 
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.2.6.v20141205:run (default-cli) on project PKPlatform_web: Execution default-cli of goal org.eclipse.jetty:jetty-maven-plugin:9.2.6.v20141205:run failed: Unable to load the mojo 'run' in the plugin 'org.eclipse.jetty:jetty-maven-plugin:9.2.6.v20141205' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/eclipse/jetty/maven/plugin/JettyRunMojo : Unsupported major.minor version 51.0
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.eclipse.jetty:jetty-maven-plugin:9.2.6.v20141205
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-maven-plugin/9.2.6.v20141205/jetty-maven-plugin-9.2.6.v20141205.jar
[ERROR] urls[1] = file:/D:/DEV/mavenRepons/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar
[ERROR] urls[2] = file:/D:/DEV/mavenRepons/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar
[ERROR] urls[3] = file:/D:/DEV/mavenRepons/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[4] = file:/D:/DEV/mavenRepons/org/sonatype/aether/aether-util/1.11/aether-util-1.11.jar
[ERROR] urls[5] = file:/D:/DEV/mavenRepons/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[6] = file:/D:/DEV/mavenRepons/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[7] = file:/D:/DEV/mavenRepons/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[8] = file:/D:/DEV/mavenRepons/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[9] = file:/D:/DEV/mavenRepons/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.1/maven-plugin-tools-api-3.1.jar
[ERROR] urls[10] = file:/D:/DEV/mavenRepons/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[11] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-util/9.2.6.v20141205/jetty-util-9.2.6.v20141205.jar
[ERROR] urls[12] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-webapp/9.2.6.v20141205/jetty-webapp-9.2.6.v20141205.jar
[ERROR] urls[13] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-xml/9.2.6.v20141205/jetty-xml-9.2.6.v20141205.jar
[ERROR] urls[14] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-servlet/9.2.6.v20141205/jetty-servlet-9.2.6.v20141205.jar
[ERROR] urls[15] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-quickstart/9.2.6.v20141205/jetty-quickstart-9.2.6.v20141205.jar
[ERROR] urls[16] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-jaas/9.2.6.v20141205/jetty-jaas-9.2.6.v20141205.jar
[ERROR] urls[17] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-security/9.2.6.v20141205/jetty-security-9.2.6.v20141205.jar
[ERROR] urls[18] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-plus/9.2.6.v20141205/jetty-plus-9.2.6.v20141205.jar
[ERROR] urls[19] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-jndi/9.2.6.v20141205/jetty-jndi-9.2.6.v20141205.jar
[ERROR] urls[20] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-server/9.2.6.v20141205/jetty-server-9.2.6.v20141205.jar
[ERROR] urls[21] = file:/D:/DEV/mavenRepons/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar
[ERROR] urls[22] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-http/9.2.6.v20141205/jetty-http-9.2.6.v20141205.jar
[ERROR] urls[23] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-io/9.2.6.v20141205/jetty-io-9.2.6.v20141205.jar
[ERROR] urls[24] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-jmx/9.2.6.v20141205/jetty-jmx-9.2.6.v20141205.jar
[ERROR] urls[25] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/jetty-annotations/9.2.6.v20141205/jetty-annotations-9.2.6.v20141205.jar
[ERROR] urls[26] = file:/D:/DEV/mavenRepons/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
[ERROR] urls[27] = file:/D:/DEV/mavenRepons/org/ow2/asm/asm/5.0.1/asm-5.0.1.jar
[ERROR] urls[28] = file:/D:/DEV/mavenRepons/org/ow2/asm/asm-commons/5.0.1/asm-commons-5.0.1.jar
[ERROR] urls[29] = file:/D:/DEV/mavenRepons/org/ow2/asm/asm-tree/5.0.1/asm-tree-5.0.1.jar
[ERROR] urls[30] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/websocket/javax-websocket-server-impl/9.2.6.v20141205/javax-websocket-server-impl-9.2.6.v20141205.jar
[ERROR] urls[31] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/websocket/javax-websocket-client-impl/9.2.6.v20141205/javax-websocket-client-impl-9.2.6.v20141205.jar
[ERROR] urls[32] = file:/D:/DEV/mavenRepons/javax/websocket/javax.websocket-api/1.0/javax.websocket-api-1.0.jar
[ERROR] urls[33] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/websocket/websocket-server/9.2.6.v20141205/websocket-server-9.2.6.v20141205.jar
[ERROR] urls[34] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/websocket/websocket-common/9.2.6.v20141205/websocket-common-9.2.6.v20141205.jar
[ERROR] urls[35] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/websocket/websocket-api/9.2.6.v20141205/websocket-api-9.2.6.v20141205.jar
[ERROR] urls[36] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/websocket/websocket-client/9.2.6.v20141205/websocket-client-9.2.6.v20141205.jar
[ERROR] urls[37] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/websocket/websocket-servlet/9.2.6.v20141205/websocket-servlet-9.2.6.v20141205.jar
[ERROR] urls[38] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/apache-jsp/9.2.6.v20141205/apache-jsp-9.2.6.v20141205.jar
[ERROR] urls[39] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/toolchain/jetty-schemas/3.1.M0/jetty-schemas-3.1.M0.jar
[ERROR] urls[40] = file:/D:/DEV/mavenRepons/org/mortbay/jasper/apache-jsp/8.0.9.M3/apache-jsp-8.0.9.M3.jar
[ERROR] urls[41] = file:/D:/DEV/mavenRepons/org/mortbay/jasper/apache-el/8.0.9.M3/apache-el-8.0.9.M3.jar
[ERROR] urls[42] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/orbit/org.eclipse.jdt.core/3.8.2.v20130121/org.eclipse.jdt.core-3.8.2.v20130121.jar
[ERROR] urls[43] = file:/D:/DEV/mavenRepons/org/eclipse/jetty/apache-jstl/9.2.6.v20141205/apache-jstl-9.2.6.v20141205.jar
[ERROR] urls[44] = file:/D:/DEV/mavenRepons/org/apache/taglibs/taglibs-standard-spec/1.2.1/taglibs-standard-spec-1.2.1.jar
[ERROR] urls[45] = file:/D:/DEV/mavenRepons/org/apache/taglibs/taglibs-standard-impl/1.2.1/taglibs-standard-impl-1.2.1.jar
[ERROR] urls[46] = file:/D:/DEV/mavenRepons/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
 
从上面发现
repository.exception.ComponentLookupException: org/eclipse/jetty/maven/plugin/JettyRunMojo : Unsupported major.minor version 51.0
很明显是版本问题. 检查jdk,版本是1.6,改为1.7后,重新运行,一切正常.