OpenVZ:修订间差异
小无编辑摘要 |
|||
(未显示4个用户的124个中间版本) | |||
第1行: | 第1行: | ||
OpevnVZ 一些自用初始化脚本 | OpevnVZ 一些自用初始化脚本 | ||
= 服务端 = | |||
== 准备 == | |||
系统 centos 6.7 | |||
== 安装 dnsmasq == | |||
<source lang=bash> | |||
yum install dnsmasq | |||
sed -i "s@#resolv-file.*$@resolv-file=/etc/resolv.masqdns" | |||
cp /etc/resolv.conf /etc/resolv.masqdns | |||
echo "nameserver 127.0.0.1" > /etc/resolv.conf | |||
chkconfig dnsmasq on | |||
service dnsmasq start | |||
</source> | |||
== 安装 openvz == | |||
<source lang=bash> | |||
wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo | |||
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ | |||
yum install vzkernel | |||
cat << "EOF" >> /etc/sysctl.conf | |||
# On Hardware Node we generally need | |||
# packet forwarding enabled and proxy arp disabled | |||
net.ipv4.ip_forward = 1 | |||
net.ipv6.conf.default.forwarding = 1 | |||
net.ipv6.conf.all.forwarding = 1 | |||
net.ipv4.conf.default.proxy_arp = 0 | |||
# Enables source route verification | |||
net.ipv4.conf.all.rp_filter = 1 | |||
# Enables the magic-sysrq key | |||
kernel.sysrq = 1 | |||
# We do not want all our interfaces to send redirects | |||
net.ipv4.conf.default.send_redirects = 1 | |||
net.ipv4.conf.all.send_redirects = 0 | |||
EOF | |||
sysctl -p | |||
echo "SELINUX=disabled" > /etc/sysconfig/selinux | |||
yum install vzctl vzquota ploop | |||
reboot | |||
</source> | |||
== 安装 OpenVZ Web Panel == | |||
<source lang=bash> | |||
yum install rubygems ruby-devel | |||
gem sources -a http://rubygems.org | |||
gem update --system | |||
gem update --system 1.8.25 | |||
gem install sqlite3-ruby | |||
wget -O - https://raw.githubusercontent.com/sibprogrammer/owp/master/installer/ai.sh | \ | |||
bash -s DOWNLOAD_URL=http://owp.softunity.com.ru/download/ovz-web-panel-latest.tgz | |||
chkconfig owp on | |||
</source> | |||
面板默认登陆用户名密码:admin/admin | |||
注意,安装完毕OpenVZ的内核后,需要重启服务器再安装面板,面板需要将ruby的版本控制在1.8.25。 | |||
删除面板的代码: | |||
<source lang=bash> | |||
wget -O - https://raw.githubusercontent.com/sibprogrammer/owp/master/installer/ai.sh | sh -s UNINSTALL=1 | |||
</source> | |||
== 配置防火墙 == | |||
<pre> | |||
iptables -A INPUT -p tcp -m tcp --dport 3000 -j ACCEPT | |||
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT | |||
iptables -t nat -A POSTROUTING -o em1 -j MASQUERADE | |||
# 不能按下面的设置地址伪装,会造成不同服务器的 192.168.2.0/24 网段之间的访问也地址伪装,这样是不对的 | |||
#iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE | |||
#iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT | |||
#iptables -A FORWARD -d 192.168.2.0/24 -j ACCEPT | |||
service iptables save | |||
service iptables restart | |||
</pre> | |||
== vz 配置 == | |||
vim /etc/sysconfig/vz | |||
mkdir /home/vz | |||
cp -ra /vz/* /home/vz | |||
mv /vz /vz_bak | |||
ln -s /home/vz / | |||
= 客户机 = | |||
== 基本环境配置 == | |||
sed -i "s/archive.ubuntu.com/mirrors.163.com/" /etc/apt/sources.list | sed -i "s/archive.ubuntu.com/mirrors.163.com/" /etc/apt/sources.list | ||
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5 | |||
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32 | |||
apt-get update | apt-get update | ||
apt-get dist-upgrade | apt-get -y dist-upgrade | ||
locale-gen --lang zh_CN.UTF-8 | locale-gen --lang zh_CN.UTF-8 | ||
dpkg-reconfigure locales | dpkg-reconfigure locales | ||
update-locale LANG=zh_CN.UTF-8 | |||
rm /etc/localtime | |||
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | |||
echo "Asia/Shanghai" >/etc/timezone | |||
apt-get install sudo screen | apt-get install sudo screen | ||
adduser ubuntu | adduser ubuntu | ||
adduser ubuntu sudo | adduser ubuntu sudo | ||
apt-get install postgresql | |||
== 安装java == | |||
apt-get install openjdk-7-jdk | |||
apt-get install maven | |||
== 安装python == | |||
apt-get -y install python3-pip python3-dev build-essential | |||
pip3 install --upgrade pip | |||
rm /usr/bin/pip3 | |||
ln -s /usr/local/bin/pip3 /usr/bin/ | |||
mkdir ~/.pip | |||
vim ~/.pip/pip.conf | |||
加入: | |||
[global] | |||
index-url = http://pypi.douban.com/simple | |||
[install] | |||
trusted-host=pypi.douban.com | |||
== 安装数据库 postgresql == | |||
apt-get install postgresql postgresql-contrib | |||
sed -i "s/#\(include_if_exists.*\)/\1/" /etc/postgresql/9.3/main/postgresql.conf | sed -i "s/#\(include_if_exists.*\)/\1/" /etc/postgresql/9.3/main/postgresql.conf | ||
echo "listen_addresses = '*'" >> /etc/postgresql/9.3/main/exists.conf | echo "listen_addresses = '*'" >> /etc/postgresql/9.3/main/exists.conf | ||
echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf | |||
/etc/init.d/postgresql restart | /etc/init.d/postgresql restart | ||
=== 设置数据库密码 === | |||
sudo -u postgres psql postgres | sudo -u postgres psql postgres | ||
postgres=# \password postgres | postgres=# \password postgres | ||
postgres=# \quit | postgres=# \quit | ||
---------------- | |||
=== 安装 uuid 扩展 === | |||
sudo -u postgres psql postgres | |||
postgres=# CREATE EXTENSION "uuid-ossp"; | |||
CREATE EXTENSION | |||
postgres=# select uuid_generate_v4(); | |||
uuid_generate_v4 | |||
-------------------------------------- | |||
a4829383-e6f9-419f-a567-196ccf72b190 | |||
(1 row) | |||
postgres=# select uuid_generate_v1(); | |||
uuid_generate_v1 | |||
-------------------------------------- | |||
ffc5a0fa-156b-11e5-a568-6f5620948752 | |||
(1 row) | |||
== 下载wildfly == | |||
su ubuntu | su ubuntu | ||
cd | cd | ||
第32行: | 第161行: | ||
cd /home/ubuntu/wildfly/standalone/deployments | cd /home/ubuntu/wildfly/standalone/deployments | ||
wget https://jdbc.postgresql.org/download/postgresql-9.4-1200.jdbc41.jar | wget https://jdbc.postgresql.org/download/postgresql-9.4-1200.jdbc41.jar | ||
--- | |||
=== 建立数据库 === | |||
sudo -u postgres createdb core -E UTF8 -T template0 | |||
=== 配置wildfly数据源 === | |||
cd /home/ubuntu/wildfly/bin | |||
./jboss-cli.sh --connect | ./jboss-cli.sh --connect | ||
[standalone@localhost:9990 /] data-source add --name=core --jndi-name=java:/core --driver-name=postgresql-9.4-1200.jdbc41.jar --connection-url=java:postgresql: | |||
创建数据源的命令为: | |||
data-source add --name=core --jndi-name=java:/core --driver-name=postgresql-9.4-1200.jdbc41.jar --connection-url=java:postgresql:core --user-name=postgres --password=postgres --transaction-isolation==TRANSACTION_READ_COMMITTED --min-pool-size=10 --max-pool-size=250 | |||
例如: | |||
[standalone@localhost:9990 /] data-source add --name=core --jndi-name=java:/core --driver-name=postgresql-9.4-1200.jdbc41.jar --connection-url=java:postgresql:core --user-name=postgres --password=postgres --transaction-isolation==TRANSACTION_READ_COMMITTED --min-pool-size=10 --max-pool-size=250 | |||
[standalone@localhost:9990 /] exit | |||
== 安装 rabbitmq == | |||
echo "deb http://www.rabbitmq.com/debian/ testing main" > /etc/apt/sources.list.d/rabbitmq.list | |||
wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc | |||
apt-key add rabbitmq-signing-key-public.asc | |||
apt-get update | |||
apt-get install rabbitmq-server | |||
rabbitmq-plugins enable rabbitmq_management | |||
rabbitmq-plugins enable rabbitmq_web_stomp | |||
rabbitmqctl add_user webuser 123456 | |||
rabbitmqctl set_user_tags webuser monitoring | |||
----权限---- | |||
rabbitmqctl set_permissions -p / user '.*' '.*' '.*' | |||
访问: http://IP:15672/ | |||
== 安装 mongodb == | |||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 | |||
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list | |||
sudo apt-get update | |||
sudo apt-get install -y mongodb-org | |||
== 安装 redis == | |||
sudo apt-get install software-properties-common | |||
apt-add-repository ppa:chris-lea/redis-server | |||
apt-get update | |||
apt-get install redis-server | |||
=== 安装 redis群集 === | |||
至少准备3台服务器 | |||
修改 /etc/redis/redis.conf 文件: | |||
bind 0.0.0.0 | |||
appendonly yes | |||
cluster-enabled yes | |||
cluster-config-file nodes.conf | |||
cluster-node-timeout 5000 | |||
service redis-server restart | |||
在其中一台上执行: | |||
wget http://download.redis.io/releases/redis-3.0.7.tar.gz | |||
tar xzvf redis-3.0.7.tar.gz | |||
apt-get install ruby | |||
cd redis-3.0.7 | |||
gem install redis | |||
添加群集 | |||
./src/create --replicas 0 192.168.X.1:6379 192.168.X.2:6379 192.168.X.3:6379 | |||
测试 | |||
redis-cli -c | |||
127.0.0.1:6379> set a 1 | |||
127.0.0.1:6379> get a | |||
"1" | |||
== zookeeper == | |||
=== 安装 zookeeper === | |||
wget http://archive.apache.org/dist/zookeeper/stable/zookeeper-3.4.9.tar.gz | |||
tar -zxvf zookeeper-3.4.9.tar.gz -C /opt | |||
ln -s /opt/zookeeper-3.4.9 /opt/zookeeper | |||
cp /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg | |||
mkdir /opt/zookeeper/data | |||
sed -i 's/dataDir=.*$/dataDir=\/opt\/zookeeper\/data/' /opt/zookeeper/conf/zoo.cfg | |||
启动 | |||
/opt/zookeeper/bin/zkServer.sh start | |||
关闭 | |||
/opt/zookeeper/bin/zkServer.sh stop | |||
=== 安装 zookeeper 面板 zkdash === | |||
apt-get install git python-pip libmysqld-dev python-dev libyaml-dev | |||
git clone https://github.com/ireaderlab/zkdash.git | |||
cd zkdash | |||
pip install -r requirements.txt | |||
安装 mysql 数据库 | |||
apt-get install mysql-server | |||
mysqladmin create zkdash | |||
修改数据库配置和连接属性: | |||
vim conf/conf.yml | |||
同步数据 | |||
python ./bin/syncdb.py | |||
启动: | |||
cd zkdash | |||
screen python init.py -port=80 | |||
=== python 使用 zookeeper === | |||
安装: | |||
pip install kazoo | |||
使用: | |||
from django.core.cache import cache | |||
from kazoo.client import KazooClient | |||
... | |||
def getmailPassword(self): | |||
password=cache.get('password') | |||
if password==None: | |||
zk = KazooClient(hosts='x.x.x.x:2181,x.x.x.x:2181') | |||
zk.start() | |||
password, stat = zk.get('/xxx/xxxx/xxxx') | |||
cache.set('password',password,3600) | |||
return password | |||
=== 安装 hadoop === | |||
==== 安装 ==== | |||
wget http://mirrors.cnnic.cn/apache/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz | |||
tar -zxf hadoop-2.7.3.tar.gz -C /usr/local | |||
cd /usr/local/ | |||
mv hadoop-2.7.3 hadoop | |||
adduser hadoop | |||
chown -R hadoop hadoop/ | |||
su hadoop | |||
ssh-keygen -t rsa | |||
cd ~/.ssh/ | |||
cat ./id_rsa.pub >> ./authorized_keys | |||
echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ~/.bashrc | |||
source ~/.bashrc | |||
/usr/local/hadoop/bin/hadoop version | |||
==== 配置 ==== | |||
cat ./etc/hadoop/core-site.xml | |||
<source lang=xml> | |||
<configuration> | |||
<property> | |||
<name>hadoop.tmp.dir</name> | |||
<value>file:/usr/local/hadoop/tmp</value> | |||
<description>Abase for other temporary directories.</description> | |||
</property> | |||
<property> | |||
<name>fs.defaultFS</name> | |||
<value>hdfs://localhost:9000</value> | |||
</property> | |||
</configuration> | |||
</source> | |||
cat ./etc/hadoop/hdfs-site.xml | |||
<source lang=xml> | |||
<configuration> | |||
<property> | |||
<name>dfs.replication</name> | |||
<value>1</value> | |||
</property> | |||
<property> | |||
<name>dfs.namenode.name.dir</name> | |||
<value>file:/usr/local/hadoop/tmp/dfs/name</value> | |||
</property> | |||
<property> | |||
<name>dfs.datanode.data.dir</name> | |||
<value>file:/usr/local/hadoop/tmp/dfs/data</value> | |||
</property> | |||
</configuration> | |||
</source> | |||
执行 NameNode 的格式化: | |||
./bin/hdfs namenode -format | |||
修改 | |||
./etc/hadoop/hadoop-env.sh | |||
./etc/hadoop/yarn-env.sh | |||
设置 JAVA_HOME 为:/usr/lib/jvm/java-7-openjdk-amd64 | |||
启动 | |||
./sbin/start-dfs.sh | |||
检查启动: | |||
<source lang=bash> | |||
hadoop@TEST:/usr/local/hadoop$ jps | |||
25413 NameNode | |||
25734 SecondaryNameNode | |||
25522 DataNode | |||
25909 Jps | |||
</source> | |||
WEB访问面板: | |||
http://192.168.2.222:50070/ | |||
关闭 | |||
./sbin/stop-dfs.sh | |||
== 安装 AeroGear == | |||
=== 安装 wildfly 8.2 === | |||
wget http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.tar.gz | |||
tar xzvf wildfly-8.2.0.Final.tar.gz | |||
=== 安装 mysql === | |||
apt-get install mysql-server | |||
=== 安装 AeroGear UnifiedPush Server === | |||
==== 环境准备 ==== | |||
wget -c https://github.com/aerogear/aerogear-unifiedpush-server/releases/download/1.1.3.Final/aerogear-unifiedpush-server-1.1.3.Final-dist.tar.gz | |||
tar xzvf aerogear-unifiedpush-server-1.1.3.Final-dist.tar.gz | |||
cd aerogear-unifiedpush-server-1.1.3.Final | |||
cd migrator | |||
unzip ups-migrator-dist.zip | |||
cp -r ~/aerogear-unifiedpush-server-1.1.3.Final/databases/src/main/resources/modules/com ~/wildfly-8.2.0.Final/modules/ | |||
cp ~/aerogear-unifiedpush-server-1.1.3.Final/migrator/ups-migrator/lib/mysql-connector-java-5.1.18.jar ~/wildfly-8.2.0.Final/modules/com/mysql/jdbc/main/ | |||
==== 数据库准备 ==== | |||
mysql -u root -p | |||
mysql> create database unifiedpush default character set = "UTF8" default collate = "utf8_general_ci"; | |||
mysql> create database keycloak default character set = "UTF8" default collate = "utf8_general_ci"; | |||
mysql> create user 'unifiedpush'@'localhost' identified by 'unifiedpush'; | |||
mysql> GRANT SELECT,INSERT,UPDATE,ALTER,DELETE,CREATE,DROP,INDEX ON unifiedpush.* TO 'unifiedpush'@'localhost'; | |||
mysql> GRANT SELECT,INSERT,UPDATE,ALTER,DELETE,CREATE,DROP ON keycloak.* TO 'unifiedpush'@'localhost'; | |||
mysql> quit | |||
~/wildfly-8.2.0.Final/bin/standalone.sh --server-config=standalone-full.xml -b 0.0.0.0 | |||
另外开一个终端执行创建Jboss数据源 | |||
~/wildfly-8.2.0.Final/bin/jboss-cli.sh --file=/root/aerogear-unifiedpush-server-1.1.3.Final/databases/mysql-database-config-wildfly.cli | |||
建立数据库表 | |||
cd ~/aerogear-unifiedpush-server-1.1.3.Final/migrator/ups-migrator | |||
cp liquibase-mysql-example.properties liquibase.properties | |||
vim liquibase.properties | |||
修改 url=jdbc:mysql://localhost:3306/unifiedpush100li 为 url=jdbc:mysql://localhost:3306/unifiedpush | |||
./bin/ups-migrator update | |||
如下提示,表示成功更新: | |||
Liquibase Update Successful | |||
==== 部署 aerogear-unifiedpush-server ==== | |||
cp ~/aerogear-unifiedpush-server-1.1.3.Final/servers/unifiedpush-auth-server.war ~/wildfly-8.2.0.Final/standalone/deployments/ | |||
cp ~/aerogear-unifiedpush-server-1.1.3.Final/servers/unifiedpush-server-wildfly.war ~/wildfly-8.2.0.Final/standalone/deployments/ | |||
看wildfly的日志 | |||
==== 访问 ==== | |||
http://x.x.x.x:8080/ag-push/ | |||
默认用户名 admin 密码 adm | |||
=== 安装 AeroGear SimplePush Server === | |||
==== 下载并直接运行 ==== | |||
git clone https://github.com/aerogear/aerogear-simplepush-server.git | |||
cd aerogear-simplepush-server | |||
mvn install -DskipTests=true | |||
cd server-netty | |||
mvn exec:java -Dexec.args="-host=localhost -port=7777 -tls=false -ack_interval=10000 -useragent_reaper_timeout=60000 -token_key=yourRandomToken" | |||
==== 部署到 wildfly 运行 ==== | |||
cd wildfly-module/ | |||
mvn package -DskipTests=true | |||
cp -r ~/aerogear-simplepush-server/wildfly-module/target/module/org ~/wildfly-8.2.0.Final/modules/system/layers/base/ | |||
~/wildfly-8.2.0.Final/bin/jboss-cli.sh --file=/root/aerogear-simplepush-server/wildfly-module/src/main/resources/wildfly-config.cli | |||
=== 安装tf支持 === | |||
sed -i "s/archive.ubuntu.com/mirrors.163.com/" /etc/apt/sources.list | |||
apt-get update | |||
locale-gen --lang zh_CN.UTF-8 | |||
apt-get install python3-pip | |||
pip3 install -i https://mirrors.aliyun.com/pypi/simple --upgrade pip | |||
rm /usr/bin/pip3 | |||
ln -s /usr/local/bin/pip3 /usr/bin/pip3 | |||
pip3 install -i https://mirrors.aliyun.com/pypi/simple gunicorn flask image | |||
pip3 install -i https://mirrors.aliyun.com/pypi/simple numpy tensorflow==1.15 | |||
=== 安装pytorch === | |||
pip3 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html | |||
== 常用维护命令 == | |||
=== 查看内存被什么消耗 === | |||
ps -eo vsz,rss,pid,cmd --sort -vsz|head -n 20 | |||
=== 解决系统更新后ssh服务无法启动的问题 === | |||
mkdir -p -m0755 /var/run/sshd && systemctl restart ssh.service |
2020年8月31日 (一) 17:46的最新版本
OpevnVZ 一些自用初始化脚本
服务端
准备
系统 centos 6.7
安装 dnsmasq
<source lang=bash> yum install dnsmasq sed -i "s@#resolv-file.*$@resolv-file=/etc/resolv.masqdns" cp /etc/resolv.conf /etc/resolv.masqdns echo "nameserver 127.0.0.1" > /etc/resolv.conf chkconfig dnsmasq on service dnsmasq start </source>
安装 openvz
<source lang=bash> wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ yum install vzkernel cat << "EOF" >> /etc/sysctl.conf
- On Hardware Node we generally need
- packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1 net.ipv6.conf.default.forwarding = 1 net.ipv6.conf.all.forwarding = 1 net.ipv4.conf.default.proxy_arp = 0
- Enables source route verification
net.ipv4.conf.all.rp_filter = 1
- Enables the magic-sysrq key
kernel.sysrq = 1
- We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0 EOF
sysctl -p echo "SELINUX=disabled" > /etc/sysconfig/selinux yum install vzctl vzquota ploop reboot </source>
安装 OpenVZ Web Panel
<source lang=bash> yum install rubygems ruby-devel gem sources -a http://rubygems.org gem update --system gem update --system 1.8.25 gem install sqlite3-ruby wget -O - https://raw.githubusercontent.com/sibprogrammer/owp/master/installer/ai.sh | \ bash -s DOWNLOAD_URL=http://owp.softunity.com.ru/download/ovz-web-panel-latest.tgz chkconfig owp on </source> 面板默认登陆用户名密码:admin/admin
注意,安装完毕OpenVZ的内核后,需要重启服务器再安装面板,面板需要将ruby的版本控制在1.8.25。
删除面板的代码: <source lang=bash> wget -O - https://raw.githubusercontent.com/sibprogrammer/owp/master/installer/ai.sh | sh -s UNINSTALL=1 </source>
配置防火墙
iptables -A INPUT -p tcp -m tcp --dport 3000 -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT iptables -t nat -A POSTROUTING -o em1 -j MASQUERADE # 不能按下面的设置地址伪装,会造成不同服务器的 192.168.2.0/24 网段之间的访问也地址伪装,这样是不对的 #iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE #iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT #iptables -A FORWARD -d 192.168.2.0/24 -j ACCEPT service iptables save service iptables restart
vz 配置
vim /etc/sysconfig/vz mkdir /home/vz cp -ra /vz/* /home/vz mv /vz /vz_bak ln -s /home/vz /
客户机
基本环境配置
sed -i "s/archive.ubuntu.com/mirrors.163.com/" /etc/apt/sources.list apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5 apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32 apt-get update apt-get -y dist-upgrade locale-gen --lang zh_CN.UTF-8 dpkg-reconfigure locales update-locale LANG=zh_CN.UTF-8 rm /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo "Asia/Shanghai" >/etc/timezone apt-get install sudo screen adduser ubuntu adduser ubuntu sudo
安装java
apt-get install openjdk-7-jdk apt-get install maven
安装python
apt-get -y install python3-pip python3-dev build-essential pip3 install --upgrade pip rm /usr/bin/pip3 ln -s /usr/local/bin/pip3 /usr/bin/ mkdir ~/.pip vim ~/.pip/pip.conf
加入:
[global] index-url = http://pypi.douban.com/simple [install] trusted-host=pypi.douban.com
安装数据库 postgresql
apt-get install postgresql postgresql-contrib sed -i "s/#\(include_if_exists.*\)/\1/" /etc/postgresql/9.3/main/postgresql.conf echo "listen_addresses = '*'" >> /etc/postgresql/9.3/main/exists.conf echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf /etc/init.d/postgresql restart
设置数据库密码
sudo -u postgres psql postgres postgres=# \password postgres postgres=# \quit
安装 uuid 扩展
sudo -u postgres psql postgres postgres=# CREATE EXTENSION "uuid-ossp"; CREATE EXTENSION postgres=# select uuid_generate_v4(); uuid_generate_v4 -------------------------------------- a4829383-e6f9-419f-a567-196ccf72b190 (1 row) postgres=# select uuid_generate_v1(); uuid_generate_v1 -------------------------------------- ffc5a0fa-156b-11e5-a568-6f5620948752 (1 row)
下载wildfly
su ubuntu cd wget http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.tar.gz tar xzvf wildfly-8.2.0.Final.tar.gz mv wildfly-8.2.0.Final wildfly rm wildfly-8.2.0.Final.tar.gz echo 'JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=0.0.0.0"' >> /home/ubuntu/wildfly/bin/standalone.conf echo 'JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address.management=0.0.0.0"' >> /home/ubuntu/wildfly/bin/standalone.conf echo 'ubuntu=35291eedea6d270cb71fe7dfd36d0c89' >> /home/ubuntu/wildfly/standalone/configuration/mgmt-users.properties echo 'ubuntu=' >> /home/ubuntu/wildfly/standalone/configuration/mgmt-groups.properties cd /home/ubuntu/wildfly/standalone/deployments wget https://jdbc.postgresql.org/download/postgresql-9.4-1200.jdbc41.jar
建立数据库
sudo -u postgres createdb core -E UTF8 -T template0
配置wildfly数据源
cd /home/ubuntu/wildfly/bin ./jboss-cli.sh --connect
创建数据源的命令为:
data-source add --name=core --jndi-name=java:/core --driver-name=postgresql-9.4-1200.jdbc41.jar --connection-url=java:postgresql:core --user-name=postgres --password=postgres --transaction-isolation==TRANSACTION_READ_COMMITTED --min-pool-size=10 --max-pool-size=250
例如:
[standalone@localhost:9990 /] data-source add --name=core --jndi-name=java:/core --driver-name=postgresql-9.4-1200.jdbc41.jar --connection-url=java:postgresql:core --user-name=postgres --password=postgres --transaction-isolation==TRANSACTION_READ_COMMITTED --min-pool-size=10 --max-pool-size=250 [standalone@localhost:9990 /] exit
安装 rabbitmq
echo "deb http://www.rabbitmq.com/debian/ testing main" > /etc/apt/sources.list.d/rabbitmq.list wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc apt-key add rabbitmq-signing-key-public.asc apt-get update apt-get install rabbitmq-server rabbitmq-plugins enable rabbitmq_management rabbitmq-plugins enable rabbitmq_web_stomp rabbitmqctl add_user webuser 123456 rabbitmqctl set_user_tags webuser monitoring ----权限---- rabbitmqctl set_permissions -p / user '.*' '.*' '.*'
访问: http://IP:15672/
安装 mongodb
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list sudo apt-get update sudo apt-get install -y mongodb-org
安装 redis
sudo apt-get install software-properties-common apt-add-repository ppa:chris-lea/redis-server apt-get update apt-get install redis-server
安装 redis群集
至少准备3台服务器 修改 /etc/redis/redis.conf 文件:
bind 0.0.0.0 appendonly yes cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 service redis-server restart
在其中一台上执行:
wget http://download.redis.io/releases/redis-3.0.7.tar.gz tar xzvf redis-3.0.7.tar.gz apt-get install ruby cd redis-3.0.7 gem install redis
添加群集
./src/create --replicas 0 192.168.X.1:6379 192.168.X.2:6379 192.168.X.3:6379
测试
redis-cli -c 127.0.0.1:6379> set a 1 127.0.0.1:6379> get a "1"
zookeeper
安装 zookeeper
wget http://archive.apache.org/dist/zookeeper/stable/zookeeper-3.4.9.tar.gz tar -zxvf zookeeper-3.4.9.tar.gz -C /opt ln -s /opt/zookeeper-3.4.9 /opt/zookeeper cp /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg mkdir /opt/zookeeper/data sed -i 's/dataDir=.*$/dataDir=\/opt\/zookeeper\/data/' /opt/zookeeper/conf/zoo.cfg
启动
/opt/zookeeper/bin/zkServer.sh start
关闭
/opt/zookeeper/bin/zkServer.sh stop
安装 zookeeper 面板 zkdash
apt-get install git python-pip libmysqld-dev python-dev libyaml-dev git clone https://github.com/ireaderlab/zkdash.git cd zkdash pip install -r requirements.txt
安装 mysql 数据库
apt-get install mysql-server mysqladmin create zkdash
修改数据库配置和连接属性:
vim conf/conf.yml
同步数据
python ./bin/syncdb.py
启动:
cd zkdash screen python init.py -port=80
python 使用 zookeeper
安装:
pip install kazoo
使用:
from django.core.cache import cache from kazoo.client import KazooClient ...
def getmailPassword(self): password=cache.get('password') if password==None: zk = KazooClient(hosts='x.x.x.x:2181,x.x.x.x:2181') zk.start() password, stat = zk.get('/xxx/xxxx/xxxx') cache.set('password',password,3600) return password
安装 hadoop
安装
wget http://mirrors.cnnic.cn/apache/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz tar -zxf hadoop-2.7.3.tar.gz -C /usr/local cd /usr/local/ mv hadoop-2.7.3 hadoop adduser hadoop chown -R hadoop hadoop/ su hadoop ssh-keygen -t rsa cd ~/.ssh/ cat ./id_rsa.pub >> ./authorized_keys echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ~/.bashrc source ~/.bashrc /usr/local/hadoop/bin/hadoop version
配置
cat ./etc/hadoop/core-site.xml
<source lang=xml> <configuration>
<property> <name>hadoop.tmp.dir</name> <value>file:/usr/local/hadoop/tmp</value> <description>Abase for other temporary directories.</description> </property> <property> <name>fs.defaultFS</name> <value>hdfs://localhost:9000</value> </property>
</configuration> </source>
cat ./etc/hadoop/hdfs-site.xml
<source lang=xml> <configuration>
<property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:/usr/local/hadoop/tmp/dfs/name</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:/usr/local/hadoop/tmp/dfs/data</value> </property>
</configuration> </source>
执行 NameNode 的格式化:
./bin/hdfs namenode -format
修改
./etc/hadoop/hadoop-env.sh ./etc/hadoop/yarn-env.sh
设置 JAVA_HOME 为:/usr/lib/jvm/java-7-openjdk-amd64
启动
./sbin/start-dfs.sh
检查启动: <source lang=bash> hadoop@TEST:/usr/local/hadoop$ jps 25413 NameNode 25734 SecondaryNameNode 25522 DataNode 25909 Jps </source>
WEB访问面板:
http://192.168.2.222:50070/
关闭
./sbin/stop-dfs.sh
安装 AeroGear
安装 wildfly 8.2
wget http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.tar.gz tar xzvf wildfly-8.2.0.Final.tar.gz
安装 mysql
apt-get install mysql-server
安装 AeroGear UnifiedPush Server
环境准备
wget -c https://github.com/aerogear/aerogear-unifiedpush-server/releases/download/1.1.3.Final/aerogear-unifiedpush-server-1.1.3.Final-dist.tar.gz tar xzvf aerogear-unifiedpush-server-1.1.3.Final-dist.tar.gz cd aerogear-unifiedpush-server-1.1.3.Final cd migrator unzip ups-migrator-dist.zip cp -r ~/aerogear-unifiedpush-server-1.1.3.Final/databases/src/main/resources/modules/com ~/wildfly-8.2.0.Final/modules/ cp ~/aerogear-unifiedpush-server-1.1.3.Final/migrator/ups-migrator/lib/mysql-connector-java-5.1.18.jar ~/wildfly-8.2.0.Final/modules/com/mysql/jdbc/main/
数据库准备
mysql -u root -p mysql> create database unifiedpush default character set = "UTF8" default collate = "utf8_general_ci"; mysql> create database keycloak default character set = "UTF8" default collate = "utf8_general_ci"; mysql> create user 'unifiedpush'@'localhost' identified by 'unifiedpush'; mysql> GRANT SELECT,INSERT,UPDATE,ALTER,DELETE,CREATE,DROP,INDEX ON unifiedpush.* TO 'unifiedpush'@'localhost'; mysql> GRANT SELECT,INSERT,UPDATE,ALTER,DELETE,CREATE,DROP ON keycloak.* TO 'unifiedpush'@'localhost'; mysql> quit ~/wildfly-8.2.0.Final/bin/standalone.sh --server-config=standalone-full.xml -b 0.0.0.0
另外开一个终端执行创建Jboss数据源
~/wildfly-8.2.0.Final/bin/jboss-cli.sh --file=/root/aerogear-unifiedpush-server-1.1.3.Final/databases/mysql-database-config-wildfly.cli
建立数据库表
cd ~/aerogear-unifiedpush-server-1.1.3.Final/migrator/ups-migrator cp liquibase-mysql-example.properties liquibase.properties vim liquibase.properties 修改 url=jdbc:mysql://localhost:3306/unifiedpush100li 为 url=jdbc:mysql://localhost:3306/unifiedpush ./bin/ups-migrator update
如下提示,表示成功更新:
Liquibase Update Successful
部署 aerogear-unifiedpush-server
cp ~/aerogear-unifiedpush-server-1.1.3.Final/servers/unifiedpush-auth-server.war ~/wildfly-8.2.0.Final/standalone/deployments/ cp ~/aerogear-unifiedpush-server-1.1.3.Final/servers/unifiedpush-server-wildfly.war ~/wildfly-8.2.0.Final/standalone/deployments/
看wildfly的日志
访问
http://x.x.x.x:8080/ag-push/ 默认用户名 admin 密码 adm
安装 AeroGear SimplePush Server
下载并直接运行
git clone https://github.com/aerogear/aerogear-simplepush-server.git cd aerogear-simplepush-server mvn install -DskipTests=true cd server-netty mvn exec:java -Dexec.args="-host=localhost -port=7777 -tls=false -ack_interval=10000 -useragent_reaper_timeout=60000 -token_key=yourRandomToken"
部署到 wildfly 运行
cd wildfly-module/ mvn package -DskipTests=true cp -r ~/aerogear-simplepush-server/wildfly-module/target/module/org ~/wildfly-8.2.0.Final/modules/system/layers/base/ ~/wildfly-8.2.0.Final/bin/jboss-cli.sh --file=/root/aerogear-simplepush-server/wildfly-module/src/main/resources/wildfly-config.cli
安装tf支持
sed -i "s/archive.ubuntu.com/mirrors.163.com/" /etc/apt/sources.list apt-get update locale-gen --lang zh_CN.UTF-8 apt-get install python3-pip pip3 install -i https://mirrors.aliyun.com/pypi/simple --upgrade pip rm /usr/bin/pip3 ln -s /usr/local/bin/pip3 /usr/bin/pip3 pip3 install -i https://mirrors.aliyun.com/pypi/simple gunicorn flask image pip3 install -i https://mirrors.aliyun.com/pypi/simple numpy tensorflow==1.15
安装pytorch
pip3 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
常用维护命令
查看内存被什么消耗
ps -eo vsz,rss,pid,cmd --sort -vsz|head -n 20
解决系统更新后ssh服务无法启动的问题
mkdir -p -m0755 /var/run/sshd && systemctl restart ssh.service