搜尋此網誌

顯示具有 CentOS Linux 標籤的文章。 顯示所有文章
顯示具有 CentOS Linux 標籤的文章。 顯示所有文章

2023年9月9日 星期六

當 Linux Xterm 的顏色(尤其是顯示目錄用的藍色)怎麼調整仍無作用,不聽話的時後,可以 修改 ~/.bashrc 及 ~/.bash_profile 加入以下,使其認真發揮作用:

LS_COLORS=$LS_COLORS:'di=0;94:' ; export LS_COLORS

 

參考來源:https://askubuntu.com/questions/466198/how-do-i-change-the-color-for-directories-with-ls-in-the-console


 

 

2023年9月8日 星期五

最近發現舊版本 CentOS 7 搭配 XFCE 桌面可解決惱人的高解析螢幕困擾。

如果需要將辛辛苦苦的 XFCE 設定參數備份起來,複製到其他節點去,可以用以下方法備份 XFCE 的 CONFIG。

總共會打包了 ${HOME}/Desktop 以及 ${HOME}/.config 兩個關鍵資料夾:

cd;tar bcfz 1 - Desktop .config >backup-settings.tgz

再將個 tgz 檔案複製到其他節點去解開即可。



參考來源:https://forum.xfce.org/viewtopic.php?id=12822

 

 
 
 


2021年5月22日 星期六

crontab @reboot 參數 - 開機自動執行

輸入  # crontab -e

加入以下一行:

@reboot sleep 60 ; /root/my-script.sh

以上設定開機後等待 1 分鐘 (60 秒) 之後 就會自動執行 /root/my-script.sh



2021年3月25日 星期四

Linux 查PORT被誰使用

lsof -i -P -n | grep LISTEN


參考 https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/


2018年4月3日 星期二

Netdata 監控程式

因工作上需要工具監控 Linux VM,不過現有的工具多半是報表式,比較不接近即時性。
Netdata 可以用瀏覽器就達到即時監控,對系統工程師SE來說是一個好用的工具。

:::安裝:
yum -y install epel-release
yum -y install autoconf automake curl gcc git libmnl-devel libuuid-devel lm_sensors make MySQL-python nc pkgconfig python python-psycopg2 PyYAML zlib-devel


:::利用 git 取得 netdata 套件:
cd /opt
git clone https://github.com/firehol/netdata.git --depth=1


:::利用 netdata 套件中的安裝程式,進行軟體編譯與安裝:
cd netdata
./netdata-installer.sh

畫面上直接按下Enter,就會自動開始進行安裝工作!


:::安裝完畢之後,準備開啟 Kernel 的 KSM 功能:
echo 1 >/sys/kernel/mm/ksm/run
echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs


:::啟動服務
systemctl enable netdata
systemctl start netdata


:::如果需要開放防火牆設定
firewall-cmd --permanent --add-port=19999/tcp
firewall-cmd --reload


:::完成
用瀏覽器訪問 http://ip:19999


2017年11月13日 星期一

透過 DU 指令,找出目錄底下體積最大的前 5 個檔案

透過 DU 指令,找出當下目錄底下體積最大的前 5 個檔案

du -h -s * | sort -rn | head -5

如果要查其他目錄,只要修改上述 * 號,例如:

du -h -s /* | sort -rn | head -5



還有更方便的工具,但是需要額外安裝 ncdu

ncdu -q -x

-q Quiet mode, doesn't update the screen 10 times a second
   while scanning, reduces network bandwidth used

-x Don't cross filesystem borders (don't descend into a
   directory which is a mounted disk)




透過CentOS 本身的 logrotate 服務控制 LOG 檔案大小

透過CentOS 本身的 logrotate 服務控制 LOG 檔案大小
在 /etc/logrotate.d/ 新增 tomcat 檔案
控制 /usr/local/apache-tomcat-6.0.37/logs/catalina.out


例如:
cat >/etc/logrotate.d/tomcat <<EOF
/usr/local/apache-tomcat-6.0.37/logs/catalina.out{
    copytruncate
    daily
    rotate 7
    missingok
    compress
    size 16M
}
EOF


上述說明:
/usr/local/apache-tomcat-8.0.28/logs/catalina.out{ # 要輪轉的文件
    copytruncate # 創建新的catalina.out副本後,截斷源catalina.out文件
    daily     # 每天進行catalina.out文件的輪轉
    rotate 7   # 至多保留7個副本
    missingok   # 如果要輪轉的文件丟失了,繼續輪轉而不報錯
    compress   # 使用壓縮的方式(非常有用,節省硬盤空間;一個2~3GB的日誌文件可以壓縮成60MB左右)
    size 16M   # 當catalina.out文件大於16MB時,就輪轉
}




2017年8月21日 星期一

CentOS7 開機 卡在 rc.local

新開機時,CentOS 卡在灰底色畫面,一直無法成功開機。
按下 ESC 按鍵之後,螢幕顯示卡在 rc.local
(A stop job is running for /etc/rc.d/rc.local Compatibility)

解決方法:
重新開機之後,按下 e 按鍵,進入編輯模式
用上下鍵,找到 quiet 關鍵字眼之後,後面加上
systemd.unit=rescue.target 
之後,按下 Ctrl+X 繼續開機

成功開機之後,輸入 root 密碼登入
修改 rc.local 檔案的屬性

sudo chmod 644 /etc/rc.local

立刻重新開機 shutdown -r
應該可以開機成功



2017年7月13日 星期四

2017年6月15日 星期四

freerdp server


yum -y install weston.x86_64
yum -y install freerdp-server.x86_64
yum -y install xfreerdp-server.x86_64

Run:
freerdp-shadow-cli -auth -sec-rdp




Install glxsphere


- Centos/Fedora
yum -y install VirtualGL.x86_64
or
dnf -y install VirtualGL.x86_64

- Ubuntu
sudo dpkg -i VirtualGL_*.deb


then we get:
glxgears      glxinfo       glxinfo64     glxspheres64

or

/opt/VirtualGL/bin/glxspheres

- The End -





2017年6月2日 星期五

CentOS 設定預設登入桌面


在 /usr/share/xsessions 目錄底下,可以看到一些桌面環境參數,例如:
cinnamon2d.desktop  gnome-fallback.desktop  openbox-gnome.desktop  xfce.desktop
cinnamon.desktop    mate.desktop            openbox-kde.desktop
gnome.desktop       openbox.desktop         ssh.desktop

決定好要以哪一個桌面為主,就留下該桌面desktop檔,
其他檔案都移至新建 FOLDER 匣裡面,
例如:只有留下 mate.desktop 檔案。

不必重新開機,重新登出入即可。

- The End -




2017年5月2日 星期二

CentOS7 安裝 redis


OS 先安置好 epel

yum -y install redis

systemctl daemon-reload
systemctl enable redis.service
systemctl start redis.service

驗證執行命令
redis-cli ping
畫面應得到
PONG



有必要時,防火牆開 6379 埠
# Add allow port 6379
firewall-cmd --permanent --add-port=6379/tcp
firewall-cmd --reload


要開放外部連線的話
vi /etc/redis.conf
找到 bind 127.0.0.1
改成 bind 0.0.0.0


- The End -

2017年4月2日 星期日

CentOS 擴充系統硬碟空間 (Expand OS hard driver space on CentOS7)

大致以下步驟:
1. Fdisk 劃分硬碟
2. pvcreate 增加硬碟
3. vgextend 增加vg空間
4. lvresize 增加lv空間
5. xfs_growfs 讓os看得到


例:系統碟要擴容 80GB 空間
1. Fdisk,劃分硬碟
fdisk –l

n
p
t
選擇8e LVM格式
w

重要 (fdisk 後不用重開機)
partprobe
fdisk -l   確認有增加partition出來 例如:/dev/sdb1


查看到當下 LVM的 TOTAL SIZE
pvscan  

增加新硬碟,成功會提示  successfully created.
pvcreate /dev/sdb1

查看現在狀況 ,成功會看到提示 --- NEW Physical volume ---
pvdisplay 

查看現在 Volume group 名稱,例如看到 VG Name:cl
vgdisplay 

延伸VG的容量,成功會提示  Volume group "cl" successfully extended
vgextend cl /dev/sdb1 

查看現在 Volume group 名稱與容量 並記錄增加的數字,
vgdisplay 
例如:Free  PE / Size       20479 / 80.00 GiB
記下 20479

lvdisplay 
查看 Volume group 名稱 對應的 LV Path,LV Name
例如看到 VG Name:cl  對應
LV Path:/dev/cl/root
LV Name:root

指定擴 80GB 空間
lvresize -l +20479 /dev/cl/root
成功會提示
Size of logical volume cl/root changed from 17.00 GiB (4351 extents) to 96.99 GiB (24830 extents).
Logical volume cl/root successfully resized.

擴容
xfs_growfs /dev/cl/root

成功會看到提示
data blocks changed from 4455424 to 25425920

df -h 查看結果


- The End -

2017年3月11日 星期六

修復損壞的 Centos VM

這裡是指 VM Workstation 的檔案格式

1.
先以另一獨立的 centos 開機,並將有問題的 vm disk mount
設定成另一個磁碟機之後,啟動開機

2.
lvscan 條列出有哪些 LVM GROUPS

3.
取消該 GROUP 的活動
vgchange -a n my_volume_group

4.
掃描與修復
xfs_repair -L /dev/sdb

接下來必須耐心等待掃描修復整顆 disk
畫面上可能會看到
...found candidate secondary superblock...unable to verify superblock, continuing.....
很恐怖... 不知道是否能修復成功...


5.
復原該 GROUP 的活動
vgchange -a y my_volume_group


2017年3月4日 星期六

mount cifs


mount -t cifs -o username="Username",password="Password" //IP/share /mnt/smb


umount /mnt/smb


- The End -

2017年2月25日 星期六

Linux mount NFS Using TCP

The default transport protocol for NFS is UDP; however, the Red Hat Enterprise Linux 3 kernel includes support for NFS over TCP. To use NFS over TCP, include the -o tcp option to mount when mounting the NFS-exported file system on the client system. For example:

mount -o tcp shadowman.example.com:/misc/export /misc/local

If the NFS mount is specified in /etc/fstab:

server:/usr/local/pub    /pub   nfs    rsize=8192,wsize=8192,timeo=14,intr,tcp


If it is specified in an autofs configuration file:

myproject  -rw,soft,intr,rsize=8192,wsize=8192,tcp penguin.example.net:/proj52


Since the default is UDP, if the -o tcp option is not specified, the NFS-exported file system is accessed via UDP.

The advantages of using TCP include the following:


  • Improved connection durability, thus less NFS stale file handles messages.
  • Performance gain on heavily loaded networks because TCP acknowledges every packet, unlike UDP which only acknowledges completion.
  • TCP has better congestion control than UDP (which has none). On a very congested network, UDP packets are the first types of packet that are dropped. Which means if NFS is writing data (in 8K chunks) all of that 8K has to retransmitted. With TCP because of its reliability, one parts of that 8K data is transmitted at a time.
  • Error detection. When a tcp connection breaks (due to the server going down) the client stops sending data and starts the reconnection process. With UDP, since its connection-less, the client continue to pound the network with data until server comes up.


The main disadvantage is that there is a very small performance hit due to the overhead associated with the TCP protocol.


Source:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/System_Administration_Guide/s1-nfs-mount.html



搜尋此網誌