2017年5月16日 星期二

Reinstall RabbitMQ & ACCESS_REFUSED

Reinstall RabbitMQ


* Starting message broker rabbitmq-server * FAILED - check /var/log/rabbitmq/startup_\{log, _err\}

安裝 RabbitMQ 的時候碰到無法啟動的問題,嘗試下面的步驟把它刪除重新安裝時,
發現 hosts 設定是有問題的,於是重新設定後再整個移除安裝就能執行了

  1. Stop RabbitMQ: rabbitmqctl stop
  2. Change /etc/hosts  

/etc/hosts

127.0.0.1 localhost
127.0.0.1(or my ip) MYHOSTNAME


  1. Change /etc/hostname

/etc/hostname

MYHOSTNAME


  1. Uninstall old RabbitMQ: dpkg -P rabbitmq-server
  2. Remove RabbitMQ’s database: rm -rf /var/lib/rabbitmq
  3. Find erlang’s process that is running rabbit: ps ax | grep rabbit
    找看看有沒有rabbitmq的程序,有的話殺掉
  4. Kill the listed process (sudo kill -9 pid )
  5. Reinstall RabbitMQ: apt-get install rabbitmq-server
    or sudo dpkg -i rabbitmq-server.deb




ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN



再安裝完成RabbitMQ後 執行 Spring 噴出下面的錯誤,主要原因是帳號認証問題

org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

Create admin account myadmin/mypassword

[~]$ sudo rabbitmqctl add_user myadmin mypassword
[~]$ sudo rabbitmqctl set_user_tags myadmin administrator
[~]$ sudo rabbitmqctl set_permissions -p "/" myadmin ".*" ".*" ".*"

去網頁( http://127.0.0.1:15672 )檢查帳號的權限或再按一次 Set permission



2016年6月21日 星期二

ubuntu 14.04 vagrant up error for VirtualBox 5.x

安裝5.x以上版本 直接透過apt-get 安裝vagrant 會出現下面的問題
vagrant up Vagrant has detected that you have a version of VirtualBox installed that is not supported. Please install one of the supported versions listed below to use Vagrant: 4.0, 4.1, 4.2, 4.3
因為vagrant 再apt版本不是最新的 [~] $ vagrant -v Vagrant 1.4.3 直接從官方網站下載最新版本(連結 -> 選擇DEBIAN) vagrant_1.8.4_x86_64.deb 檔案下載下來之後 點選右鍵 > 以 軟體中心 開啟
再點選『更新』執行完成之後就可以使用了 [~] $ vagrant -v Vagrant 1.8.4 [~] $ vagrant up Vagrant is upgrading some internal state for the latest version. Please do not quit Vagrant at this time. While upgrading, Vagrant will need to copy all your boxes, so it will use a considerable amount of disk space. After it is done upgrading, the temporary disk space will be freed. Press ctrl-c now to exit if you want to remove some boxes or free up some disk space. Press the Enter or Return key to continue.

2016年6月8日 星期三

JMX connection

為了監控Java App 程式的使用量,java有提供一些 tools 如 jstat , jvisualvm 等.. 當我打算監控的是一個遠端的程式的話可以透過JMX connection來達成 在要被監控遠端電腦 JavaApp程式啟動加入下列指令 java -jar -Dcom.sun.management.jmxremote.ssl=false // 是否透過ssh登入 -Dcom.sun.management.jmxremote.authenticate=false //是否驗證 -Dcom.sun.management.jmxremote.port= 1234 //連接port -Djava.rmi.server.hostname= 192.168.1.x //連接IP 或 主機名稱 MyJavaApp.jar 程式啟動後,再本機端啟動 jvisualvm (ubuntu 通常位置會在/usr/lib/jvm/jdk_version/bin 底下) 並且再Remote新增要連接的名稱 ex: 192.168.1.x
點選該主機名稱->右鍵->Add JMX Connection... 設定IP:Port
完成連接後就可以監控遠端的jar 檔案 資源的使用量了

2015年9月3日 星期四

eclipse auto activation No Default Proposals 問題

Eclipse 有個 auto activation 可以自動補完程式碼
  Window -> Preferences -> Java -> Editor -> Content Assist 
的 auto activation 區域

這邊可以設定 Auto activation delay (ms) : 0 或 10 加快顯示提示程式碼 下面這是指說哪些文字開頭要觸發 通常會把26字母大小跟逗號加上去 Auto activation triggers for Java: .abcdefghijkemnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_ 接下來是本篇的主題因為某次突然發現找不到自動提示程式碼
一直給我出現 No Default Proposals 畫面
只好花點時間去找找解決方法 Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced (在Content Assist 往下一階層) 「Select the proposal kinds contained in the 'default' content assist list:」 底下的 「Java Proposals」,打勾就會有了。

2015年7月23日 星期四

Ubuntu 14.04 讀取隨身硬碟 (exFAT)

如果讀取隨身硬碟發現怎樣都無法mount ,可能是缺少了exFAT的套件 。

How to enable exFAT(FAT64) in Ubuntu 14.04

sudo apt-get install exfat-fuse exfat-utils
原始網址

2014年7月30日 星期三

Guake Terminal多螢幕時在最右邊顯示

當使用多螢幕時候Guake Terminal預設會在最左邊螢幕出現
如果要讓其顯示於最右邊可以透過修改
/usr/lib/guake/guake.py 的 get_final_window_rect

原文連結
  def get_final_window_rect(self):
        """Gets the final size of the main window of guake. The height
        is the window_height property, width is window_width and the
        horizontal alignment is given by window_alignment.
        """
        screen = self.window.get_screen()
        height = self.client.get_int(KEY('/general/window_height'))
        width = 80 #設定Guake寬度為80%
        halignment = self.client.get_int(KEY('/general/window_halignment'))
 
        # future we might create a field to select which monitor you
        # wanna use
        #monitor = 0 # use the left most monitor
        monitor = screen.get_n_monitors() - 1 # use the right most monitor
 
        monitor_rect = screen.get_monitor_geometry(monitor)
        window_rect = monitor_rect.copy()
        window_rect.height = window_rect.height * height / 100
        window_rect.width = window_rect.width * width / 100
       #設定Guake顯示位置
        if width < monitor_rect.width:
            if halignment == ALIGN_CENTER:
                window_rect.x = monitor_rect.x + (monitor_rect.width - window_rect.width) / 2
            elif halignment == ALIGN_LEFT:
                window_rect.x = monitor_rect.x
            elif halignment == ALIGN_RIGHT:
                window_rect.x = monitor_rect.x + monitor_rect.width - window_rect.width
 
        window_rect.y = monitor_rect.y
        return window_rect

2014年4月8日 星期二

wrk HTTP基準測試工具

github fork wrk 


下載到/tmp
 解壓縮後 sudo make
然後搬移wrk  
sudo mv wrk /usr/local/bin

就能執行下面命令


  wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html

  This runs a benchmark for 30 seconds, using 12 threads, and keeping
  400 HTTP connections open.
  
  -t :多少線程
  -c :多少同時連線測試數量
  -d :執行多少秒


*測試注意sudo ulimit -n 可查詢最大連線數 依照需求調整

搜尋此網誌