linux搭建挂机宝教程,nokvm – 单ip搭建挂机宝详细教程
nokvm 介紹:
全國首家免費(fèi)的私有云計(jì)算虛擬化管理系統(tǒng)一款強(qiáng)大的基于Web的虛擬化控制面板。 管理員可以通過點(diǎn)擊按鈕即時創(chuàng)建主機(jī),用戶可以使用非常高級的基于Web的GUI來啟動,停止,重新啟動和管理他們的主機(jī)。 用戶和管理員可以更好地管理其資源。下面教大家如果搭建單ip掛機(jī)寶。
單ip掛機(jī)寶和開一臺轉(zhuǎn)發(fā)機(jī)步驟類似:
雙ip掛機(jī)寶教程請移步:
單ip掛機(jī)寶 如果被ddos 母雞會直接癱瘓。建議選擇高防ip,
1、首先開一臺轉(zhuǎn)發(fā)機(jī),設(shè)定的ssh密碼一定要和宿主機(jī)ssh密碼一致。
2、強(qiáng)制關(guān)閉這臺轉(zhuǎn)發(fā)機(jī)器電源(用不到了但是也不可以刪除)。
3、登錄宿主機(jī)執(zhí)行 virsh autostart –disable ****? (****是你第一個機(jī)器名字 比如我們測試機(jī)名字是:ecs-heTqk 就輸入?virsh autostart –disable?ecs-heTqk) (取消開機(jī)自啟動)
4、ssh登錄主控,連接control數(shù)據(jù)庫,修改ip_address表 找到分配給這臺轉(zhuǎn)發(fā)機(jī)的ip 修改為宿主機(jī)的ip (這樣 ip 和 密碼都和宿主機(jī)一致了 也就相當(dāng)于ssh遠(yuǎn)程連接到宿主機(jī)執(zhí)行命令)
1)查看數(shù)據(jù)庫密碼?cat /home/wwwroot/control/.env?DB_PASSWORD 字段就是數(shù)據(jù)庫密碼
2)連接數(shù)據(jù)庫?mysql -uroot -p
然后輸入上面查詢到密碼
3)進(jìn)入到control表?use control; (;一定要輸入)
4)修改轉(zhuǎn)發(fā)機(jī)ip為宿主機(jī)ip?查看表數(shù)據(jù) : select * from ip_address;?(;一定要輸入)
update ip_address set ip='宿主機(jī)ip' where id=xxx;? (Id=xxx? xxx是IP ID 我是剛搭建的所以ID是 1??update ip_address set ip='宿主機(jī)ip' where id=1;)??(;一定要輸入)
(以下操作還在實(shí)驗(yàn)中 ,上面的成功了 但是不能遠(yuǎn)程 機(jī)器里面能上網(wǎng))
5、在宿主機(jī)虛擬機(jī)數(shù)據(jù)目錄中(/home/nokvm/resource/轉(zhuǎn)發(fā)機(jī)名/change.sh),拷貝轉(zhuǎn)發(fā)機(jī)目錄的change.sh 并修改其內(nèi)容 (網(wǎng)段不一定要按照我的來 可以自己劃分網(wǎng)段,使vps的網(wǎng)關(guān)指定為br0:0配置的ip地址)
cd /home/nokvm/resource/ecs-xxx/
cp change.sh modify.sh
// 修改過的樣例:
# cat modify.sh
ncf2=/etc/sysconfig/network-scripts/ifcfg-br0:0
/usr/bin/rm -rf $ncf2
/usr/bin/echo DEVICE=br0:0 >>$ncf2
/usr/bin/echo TYPE=Ethernet >>$ncf2
/usr/bin/echo BOOTPROTO=static >>$ncf2
/usr/bin/echo IPADDR=172.16.0.1 >>$ncf2
/usr/bin/echo NETMASK=255.255.248.0 >>$ncf2
/usr/bin/echo ONBOOT=yes >>$ncf2
systemctl restart network
ulimit -n 65535
/usr/bin/echo 'root soft nofile 65535' >> /etc/security/limits.conf
/usr/bin/echo 'root hard nofile 65535' >> /etc/security/limits.conf
/usr/bin/echo '* soft nofile 65535' >> /etc/security/limits.conf
/usr/bin/echo '* hard nofile 65535' >> /etc/security/limits.conf
/usr/bin/echo '* soft nproc 65535' >> /etc/security/limits.conf
/usr/bin/echo '* hard nproc 65535' >> /etc/security/limits.conf
/usr/bin/echo '* soft nofile 65535' >> /etc/security/limits.conf
/usr/bin/echo '* hard nofile 65535' >> /etc/security/limits.conf
/usr/bin/echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf
/usr/sbin/sysctl -p
/usr/bin/wget -O /root/iptables-1.4.21-28.el7.x86_64.rpm http://down.tasiyun.com/soft/iptables-1.4.21-28.el7.x86_64.rpm
/usr/bin/wget -O /root/iptables-services-1.4.21-28.el7.x86_64.rpm http://down.tasiyun.com/soft/iptables-services-1.4.21-28.el7.x86_64.rpm
/usr/bin/rpm -i /root/iptables-1.4.21-28.el7.x86_64.rpm --nodeps
/usr/bin/rpm -i /root/iptables-services-1.4.21-28.el7.x86_64.rpm --nodeps
systemctl stop firewalld
systemctl disable firewalld
systemctl enable iptables
systemctl start iptables
iptables -F
iptables -X
iptables -Z
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 8088 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
iptables -t nat -A POSTROUTING -s 172.16.0.0/21 -o br0 -j MASQUERADE
iptables -A FORWARD -s 172.16.0.0/21 -o br0 -j ACCEPT
iptables -A FORWARD -d 172.16.0.0/21 -m state --state ESTABLISHED,RELATED -i br0 -j ACCEPT
service iptables save
/usr/bin/wget -O /root/nginx-1.16.0-1.el7.ngx.x86_64.rpm http://down.tasiyun.com/soft/nginx-1.16.0-1.el7.ngx.x86_64.rpm
/usr/bin/rpm -i /root/nginx-1.16.0-1.el7.ngx.x86_64.rpm --nodeps
/usr/bin/rm -rf /etc/nginx/nginx.conf
/usr/bin/rm -rf /root/nginx-1.16.0-1.el7.ngx.x86_64.rpm
/usr/bin/wget -O /etc/nginx/nginx.conf http://down.tasiyun.com/soft/nginx.conf
/usr/bin/systemctl start nginx
/usr/bin/systemctl enable nginx
6、在母雞執(zhí)行修改過的腳本。
7、后面就是添加vps的ip池 網(wǎng)關(guān)指定br0:0的ip 子網(wǎng)自行劃分。
總結(jié)
以上是生活随笔為你收集整理的linux搭建挂机宝教程,nokvm – 单ip搭建挂机宝详细教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Note For Linux By Je
- 下一篇: Linux的文件操作