Tag: CentOS

  • Resize Disk Using `growpart` on CentOS

    First install growpart:

    yum install cloud-utils-growpart

    Check current disk info:

    fdisk -l
    
    Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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 label type: dos
    Disk identifier: 0x0008d73a
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048    41943039    20970496   83  Linux

    Check disk partition info:

    df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda1        20G   15G  4.5G  77% /
    devtmpfs        486M     0  486M   0% /dev
    tmpfs           496M     0  496M   0% /dev/shm
    tmpfs           496M  460K  496M   1% /run
    tmpfs           496M     0  496M   0% /sys/fs/cgroup
    tmpfs           100M     0  100M   0% /run/user/0

    Run growpart on our device:

    growpart /dev/vda 1
    CHANGED: partition=1 start=2048 old: size=41940992 end=41943040 new: size=83883999,end=83886047

    Resize:

    resize2fs /dev/vda1
    resize2fs 1.42.9 (28-Dec-2013)
    Filesystem at /dev/vda1 is mounted on /; on-line resizing required
    old_desc_blocks = 2, new_desc_blocks = 3
    The filesystem on /dev/vda1 is now 10485499 blocks long.

    Check if disk resized:

    df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda1        40G   15G   24G  38% /
    devtmpfs        486M     0  486M   0% /dev
    tmpfs           496M     0  496M   0% /dev/shm
    tmpfs           496M  460K  496M   1% /run
    tmpfs           496M     0  496M   0% /sys/fs/cgroup
    tmpfs           100M     0  100M   0% /run/user/0
  • OpenJDK 64-Bit Server VM warning: XX:ParallelGCThreads=N

    Just adding -XX:-AssumeMP to /etc/elasticsearch/jvm.options

  • Install Tsunami UDP on CentOS 7

    Install dependencies:

    $ yum install cvs git gcc automake autoconf libtool -y
    

    Download Tsunami UDP:

    $ cd /tmp
    $ cvs -z3 -d:pserver:[email protected]:/cvsroot/tsunami-udp co -P tsunami-udp
    $ cd tsunami-udp
    $ ./recompile.sh
    $ make install
    

    Then on the server side:

    $ tsunamid --port 46224 * # (Serves all files from current directory for copy)
    

    On the client side:

    $ tsunami connect <server_ip> get *
    

    Transfer dataset back to S3:

    aws s3 cp --recursive /mnt/bigephemeral s3://<your-new-bucket>/
    

    Limitations:

    • Tsunami UDP transfers only files and doesn’t do directories/ subdirectories, we need to tar them all up as one single tar file (additional storage capacity needs to be taken into consideration).
    • Multi-threading is not supported.
    • Multi session not supported. Client supports only one connection to the server at a time. No parallel file transfer.
    • No resume or retry for file transfer.
    • Does not support Native encryption.

    Refs:

  • redhat – No ruby-devel in RHEL7? – Stack Overflow

    This answer comes by way of piecing together bits from other answers – so to the previous contributors…thank you because I would not have figured this out.This example is based on the RHEL 7 AMI (Amazon Managed Image) 3.10.0-229.el7.x86_64.So by default as mentioned above the optional repository is not enabled. Don’t add another repo.d file as it already exists just that it is disabled.To enable first you need the name. I used grep to do this:grep -B1 -i optional /etc/yum.repos.d/*above each name will be the repo id enclosed in [ ] look for the optional not optional-sourceEnable the optional repo:yum-config-manager –enable Refresh the yum cache (not sure if this is necessary but it doesn’t hurt):sudo yum makecacheFinally, you can install ruby-devel:yum install ruby-develDepending on your user’s permissions you may need to use sudo.

    Source: redhat – No ruby-devel in RHEL7? – Stack Overflow

  • Install Transmission on CentOS 7

    Nowadays it’s really simple to install Transmission on CentOS 7 or EL distro. First you need to install EPEL packages:

    $ yum install epel-release
    $ yum -y update
    

    …or use the following command if you’re running Red Hat Enterprise Linux:

    $ yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E '%{rhel}').noarch.rpm
    

    Install Transmission:

    $ yum install transmission-cli transmission-common transmission-daemon
    

    Create storage directory:

    $ mkdir /ebs-data/transmission/
    $ chown -R transmission.transmission /ebs-data/transmission/
    

    Start and stop the Transmission to auto generate configs:

    $ systemctl start transmission-daemon.service
    $ systemctl stop transmission-daemon.service
    

    To edit the config, you MUST first stop the daemon, otherwise the config will be overwritten after you restart the daemon:

    $ systemctl stop transmission-daemon.service
    $ var /var/lib/transmission/.config/transmission-daemon/settings.json
    

    Edit config:

    "download-dir": "/ebs-data/transmission",
    "incomplete-dir": "/ebs-data/transmission",
    "rpc-authentication-required": true,
    "rpc-enabled": true,
    "rpc-password": "my_password",
    "rpc-username": "my_user",
    "rpc-whitelist": "0.0.0.0",
    "rpc-whitelist-enabled": false,
    

    Save and start daemon:

    $ systemctl start transmission-daemon.service
    

    Access via your browser:

    $ open http://localhost:9091/transmission/web/
    
  • Enable IPv6 Tunnel Broker on Aliyun CentOS 7

    In /etc/modprobe.d/disable_ipv6.conf:

    alias net-pf-10 off
    #alias ipv6 off
    options ipv6 disable=0
    

    In /etc/sysctl.conf:

    net.ipv6.conf.all.disable_ipv6=0
    net.ipv6.conf.default.disable_ipv6=0
    net.ipv6.conf.lo.disable_ipv6=0
    

    Then run sysctl -p to take effect.

    Then in Example Configurations under HE.net Tunnel Details page, in the dropdown menu select Linux-route2, copy all the commands and paste into your server:

    modprobe ipv6
    ip tunnel add he-ipv6 mode sit remote 1.2.3.4 local 5.6.7.8 ttl 255
    ip link set he-ipv6 up
    ip addr add 2001:470:18:d18::2/64 dev he-ipv6
    ip route add ::/0 dev he-ipv6
    ip -f inet6 addr
    

    Test the tunnel:

    ping6 irc6.oftc.net
    
  • SELinux policy for nginx and GitLab unix socket in Fedora 19

    The installation of GitLab in Fedora 19 went fine. I followed the official installation guide with some deviations where necessary, mostly taken from the CentOS guide in gitlab-recipes. I setup nginx using the ssl config, and poked some holes in iptables. For systemd services I used these files.

    Source: SELinux policy for nginx and GitLab unix socket in Fedora 19

  • rsync and sudo over SSH | crashingdaily

    I do not have a root password for many of the servers I interact with so I can not SSH directly in as the root user. Also, the ssh daemons are wisely configured with ‘PermitRootLogin’ s…

    Source: rsync and sudo over SSH | crashingdaily

  • Run `sudo` with Ansible `become` Option on Google Compute Engine

    Playbook config:

    - name: basic setup
      hosts: default
      user: user
      become: true
      become_user: root
      become_method: sudo
      roles:
        - tasks
    

    If you got the following errors:

    GATHERING FACTS *************************************************************** 
    failed: [server1] => {"failed": true, "parsed": false}
    OpenSSH_6.9p1, LibreSSL 2.1.8
    debug1: Reading configuration data /Users/user/.ssh/config
    debug1: /Users/user/.ssh/config line 139: Applying options for server1
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 21: Applying options for *
    debug1: auto-mux: Trying existing master
    debug1: mux_client_request_session: master session id: 2
    sudo: sorry, you must have a tty to run sudo
    

    Then visudo and disable requiretty:

    Defaults    !requiretty
    
  • List and Change Kernel in CentOS 7

    List kernels:

    $ egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
    CentOS Linux (3.10.0-327.10.1.el7.x86_64) 7 (Core)
    CentOS Linux (3.10.0-327.4.5.el7.x86_64) 7 (Core)
    CentOS Linux (3.10.0-327.3.1.el7.x86_64) 7 (Core)
    CentOS Linux (3.10.0-229.20.1.el7.x86_64) 7 (Core)
    CentOS Linux (3.10.0-123.9.3.el7.x86_64) 7 (Core)
    CentOS Linux, with Linux 0-rescue-45461f76679f48ee96e95da6cc798cc8
    

    Set kernel to the fourth:

    $ grub2-set-default 3
    
  • RHEL7: How to get started with Firewalld. – CertDepot

    To assign the eth0 network interface temporarily to the internal zone, type:

    $ firewall-cmd --zone=internal --change-interface=eth0
    success
    

    To assign the eth0 network interface permanently to the internal zone (a file called internal.xml is created in the /etc/firewalld/zones directory), type:

    $ firewall-cmd --permanent --zone=internal --change-interface=eth0
    success
    

    Source: RHEL7: How to get started with Firewalld. – CertDepot

  • How To Set Up a Firewall Using FirewallD on CentOS 7 | DigitalOcean

    Firewalld is a complete firewall solution available by default on CentOS and Fedora servers. In this guide, we will cover how to set up a basic firewall for your server and show you the basics of managing the firewall with firewall-cmd, its command-li

    Source: How To Set Up a Firewall Using FirewallD on CentOS 7 | DigitalOcean

  • Fix rsync “Host Key Verification Failed” in Jenkins

    If you got the following error in Jenkins output using rsync:

    Running "shell:sync" (shell) task
    Host key verification failed.
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
    Warning: Command failed: Host key verification failed.
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
     Use --force to continue.
    

    Try the following:

    • su -s /bin/bash jenkins, since Jenkins install doesn’t have login shell by default on CentOS
    • ssh into target server
    • When prompt “Are you sure you want to continue connecting (yes/no)?”, type yes
    • Rerun the job
  • Allow sudo commands in Jenkins

    CentOS version. You should edit sudoers file:

    First add jenkins as sudoer without password:

    jenkins ALL= NOPASSWD:  ALL
    

    Then disable requiretty:

    Defaults    !requiretty
    
  • CentOS 6.1 上安装 git 出现 Requires: libcurl.so.3 的解决方案

    6 升级到 6.1 后安装 git 报错:

    root@dad:/# yum install git
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirror.nsc.liu.se
     * epel: ftp.riken.jp
     * extras: mirror.nsc.liu.se
     * ius: pancks.sothatswhy.org.uk
     * rpmforge: ftp-stud.fht-esslingen.de
     * updates: centosu.centos.org
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package git.i386 0:1.7.6.4-1.el5.rf will be installed
    --> Processing Dependency: perl-Git = 1.7.6.4-1.el5.rf for package: git-1.7.6.4-1.el5.rf.i386
    --> Processing Dependency: libcurl.so.3 for package: git-1.7.6.4-1.el5.rf.i386
    --> Processing Dependency: libexpat.so.0 for package: git-1.7.6.4-1.el5.rf.i386
    --> Processing Dependency: perl(Git) for package: git-1.7.6.4-1.el5.rf.i386
    --> Running transaction check
    ---> Package compat-expat1.i686 0:1.95.8-8.el6 will be installed
    ---> Package git.i386 0:1.7.6.4-1.el5.rf will be installed
    --> Processing Dependency: libcurl.so.3 for package: git-1.7.6.4-1.el5.rf.i386
    ---> Package perl-Git.i386 0:1.7.6.4-1.el5.rf will be installed
    --> Finished Dependency Resolution
    Error: Package: git-1.7.6.4-1.el5.rf.i386 (rpmforge)
               Requires: libcurl.so.3
     You could try using --skip-broken to work around the problem
     You could try running: rpm -Va --nofiles --nodigest
    

    解决方案:编辑 /etc/yum.repos.d/rpmforge.repo,开启 extra repo

    再次执行后:

    ...
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Warning: RPMDB altered outside of yum.
      Installing : git-1.7.6.4-1.el6.rfx.i686                                                                       1/2 
      Installing : perl-Git-1.7.6.4-1.el6.rfx.i686                                                                  2/2 
    
    Installed:
      git.i686 0:1.7.6.4-1.el6.rfx                                                                                      
    
    Dependency Installed:
      perl-Git.i686 0:1.7.6.4-1.el6.rfx                                                                                 
    
    Complete!
    

    解决方案(来源):

    yum clean all
    
  • CentOS 运行 rtorrent / libtorrent 教程指北

    东拼西凑,备忘属性很多,总之 CentOS 上跑 rtorrent 做 seedbox 大体需要以下这些:

    • pkg-config
    • libcurl
    • openssl
    • ncurses
    • libsigc++
    • libtorrent
    • rtorrent

    (more…)