‘IT DOC’ Posts

 

jenkins 以自定义时区运行

Read full article  | 评论关闭

 

java -Duser.timezone=Asia/Shanghai -Dorg.apache.commons.jelly.tags.fmt.timeZone=Asia/Shanghai -jar jenkins.war

 

两个参数都需要

Read More

AWS EC2 调整centos 云主机根卷大小

Read full article  | 评论关闭

[root@ip-10-0-8-58 ~]# fdisk -u /dev/xvda

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’).

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0×00098461

Device Boot      Start         End      Blocks   Id  System

/dev/xvda1 * 2048 41943039 20970496 83 Linux

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-41943039, default 63): p
First sector (63-41943039, default 63): 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0×00098461

Device Boot      Start         End      Blocks   Id  System

/dev/xvda1 2048 41943039 20970496 83 Linux

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0×00098461

Device Boot      Start         End      Blocks   Id  System

/dev/xvda1 * 2048 41943039 20970496 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource
busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@ip-10-0-8-58 ~]# reboot

Broadcast message from root@ip-10-0-8-58
(/dev/pts/0) at 4:03 …

The system is going down for reboot NOW!
[root@ip-10-0-8-58 ~]# Connection to 54.223.220.111 closed by remote host.
Connection to 54.223.220.111 closed.

$ ssh -i aws-ssh-key.pem root@54.223.220.111
Last login: Wed Jul 29 03:59:36 2015 from 223.71.247.139
[root@ip-10-0-8-58 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 802M 6.7G 11% /
tmpfs 7.3G 0 7.3G 0% /dev/shm
/dev/xvdb 493G 198M 467G 1% /mnt
[root@ip-10-0-8-58 ~]#
[root@ip-10-0-8-58 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 802M 6.7G 11% /
tmpfs 7.3G 0 7.3G 0% /dev/shm
/dev/xvdb 493G 198M 467G 1% /mnt
[root@ip-10-0-8-58 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 20G 0 part /
xvdb 202:16 0 500G 0 disk /mnt
[root@ip-10-0-8-58 ~]# resize2fs /dev/xvda1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/xvda1 to 5242624 (4k) blocks.
The filesystem on /dev/xvda1 is now 5242624 blocks long.

[root@ip-10-0-8-58 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 806M 18G 5% /
tmpfs 7.3G 0 7.3G 0% /dev/shm
/dev/xvdb 493G 198M 467G 1% /mnt

Read More

innodb optimize

Read full article  | 评论关闭

 

MySQL Innodb Settings
The most important ones are:
innodb_buffer_pool_size 70-80% of memory is a safe bet. I set it to 12G on 16GB box.
UPDATE: If you’re looking for more details, check out detailed guide on tuning innodb buffer pool
innodb_log_file_size – This depends on your recovery speed needs but 256M seems to be a good balance between reasonable recovery time and good performance
innodb_log_buffer_size=4M 4M is good for most cases unless you’re piping large blobs to Innodb in this case increase it a bit.
innodb_flush_log_at_trx_commit=2 If you’re not concern about ACID and can loose transactions for last second or two in case of full OS crash than set this value. It can dramatic effect especially on a lot of short write transactions.
innodb_thread_concurrency=8 Even with current Innodb Scalability Fixes having limited concurrency helps. The actual number may be higher or lower depending on your application and default which is 8 is decent start
innodb_flush_method=O_DIRECT Avoid double buffering and reduce swap pressure, in most cases this setting improves performance. Though be careful if you do not have battery backed up RAID cache as when write IO may suffer.
innodb_file_per_table – If you do not have too many tables use this option, so you will not have uncontrolled innodb main tablespace growth which you can’t reclaim. This option was added in MySQL 4.1 and now stable enough to use.

Also check if your application can run in READ-COMMITED isolation mode – if it does – set it to be default as transaction-isolation=READ-COMMITTED. This option has some performance benefits, especially in locking in 5.0 and even more to come with MySQL 5.1 and row level replication.

 

 

innodb_buffer_pool_size

innodb_log_file_size

innodb_log_buffer_size=4M

innodb_flush_log_at_trx_commit=2   ?

 

innodb_flush_method=O_DIRECT

innodb_file_per_table

transaction-isolation=READ-COMMITTED   ?   repeatable-read

 

innodb_write_io_threads = 8

innodb_read_io_threads = 8

innodb_thread_concurrency=8     ?

 

innodb_thread_sleep_delay  10000

Read More

RDS 清除日志

Read full article  | 评论关闭

 

PROMPT> CALL mysql.rds_rotate_slow_log;
PROMPT> CALL mysql.rds_rotate_general_log;

CALL mysql.rds_skip_repl_error;
 

Read More

mysql lock

Read full article  | 评论关闭

1、查询是否锁表
show OPEN TABLES where In_use > 0;

2、查询进程

   show processlist
 查询到相对应的进程===然后 kill    id

补充:

查看正在锁的事务

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS; 

查看等待锁的事务

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;

Read More

elasticsearch status

Read full article  | 评论关闭

_cat/indices/?v

_cluster/health?level=shards&pretty

Read More

rvm

Read full article  | 评论关闭

rvm autolibs disable
rvm install 1.9.3
rvm --default 1.9.3

Read More

Log4j、Log4j 2、Logback、SFL4J、JUL、JCL的比较

Read full article  | 评论关闭

 Log4j

Log4j = Log for Java.
author: Ceki Gülcü
license: Apache License V2.0
Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台、文件、数据库等;我们也可以控制每一条日志的输出格式;通过定义每一条日志信息的级别,我们能够更加细致地控制日志的生成过程。
Log4j有7种不同的log级别,按照等级从低到高依次为:TRACE<DEBUG<INFO<WARN<ERROR<FATAL<OFF。如果配置为OFF级别,表示关闭log。
Log4j支持两种格式的配置文件:properties和xml。包含三个主要的组件:Logger、appender、Layout。
     Example for log4j 1.2     

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//LOGGER" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration>    
  <!--an appender is an output destination, such as the console or a file; names of appenders are arbitrarily chosen-->    
  <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
    </layout>
  </appender>

  <!--loggers of category 'org.springframework' will only log messages of level "info" or higher; if you retrieve Loggers by using the class name (e.g. Logger.getLogger(AClass.class)) and if AClass is part of the org.springframework package, it will belong to this category-->    
  <logger name="org.springframework">        
    <level value="info"/>    
  </logger>    

  <!--everything of spring was set to "info" but for class PropertyEditorRegistrySupport we want "debug" logging-->    
  <logger name="org.springframework.beans.PropertyEditorRegistrySupport">        
    <level value="debug"/>    
  </logger>     

  <root>    
  <!--all log messages of level "debug" or higher will be logged, unless defined otherwise all log messages will be logged to the appender "stdout", unless defined otherwise-->        
    <level value="debug" />        
    <appender-ref ref="stdout" />    
  </root>

</log4j:configuration>

SLF4J

SLF4J = Simple Logging Facade for Java.
author: Ceki Gülcü
SLF4J,即简单日志门面(Simple Logging Facade for Java),不是具体的日志解决方案,而是通过Facade Pattern提供一些Java logging API,它只服务于各种各样的日志系统。按照官方的说法,SLF4J是一个用于日志系统的简单Facade,允许最终用户在部署其应用时使用其所希望的日志系统。作者创建SLF4J的目的是为了替代Jakarta Commons-Logging。
实际上,SLF4J所提供的核心API是一些接口以及一个LoggerFactory的工厂类。在使用SLF4J的时候,不需要在代码中或配置文件中指定你打算使用那个具体的日志系统。SLF4J提供了统一的记录日志的接口,只要按照其提供的方法记录即可,最终日志的格式、记录级别、输出方式等通过具体日志系统的配置来实现,因此可以在应用中灵活切换日志系统。
那么什么时候使用SLF4J比较合适呢?
如果你开发的是类库或者嵌入式组件,那么就应该考虑采用SLF4J,因为不可能影响最终用户选择哪种日志系统。在另一方面,如果是一个简单或者独立的应用,确定只有一种日志系统,那么就没有使用SLF4J的必要。假设你打算将你使用log4j的产品卖给要求使用JDK 1.4 Logging的用户时,面对成千上万的log4j调用的修改,相信这绝对不是一件轻松的事情。但是如果开始便使用SLF4J,那么这种转换将是非常轻松的事情。

Logback

author: Ceki Gülcü
licences:EPL v1.0 and LGPL 2.1
Logback,一个“可靠、通用、快速而又灵活的Java日志框架”。

logback当前分成三个模块:logback-core,logback- classic和logback-access。

logback-core是其它两个模块的基础模块。

logback-classic是log4j的一个改良版本。此外logback-classic完整实现SLF4J API使你可以很方便地更换成其它日志系统如log4j或JDK14 Logging。

logback-access访问模块与Servlet容器集成提供通过Http来访问日志的功能。

1. logback-core: Joran, Status, context, pattern parsing
2. logback-classic: developer logging
3. logback-access: The log generated when a user accesses a web-page on a web server. Integrates seamlessly with Jetty and Tomcat.
选择logback的理由:(http://logback.qos.ch/reasonsToSwitch.html#fasterImpl )
1. logback比log4j要快大约10倍,而且消耗更少的内存。
2. logback-classic模块直接实现了SLF4J的接口,所以我们迁移到logback几乎是零开销的。
3. logback不仅支持xml格式的配置文件,还支持groovy格式的配置文件。相比之下,Groovy风格的配置文件更加直观,简洁。
4. logback-classic能够检测到配置文件的更新,并且自动重新加载配置文件。
5. logback能够优雅的从I/O异常中恢复,从而我们不用重新启动应用程序来恢复logger。
6. logback能够根据配置文件中设置的上限值,自动删除旧的日志文件。
7. logback能够自动压缩日志文件。
8. logback能够在配置文件中加入条件判断(if-then-else)。可以避免不同的开发环境(dev、test、uat…)的配置文件的重复。
9. logback带来更多的filter。
10. logback的stack trace中会包含详细的包信息。
11. logback-access和Jetty、Tomcat集成提供了功能强大的HTTP-access日志。
配置文件:需要在项目的src目录下建立一个logback.xml。注:(1)logback首先会试着查找logback.groovy文件;(2)当没有找到时,继续试着查找logback-test.xml文件;(3)当没有找到时,继续试着查找logback.xml文件;(4)如果仍然没有找到,则使用默认配置(打印到控制台)。 详细的配置在http://aub.iteye.com/blog/1101222这片博客中解释的非常清楚。在这里感谢一下原作者(^_^)。

JUL

JUL = java.util.logging.

Java提供了自己的日志框架,类似于Log4J,但是API并不完善,对开发者不是很友好,而且对于日志的级别分类也不是很清晰,比如:SEVERE, WARNING, INFO, CONFIG, FINE,FINER, FINEST。所以不推荐使用这种方式输出日志。

JCL

JCL = Jakarta Commons-Logging.
Jakarta Commons Logging和SLF4J非常类似,也是提供的一套API来掩盖了真正的Logger实现。便于不同的Logger的实现的替换,而不需要重新编译代码。缺点在于它的查找Logger的实现者的算法比较复杂,而且当出现了一些class loader之类的异常时,无法去修复它。

Log4j 2

已经有很多其他的日志框架对Log4j进行了改良,比如说SLF4J、Logback等。而且Log4j 2在各个方面都与Logback非常相似,那么为什么我们还需要Log4j 2呢?
1. 插件式结构。Log4j 2支持插件式结构。我们可以根据自己的需要自行扩展Log4j 2. 我们可以实现自己的appender、logger、filter。
2. 配置文件优化。在配置文件中可以引用属性,还可以直接替代或传递到组件。而且支持json格式的配置文件。不像其他的日志框架,它在重新配置的时候不会丢失之前的日志文件。
3. Java 5的并发性。Log4j 2利用Java 5中的并发特性支持,尽可能地执行最低层次的加锁。解决了在log4j 1.x中存留的死锁的问题。如果你的程序仍然在饱受内存泄露的折磨,请毫不犹豫地试一下log4j 2吧。
4. 异步logger。Log4j 2是基于LMAX Disruptor库的。在多线程的场景下,和已有的日志框架相比,异步的logger拥有10左右的效率提升。
还有更多的新特性,在这里就不一一赘述了。了解更多请移步到:http://logging.apache.org/log4j/2.x/manual/index.html

Read More

NTP drift

Read full article  | 评论关闭

The units for the drift file are “PPM”, or “parts per million”. Your clock will drift due to fluctuations in the frequency oscillating the quartz crystal on your motherboard. A fluctuation of just 0.001% (0.00001, or 10 PPM) means losing or gaining about 1 second per day. NTP has finer grained control than that, so we look at errors of margin using 0.0001% (0.000001, or 1 PPM). Thus:

  • 1 PPM = 1 part per million = 1 microsecond per second = 3.6ms per hour = 86.4ms per day

Thus, my drift file shows the value of “2.643″ which means my clock is off by 2.643 parts per million, which means it’s currently off at 228.3552ms per day.

Read More

jenkins ssl

Read full article  | 评论关闭

https://github.com/hughperkins/howto-jenkins-ssl

Read More