1.修改安装配置文件

wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz
tar xzf oneinstack-full.tar.gz
备分 AND 修改option.cof 文件

  1. # Nginx Apache and PHP-FPM process is run as $run_user(Default "www"), you can freely specify
  2. run_user=www
  3. # set the default install path, you can freely specify
  4. nginx_install_dir=/data/services/nginx
  5. tengine_install_dir=/data/services/tengine
  6. openresty_install_dir=/data/services/openresty
  7. apache_install_dir=/data/services/apache
  8. tomcat_install_dir=/data/webservers/tomcat
  9. mysql_install_dir=/data/services/mysql
  10. mariadb_install_dir=/data/services/mariadb
  11. percona_install_dir=/data/services/percona
  12. alisql_install_dir=/data/services/alisql
  13. pgsql_install_dir=/data/services/pgsql
  14. mongo_install_dir=/data/services/mongodb
  15. php_install_dir=/data/services/php
  16. pureftpd_install_dir=/data/services/pureftpd
  17. memcached_install_dir=/data/services/memcached
  18. redis_install_dir=/data/services/redis
  19. python_install_dir=/data/services/python
  20. openssl_install_dir=/data/services/openssl
  21. imagick_install_dir=/data/services/imagemagick
  22. gmagick_install_dir=/data/services/graphicsmagick
  23. curl_install_dir=/data/services/curl
  24. # Add modules
  25. nginx_modules_options=''
  26. php_modules_options=''
  27. #########################################################################
  28. # database data storage directory, you can freely specify
  29. mysql_data_dir=/data/services/mysql/data
  30. mariadb_data_dir=/data/services/mariadb/data
  31. percona_data_dir=/data/services/percona/data
  32. alisql_data_dir=/data/services/alisql/data
  33. pgsql_data_dir=/data/services/pgsql/data
  34. mongo_data_dir=/data/services/mongodb/data
  35. # web directory, you can customize
  36. wwwroot_dir=/data/wwwroot
  37. # nginx Generate a log storage directory, you can freely specify.
  38. wwwlogs_dir=/data/wwwlogs
  39. #########################################################################
  40. # [MySQL/MariaDB/Percona/AliSQL] automatically generated, You can't change
  41. dbrootpwd=
  42. # [PostgreSQL] automatically generated, You can't change
  43. dbpostgrespwd=
  44. # [MongoDB] automatically generated, You can't change
  45. dbmongopwd=
  46. #########################################################################
  47. # Backup Dest directory, change this if you have someother location
  48. backup_dir=/data/backup
  49. # How many days before the backup directory will be removed
  50. expired_days=5
  51. # local ; remote ; upyun ; local,upyun
  52. backup_destination=
  53. # db ; web, You can't change
  54. backup_content=
  55. # aliyun OSS Bucket, You can't change
  56. oss_bucket=
  57. # qiniu Bucket, You can't change
  58. qiniu_bucket=
  59. # The backup of the database, You can't change
  60. db_name=
  61. # The backup of the website, You can't change
  62. website_name=
  63. # oneinstack.tar.gz md5, You can't change
  64. oneinstack_md5=

./oneinstack/install.sh —nginx_option 1 —tomcat_option 2 —jdk_option 2 —db_option 15 —dbinstallmethod 1 —dbrootpwd oneinstack —pureftpd —redis —memcached —iptables —reboot

Linux安装软件 - 图1

./oneinstack/install.sh —nginx_option 1 —tomcat_option 2 —jdk_option 2 —db_option 15 —dbinstallmethod 1 —dbrootpwd oneinstack —pureftpd —redis —memcached —iptables —reboot

p
yum -y install wget screen curl python #for CentOS/Redhat

wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz #包含源码,国内外均可下载
tar xzf oneinstack-full.tar.gz
cd oneinstack #如果需要修改目录(安装、数据存储、Nginx日志),请修改options.conf文件
screen -S oneinstack #如果网路出现中断,可以执行命令screen -R oneinstack重新连接安装窗口
./install.sh #注:请勿sh install.sh或者bash install.sh这样执行

Nginx/Tengine/OpenResty:
service nginx {start|stop|status|restart|reload|configtest}

MySQL/MariaDB/Percona:
service mysqld {start|stop|restart|reload|status}

PHP:
service php-fpm {start|stop|restart|reload|status}

HHVM(hhvm进程交给supervisord管理):
service supervisord {start|stop|status|restart|reload}

Apache:
service httpd {start|restart|stop}

Tomcat:
service tomcat {start|stop|status|restart}

Pure-Ftpd:
service pureftpd {start|stop|restart|status}

Redis:
service redis-server {start|stop|status|restart|reload}

Memcached:
service memcached {start|stop|status|restart|reload}

2.安装数据库Mongodb4.0.0

2.1 下载

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon2-4.0.0.tgz

2.2 解压

tar -zxvf mongodb-linux-x86_64-amazon2-4.0.0.tgz

2.3 拷贝到自己的所需要的安装目录

mv mongodb-linux-x86_64-amazon2-4.0.0 /data/service/mongodb

2.4 设置环境变量

vim /etc/profile
export PATH=/data/service/mongodb/bin:$PATH source /etc/profile

2.5创建的数据存储目录、日志存储目录及日志文件

  1. mkdir -p /data/services/mongodb/data/db
  2. mkdir -p /data/services/mongodb/conf/
  3. mkdir -p /data/services/mongodb/logs
  4. touch /data/services/mongodb/logs/mongod.log
  5. chmod -R 777 /data/logs/mongod.log

2.6调整shell资源的设置,以防频繁访问MongoDB产生错误导致无法连接MongoDB实例

  1. ulimit -n 25000 #同一时刻最多开启文件数
  2. ulimit -u 25000 #同一时刻最多开启程序数

2.7配置文件mongod.conf

  1. vim /data/services/mongodb/config/mongod.conf
  1. # mongod.conf
  2. # for documentation of all options, see:
  3. # http://docs.mongodb.org/manual/reference/configuration-options/
  4. # where to write logging data.
  5. systemLog:
  6. destination: file
  7. logAppend: true
  8. path: /data/services/mongodb/logs/mongod.log
  9. # Where and how to store data.
  10. storage:
  11. dbPath: /data/services/mongodb/data/db
  12. journal:
  13. enabled: true
  14. # engine:
  15. # mmapv1:
  16. # wiredTiger:
  17. # how the process runs
  18. processManagement:
  19. fork: true # fork and run in background
  20. pidFilePath: /data/services/mongodb/data/db/mongod.pid
  21. timeZoneInfo: /usr/share/zoneinfo
  22. # network interfaces
  23. net:
  24. port: 27017
  25. bindIp: 0.0.0.0
  26. # unixDomainSocket:
  27. # enabled: false
  28. #security:
  29. # authorization: enabled
  30. #operationProfiling:
  31. #replication:
  32. #sharding:

2.8 设置MongoDB开机自启动 (未用)

  1. vim /etc/rc.local

rm -rf /data/mongodb/mongodb1/mongod.lock
/usr/local/mongodb/bin/mongod -f /data/conf/mongodb1.conf //启动实例

2.9 启动MongoDB数据库

  1. mongod -f /data/services/mongodb/config/mongod.conf

如有glibc 2.18 包缺失,要升级一下

2.10 检查MongoDB进程

  1. netstat -tunlp | grep mongod

2.11 停止MongoDB数据库

  1. mongod -f /data/services/mongodb/config/mongod.conf --shutdown

2.12 本地客户端连接并访问MongoDB数据库(默认端口为:27017)

  1. mongo

2.13 相关命令

  • mongod.exe负责开机

  • mongo.exe负责运行数据库(开机)

  • mongoimport.exe负责导入数据库

  • mongoexport.exe负责输出数据库

  • mongorestore.exe负责备份数据库

2.14 设置用户与配置开关

设置用户后,开启mongodb权限开关

  1. #切换数据库
  2. use admin
  3. db.createUser({user: "admin",pwd: "Root@123",roles: [ { role: "root", db: "admin" } ]});
  4. #(这个命令是解决问题的重点)
  5. exit
  6. #切换数据库
  7. use bdd
  8. db.createUser({user: "bdd",pwd: "bdd2018",roles: [{ role: "readWrite", db: "bdd" }]});
  9. exit
  10. db.createUser({user: "bdd",pwd: "PlM_pro_pw2018",roles: [{ role: "readWrite", db: "bdd" }]});
  1. vim /data/services/mongodb/config/mongod.conf
  1. security:
  2. authorization: enabled

防火墙设置

vim /etc/sysconfig/iptables

  1. #特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
  2. # Firewall configuration written by system-config-firewall
  3. # Manual customization of this file is not recommended.
  4. *filter
  5. :INPUT ACCEPT [0:0]
  6. :FORWARD ACCEPT [0:0]
  7. :OUTPUT ACCEPT [0:0]
  8. -A INPUT -m state state ESTABLISHED,RELATED -j ACCEPT
  9. -A INPUT -p icmp -j ACCEPT
  10. -A INPUT -i lo -j ACCEPT
  11. -A INPUT -m state state NEW -m tcp -p tcp dport 22 -j ACCEPT
  12. -A INPUT -m state state NEW -m tcp -p tcp dport 27017 -j ACCEPT
  13. -A INPUT -m state state NEW -m tcp -p tcp dport 3306 -j ACCEPT
  14. -A INPUT -j REJECT reject-with icmp-host-prohibited
  15. -A FORWARD -j REJECT reject-with icmp-host-prohibited
  16. COMMIT

vim /etc/sysconfig/iptables

  1. #service iptables restart
  2. Redirecting to /bin/systemctl restart iptable.service
  3. Failed to issue method call: Unit iptable.service failed to load: No such file or directory.
  4. 据说从某个版本的Linux系统(CenterOS/RedHat)后就将service命令改了,如下
  5. #systemctl restart iptables.service
  6. #iptables -L
  7. 重启防火墙成功~~~~