Bitcoin Forum

Other => Off-topic => Topic started by: kodtycoon on December 28, 2014, 02:51:48 AM



Title: someone who knows centOS 6 please help me.
Post by: kodtycoon on December 28, 2014, 02:51:48 AM
yes i know this if totally off topic but please dont shoot me. im on the very last hurdle after a 24 hour binge of learning linux from scratch to do this so im way too tired to set up an account anywhere else to post the problem. (mods move this to where ever appropriate if needed)

im configuring a server and im using these lines of code:

Code:
iptables -D INPUT 1
iptables -D INPUT 1
iptables -D INPUT 1
iptables -D INPUT 1
iptables -D INPUT 1
iptables -D OUTPUT 1
iptables -D FORWARD 1

iptables -I INPUT 1 -p tcp --dport 7890 -j ACCEPT
iptables -I OUTPUT 1 -p tcp --dport 7890 -j ACCEPT
iptables -I FORWARD 1 -p tcp --dport 7890 -j ACCEPT

yum install java-1.8.0-openjdk-headless.x86_x64

           sudo dd if=/dev/zero of=/swapfile bs=2048 count=512k

sudo mkswap /swapfile
sudo swapon /swapfile

sudo nano /etc/fstab
<inserted> swap     /swapfile    swap     defaults      0 0

sudo nano /etc/sysctl.conf
<inserted> vm.swappiness=10

the code goes in fine, but after reboot of the server, swappiness is still at 10. /swapfile is still saved in /fstab, java is still on it as are the iptable settings, but the swap disk(indented line) vanishes ie when i do "swapon -s" nothing is there. isnt saving /swapfile into /fstab and/or setting vm.swappiness=10 supposed to make it permanent?


Title: Re: someone who knows centOS 6 please help me.
Post by: moni3z on December 28, 2014, 03:42:19 AM
yes i know this if totally off topic but please dont shoot me. im on the very last hurdle after a 24 hour binge of learning linux from scratch to do this so im way too tired to set up an account anywhere else to post the problem. (mods move this to where ever appropriate if needed)

im configuring a server and im using these lines of code:

Code:
iptables -D INPUT 1
iptables -D INPUT 1
iptables -D INPUT 1
iptables -D INPUT 1
iptables -D INPUT 1
iptables -D OUTPUT 1
iptables -D FORWARD 1

iptables -I INPUT 1 -p tcp --dport 7890 -j ACCEPT
iptables -I OUTPUT 1 -p tcp --dport 7890 -j ACCEPT
iptables -I FORWARD 1 -p tcp --dport 7890 -j ACCEPT

yum install java-1.8.0-openjdk-headless.x86_x64

           sudo dd if=/dev/zero of=/swapfile bs=2048 count=512k

sudo mkswap /swapfile
sudo swapon /swapfile

sudo nano /etc/fstab
<inserted> swap     /swapfile    swap     defaults      0 0

sudo nano /etc/sysctl.conf
<inserted> vm.swappiness=10

the code goes in fine, but after reboot of the server, swappiness is still at 10. /swapfile is still saved in /fstab, java is still on it as are the iptable settings, but the swap disk(indented line) vanishes ie when i do "swapon -s" nothing is there. isnt saving /swapfile into /fstab and/or setting vm.swappiness=10 supposed to make it permanent?

I don't use CentOS but https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-6
/etc/fstab seems it should be:

/swapfile          swap            swap    defaults        0 0

edit: man fstab confirms digital ocean guide is correct http://linux.die.net/man/5/fstab


Title: Re: someone who knows centOS 6 please help me.
Post by: Flashman on December 28, 2014, 03:51:30 AM
No linux guru, just a meddler, but two thoughts, don't you have to mount it? annnd not sure if you're complaining of lack of swapping to swapfile, which might not happen until you run out of RAM.


Title: Re: someone who knows centOS 6 please help me.
Post by: Flashman on December 28, 2014, 04:29:22 AM
Oh right, and it won't come back with swapon /swapfile ? because that is a non-persistent command needs to be run on boot.


Title: Re: someone who knows centOS 6 please help me.
Post by: Bitsky on December 28, 2014, 09:02:14 AM
Try that. You have an error in your fstab; and setting up iptables like this just calls for errors.

Code:
cp /etc/sysconfig/iptables /etc/sysconfig/iptables.org
cat << EOF > /etc/sysconfig/iptables
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp --icmp-type 0 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -p tcp --dport 7890 -j ACCEPT
COMMIT
EOF
service iptables restart

yum install java-1.8.0-openjdk-headless.x86_x64

echo "vm.swappiness = 10" > /etc/sysctl.conf
echo "swap                    /swapfile               swap    defaults  0 0" >> /etc/fstab
dd if=/dev/zero of=/swapfile bs=2048 count=512k
chmod 0600 /swapfile
mkswap /swapfile
swapon -va

reboot


Title: Re: someone who knows centOS 6 please help me.
Post by: Bitsky on December 29, 2014, 08:52:32 AM
Don't run it as part of the normal boot process, because it will add entries to sysctl.conf and fstab each time.

And my bad, I forgot to correct the fstab line you had wrong, sorry :-[ I had the correct entry in my fstab where it works fine.
You shouldn't need any extra steps after that. Since it's in fstab it should come up right during boot.

Try this one:
Code:
/swapfile               swap                    swap    defaults  0 0
Check with "swapoff -va && swapon -va && swapon -s" if the swaps are activated and used